From 376c0a13df05f30367b2a89c2cac7bdab22600ed Mon Sep 17 00:00:00 2001 From: Nemo bis Date: Sun, 31 Aug 2014 13:25:18 +0300 Subject: [PATCH] Add top help link to MediaWiki.org in several pages via indicator MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- includes/OutputPage.php | 31 +++++++++++++++++- includes/actions/DeleteAction.php | 3 +- includes/specials/SpecialAllMessages.php | 1 + includes/specials/SpecialBlock.php | 2 ++ includes/specials/SpecialMergeHistory.php | 9 +++-- includes/specials/SpecialMovepage.php | 1 + includes/specials/SpecialNewimages.php | 7 ++-- includes/specials/SpecialNewpages.php | 2 ++ includes/specials/SpecialUndelete.php | 1 + includes/specials/SpecialUpload.php | 2 ++ includes/specials/SpecialUserrights.php | 1 + languages/i18n/en.json | 1 + languages/i18n/qqq.json | 1 + resources/Resources.php | 6 ++++ resources/src/mediawiki/images/help.png | Bin 0 -> 428 bytes .../src/mediawiki/mediawiki.helplink.css | 5 +++ 16 files changed, 66 insertions(+), 7 deletions(-) create mode 100644 resources/src/mediawiki/images/help.png create mode 100644 resources/src/mediawiki/mediawiki.helplink.css diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 5c146e4d25..d62d49b812 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -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. diff --git a/includes/actions/DeleteAction.php b/includes/actions/DeleteAction.php index 12f0dff044..82424eb00e 100644 --- a/includes/actions/DeleteAction.php +++ b/includes/actions/DeleteAction.php @@ -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(); } } diff --git a/includes/specials/SpecialAllMessages.php b/includes/specials/SpecialAllMessages.php index 0008b100c1..5211e3016c 100644 --- a/includes/specials/SpecialAllMessages.php +++ b/includes/specials/SpecialAllMessages.php @@ -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, diff --git a/includes/specials/SpecialBlock.php b/includes/specials/SpecialBlock.php index 1d4a8606bf..0323505fc9 100644 --- a/includes/specials/SpecialBlock.php +++ b/includes/specials/SpecialBlock.php @@ -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 ); diff --git a/includes/specials/SpecialMergeHistory.php b/includes/specials/SpecialMergeHistory.php index 7e74cd5b11..368d4919d1 100644 --- a/includes/specials/SpecialMergeHistory.php +++ b/includes/specials/SpecialMergeHistory.php @@ -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 { '' . '' ); + + $out->addHelpLink( 'Help:Merge history' ); } private function showHistory() { diff --git a/includes/specials/SpecialMovepage.php b/includes/specials/SpecialMovepage.php index cac324ac00..53d084586e 100644 --- a/includes/specials/SpecialMovepage.php +++ b/includes/specials/SpecialMovepage.php @@ -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; diff --git a/includes/specials/SpecialNewimages.php b/includes/specials/SpecialNewimages.php index 94e77e3f64..de19fa4841 100644 --- a/includes/specials/SpecialNewimages.php +++ b/includes/specials/SpecialNewimages.php @@ -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() ); } } diff --git a/includes/specials/SpecialNewpages.php b/includes/specials/SpecialNewpages.php index 994a2e5154..594628f7bc 100644 --- a/includes/specials/SpecialNewpages.php +++ b/includes/specials/SpecialNewpages.php @@ -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(); diff --git a/includes/specials/SpecialUndelete.php b/includes/specials/SpecialUndelete.php index fb2c421d16..c88c2f1154 100644 --- a/includes/specials/SpecialUndelete.php +++ b/includes/specials/SpecialUndelete.php @@ -790,6 +790,7 @@ class SpecialUndelete extends SpecialPage { return; } + $out->addHelpLink( 'Help:Undelete' ); if ( $this->mAllowed ) { $out->setPageTitle( $this->msg( 'undeletepage' ) ); } else { diff --git a/includes/specials/SpecialUpload.php b/includes/specials/SpecialUpload.php index ce8192b1f7..72d02e0c5a 100644 --- a/includes/specials/SpecialUpload.php +++ b/includes/specials/SpecialUpload.php @@ -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 ); diff --git a/includes/specials/SpecialUserrights.php b/includes/specials/SpecialUserrights.php index a5edcb02ca..7dd2b87149 100644 --- a/includes/specials/SpecialUserrights.php +++ b/includes/specials/SpecialUserrights.php @@ -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'] ) ) { diff --git a/languages/i18n/en.json b/languages/i18n/en.json index cff74b4e64..d2caad300d 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -234,6 +234,7 @@ "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", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 64701032cd..0152e9ed29 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -398,6 +398,7 @@ "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 \"Help:\" 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 Project: part.}}\nThe URL of the project page describing the policies of the wiki.\n\nThis is shown below every page (the left link).", diff --git a/resources/Resources.php b/resources/Resources.php index 233485c345..1829cfacf5 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -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 index 0000000000000000000000000000000000000000..f1bc368d424e34ce412dd3efa028abe11183d93a GIT binary patch literal 428 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbMft^l79*Z=?j=k9y~MA zjBU@ImOM(@{M=#jL+=%jQ@1{MUHS+p?y>waP#nkxiu*rfN8Wt>^|x&AtKhXycisDP<<*aeAAdC*dXus3#r4-emtOu@xclXU z55It}nlf==qO-A&r((R|XX>n0f5Oaf5|7!j`ApWVkc2NT-Yc zI_si(Rpmv&$HWi5-#j7?*+C2O<1r!Smp00i_ I>zopr03GS*TmS$7 literal 0 HcmV?d00001 diff --git a/resources/src/mediawiki/mediawiki.helplink.css b/resources/src/mediawiki/mediawiki.helplink.css new file mode 100644 index 0000000000..5d45778e41 --- /dev/null +++ b/resources/src/mediawiki/mediawiki.helplink.css @@ -0,0 +1,5 @@ +#mw-indicator-mw-helplink a { + /* @embed */ + background: url(images/help.png) no-repeat scroll left center transparent; + padding-left: 20px; +} -- 2.20.1