/** * Prefix search special-case for Special: namespace. */ protected static function specialSearch($search, $limit) { global $wgContLang; $searchKey = $wgContLang->caseFold($search); // Unlike SpecialPage itself, we want the canonical forms of both // canonical and alias title forms... SpecialPage::initList(); SpecialPage::initAliasList(); $keys = array(); foreach (array_keys(SpecialPage::$mList) as $page) { $keys[$wgContLang->caseFold($page)] = $page; } foreach ($wgContLang->getSpecialPageAliases() as $page => $aliases) { foreach ($aliases as $alias) { $keys[$wgContLang->caseFold($alias)] = $alias; } } ksort($keys); $srchres = array(); foreach ($keys as $pageKey => $page) { if ($searchKey === '' || strpos($pageKey, $searchKey) === 0) { $srchres[] = Title::makeTitle(NS_SPECIAL, $page)->getPrefixedText(); } if (count($srchres) >= $limit) { break; } } return $srchres; }
/** * Prefix search special-case for Special: namespace. * * @param $search String: term * @param $limit Integer: max number of items to return * @return Array */ protected static function specialSearch($search, $limit) { global $wgContLang; # normalize searchKey, so aliases with spaces can be found - bug 25675 $search = str_replace(' ', '_', $search); $searchKey = $wgContLang->caseFold($search); // Unlike SpecialPage itself, we want the canonical forms of both // canonical and alias title forms... SpecialPage::initList(); SpecialPage::initAliasList(); $keys = array(); foreach (array_keys(SpecialPage::$mList) as $page) { $keys[$wgContLang->caseFold($page)] = $page; } foreach ($wgContLang->getSpecialPageAliases() as $page => $aliases) { if (!array_key_exists($page, SpecialPage::$mList)) { # bug 20885 continue; } foreach ($aliases as $alias) { $keys[$wgContLang->caseFold($alias)] = $alias; } } ksort($keys); $srchres = array(); foreach ($keys as $pageKey => $page) { if ($searchKey === '' || strpos($pageKey, $searchKey) === 0) { wfSuppressWarnings(); // bug 27671: Don't use SpecialPage::getTitleFor() here because it // localizes its input leading to searches for e.g. Special:All // returning Spezial:MediaWiki-Systemnachrichten and returning // Spezial:Alle_Seiten twice when $wgLanguageCode == 'de' $srchres[] = Title::makeTitleSafe(NS_SPECIAL, $page)->getPrefixedText(); wfRestoreWarnings(); } if (count($srchres) >= $limit) { break; } } return $srchres; }