]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Inject tag list everywhere to make autocomplete work on the fixed search bar 862/head
authorArthurHoaro <arthur@hoa.ro>
Sun, 7 May 2017 16:19:09 +0000 (18:19 +0200)
committerArthurHoaro <arthur@hoa.ro>
Sun, 7 May 2017 16:21:38 +0000 (18:21 +0200)
application/PageBuilder.php
index.php

index 8e39455bffe443b975be7d376628e66382e7b8bc..50e3f1248d789436741341d80fb78211a728fccc 100644 (file)
@@ -21,16 +21,23 @@ class PageBuilder
      */
     protected $conf;
 
+    /**
+     * @var LinkDB $linkDB instance.
+     */
+    protected $linkDB;
+
     /**
      * PageBuilder constructor.
      * $tpl is initialized at false for lazy loading.
      *
-     * @param ConfigManager $conf Configuration Manager instance (reference).
+     * @param ConfigManager $conf   Configuration Manager instance (reference).
+     * @param LinkDB        $linkDB instance.
      */
-    public function __construct(&$conf)
+    public function __construct(&$conf, $linkDB = null)
     {
         $this->tpl = false;
         $this->conf = $conf;
+        $this->linkDB = $linkDB;
     }
 
     /**
@@ -81,6 +88,9 @@ class PageBuilder
         $this->tpl->assign('feed_type', $this->conf->get('feed.show_atom', true) !== false ? 'atom' : 'rss');
         $this->tpl->assign('hide_timestamps', $this->conf->get('privacy.hide_timestamps', false));
         $this->tpl->assign('token', getToken($this->conf));
+        if ($this->linkDB !== null) {
+            $this->tpl->assign('tags', $this->linkDB->allTags());
+        }
         // To be removed with a proper theme configuration.
         $this->tpl->assign('conf', $this->conf);
     }
index ba1c2b2b4618a31a8a4054f6a622bb635363829d..ab1e30da9154c91c610014a93eafff882a7a01d9 100644 (file)
--- a/index.php
+++ b/index.php
@@ -728,7 +728,7 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history)
         die($e->getMessage());
     }
 
-    $PAGE = new PageBuilder($conf);
+    $PAGE = new PageBuilder($conf, $LINKSDB);
     $PAGE->assign('linkcount', count($LINKSDB));
     $PAGE->assign('privateLinkcount', count_private($LINKSDB));
     $PAGE->assign('plugin_errors', $pluginManager->getErrors());
@@ -1170,7 +1170,6 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history)
     if ($targetPage == Router::$PAGE_CHANGETAG)
     {
         if (empty($_POST['fromtag']) || (empty($_POST['totag']) && isset($_POST['renametag']))) {
-            $PAGE->assign('tags', $LINKSDB->allTags());
             $PAGE->renderPage('changetag');
             exit;
         }
@@ -1700,7 +1699,6 @@ function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager)
         'visibility' => ! empty($_SESSION['privateonly']) ? 'private' : '',
         'redirector' => $conf->get('redirector.url'),  // Optional redirector URL.
         'links' => $linkDisp,
-        'tags' => $LINKSDB->allTags(),
     );
 
     // If there is only a single link, we change on-the-fly the title of the page.