Add top help link to MediaWiki.org in several pages via indicator
authorNemo bis <federicoleva@tiscali.it>
Sun, 31 Aug 2014 10:25:18 +0000 (13:25 +0300)
committerFederico Leva <federicoleva@tiscali.it>
Wed, 4 Mar 2015 09:59:03 +0000 (10:59 +0100)
All the chosen targets are translatable public domain help pages
on MediaWiki.org. Mostly special pages and actions for privileged
users for now.

Adapted from the Translate extension, credit to Niklas Laxström
(TranslateUtils::addSpecialHelpLink).

Depends on 6f5b29ff4e6fdf21b5a8cacaf10d6aceaee26a7d, whose commit
message has a typo addIndicator() instead of setIndicator().

Bug: T45591
Change-Id: I2934b1708a0d207dcf3d940264f140613646f203

16 files changed:
includes/OutputPage.php
includes/actions/DeleteAction.php
includes/specials/SpecialAllMessages.php
includes/specials/SpecialBlock.php
includes/specials/SpecialMergeHistory.php
includes/specials/SpecialMovepage.php
includes/specials/SpecialNewimages.php
includes/specials/SpecialNewpages.php
includes/specials/SpecialUndelete.php
includes/specials/SpecialUpload.php
includes/specials/SpecialUserrights.php
languages/i18n/en.json
languages/i18n/qqq.json
resources/Resources.php
resources/src/mediawiki/images/help.png [new file with mode: 0644]
resources/src/mediawiki/mediawiki.helplink.css [new file with mode: 0644]

index 5c146e4..d62d49b 100644 (file)
@@ -1379,7 +1379,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.
         *
@@ -1404,6 +1405,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.
index 12f0dff..82424eb 100644 (file)
@@ -41,13 +41,14 @@ class DeleteAction extends FormlessAction {
        }
 
        public function show() {
+               $out = $this->getOutput();
                if ( $this->getContext()->getConfig()->get( 'UseMediaWikiUIEverywhere' ) ) {
-                       $out = $this->getOutput();
                        $out->addModuleStyles( array(
                                'mediawiki.ui.input',
                                'mediawiki.ui.checkbox',
                        ) );
                }
+               $out->addHelpLink( 'Help:Sysop deleting and undeleting' );
                $this->page->delete();
        }
 }
index 0008b10..5211e30 100644 (file)
@@ -59,6 +59,7 @@ class SpecialAllMessages extends SpecialPage {
 
                $this->outputHeader( 'allmessagestext' );
                $out->addModuleStyles( 'mediawiki.special' );
+               $out->addHelpLink( 'Help:System message' );
 
                $this->table = new AllmessagesTablePager(
                        $this,
index 1d4a860..0323505 100644 (file)
@@ -103,6 +103,8 @@ class SpecialBlock extends FormSpecialPage {
                $msg = $this->alreadyBlocked ? 'ipb-change-block' : 'ipbsubmit';
                $form->setSubmitTextMsg( $msg );
 
+               $this->getOutput()->addHelpLink( 'Help:Blocking users' );
+
                # Don't need to do anything if the form has been posted
                if ( !$this->getRequest()->wasPosted() && $this->preErrors ) {
                        $s = $form->formatErrors( $this->preErrors );
index 7e74cd5..368d491 100644 (file)
@@ -152,16 +152,17 @@ class SpecialMergeHistory extends SpecialPage {
 
                if ( count( $errors ) ) {
                        $this->showMergeForm();
-                       $this->getOutput()->addHTML( implode( "\n", $errors ) );
+                       $out->addHTML( implode( "\n", $errors ) );
                } else {
                        $this->showHistory();
                }
        }
 
        function showMergeForm() {
-               $this->getOutput()->addWikiMsg( 'mergehistory-header' );
+               $out = $this->getOutput();
+               $out->addWikiMsg( 'mergehistory-header' );
 
-               $this->getOutput()->addHTML(
+               $out->addHTML(
                        Xml::openElement( 'form', array(
                                'method' => 'get',
                                'action' => wfScript() ) ) .
@@ -185,6 +186,8 @@ class SpecialMergeHistory extends SpecialPage {
                                '</fieldset>' .
                                '</form>'
                );
+
+               $out->addHelpLink( 'Help:Merge history' );
        }
 
        private function showHistory() {
index cac324a..53d0845 100644 (file)
@@ -140,6 +140,7 @@ class MovePageForm extends UnlistedSpecialPage {
                $out = $this->getOutput();
                $out->setPageTitle( $this->msg( 'move-page', $this->oldTitle->getPrefixedText() ) );
                $out->addModules( 'mediawiki.special.movePage' );
+               $out->addHelpLink( 'Help:Moving a page' );
 
                $newTitle = $this->newTitle;
 
index 94e77e3..de19fa4 100644 (file)
@@ -30,6 +30,9 @@ class SpecialNewFiles extends IncludableSpecialPage {
                $this->setHeaders();
                $this->outputHeader();
 
+               $out = $this->getOutput();
+               $out->addHelpLink( 'Help:New images' );
+
                $pager = new NewFilesPager( $this->getContext(), $par );
 
                if ( !$this->including() ) {
@@ -39,9 +42,9 @@ class SpecialNewFiles extends IncludableSpecialPage {
                        $form->displayForm( '' );
                }
 
-               $this->getOutput()->addHTML( $pager->getBody() );
+               $out->addHTML( $pager->getBody() );
                if ( !$this->including() ) {
-                       $this->getOutput()->addHTML( $pager->getNavigationBar() );
+                       $out->addHTML( $pager->getNavigationBar() );
                }
        }
 
index 994a2e5..594628f 100644 (file)
@@ -127,6 +127,8 @@ class SpecialNewpages extends IncludableSpecialPage {
                $this->showNavigation = !$this->including(); // Maybe changed in setup
                $this->setup( $par );
 
+               $out->addHelpLink( 'Help:New pages' );
+
                if ( !$this->including() ) {
                        // Settings
                        $this->form();
index fb2c421..c88c2f1 100644 (file)
@@ -790,6 +790,7 @@ class SpecialUndelete extends SpecialPage {
                        return;
                }
 
+               $out->addHelpLink( 'Help:Undelete' );
                if ( $this->mAllowed ) {
                        $out->setPageTitle( $this->msg( 'undeletepage' ) );
                } else {
index ce8192b..72d02e0 100644 (file)
@@ -160,6 +160,8 @@ class SpecialUpload extends SpecialPage {
                        throw new ErrorPageError( 'uploaddisabled', 'uploaddisabledtext' );
                }
 
+               $this->getOutput()->addHelpLink( 'Help:Managing files' );
+
                # Check permissions
                $user = $this->getUser();
                $permissionRequired = UploadBase::isAllowed( $user );
index a5edcb0..7dd2b87 100644 (file)
@@ -135,6 +135,7 @@ class UserrightsPage extends SpecialPage {
 
                $out = $this->getOutput();
                $out->addModuleStyles( 'mediawiki.special' );
+               $out->addHelpLink( 'Help:Assigning permissions' );
 
                // show the general form
                if ( count( $available['add'] ) || count( $available['remove'] ) ) {
index cff74b4..d2caad3 100644 (file)
        "edithelp": "Editing help",
        "edithelppage": "https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Editing_pages",
        "helppage": "https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents",
+       "helppage-top-gethelp": "Help",
        "mainpage": "Main Page",
        "mainpage-description": "Main page",
        "policy-url": "Project:Policy",
index 6470103..0152e9e 100644 (file)
        "edithelp": "This is the text that appears on the editing help link that is near the bottom of the editing page",
        "edithelppage": "The help page displayed when a user clicks on editing help link which is present on the right of Show changes button.\n{{doc-important|Do not change the \"<tt>Help:</tt>\" part.}}",
        "helppage": "{{ignored}}\nThe link destination used by default in the sidebar, and in {{msg-mw|Noarticletext}}.",
+       "helppage-top-gethelp": "Link to some MediaWiki.org help page or tutorial.\n{{Identical|Help}}",
        "mainpage": "Defines the link and display name of the main page of the wiki. Shown as the top link in the navigation part of the interface. Please do not change it too often, that could break things!\n\nSee also:\n* {{msg-mw|Mainpage}}\n* {{msg-mw|Accesskey-n-mainpage}}\n* {{msg-mw|Tooltip-n-mainpage}}\n{{Identical|Main page}}",
        "mainpage-description": "The same as {{msg-mw|mainpage}}, used as link text on [[MediaWiki:Sidebar]].\n\nThis makes it possible to the change the link destination (the message \"mainpage\") without changing the link text or without disabling translations.\n\nSee also:\n* {{msg-mw|Mainpage-description}}\n* {{msg-mw|Accesskey-n-mainpage-description}}\n* {{msg-mw|Tooltip-n-mainpage-description}}\n{{Identical|Main page}}",
        "policy-url": "{{doc-important|Do not change the <code>Project:</code> part.}}\nThe URL of the project page describing the policies of the wiki.\n\nThis is shown below every page (the left link).",
index 233485c..1829cfa 100644 (file)
@@ -883,6 +883,12 @@ return array(
                        'feedback-bugnew',
                ),
        ),
+       'mediawiki.helplink' => array(
+               'styles' => array(
+                       'resources/src/mediawiki/mediawiki.helplink.css',
+               ),
+               'targets' => array( 'desktop', 'mobile' ),
+       ),
        'mediawiki.hidpi' => array(
                'scripts' => 'resources/src/mediawiki/mediawiki.hidpi.js',
                'dependencies' => array(
diff --git a/resources/src/mediawiki/images/help.png b/resources/src/mediawiki/images/help.png
new file mode 100644 (file)
index 0000000..f1bc368
Binary files /dev/null and b/resources/src/mediawiki/images/help.png differ
diff --git a/resources/src/mediawiki/mediawiki.helplink.css b/resources/src/mediawiki/mediawiki.helplink.css
new file mode 100644 (file)
index 0000000..5d45778
--- /dev/null
@@ -0,0 +1,5 @@
+#mw-indicator-mw-helplink a {
+       /* @embed */
+       background: url(images/help.png) no-repeat scroll left center transparent;
+       padding-left: 20px;
+}