diff options
author | Adrian Lang <mail@adrianlang.de> | 2011-05-08 20:55:40 +0200 |
---|---|---|
committer | Adrian Lang <mail@adrianlang.de> | 2011-05-08 20:55:40 +0200 |
commit | 9199737c351d653a1d384cb50ed0d185f6512826 (patch) | |
tree | 2da4dbc0b92a72c767712549b6d90f53b0a3605e /inc/fulltext.php | |
parent | e68653d8ef3df043761e4042c563d65731f9b9c6 (diff) | |
parent | 2b537ba8dc1863d603770c208ae4f91d4d0877b9 (diff) | |
download | rpg-9199737c351d653a1d384cb50ed0d185f6512826.tar.gz rpg-9199737c351d653a1d384cb50ed0d185f6512826.tar.bz2 |
Merge branch 'master' into stable
Conflicts:
doku.php
Diffstat (limited to 'inc/fulltext.php')
-rw-r--r-- | inc/fulltext.php | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/inc/fulltext.php b/inc/fulltext.php index 8155325ee..6ab710d54 100644 --- a/inc/fulltext.php +++ b/inc/fulltext.php @@ -230,22 +230,21 @@ function _ft_pageLookup(&$data){ foreach ($page_idx as $p_id) { if ((strpos($in_ns ? $p_id : noNSorNS($p_id), $cleaned) !== false)) { if (!isset($pages[$p_id])) - $pages[$p_id] = p_get_first_heading($p_id, false); + $pages[$p_id] = p_get_first_heading($p_id, METADATA_DONT_RENDER); } } if ($in_title) { - $wildcard_id = "*$id*"; - foreach ($Indexer->lookupKey('title', $wildcard_id) as $p_id) { + foreach ($Indexer->lookupKey('title', $id, '_ft_pageLookupTitleCompare') as $p_id) { if (!isset($pages[$p_id])) - $pages[$p_id] = p_get_first_heading($p_id, false); + $pages[$p_id] = p_get_first_heading($p_id, METADATA_DONT_RENDER); } } } + if (isset($ns)) { - foreach ($page_idx as $p_id) { - if (strpos($p_id, $ns) === 0) { - if (!isset($pages[$p_id])) - $pages[$p_id] = p_get_first_heading($p_id, false); + foreach (array_keys($pages) as $p_id) { + if (strpos($p_id, $ns) !== 0) { + unset($pages[$p_id]); } } } @@ -265,6 +264,15 @@ function _ft_pageLookup(&$data){ } /** + * Tiny helper function for comparing the searched title with the title + * from the search index. This function is a wrapper around stripos with + * adapted argument order and return value. + */ +function _ft_pageLookupTitleCompare($search, $title) { + return stripos($title, $search) !== false; +} + +/** * Sort pages based on their namespace level first, then on their string * values. This makes higher hierarchy pages rank higher than lower hierarchy * pages. |