From b1eb5d1d31e3ea256501c08a3ed9aa7183b27466 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Thu, 14 Apr 2016 17:59:37 +0200 Subject: Fixes #497: ignore case difference between tags While retrieving all tags, case differences will be ignored. This affects: * tag cloud * tag autocompletion --- application/LinkDB.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'application') diff --git a/application/LinkDB.php b/application/LinkDB.php index a62341fc..4c1a45b5 100644 --- a/application/LinkDB.php +++ b/application/LinkDB.php @@ -417,11 +417,18 @@ You use the community supported version of the original Shaarli project, by Seba public function allTags() { $tags = array(); + $caseMapping = array(); foreach ($this->_links as $link) { foreach (explode(' ', $link['tags']) as $tag) { - if (!empty($tag)) { - $tags[$tag] = (empty($tags[$tag]) ? 1 : $tags[$tag] + 1); + if (empty($tag)) { + continue; } + // The first case found will be displayed. + if (!isset($caseMapping[strtolower($tag)])) { + $caseMapping[strtolower($tag)] = $tag; + $tags[$caseMapping[strtolower($tag)]] = 0; + } + $tags[$caseMapping[strtolower($tag)]]++; } } // Sort tags by usage (most used tag first) -- cgit v1.2.3