From: umherirrender Date: Sat, 13 Dec 2014 19:55:13 +0000 (+0100) Subject: Fix edit link for messages in $wgForceUIMsgAsContentMsg X-Git-Tag: 1.31.0-rc.0~11324^2 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=e51eaf619fb15521f84e35f1a64e66aa38e63106;p=lhc%2Fweb%2Fwiklou.git Fix edit link for messages in $wgForceUIMsgAsContentMsg Some special pages or actions have a link for users with editinterface rights to edit the message used in scroll down menu. When the message is parsed for the scroll down menu the config $wgForceUIMsgAsContentMsg is used, but that was not used for the edit link. Add a new function Message::getTitle and use it in all places in core. Most benefit will have the edit link for MediaWiki:Licenses on Special:Upload, because commons.wikimedia.org has that message in $wgForceUIMsgAsContentMsg. Change-Id: Ib800b9adcc9ae88ef53228b66838bf61d2065f0f --- diff --git a/includes/FileDeleteForm.php b/includes/FileDeleteForm.php index c1d14db0a6..6d74af2da1 100644 --- a/includes/FileDeleteForm.php +++ b/includes/FileDeleteForm.php @@ -296,7 +296,7 @@ class FileDeleteForm { Xml::closeElement( 'form' ); if ( $wgUser->isAllowed( 'editinterface' ) ) { - $title = Title::makeTitle( NS_MEDIAWIKI, 'Filedelete-reason-dropdown' ); + $title = wfMessage( 'filedelete-reason-dropdown' )->inContentLanguage()->getTitle(); $link = Linker::link( $title, wfMessage( 'filedelete-edit-reasonlist' )->escaped(), diff --git a/includes/Message.php b/includes/Message.php index 4935e33946..329d97afac 100644 --- a/includes/Message.php +++ b/includes/Message.php @@ -364,6 +364,31 @@ class Message implements MessageSpecifier { return new self( $keys ); } + /** + * Get a title object for a mediawiki message, where it can be found in the mediawiki namespace. + * The title will be for the current language, if the message key is in + * $wgForceUIMsgAsContentMsg it will be append with the language code (except content + * language), because Message::inContentLanguage will also return in user language. + * + * @see $wgForceUIMsgAsContentMsg + * @return Title + * @since 1.26 + */ + public function getTitle() { + global $wgContLang, $wgForceUIMsgAsContentMsg; + + $code = $this->language->getCode(); + $title = $this->key; + if ( + $wgContLang->getCode() !== $code + && in_array( $this->key, (array)$wgForceUIMsgAsContentMsg ) + ) { + $title .= '/' . $code; + } + + return Title::makeTitle( NS_MEDIAWIKI, $wgContLang->ucfirst( strtr( $title, ' ', '_' ) ) ); + } + /** * Adds parameters to the parameter list of this message. * diff --git a/includes/ProtectionForm.php b/includes/ProtectionForm.php index c546de75f3..69b64dd62b 100644 --- a/includes/ProtectionForm.php +++ b/includes/ProtectionForm.php @@ -541,9 +541,8 @@ class ProtectionForm { $out .= Xml::closeElement( 'fieldset' ); if ( $user->isAllowed( 'editinterface' ) ) { - $title = Title::makeTitle( NS_MEDIAWIKI, 'Protect-dropdown' ); $link = Linker::link( - $title, + $context->msg( 'protect-dropdown' )->inContentLanguage()->getTitle(), $context->msg( 'protect-edit-reasonlist' )->escaped(), array(), array( 'action' => 'edit' ) diff --git a/includes/page/Article.php b/includes/page/Article.php index 25bf844853..996ff15d11 100644 --- a/includes/page/Article.php +++ b/includes/page/Article.php @@ -1750,9 +1750,8 @@ class Article implements Page { Xml::closeElement( 'form' ); if ( $user->isAllowed( 'editinterface' ) ) { - $dropdownTitle = Title::makeTitle( NS_MEDIAWIKI, 'Deletereason-dropdown' ); $link = Linker::link( - $dropdownTitle, + $ctx->msg( 'deletereason-dropdown' )->inContentLanguage()->getTitle(), wfMessage( 'delete-edit-reasonlist' )->escaped(), array(), array( 'action' => 'edit' ) diff --git a/includes/specials/SpecialBlock.php b/includes/specials/SpecialBlock.php index 3f13510de2..c67c03c137 100644 --- a/includes/specials/SpecialBlock.php +++ b/includes/specials/SpecialBlock.php @@ -395,7 +395,7 @@ class SpecialBlock extends FormSpecialPage { # Link to edit the block dropdown reasons, if applicable if ( $user->isAllowed( 'editinterface' ) ) { $links[] = Linker::link( - Title::makeTitle( NS_MEDIAWIKI, 'Ipbreason-dropdown' ), + $this->msg( 'ipbreason-dropdown' )->inContentLanguage()->getTitle(), $this->msg( 'ipb-edit-dropdown' )->escaped(), array(), array( 'action' => 'edit' ) diff --git a/includes/specials/SpecialRevisiondelete.php b/includes/specials/SpecialRevisiondelete.php index 62025e75d6..6f1b1282af 100644 --- a/includes/specials/SpecialRevisiondelete.php +++ b/includes/specials/SpecialRevisiondelete.php @@ -450,9 +450,8 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { Xml::closeElement( 'form' ) . "\n"; // Show link to edit the dropdown reasons if ( $this->getUser()->isAllowed( 'editinterface' ) ) { - $title = Title::makeTitle( NS_MEDIAWIKI, 'Revdelete-reason-dropdown' ); $link = Linker::link( - $title, + $this->msg( 'revdelete-reason-dropdown' )->inContentLanguage()->getTitle(), $this->msg( 'revdelete-edit-reasonlist' )->escaped(), array(), array( 'action' => 'edit' ) diff --git a/includes/specials/SpecialTags.php b/includes/specials/SpecialTags.php index 0b8147e196..64c2cf3b96 100644 --- a/includes/specials/SpecialTags.php +++ b/includes/specials/SpecialTags.php @@ -160,7 +160,7 @@ class SpecialTags extends SpecialPage { if ( $user->isAllowed( 'editinterface' ) ) { $disp .= ' '; $editLink = Linker::link( - Title::makeTitle( NS_MEDIAWIKI, "Tag-$tag" ), + $this->msg( "tag-$tag" )->inContentLanguage()->getTitle(), $this->msg( 'tags-edit' )->escaped() ); $disp .= $this->msg( 'parentheses' )->rawParams( $editLink )->escaped(); @@ -172,7 +172,7 @@ class SpecialTags extends SpecialPage { if ( $user->isAllowed( 'editinterface' ) ) { $desc .= ' '; $editDescLink = Linker::link( - Title::makeTitle( NS_MEDIAWIKI, "Tag-$tag-description" ), + $this->msg( "tag-$tag-description" )->inContentLanguage()->getTitle(), $this->msg( 'tags-edit' )->escaped() ); $desc .= $this->msg( 'parentheses' )->rawParams( $editDescLink )->escaped(); diff --git a/includes/specials/SpecialUpload.php b/includes/specials/SpecialUpload.php index 3f1ea42626..277e52bd8f 100644 --- a/includes/specials/SpecialUpload.php +++ b/includes/specials/SpecialUpload.php @@ -818,7 +818,7 @@ class UploadForm extends HTMLForm { # Add a link to edit MediaWik:Licenses if ( $this->getUser()->isAllowed( 'editinterface' ) ) { $licensesLink = Linker::link( - Title::makeTitle( NS_MEDIAWIKI, 'Licenses' ), + $this->msg( 'licenses' )->inContentLanguage()->getTitle(), $this->msg( 'licenses-edit' )->escaped(), array(), array( 'action' => 'edit' )