X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=application%2FLinkDB.php;h=7802cc8a1dd408a022d2471efec794fbca1bbfe7;hb=7481dd6e66c132ae064613de19e73dab0ca2de19;hp=0d3c85bd9815e2c879d8b18160441dfd19fd80f5;hpb=eb6e729808e1c3d9787ad1183aa61ab2e375a537;p=github%2Fshaarli%2FShaarli.git 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;