X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecialpage%2FSpecialPage.php;h=9594952d020aa737e28668e72138bc40fb3eb6d4;hb=2480aae0c97d822e10b50619e7b48b25c45af073;hp=99b9f33d4c43d28ce864fbf619df21e515506563;hpb=52f5f388a40e08a76b6c4efc52fedd1c65cc166d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specialpage/SpecialPage.php b/includes/specialpage/SpecialPage.php index 99b9f33d4c..4c3ca54b32 100644 --- a/includes/specialpage/SpecialPage.php +++ b/includes/specialpage/SpecialPage.php @@ -33,7 +33,7 @@ use MediaWiki\MediaWikiServices; * * @ingroup SpecialPage */ -class SpecialPage { +class SpecialPage implements MessageLocalizer { // The canonical name of this special page // Also used for the default

heading, @see getDescription() protected $mName; @@ -67,6 +67,8 @@ class SpecialPage { /** * Get a localised Title object for a specified special page name + * If you don't need a full Title object, consider using TitleValue through + * getTitleValueFor() below. * * @since 1.9 * @since 1.21 $fragment parameter added @@ -78,9 +80,24 @@ class SpecialPage { * @throws MWException */ public static function getTitleFor( $name, $subpage = false, $fragment = '' ) { + return Title::newFromTitleValue( + self::getTitleValueFor( $name, $subpage, $fragment ) + ); + } + + /** + * Get a localised TitleValue object for a specified special page name + * + * @since 1.28 + * @param string $name + * @param string|bool $subpage Subpage string, or false to not use a subpage + * @param string $fragment The link fragment (after the "#") + * @return TitleValue + */ + public static function getTitleValueFor( $name, $subpage = false, $fragment = '' ) { $name = SpecialPageFactory::getLocalNameFor( $name, $subpage ); - return Title::makeTitle( NS_SPECIAL, $name, $fragment ); + return new TitleValue( NS_SPECIAL, $name, $fragment ); } /** @@ -366,7 +383,7 @@ class SpecialPage { return true; } elseif ( $securityStatus === AuthManager::SEC_REAUTH ) { $request = $this->getRequest(); - $title = SpecialPage::getTitleFor( 'Userlogin' ); + $title = self::getTitleFor( 'Userlogin' ); $query = [ 'returnto' => $this->getFullTitle()->getPrefixedDBkey(), 'returntoquery' => wfArrayToCgi( array_diff_key( $request->getQueryValues(), @@ -439,7 +456,7 @@ class SpecialPage { $searchEngine->setLimitOffset( $limit, $offset ); $searchEngine->setNamespaces( [] ); $result = $searchEngine->defaultPrefixSearch( $search ); - return array_map( function( Title $t ) { + return array_map( function ( Title $t ) { return $t->getPrefixedText(); }, $result ); } @@ -726,7 +743,7 @@ class SpecialPage { * @return Message * @see wfMessage */ - public function msg( /* $args */ ) { + public function msg( $key /* $args */ ) { $message = call_user_func_array( [ $this->getContext(), 'msg' ], func_get_args() @@ -766,6 +783,10 @@ class SpecialPage { * @since 1.25 */ public function addHelpLink( $to, $overrideBaseUrl = false ) { + if ( $this->including() ) { + return; + } + global $wgContLang; $msg = $this->msg( $wgContLang->lc( $this->getName() ) . '-helppage' ); @@ -836,7 +857,7 @@ class SpecialPage { * @since 1.28 * @return \MediaWiki\Linker\LinkRenderer */ - protected function getLinkRenderer() { + public function getLinkRenderer() { if ( $this->linkRenderer ) { return $this->linkRenderer; } else {