From 6ccd0b218fbd34de750f55b78f3dc43bb3d9fa8e Mon Sep 17 00:00:00 2001 From: Lucas Cimon Date: Thu, 18 May 2017 20:28:11 +0200 Subject: Adding ability to display subtags in tagcloud --- application/LinkDB.php | 11 +++++++---- application/PageBuilder.php | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'application') diff --git a/application/LinkDB.php b/application/LinkDB.php index 0d3c85bd..7802cc8a 100644 --- a/application/LinkDB.php +++ b/application/LinkDB.php @@ -452,14 +452,17 @@ You use the community supported version of the original Shaarli project, by Seba } /** - * Returns the list of all tags - * Output: associative array key=tags, value=0 + * Returns the list tags appearing in the links with the given tags + * @param $filteringTags: tags selecting the links to consider + * @param $visibility: process only all/private/public links + * @return: a tag=>linksCount array */ - public function allTags() + public function linksCountPerTag($filteringTags = [], $visibility = 'all') { + $links = empty($filteringTags) ? $this->links : $this->filterSearch(['searchtags' => $filteringTags], false, $visibility); $tags = array(); $caseMapping = array(); - foreach ($this->links as $link) { + foreach ($links as $link) { foreach (preg_split('/\s+/', $link['tags'], 0, PREG_SPLIT_NO_EMPTY) as $tag) { if (empty($tag)) { continue; diff --git a/application/PageBuilder.php b/application/PageBuilder.php index 50e3f124..c86621a2 100644 --- a/application/PageBuilder.php +++ b/application/PageBuilder.php @@ -89,7 +89,7 @@ class PageBuilder $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()); + $this->tpl->assign('tags', $this->linkDB->linksCountPerTag()); } // To be removed with a proper theme configuration. $this->tpl->assign('conf', $this->conf); -- cgit v1.2.3