コード例 #1
0
 public function testGetAliasListRecursion()
 {
     $called = false;
     $this->mergeMwGlobalArrayValue('wgHooks', array('SpecialPage_initList' => array(function () use(&$called) {
         SpecialPageFactory::getLocalNameFor('Specialpages');
         $called = true;
     })));
     SpecialPageFactory::resetList();
     SpecialPageFactory::getLocalNameFor('Specialpages');
     $this->assertTrue($called, 'Recursive call succeeded');
 }
コード例 #2
0
ファイル: Title.php プロジェクト: MediaWiki-stable/1.26.1
 /**
  * If the Title refers to a special page alias which is not the local default, resolve
  * the alias, and localise the name as necessary.  Otherwise, return $this
  *
  * @return Title
  */
 public function fixSpecialName()
 {
     if ($this->isSpecialPage()) {
         list($canonicalName, $par) = SpecialPageFactory::resolveAlias($this->mDbkeyform);
         if ($canonicalName) {
             $localName = SpecialPageFactory::getLocalNameFor($canonicalName, $par);
             if ($localName != $this->mDbkeyform) {
                 return Title::makeTitle(NS_SPECIAL, $localName);
             }
         }
     }
     return $this;
 }
コード例 #3
0
ファイル: SMW_DV_Types.php プロジェクト: Tjorriemorrie/app
 /**
  * Gets the title text for the types special page.
  * Takes care of compatibility changes in MW 1.17 and 1.18.
  * 1.17 introduces SpecialPageFactory
  * 1.18 deprecates SpecialPage::getLocalNameFor
  *
  * @since 1.6
  *
  * @return string
  */
 protected function getSpecialPageTitleText()
 {
     return is_callable(array('SpecialPageFactory', 'getLocalNameFor')) ? SpecialPageFactory::getLocalNameFor('Types', $this->m_realLabel) : SpecialPage::getLocalNameFor('Types', $this->m_realLabel);
 }
コード例 #4
0
ファイル: SpecialPage.php プロジェクト: seedbank/old-repo
 /**
  * Get the localised name of the special page
  */
 function getLocalName()
 {
     if (!isset($this->mLocalName)) {
         $this->mLocalName = SpecialPageFactory::getLocalNameFor($this->mName);
     }
     return $this->mLocalName;
 }
コード例 #5
0
 /**
  * @dataProvider provideTestConflictResolution
  */
 public function testConflictResolution($test, $aliasesList, $alias, $expectedName, $expectedAlias, $expectWarnings)
 {
     global $wgContLang;
     $lang = clone $wgContLang;
     $lang->mExtendedSpecialPageAliases = $aliasesList;
     $this->setMwGlobals('wgContLang', $lang);
     $this->setMwGlobals('wgSpecialPages', array_combine(array_keys($aliasesList), array_keys($aliasesList)));
     SpecialPageFactory::resetList();
     // Catch the warnings we expect to be raised
     $warnings = array();
     $this->setMwGlobals('wgDevelopmentWarnings', true);
     set_error_handler(function ($errno, $errstr) use(&$warnings) {
         if (preg_match('/First alias \'[^\']*\' for .*/', $errstr) || preg_match('/Did not find a usable alias for special page .*/', $errstr)) {
             $warnings[] = $errstr;
             return true;
         }
         return false;
     });
     $reset = new ScopedCallback('restore_error_handler');
     list($name, ) = SpecialPageFactory::resolveAlias($alias);
     $this->assertEquals($expectedName, $name, "{$test}: Alias to name");
     $result = SpecialPageFactory::getLocalNameFor($name);
     $this->assertEquals($expectedAlias, $result, "{$test}: Alias to name to alias");
     $gotWarnings = count($warnings);
     if ($gotWarnings !== $expectWarnings) {
         $this->fail("Expected {$expectWarnings} warning(s), but got {$gotWarnings}:\n" . join("\n", $warnings));
     }
 }
コード例 #6
0
 /**
  * Handler for PostLoginRedirect
  * @param string $returnTo The page to return to
  * @param array $returnToQuery Url parameters
  * @param string $type Type of login redirect
  */
 public static function onPostLoginRedirect(&$returnTo, &$returnToQuery, &$type)
 {
     global $wgCentralAuthCheckSULMigration, $wgUser;
     if ($wgCentralAuthCheckSULMigration && $wgUser->getRequest()->getSessionData('CentralAuthForcedRename') === true && ($type == 'success' || $type == 'successredirect')) {
         wfDebugLog('SUL', 'Redirecting user to Special:SulRenameWarning');
         // Store current redirect target in session so we can provide a link
         // later.
         $wgUser->getRequest()->setSessionData('SulRenameWarning', array('returnTo' => $returnTo, 'returnToQuery' => $returnToQuery));
         $returnTo = SpecialPageFactory::getLocalNameFor('Special:SulRenameWarning');
         $returnToQuery = array();
         return false;
     }
     return true;
 }
コード例 #7
0
 /**
  * Gets the title text for the types special page.
  *
  * @since 1.6
  *
  * @return string
  */
 protected function getSpecialPageTitleText()
 {
     return SpecialPageFactory::getLocalNameFor('Types', $this->m_realLabel);
 }