Fixes #403: build the daily page through renderPage()

* new entry in the Router for daily page.
  * add an always displayed button in demo_plugin
This commit is contained in:
ArthurHoaro 2015-12-07 11:25:11 +01:00
parent 4c3df9aa12
commit 38603b2450
3 changed files with 22 additions and 6 deletions

View file

@ -13,6 +13,8 @@ class Router
public static $PAGE_TAGCLOUD = 'tagcloud'; public static $PAGE_TAGCLOUD = 'tagcloud';
public static $PAGE_DAILY = 'daily';
public static $PAGE_TOOLS = 'tools'; public static $PAGE_TOOLS = 'tools';
public static $PAGE_CHANGEPASSWORD = 'changepasswd'; public static $PAGE_CHANGEPASSWORD = 'changepasswd';
@ -69,6 +71,10 @@ public static function findPage($query, $get, $loggedIn)
return self::$PAGE_OPENSEARCH; return self::$PAGE_OPENSEARCH;
} }
if (startsWith($query, 'do='. self::$PAGE_DAILY)) {
return self::$PAGE_DAILY;
}
// At this point, only loggedin pages. // At this point, only loggedin pages.
if (!$loggedIn) { if (!$loggedIn) {
return self::$PAGE_LINKLIST; return self::$PAGE_LINKLIST;

View file

@ -995,8 +995,12 @@ function showDailyRSS() {
exit; exit;
} }
// "Daily" page. /**
function showDaily() * Show the 'Daily' page.
*
* @param PageBuilder $pageBuilder Template engine wrapper.
*/
function showDaily($pageBuilder)
{ {
$LINKSDB = new LinkDB( $LINKSDB = new LinkDB(
$GLOBALS['config']['DATASTORE'], $GLOBALS['config']['DATASTORE'],
@ -1059,7 +1063,7 @@ function showDaily()
array_push($columns[$index],$link); // Put entry in this column. array_push($columns[$index],$link); // Put entry in this column.
$fill[$index]+=$length; $fill[$index]+=$length;
} }
$PAGE = new pageBuilder;
$data = array( $data = array(
'linksToDisplay' => $linksToDisplay, 'linksToDisplay' => $linksToDisplay,
'linkcount' => count($LINKSDB), 'linkcount' => count($LINKSDB),
@ -1072,10 +1076,10 @@ function showDaily()
$pluginManager->executeHooks('render_daily', $data, array('loggedin' => isLoggedIn())); $pluginManager->executeHooks('render_daily', $data, array('loggedin' => isLoggedIn()));
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
$PAGE->assign($key, $value); $pageBuilder->assign($key, $value);
} }
$PAGE->renderPage('daily'); $pageBuilder->renderPage('daily');
exit; exit;
} }
@ -1209,6 +1213,11 @@ function renderPage()
exit; exit;
} }
// Daily page.
if ($targetPage == Router::$PAGE_DAILY) {
showDaily($PAGE);
}
// Display openseach plugin (XML) // Display openseach plugin (XML)
if ($targetPage == Router::$PAGE_OPENSEARCH) { if ($targetPage == Router::$PAGE_OPENSEARCH) {
header('Content-Type: application/xml; charset=utf-8'); header('Content-Type: application/xml; charset=utf-8');
@ -2456,7 +2465,6 @@ function resizeImage($filepath)
if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=rss')) { showRSS(); exit; } if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=rss')) { showRSS(); exit; }
if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=atom')) { showATOM(); exit; } if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=atom')) { showATOM(); exit; }
if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=dailyrss')) { showDailyRSS(); exit; } if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=dailyrss')) { showDailyRSS(); exit; }
if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=daily')) { showDaily(); exit; }
if (!isset($_SESSION['LINKS_PER_PAGE'])) $_SESSION['LINKS_PER_PAGE']=$GLOBALS['config']['LINKS_PER_PAGE']; if (!isset($_SESSION['LINKS_PER_PAGE'])) $_SESSION['LINKS_PER_PAGE']=$GLOBALS['config']['LINKS_PER_PAGE'];
renderPage(); renderPage();
?> ?>

View file

@ -40,6 +40,8 @@ function hook_demo_plugin_render_header($data)
// Fields in toolbar // Fields in toolbar
$data['fields_toolbar'][] = 'DEMO_fields_toolbar'; $data['fields_toolbar'][] = 'DEMO_fields_toolbar';
} }
// Another button always displayed
$data['buttons_toolbar'][] = '<li><a href="#">DEMO</a></li>';
return $data; return $data;
} }