Merge "Add top help link to MediaWiki.org in several pages via indicator"
[lhc/web/wiklou.git] / includes / OutputPage.php
index 4070822..33483eb 100644 (file)
@@ -1373,7 +1373,8 @@ class OutputPage extends ContextSource {
        }
 
        /**
-        * Add an array of indicators, with their identifiers as array keys and HTML contents as values.
+        * Add an array of indicators, with their identifiers as array
+        * keys and HTML contents as values.
         *
         * In case of duplicate keys, existing values are overwritten.
         *
@@ -1398,6 +1399,34 @@ class OutputPage extends ContextSource {
                return $this->mIndicators;
        }
 
+       /**
+        * Adds help link with an icon via page indicators.
+        * @param string $to
+        * @param bool $overrideBaseUrl
+        * @since 1.25
+        */
+       public function addHelpLink( $to, $overrideBaseUrl = false ) {
+               $this->addModules( 'mediawiki.helplink' );
+               $text = wfMessage( 'helppage-top-gethelp' )->escaped();
+
+               if ( $overrideBaseUrl ) {
+                       $helpUrl = $to;
+               } else {
+                       $helpUrl = "//www.mediawiki.org/wiki/Special:MyLanguage/$to";
+               }
+               $link = Html::rawElement(
+                       'a',
+                       array(
+                               'href' => $helpUrl,
+                               'target' => '_blank',
+                               'class' => 'mw-helplink',
+                       ),
+                       $text
+               );
+
+               $this->setIndicators( array( 'mw-helplink' => $link ) );
+       }
+
        /**
         * Do not allow scripts which can be modified by wiki users to load on this page;
         * only allow scripts bundled with, or generated by, the software.