当前位置: 首页>>代码示例>>PHP>>正文


PHP SpecialPageFactory::getNames方法代码示例

本文整理汇总了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);
 }
开发者ID:jpena88,项目名称:mediawiki-dokku-deploy,代码行数:11,代码来源:SpecialPageFactoryTest.php

示例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;
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:70,代码来源:PrefixSearch.php

示例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);
 }
开发者ID:spicy-tmw,项目名称:wiki-raw,代码行数:15,代码来源:ApiQuerySiteinfo.php


注:本文中的SpecialPageFactory::getNames方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。