From 73c896265424873a4e8e5dc70f99413e56dfcce9 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sun, 7 May 2017 18:19:09 +0200 Subject: [PATCH] Inject tag list everywhere to make autocomplete work on the fixed search bar --- application/PageBuilder.php | 14 ++++++++++++-- index.php | 4 +--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/application/PageBuilder.php b/application/PageBuilder.php index 8e39455..50e3f12 100644 --- a/application/PageBuilder.php +++ b/application/PageBuilder.php @@ -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); } diff --git a/index.php b/index.php index ba1c2b2..ab1e30d 100644 --- 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.