]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Fixes #403: build the daily page through renderPage() 407/head
authorArthurHoaro <arthur@hoa.ro>
Mon, 7 Dec 2015 10:25:11 +0000 (11:25 +0100)
committerArthurHoaro <arthur@hoa.ro>
Tue, 8 Dec 2015 14:51:49 +0000 (15:51 +0100)
  * new entry in the Router for daily page.
  * add an always displayed button in demo_plugin

application/Router.php
index.php
plugins/demo_plugin/demo_plugin.php

index 1e6a3983231f9a9eff01abb1e88b8dd63a4717b9..0c813847b282162c40e61ae6a2e16e83a34d3508 100644 (file)
@@ -13,6 +13,8 @@ class Router
 
     public static $PAGE_TAGCLOUD = 'tagcloud';
 
+    public static $PAGE_DAILY = 'daily';
+
     public static $PAGE_TOOLS = 'tools';
 
     public static $PAGE_CHANGEPASSWORD = 'changepasswd';
@@ -69,6 +71,10 @@ class Router
             return self::$PAGE_OPENSEARCH;
         }
 
+        if (startsWith($query, 'do='. self::$PAGE_DAILY)) {
+            return self::$PAGE_DAILY;
+        }
+
         // At this point, only loggedin pages.
         if (!$loggedIn) {
             return self::$PAGE_LINKLIST;
index 81ab7676fec90ee0b05ef1614dc2c41811c0d385..1850e40c0633298124bebc0581a1cc342495c4c6 100644 (file)
--- a/index.php
+++ b/index.php
@@ -995,8 +995,12 @@ function showDailyRSS() {
     exit;
 }
 
-// "Daily" page.
-function showDaily()
+/**
+ * Show the 'Daily' page.
+ *
+ * @param PageBuilder $pageBuilder Template engine wrapper.
+ */
+function showDaily($pageBuilder)
 {
     $LINKSDB = new LinkDB(
         $GLOBALS['config']['DATASTORE'],
@@ -1059,7 +1063,7 @@ function showDaily()
         array_push($columns[$index],$link); // Put entry in this column.
         $fill[$index]+=$length;
     }
-    $PAGE = new pageBuilder;
+
     $data = array(
         'linksToDisplay' => $linksToDisplay,
         'linkcount' => count($LINKSDB),
@@ -1072,10 +1076,10 @@ function showDaily()
     $pluginManager->executeHooks('render_daily', $data, array('loggedin' => isLoggedIn()));
 
     foreach ($data as $key => $value) {
-        $PAGE->assign($key, $value);
+        $pageBuilder->assign($key, $value);
     }
 
-    $PAGE->renderPage('daily');
+    $pageBuilder->renderPage('daily');
     exit;
 }
 
@@ -1209,6 +1213,11 @@ function renderPage()
         exit;
     }
 
+    // Daily page.
+    if ($targetPage == Router::$PAGE_DAILY) {
+        showDaily($PAGE);
+    }
+
     // Display openseach plugin (XML)
     if ($targetPage == Router::$PAGE_OPENSEARCH) {
         header('Content-Type: application/xml; charset=utf-8');
@@ -2456,7 +2465,6 @@ if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=g
 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=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'];
 renderPage();
 ?>
index 84763c2b25050e05b5afa692178536fe128c3c81..9384c21f53232652b4df891a0a179f3a6f41a8fe 100644 (file)
@@ -40,6 +40,8 @@ function hook_demo_plugin_render_header($data)
         // Fields in toolbar
         $data['fields_toolbar'][] = 'DEMO_fields_toolbar';
     }
+    // Another button always displayed
+    $data['buttons_toolbar'][] = '<li><a href="#">DEMO</a></li>';
 
     return $data;
 }