Fixes #497: ignore case difference between tags
While retrieving all tags, case differences will be ignored. This affects: * tag cloud * tag autocompletion
This commit is contained in:
parent
11609d9fd8
commit
b1eb5d1d31
4 changed files with 15 additions and 6 deletions
|
@ -417,11 +417,18 @@ public function filterSearch($filterRequest = array(), $casesensitive = false, $
|
||||||
public function allTags()
|
public function allTags()
|
||||||
{
|
{
|
||||||
$tags = array();
|
$tags = array();
|
||||||
|
$caseMapping = array();
|
||||||
foreach ($this->_links as $link) {
|
foreach ($this->_links as $link) {
|
||||||
foreach (explode(' ', $link['tags']) as $tag) {
|
foreach (explode(' ', $link['tags']) as $tag) {
|
||||||
if (!empty($tag)) {
|
if (empty($tag)) {
|
||||||
$tags[$tag] = (empty($tags[$tag]) ? 1 : $tags[$tag] + 1);
|
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)
|
// Sort tags by usage (most used tag first)
|
||||||
|
|
|
@ -93,7 +93,7 @@ public function testRSSBuildData()
|
||||||
$this->assertContains('Permalink', $link['description']);
|
$this->assertContains('Permalink', $link['description']);
|
||||||
$this->assertContains('http://host.tld/?WDWyig', $link['description']);
|
$this->assertContains('http://host.tld/?WDWyig', $link['description']);
|
||||||
$this->assertEquals(1, count($link['taglist']));
|
$this->assertEquals(1, count($link['taglist']));
|
||||||
$this->assertEquals('stuff', $link['taglist'][0]);
|
$this->assertEquals('sTuff', $link['taglist'][0]);
|
||||||
|
|
||||||
// Test URL with external link.
|
// Test URL with external link.
|
||||||
$this->assertEquals('https://static.fsf.org/nosvn/faif-2.0.pdf', $data['links']['20150310_114633']['url']);
|
$this->assertEquals('https://static.fsf.org/nosvn/faif-2.0.pdf', $data['links']['20150310_114633']['url']);
|
||||||
|
|
|
@ -290,7 +290,9 @@ public function testAllTags()
|
||||||
'stallman' => 1,
|
'stallman' => 1,
|
||||||
'free' => 1,
|
'free' => 1,
|
||||||
'-exclude' => 1,
|
'-exclude' => 1,
|
||||||
'stuff' => 2,
|
// The DB contains a link with `sTuff` and another one with `stuff` tag.
|
||||||
|
// They need to be grouped with the first case found (`sTuff`).
|
||||||
|
'sTuff' => 2,
|
||||||
),
|
),
|
||||||
self::$publicLinkDB->allTags()
|
self::$publicLinkDB->allTags()
|
||||||
);
|
);
|
||||||
|
@ -310,7 +312,7 @@ public function testAllTags()
|
||||||
'w3c' => 1,
|
'w3c' => 1,
|
||||||
'css' => 1,
|
'css' => 1,
|
||||||
'Mercurial' => 1,
|
'Mercurial' => 1,
|
||||||
'stuff' => 2,
|
'sTuff' => 2,
|
||||||
'-exclude' => 1,
|
'-exclude' => 1,
|
||||||
'.hidden' => 1,
|
'.hidden' => 1,
|
||||||
),
|
),
|
||||||
|
|
|
@ -21,7 +21,7 @@ function __construct()
|
||||||
'Stallman has a beard and is part of the Free Software Foundation (or not). Seriously, read this.',
|
'Stallman has a beard and is part of the Free Software Foundation (or not). Seriously, read this.',
|
||||||
0,
|
0,
|
||||||
'20150310_114651',
|
'20150310_114651',
|
||||||
'stuff'
|
'sTuff'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->addLink(
|
$this->addLink(
|
||||||
|
|
Loading…
Reference in a new issue