Merge "Allow to customise addHelpLink() target via system message"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 15 May 2015 10:42:51 +0000 (10:42 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 15 May 2015 10:42:51 +0000 (10:42 +0000)
1  2 
RELEASE-NOTES-1.25
includes/OutputPage.php
includes/page/Article.php

diff --combined RELEASE-NOTES-1.25
@@@ -47,8 -47,6 +47,8 @@@ production
    be installed and running for any such queues to work.
  * $wgAutopromoteOnce no longer supports the 'view' event. For keeping some
    compatibility, any 'view' event triggers will still trigger on 'edit'.
 +* $wgExtensionDirectory was added for when your extensions directory is somewhere
 +  other than $IP/extensions (as $wgStyleDirectory does with the skins directory).
  
  === New features in 1.25 ===
  * (T64861) Updated plural rules to CLDR 26. Includes incompatible changes
@@@ -378,17 -376,16 +378,21 @@@ MediaWiki supports over 350 languages. 
  regularly. Below only new and removed languages are listed, as well as
  changes to languages because of Bugzilla reports.
  
 +* Languages added:
 +** awa (अवधी / Awadhi), thanks to translator 1AnuraagPandey;
 +** bgn (بلوچی رخشانی / Western Balochi), thanks to translators
 +   Baloch Afghanistan, Ibrahim khashrowdi and Rachitrali;
 +** ses (Koyraboro Senni), thanks to translator Songhay.
  * (T66440) Kazakh (kk) wikis should no longer forcefully reset the user's
    interface language to kk where unexpected.
  * The Chinese conversion table was substantially updated to fix a lot of
    bugs and ensure better reading experience for different variants.
  
  === Other changes in 1.25 ===
+ * (T45591) Links to MediaWiki.org translatable help were added to indicators,
+   mostly in special pages. Local custom target titles can be placed in the
+   relevant '(namespace-X|action name|special page name)-helppage' system
+   message. Extensions can use the addHelpLink() function to do the same.
  * The skin autodiscovery mechanism, deprecated in MediaWiki 1.23, has been
    removed. See https://www.mediawiki.org/wiki/Manual:Skin_autodiscovery for
    migration guide for creators and users of custom skins that relied on it.
  * $wgResourceModuleSkinStyles no longer supports per-module local or remote paths. They
    can only be set for the entire skin.
  * Removed global function swap(). (deprecated since 1.24)
 -* Deprecated the ".php5" file extension entry points. Refer to the ".php" files
 -  instead. If you want ".php5" URLs to continue to work, set up redirects. In
 -  Apache, this can be done by enabling mod_rewrite and adding the following
 -  rules to your configuration:
 +* Deprecated the ".php5" file extension entry points and the $wgScriptExtension
 +  configuration variable. Refer to the ".php" files instead. If you want
 +  ".php5" URLs to continue to work, set up redirects. In Apache, this can be
 +  done by enabling mod_rewrite and adding the following rules to your
 +  configuration:
  
      RewriteEngine On
      RewriteBase /
diff --combined includes/OutputPage.php
@@@ -162,6 -162,9 +162,6 @@@ class OutputPage extends ContextSource 
        /** @var array */
        protected $mModuleStyles = array();
  
 -      /** @var array */
 -      protected $mModuleMessages = array();
 -
        /** @var ResourceLoader */
        protected $mResourceLoader;
  
        /**
         * Get the list of module messages to include on this page
         *
 +       * @deprecated since 1.26 Obsolete
         * @param bool $filter
         * @param string|null $position
 -       *
         * @return array Array of module names
         */
        public function getModuleMessages( $filter = false, $position = null ) {
 -              return $this->getModules( $filter, $position, 'mModuleMessages' );
 +              wfDeprecated( __METHOD__, '1.26' );
 +              return array();
        }
  
        /**
 -       * Add only messages of one or more modules recognized by the resource loader.
 -       * Module messages added through this function will be loaded by the resource
 -       * loader when the page loads.
 +       * Load messages of one or more ResourceLoader modules.
         *
 +       * @deprecated since 1.26 Use addModules() instead
         * @param string|array $modules Module name (string) or array of module names
         */
        public function addModuleMessages( $modules ) {
 -              $this->mModuleMessages = array_merge( $this->mModuleMessages, (array)$modules );
 +              wfDeprecated( __METHOD__, '1.26' );
        }
  
        /**
  
        /**
         * Adds help link with an icon via page indicators.
-        * @param string $to
-        * @param bool $overrideBaseUrl
+        * Link target can be overridden by a local message containing a wikilink:
+        * the message key is: lowercase action or special page name + '-helppage'.
+        * @param string $to Target MediaWiki.org page title or encoded URL.
+        * @param bool $overrideBaseUrl Whether $url is a full URL, to avoid MW.o.
         * @since 1.25
         */
        public function addHelpLink( $to, $overrideBaseUrl = false ) {
                        $toUrlencoded = wfUrlencode( str_replace( ' ', '_', $to ) );
                        $helpUrl = "//www.mediawiki.org/wiki/Special:MyLanguage/$toUrlencoded";
                }
                $link = Html::rawElement(
                        'a',
                        array(
                $this->addModules( $parserOutput->getModules() );
                $this->addModuleScripts( $parserOutput->getModuleScripts() );
                $this->addModuleStyles( $parserOutput->getModuleStyles() );
 -              $this->addModuleMessages( $parserOutput->getModuleMessages() );
                $this->addJsConfigVars( $parserOutput->getJsConfigVars() );
                $this->mPreventClickjacking = $this->mPreventClickjacking
                        || $parserOutput->preventClickjacking();
                $this->addModules( $parserOutput->getModules() );
                $this->addModuleScripts( $parserOutput->getModuleScripts() );
                $this->addModuleStyles( $parserOutput->getModuleStyles() );
 -              $this->addModuleMessages( $parserOutput->getModuleMessages() );
  
                $this->addJsConfigVars( $parserOutput->getJsConfigVars() );
        }
                $links[] = $this->makeResourceLoaderLink( $embedScripts, ResourceLoaderModule::TYPE_COMBINED );
  
                // Scripts and messages "only" requests marked for top inclusion
 -              // Messages should go first
 -              $links[] = $this->makeResourceLoaderLink(
 -                      $this->getModuleMessages( true, 'top' ),
 -                      ResourceLoaderModule::TYPE_MESSAGES
 -              );
                $links[] = $this->makeResourceLoaderLink(
                        $this->getModuleScripts( true, 'top' ),
                        ResourceLoaderModule::TYPE_SCRIPTS
         * @return string
         */
        function getScriptsForBottomQueue( $inHead ) {
 -              // Scripts and messages "only" requests marked for bottom inclusion
 +              // Scripts "only" requests marked for bottom inclusion
                // If we're in the <head>, use load() calls rather than <script src="..."> tags
 -              // Messages should go first
                $links = array();
 -              $links[] = $this->makeResourceLoaderLink( $this->getModuleMessages( true, 'bottom' ),
 -                      ResourceLoaderModule::TYPE_MESSAGES, /* $useESI = */ false, /* $extraQuery = */ array(),
 -                      /* $loadCall = */ $inHead
 -              );
                $links[] = $this->makeResourceLoaderLink( $this->getModuleScripts( true, 'bottom' ),
                        ResourceLoaderModule::TYPE_SCRIPTS, /* $useESI = */ false, /* $extraQuery = */ array(),
                        /* $loadCall = */ $inHead
@@@ -1254,22 -1254,22 +1254,22 @@@ class Article implements Page 
  
                # Show error message
                $oldid = $this->getOldID();
 -              if ( $oldid ) {
 -                      $text = wfMessage( 'missing-revision', $oldid )->plain();
 -              } elseif ( $title->getNamespace() === NS_MEDIAWIKI ) {
 -                      // Use the default message text
 -                      $text = $title->getDefaultMessageText();
 -              } elseif ( $title->quickUserCan( 'create', $this->getContext()->getUser() )
 -                      && $title->quickUserCan( 'edit', $this->getContext()->getUser() )
 -              ) {
 -                      $message = $this->getContext()->getUser()->isLoggedIn() ? 'noarticletext' : 'noarticletextanon';
 -                      $text = wfMessage( $message )->plain();
 +              if ( !$oldid && $title->getNamespace() === NS_MEDIAWIKI ) {
 +                      $outputPage->addParserOutput( $this->getContentObject()->getParserOutput( $title ) );
                } else {
 -                      $text = wfMessage( 'noarticletext-nopermission' )->plain();
 -              }
 -              $text = "<div class='noarticletext'>\n$text\n</div>";
 +                      if ( $oldid ) {
 +                              $text = wfMessage( 'missing-revision', $oldid )->plain();
 +                      } elseif ( $title->quickUserCan( 'create', $this->getContext()->getUser() )
 +                              && $title->quickUserCan( 'edit', $this->getContext()->getUser() )
 +                      ) {
 +                              $message = $this->getContext()->getUser()->isLoggedIn() ? 'noarticletext' : 'noarticletextanon';
 +                              $text = wfMessage( $message )->plain();
 +                      } else {
 +                              $text = wfMessage( 'noarticletext-nopermission' )->plain();
 +                      }
  
 -              $outputPage->addWikiText( $text );
 +                      $outputPage->addWikiText( "<div class='noarticletext'>\n$text\n</div>" );
 +              }
        }
  
        /**
                        '</div>';
        }
  
+       /**
+        * Adds help link with an icon via page indicators.
+        * Link target can be overridden by a local message containing a wikilink:
+        * the message key is: 'namespace-' + namespace number + '-helppage'.
+        * @param string $to Target MediaWiki.org page title or encoded URL.
+        * @param bool $overrideBaseUrl Whether $url is a full URL, to avoid MW.o.
+        * @since 1.25
+        */
+       public function addHelpLink( $to, $overrideBaseUrl = false ) {
+               $msg = wfMessage(
+                       'namespace-' . $this->getTitle()->getNamespace() . '-helppage'
+               );
+               if ( !$msg->isDisabled() ) {
+                       $helpUrl = Skin::makeUrl( $msg->plain() );
+                       $this->getOutput()->addHelpLink( $helpUrl, true );
+               } else {
+                       $this->getOutput()->addHelpLink( $to, $overrideBaseUrl );
+               }
+       }
        /**
         * Handle action=render
         */