Fix edit link for messages in $wgForceUIMsgAsContentMsg
authorumherirrender <umherirrender_de.wp@web.de>
Sat, 13 Dec 2014 19:55:13 +0000 (20:55 +0100)
committerumherirrender <umherirrender_de.wp@web.de>
Fri, 15 May 2015 18:38:32 +0000 (20:38 +0200)
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

includes/FileDeleteForm.php
includes/Message.php
includes/ProtectionForm.php
includes/page/Article.php
includes/specials/SpecialBlock.php
includes/specials/SpecialRevisiondelete.php
includes/specials/SpecialTags.php
includes/specials/SpecialUpload.php

index c1d14db..6d74af2 100644 (file)
@@ -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(),
index 4935e33..329d97a 100644 (file)
@@ -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.
         *
index c546de7..69b64dd 100644 (file)
@@ -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' )
index 25bf844..996ff15 100644 (file)
@@ -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' )
index 3f13510..c67c03c 100644 (file)
@@ -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' )
index 62025e7..6f1b128 100644 (file)
@@ -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' )
index 0b8147e..64c2cf3 100644 (file)
@@ -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();
index 3f1ea42..277e52b 100644 (file)
@@ -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' )