本文整理汇总了PHP中SpecialPageFactory::getNames方法的典型用法代码示例。如果您正苦于以下问题:PHP SpecialPageFactory::getNames方法的具体用法?PHP SpecialPageFactory::getNames怎么用?PHP SpecialPageFactory::getNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpecialPageFactory
的用法示例。
在下文中一共展示了SpecialPageFactory::getNames方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetNames
/**
* @covers SpecialPageFactory::getNames
*/
public function testGetNames()
{
$this->mergeMwGlobalArrayValue('wgSpecialPages', array('testdummy' => 'SpecialAllPages'));
SpecialPageFactory::resetList();
$names = SpecialPageFactory::getNames();
$this->assertInternalType('array', $names);
$this->assertContains('testdummy', $names);
}
示例2: specialSearch
/**
* Prefix search special-case for Special: namespace.
*
* @param string $search Term
* @param int $limit Max number of items to return
* @param int $offset Number of items to offset
* @return array
*/
protected function specialSearch($search, $limit, $offset)
{
global $wgContLang;
$searchParts = explode('/', $search, 2);
$searchKey = $searchParts[0];
$subpageSearch = isset($searchParts[1]) ? $searchParts[1] : null;
// Handle subpage search separately.
if ($subpageSearch !== null) {
// Try matching the full search string as a page name
$specialTitle = Title::makeTitleSafe(NS_SPECIAL, $searchKey);
if (!$specialTitle) {
return array();
}
$special = SpecialPageFactory::getPage($specialTitle->getText());
if ($special) {
$subpages = $special->prefixSearchSubpages($subpageSearch, $limit, $offset);
return array_map(function ($sub) use($specialTitle) {
return $specialTitle->getSubpage($sub);
}, $subpages);
} else {
return array();
}
}
# normalize searchKey, so aliases with spaces can be found - bug 25675
$searchKey = str_replace(' ', '_', $searchKey);
$searchKey = $wgContLang->caseFold($searchKey);
// Unlike SpecialPage itself, we want the canonical forms of both
// canonical and alias title forms...
$keys = array();
foreach (SpecialPageFactory::getNames() as $page) {
$keys[$wgContLang->caseFold($page)] = $page;
}
foreach ($wgContLang->getSpecialPageAliases() as $page => $aliases) {
if (!in_array($page, SpecialPageFactory::getNames())) {
# bug 20885
continue;
}
foreach ($aliases as $alias) {
$keys[$wgContLang->caseFold($alias)] = $alias;
}
}
ksort($keys);
$srchres = array();
$skipped = 0;
foreach ($keys as $pageKey => $page) {
if ($searchKey === '' || strpos($pageKey, $searchKey) === 0) {
// 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'
if ($offset > 0 && $skipped < $offset) {
$skipped++;
continue;
}
$srchres[] = Title::makeTitleSafe(NS_SPECIAL, $page);
}
if (count($srchres) >= $limit) {
break;
}
}
return $srchres;
}
示例3: appendSpecialPageAliases
protected function appendSpecialPageAliases($property)
{
global $wgContLang;
$data = array();
$aliases = $wgContLang->getSpecialPageAliases();
foreach (SpecialPageFactory::getNames() as $specialpage) {
if (isset($aliases[$specialpage])) {
$arr = array('realname' => $specialpage, 'aliases' => $aliases[$specialpage]);
ApiResult::setIndexedTagName($arr['aliases'], 'alias');
$data[] = $arr;
}
}
ApiResult::setIndexedTagName($data, 'specialpage');
return $this->getResult()->addValue('query', $property, $data);
}