aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2015-07-15 11:42:15 +0200
committerArthurHoaro <arthur@hoa.ro>2015-11-07 15:27:17 +0100
commit6fc14d530369740d27d6bd641369d4f5f5f04080 (patch)
tree2da553378e8f0ff367dcb677d6f519d1fb3e803c /index.php
parent38bedfbbcdd2a40e9f04f5753e0fd6f4fd513c21 (diff)
downloadShaarli-6fc14d530369740d27d6bd641369d4f5f5f04080.tar.gz
Shaarli-6fc14d530369740d27d6bd641369d4f5f5f04080.tar.zst
Shaarli-6fc14d530369740d27d6bd641369d4f5f5f04080.zip
Plugin system - CORE
see shaarli/Shaarli#275
Diffstat (limited to 'index.php')
-rwxr-xr-xindex.php230
1 files changed, 162 insertions, 68 deletions
diff --git a/index.php b/index.php
index c430a200..c82735ca 100755
--- a/index.php
+++ b/index.php
@@ -45,9 +45,18 @@ $GLOBALS['config']['RAINTPL_TPL'] = 'tpl/' ; // Raintpl template directory (keep
45$GLOBALS['config']['UPDATECHECK_FILENAME'] = $GLOBALS['config']['DATADIR'].'/lastupdatecheck.txt'; // For updates check of Shaarli. 45$GLOBALS['config']['UPDATECHECK_FILENAME'] = $GLOBALS['config']['DATADIR'].'/lastupdatecheck.txt'; // For updates check of Shaarli.
46$GLOBALS['config']['UPDATECHECK_INTERVAL'] = 86400 ; // Updates check frequency for Shaarli. 86400 seconds=24 hours 46$GLOBALS['config']['UPDATECHECK_INTERVAL'] = 86400 ; // Updates check frequency for Shaarli. 86400 seconds=24 hours
47 // Note: You must have publisher.php in the same directory as Shaarli index.php 47 // Note: You must have publisher.php in the same directory as Shaarli index.php
48$GLOBALS['config']['ARCHIVE_ORG'] = false; // For each link, add a link to an archived version on archive.org
49$GLOBALS['config']['ENABLE_RSS_PERMALINKS'] = true; // Enable RSS permalinks by default. This corresponds to the default behavior of shaarli before this was added as an option. 48$GLOBALS['config']['ENABLE_RSS_PERMALINKS'] = true; // Enable RSS permalinks by default. This corresponds to the default behavior of shaarli before this was added as an option.
50$GLOBALS['config']['HIDE_PUBLIC_LINKS'] = false; 49$GLOBALS['config']['HIDE_PUBLIC_LINKS'] = false;
50//$GLOBALS['config']['ENABLED_PLUGINS'] = array(
51// 'qrcode', 'archiveorg', 'readityourself', 'demo_plugin', 'playvideos',
52// 'wallabag', 'markdown', 'addlink_toolbar',
53//);
54// Warning: order matters.
55$GLOBALS['config']['ENABLED_PLUGINS'] = array('qrcode');
56
57// Default plugins, default config - will be overriden by config.php and then plugin's config.php file.
58$GLOBALS['plugins']['READITYOUSELF_URL'] = 'http://someurl.com';
59$GLOBALS['plugins']['WALLABAG_URL'] = 'https://demo.wallabag.org/';
51// ----------------------------------------------------------------------------------------------- 60// -----------------------------------------------------------------------------------------------
52define('shaarli_version', '0.5.4'); 61define('shaarli_version', '0.5.4');
53// http://server.com/x/shaarli --> /shaarli/ 62// http://server.com/x/shaarli --> /shaarli/
@@ -75,6 +84,8 @@ require_once 'application/TimeZone.php';
75require_once 'application/Url.php'; 84require_once 'application/Url.php';
76require_once 'application/Utils.php'; 85require_once 'application/Utils.php';
77require_once 'application/Config.php'; 86require_once 'application/Config.php';
87require_once 'application/PluginManager.php';
88require_once 'application/Router.php';
78 89
79// Ensure the PHP version is supported 90// Ensure the PHP version is supported
80try { 91try {
@@ -119,6 +130,9 @@ include "inc/rain.tpl.class.php"; //include Rain TPL
119raintpl::$tpl_dir = $GLOBALS['config']['RAINTPL_TPL']; // template directory 130raintpl::$tpl_dir = $GLOBALS['config']['RAINTPL_TPL']; // template directory
120raintpl::$cache_dir = $GLOBALS['config']['RAINTPL_TMP']; // cache directory 131raintpl::$cache_dir = $GLOBALS['config']['RAINTPL_TMP']; // cache directory
121 132
133$pluginManager = PluginManager::getInstance();
134$pluginManager->load($GLOBALS['config']['ENABLED_PLUGINS']);
135
122ob_start(); // Output buffering for the page cache. 136ob_start(); // Output buffering for the page cache.
123 137
124 138
@@ -962,16 +976,31 @@ function showDaily()
962 $fill[$index]+=$length; 976 $fill[$index]+=$length;
963 } 977 }
964 $PAGE = new pageBuilder; 978 $PAGE = new pageBuilder;
965 $PAGE->assign('linksToDisplay',$linksToDisplay); 979 $data = array(
966 $PAGE->assign('linkcount',count($LINKSDB)); 980 'linksToDisplay' => $linksToDisplay,
967 $PAGE->assign('cols', $columns); 981 'linkcount' => count($LINKSDB),
968 $PAGE->assign('day',linkdate2timestamp($day.'_000000')); 982 'cols' => $columns,
969 $PAGE->assign('previousday',$previousday); 983 'day' => linkdate2timestamp($day.'_000000'),
970 $PAGE->assign('nextday',$nextday); 984 'previousday' => $previousday,
985 'nextday' => $nextday,
986 );
987 $pluginManager = PluginManager::getInstance();
988 $pluginManager->executeHooks('render_daily', $data, array('loggedin' => isLoggedIn()));
989
990 foreach ($data as $key => $value) {
991 $PAGE->assign($key, $value);
992 }
993
971 $PAGE->renderPage('daily'); 994 $PAGE->renderPage('daily');
972 exit; 995 exit;
973} 996}
974 997
998// Renders the linklist
999function showLinkList($PAGE, $LINKSDB) {
1000 buildLinkList($PAGE,$LINKSDB); // Compute list of links to display
1001 $PAGE->renderPage('linklist');
1002}
1003
975 1004
976// ------------------------------------------------------------------------------------------ 1005// ------------------------------------------------------------------------------------------
977// Render HTML page (according to URL parameters and user rights) 1006// Render HTML page (according to URL parameters and user rights)
@@ -983,12 +1012,36 @@ function renderPage()
983 $GLOBALS['config']['HIDE_PUBLIC_LINKS'] 1012 $GLOBALS['config']['HIDE_PUBLIC_LINKS']
984 ); 1013 );
985 1014
1015 $PAGE = new pageBuilder;
1016
1017 // Determine which page will be rendered.
1018 $query = (isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : '';
1019 $targetPage = Router::findPage($query, $_GET, isLoggedIn());
1020
1021 // Call plugin hooks for header, footer and includes, specifying which page will be rendered.
1022 // Then assign generated data to RainTPL.
1023 $common_hooks = array(
1024 'header',
1025 'footer',
1026 'includes',
1027 );
1028 $pluginManager = PluginManager::getInstance();
1029 foreach($common_hooks as $name) {
1030 $plugin_data = array();
1031 $pluginManager->executeHooks('render_' . $name, $plugin_data,
1032 array(
1033 'target' => $targetPage,
1034 'loggedin' => isLoggedIn()
1035 )
1036 );
1037 $PAGE->assign('plugins_' . $name, $plugin_data);
1038 }
1039
986 // -------- Display login form. 1040 // -------- Display login form.
987 if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=login')) 1041 if ($targetPage == Router::$PAGE_LOGIN)
988 { 1042 {
989 if ($GLOBALS['config']['OPEN_SHAARLI']) { header('Location: ?'); exit; } // No need to login for open Shaarli 1043 if ($GLOBALS['config']['OPEN_SHAARLI']) { header('Location: ?'); exit; } // No need to login for open Shaarli
990 $token=''; if (ban_canLogin()) $token=getToken(); // Do not waste token generation if not useful. 1044 $token=''; if (ban_canLogin()) $token=getToken(); // Do not waste token generation if not useful.
991 $PAGE = new pageBuilder;
992 $PAGE->assign('token',$token); 1045 $PAGE->assign('token',$token);
993 $PAGE->assign('returnurl',(isset($_SERVER['HTTP_REFERER']) ? escape($_SERVER['HTTP_REFERER']):'')); 1046 $PAGE->assign('returnurl',(isset($_SERVER['HTTP_REFERER']) ? escape($_SERVER['HTTP_REFERER']):''));
994 $PAGE->renderPage('loginform'); 1047 $PAGE->renderPage('loginform');
@@ -1004,7 +1057,7 @@ function renderPage()
1004 } 1057 }
1005 1058
1006 // -------- Picture wall 1059 // -------- Picture wall
1007 if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=picwall')) 1060 if ($targetPage == Router::$PAGE_PICWALL)
1008 { 1061 {
1009 // Optionally filter the results: 1062 // Optionally filter the results:
1010 $links=array(); 1063 $links=array();
@@ -1027,15 +1080,22 @@ function renderPage()
1027 } 1080 }
1028 } 1081 }
1029 1082
1030 $PAGE = new pageBuilder; 1083 $data = array(
1031 $PAGE->assign('linkcount',count($LINKSDB)); 1084 'linkcount' => count($LINKSDB),
1032 $PAGE->assign('linksToDisplay',$linksToDisplay); 1085 'linksToDisplay' => $linksToDisplay,
1086 );
1087 $pluginManager->executeHooks('render_picwall', $data, array('loggedin' => isLoggedIn()));
1088
1089 foreach ($data as $key => $value) {
1090 $PAGE->assign($key, $value);
1091 }
1092
1033 $PAGE->renderPage('picwall'); 1093 $PAGE->renderPage('picwall');
1034 exit; 1094 exit;
1035 } 1095 }
1036 1096
1037 // -------- Tag cloud 1097 // -------- Tag cloud
1038 if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=tagcloud')) 1098 if ($targetPage == Router::$PAGE_TAGCLOUD)
1039 { 1099 {
1040 $tags= $LINKSDB->allTags(); 1100 $tags= $LINKSDB->allTags();
1041 1101
@@ -1049,9 +1109,17 @@ function renderPage()
1049 { 1109 {
1050 $tagList[$key] = array('count'=>$value,'size'=>log($value, 15) / log($maxcount, 30) * (22-6) + 6); 1110 $tagList[$key] = array('count'=>$value,'size'=>log($value, 15) / log($maxcount, 30) * (22-6) + 6);
1051 } 1111 }
1052 $PAGE = new pageBuilder; 1112
1053 $PAGE->assign('linkcount',count($LINKSDB)); 1113 $data = array(
1054 $PAGE->assign('tags',$tagList); 1114 'linkcount' => count($LINKSDB),
1115 'tags' => $tagList,
1116 );
1117 $pluginManager->executeHooks('render_tagcloud', $data, array('loggedin' => isLoggedIn()));
1118
1119 foreach ($data as $key => $value) {
1120 $PAGE->assign($key, $value);
1121 }
1122
1055 $PAGE->renderPage('tagcloud'); 1123 $PAGE->renderPage('tagcloud');
1056 exit; 1124 exit;
1057 } 1125 }
@@ -1164,32 +1232,36 @@ function renderPage()
1164 header('Location: ?do=login&post='); 1232 header('Location: ?do=login&post=');
1165 exit; 1233 exit;
1166 } 1234 }
1167 1235 showLinkList($PAGE, $LINKSDB);
1168 if (isset($_GET['edit_link'])) { 1236 if (isset($_GET['edit_link'])) {
1169 header('Location: ?do=login&edit_link='. escape($_GET['edit_link'])); 1237 header('Location: ?do=login&edit_link='. escape($_GET['edit_link']));
1170 exit; 1238 exit;
1171 } 1239 }
1172 1240
1173 $PAGE = new pageBuilder;
1174 buildLinkList($PAGE,$LINKSDB); // Compute list of links to display
1175 $PAGE->renderPage('linklist');
1176 exit; // Never remove this one! All operations below are reserved for logged in user. 1241 exit; // Never remove this one! All operations below are reserved for logged in user.
1177 } 1242 }
1178 1243
1179 // -------- All other functions are reserved for the registered user: 1244 // -------- All other functions are reserved for the registered user:
1180 1245
1181 // -------- Display the Tools menu if requested (import/export/bookmarklet...) 1246 // -------- Display the Tools menu if requested (import/export/bookmarklet...)
1182 if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=tools')) 1247 if ($targetPage == Router::$PAGE_TOOLS)
1183 { 1248 {
1184 $PAGE = new pageBuilder; 1249 $data = array(
1185 $PAGE->assign('linkcount',count($LINKSDB)); 1250 'linkcount' => count($LINKSDB),
1186 $PAGE->assign('pageabsaddr',index_url($_SERVER)); 1251 'pageabsaddr' => index_url($_SERVER),
1252 );
1253 $pluginManager->executeHooks('render_tools', $data);
1254
1255 foreach ($data as $key => $value) {
1256 $PAGE->assign($key, $value);
1257 }
1258
1187 $PAGE->renderPage('tools'); 1259 $PAGE->renderPage('tools');
1188 exit; 1260 exit;
1189 } 1261 }
1190 1262
1191 // -------- User wants to change his/her password. 1263 // -------- User wants to change his/her password.
1192 if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=changepasswd')) 1264 if ($targetPage == Router::$PAGE_CHANGEPASSWORD)
1193 { 1265 {
1194 if ($GLOBALS['config']['OPEN_SHAARLI']) die('You are not supposed to change a password on an Open Shaarli.'); 1266 if ($GLOBALS['config']['OPEN_SHAARLI']) die('You are not supposed to change a password on an Open Shaarli.');
1195 if (!empty($_POST['setpassword']) && !empty($_POST['oldpassword'])) 1267 if (!empty($_POST['setpassword']) && !empty($_POST['oldpassword']))
@@ -1220,7 +1292,6 @@ function renderPage()
1220 } 1292 }
1221 else // show the change password form. 1293 else // show the change password form.
1222 { 1294 {
1223 $PAGE = new pageBuilder;
1224 $PAGE->assign('linkcount',count($LINKSDB)); 1295 $PAGE->assign('linkcount',count($LINKSDB));
1225 $PAGE->assign('token',getToken()); 1296 $PAGE->assign('token',getToken());
1226 $PAGE->renderPage('changepassword'); 1297 $PAGE->renderPage('changepassword');
@@ -1229,7 +1300,7 @@ function renderPage()
1229 } 1300 }
1230 1301
1231 // -------- User wants to change configuration 1302 // -------- User wants to change configuration
1232 if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=configure')) 1303 if ($targetPage == Router::$PAGE_CONFIGURE)
1233 { 1304 {
1234 if (!empty($_POST['title']) ) 1305 if (!empty($_POST['title']) )
1235 { 1306 {
@@ -1265,7 +1336,6 @@ function renderPage()
1265 } 1336 }
1266 else // Show the configuration form. 1337 else // Show the configuration form.
1267 { 1338 {
1268 $PAGE = new pageBuilder;
1269 $PAGE->assign('linkcount',count($LINKSDB)); 1339 $PAGE->assign('linkcount',count($LINKSDB));
1270 $PAGE->assign('token',getToken()); 1340 $PAGE->assign('token',getToken());
1271 $PAGE->assign('title', empty($GLOBALS['title']) ? '' : $GLOBALS['title'] ); 1341 $PAGE->assign('title', empty($GLOBALS['title']) ? '' : $GLOBALS['title'] );
@@ -1279,11 +1349,10 @@ function renderPage()
1279 } 1349 }
1280 1350
1281 // -------- User wants to rename a tag or delete it 1351 // -------- User wants to rename a tag or delete it
1282 if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=changetag')) 1352 if ($targetPage == Router::$PAGE_CHANGETAG)
1283 { 1353 {
1284 if (empty($_POST['fromtag'])) 1354 if (empty($_POST['fromtag']))
1285 { 1355 {
1286 $PAGE = new pageBuilder;
1287 $PAGE->assign('linkcount',count($LINKSDB)); 1356 $PAGE->assign('linkcount',count($LINKSDB));
1288 $PAGE->assign('token',getToken()); 1357 $PAGE->assign('token',getToken());
1289 $PAGE->assign('tags', $LINKSDB->allTags()); 1358 $PAGE->assign('tags', $LINKSDB->allTags());
@@ -1328,9 +1397,8 @@ function renderPage()
1328 } 1397 }
1329 1398
1330 // -------- User wants to add a link without using the bookmarklet: Show form. 1399 // -------- User wants to add a link without using the bookmarklet: Show form.
1331 if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=addlink')) 1400 if ($targetPage == Router::$PAGE_ADDLINK)
1332 { 1401 {
1333 $PAGE = new pageBuilder;
1334 $PAGE->assign('linkcount',count($LINKSDB)); 1402 $PAGE->assign('linkcount',count($LINKSDB));
1335 $PAGE->renderPage('addlink'); 1403 $PAGE->renderPage('addlink');
1336 exit; 1404 exit;
@@ -1349,6 +1417,9 @@ function renderPage()
1349 $link = array('title'=>trim($_POST['lf_title']),'url'=>$url,'description'=>trim($_POST['lf_description']),'private'=>(isset($_POST['lf_private']) ? 1 : 0), 1417 $link = array('title'=>trim($_POST['lf_title']),'url'=>$url,'description'=>trim($_POST['lf_description']),'private'=>(isset($_POST['lf_private']) ? 1 : 0),
1350 'linkdate'=>$linkdate,'tags'=>str_replace(',',' ',$tags)); 1418 'linkdate'=>$linkdate,'tags'=>str_replace(',',' ',$tags));
1351 if ($link['title']=='') $link['title']=$link['url']; // If title is empty, use the URL as title. 1419 if ($link['title']=='') $link['title']=$link['url']; // If title is empty, use the URL as title.
1420
1421 $pluginManager->executeHooks('save_link', $link);
1422
1352 $LINKSDB[$linkdate] = $link; 1423 $LINKSDB[$linkdate] = $link;
1353 $LINKSDB->savedb($GLOBALS['config']['PAGECACHE']); // Save to disk. 1424 $LINKSDB->savedb($GLOBALS['config']['PAGECACHE']); // Save to disk.
1354 pubsubhub(); 1425 pubsubhub();
@@ -1382,6 +1453,9 @@ function renderPage()
1382 // - confirmation is handled by JavaScript 1453 // - confirmation is handled by JavaScript
1383 // - we are protected from XSRF by the token. 1454 // - we are protected from XSRF by the token.
1384 $linkdate=$_POST['lf_linkdate']; 1455 $linkdate=$_POST['lf_linkdate'];
1456
1457 $pluginManager->executeHooks('delete_link', $LINKSDB[$linkdate]);
1458
1385 unset($LINKSDB[$linkdate]); 1459 unset($LINKSDB[$linkdate]);
1386 $LINKSDB->savedb($GLOBALS['config']['PAGECACHE']); // save to disk 1460 $LINKSDB->savedb($GLOBALS['config']['PAGECACHE']); // save to disk
1387 1461
@@ -1423,13 +1497,20 @@ function renderPage()
1423 { 1497 {
1424 $link = $LINKSDB[$_GET['edit_link']]; // Read database 1498 $link = $LINKSDB[$_GET['edit_link']]; // Read database
1425 if (!$link) { header('Location: ?'); exit; } // Link not found in database. 1499 if (!$link) { header('Location: ?'); exit; } // Link not found in database.
1426 $PAGE = new pageBuilder; 1500 $data = array(
1427 $PAGE->assign('linkcount',count($LINKSDB)); 1501 'linkcount' => count($LINKSDB),
1428 $PAGE->assign('link',$link); 1502 'link' => $link,
1429 $PAGE->assign('link_is_new',false); 1503 'link_is_new' => false,
1430 $PAGE->assign('token',getToken()); // XSRF protection. 1504 'token' => getToken(),
1431 $PAGE->assign('http_referer',(isset($_SERVER['HTTP_REFERER']) ? escape($_SERVER['HTTP_REFERER']) : '')); 1505 'http_referer' => (isset($_SERVER['HTTP_REFERER']) ? escape($_SERVER['HTTP_REFERER']) : ''),
1432 $PAGE->assign('tags', $LINKSDB->allTags()); 1506 'tags' => $LINKSDB->allTags(),
1507 );
1508 $pluginManager->executeHooks('render_editlink', $data);
1509
1510 foreach ($data as $key => $value) {
1511 $PAGE->assign($key, $value);
1512 }
1513
1433 $PAGE->renderPage('editlink'); 1514 $PAGE->renderPage('editlink');
1434 exit; 1515 exit;
1435 } 1516 }
@@ -1493,24 +1574,30 @@ function renderPage()
1493 ); 1574 );
1494 } 1575 }
1495 1576
1496 $PAGE = new pageBuilder; 1577 $data = array(
1497 $PAGE->assign('linkcount',count($LINKSDB)); 1578 'linkcount' => count($LINKSDB),
1498 $PAGE->assign('link',$link); 1579 'link' => $link,
1499 $PAGE->assign('link_is_new',$link_is_new); 1580 'link_is_new' => $link_is_new,
1500 $PAGE->assign('token',getToken()); // XSRF protection. 1581 'token' => getToken(), // XSRF protection.
1501 $PAGE->assign('http_referer',(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '')); 1582 'http_referer' => (isset($_SERVER['HTTP_REFERER']) ? escape($_SERVER['HTTP_REFERER']) : ''),
1502 $PAGE->assign('source',(isset($_GET['source']) ? $_GET['source'] : '')); 1583 'source' => (isset($_GET['source']) ? $_GET['source'] : ''),
1503 $PAGE->assign('tags', $LINKSDB->allTags()); 1584 'tags' => $LINKSDB->allTags(),
1585 );
1586 $pluginManager->executeHooks('render_editlink', $data);
1587
1588 foreach ($data as $key => $value) {
1589 $PAGE->assign($key, $value);
1590 }
1591
1504 $PAGE->renderPage('editlink'); 1592 $PAGE->renderPage('editlink');
1505 exit; 1593 exit;
1506 } 1594 }
1507 1595
1508 // -------- Export as Netscape Bookmarks HTML file. 1596 // -------- Export as Netscape Bookmarks HTML file.
1509 if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=export')) 1597 if ($targetPage == Router::$PAGE_EXPORT)
1510 { 1598 {
1511 if (empty($_GET['what'])) 1599 if (empty($_GET['what']))
1512 { 1600 {
1513 $PAGE = new pageBuilder;
1514 $PAGE->assign('linkcount',count($LINKSDB)); 1601 $PAGE->assign('linkcount',count($LINKSDB));
1515 $PAGE->renderPage('export'); 1602 $PAGE->renderPage('export');
1516 exit; 1603 exit;
@@ -1562,9 +1649,8 @@ HTML;
1562 } 1649 }
1563 1650
1564 // -------- Show upload/import dialog: 1651 // -------- Show upload/import dialog:
1565 if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=import')) 1652 if ($targetPage == Router::$PAGE_IMPORT)
1566 { 1653 {
1567 $PAGE = new pageBuilder;
1568 $PAGE->assign('linkcount',count($LINKSDB)); 1654 $PAGE->assign('linkcount',count($LINKSDB));
1569 $PAGE->assign('token',getToken()); 1655 $PAGE->assign('token',getToken());
1570 $PAGE->assign('maxfilesize',getMaxFileSize()); 1656 $PAGE->assign('maxfilesize',getMaxFileSize());
@@ -1573,9 +1659,7 @@ HTML;
1573 } 1659 }
1574 1660
1575 // -------- Otherwise, simply display search form and links: 1661 // -------- Otherwise, simply display search form and links:
1576 $PAGE = new pageBuilder; 1662 showLinkList($PAGE, $LINKSDB);
1577 buildLinkList($PAGE,$LINKSDB); // Compute list of links to display
1578 $PAGE->renderPage('linklist');
1579 exit; 1663 exit;
1580} 1664}
1581 1665
@@ -1746,7 +1830,7 @@ function buildLinkList($PAGE,$LINKSDB)
1746 $taglist = explode(' ',$link['tags']); 1830 $taglist = explode(' ',$link['tags']);
1747 uasort($taglist, 'strcasecmp'); 1831 uasort($taglist, 'strcasecmp');
1748 $link['taglist']=$taglist; 1832 $link['taglist']=$taglist;
1749 1833 $link['shorturl'] = smallHash($link['linkdate']);
1750 if ($link["url"][0] === '?' && // Check for both signs of a note: starting with ? and 7 chars long. I doubt that you'll post any links that look like this. 1834 if ($link["url"][0] === '?' && // Check for both signs of a note: starting with ? and 7 chars long. I doubt that you'll post any links that look like this.
1751 strlen($link["url"]) === 7) { 1835 strlen($link["url"]) === 7) {
1752 $link["url"] = index_url($_SERVER) . $link["url"]; 1836 $link["url"] = index_url($_SERVER) . $link["url"];
@@ -1766,18 +1850,28 @@ function buildLinkList($PAGE,$LINKSDB)
1766 $token = ''; if (isLoggedIn()) $token=getToken(); 1850 $token = ''; if (isLoggedIn()) $token=getToken();
1767 1851
1768 // Fill all template fields. 1852 // Fill all template fields.
1769 $PAGE->assign('linkcount',count($LINKSDB)); 1853 $data = array(
1770 $PAGE->assign('previous_page_url',$previous_page_url); 1854 'linkcount' => count($LINKSDB),
1771 $PAGE->assign('next_page_url',$next_page_url); 1855 'previous_page_url' => $previous_page_url,
1772 $PAGE->assign('page_current',$page); 1856 'next_page_url' => $next_page_url,
1773 $PAGE->assign('page_max',$pagecount); 1857 'page_current' => $page,
1774 $PAGE->assign('result_count',count($linksToDisplay)); 1858 'page_max' => $pagecount,
1775 $PAGE->assign('search_type',$search_type); 1859 'result_count' => count($linksToDisplay),
1776 $PAGE->assign('search_crits',$search_crits); 1860 'search_type' => $search_type,
1777 $PAGE->assign('redirector',empty($GLOBALS['redirector']) ? '' : $GLOBALS['redirector']); // Optional redirector URL. 1861 'search_crits' => $search_crits,
1778 $PAGE->assign('token',$token); 1862 'redirector' => empty($GLOBALS['redirector']) ? '' : $GLOBALS['redirector'], // Optional redirector URL.
1779 $PAGE->assign('links',$linkDisp); 1863 'token' => $token,
1780 $PAGE->assign('tags', $LINKSDB->allTags()); 1864 'links' => $linkDisp,
1865 'tags' => $LINKSDB->allTags(),
1866 );
1867
1868 $pluginManager = PluginManager::getInstance();
1869 $pluginManager->executeHooks('render_linklist', $data, array('loggedin' => isLoggedIn()));
1870
1871 foreach ($data as $key => $value) {
1872 $PAGE->assign($key, $value);
1873 }
1874
1781 return; 1875 return;
1782} 1876}
1783 1877