Allow to customise addHelpLink() target via system message
Method similar to SpecialPage::outputHeader() to avoid registering tons of system messages and to have -summary and -helppage tidily listed together in Special:AllMessages by default. Bug: T45591 Change-Id: Ic849dde00be7379c1909a8486cf20f48c5aea5cf
This commit is contained in:
parent
01799a7cb3
commit
e928d5bdd0
22 changed files with 86 additions and 19 deletions
|
|
@ -382,6 +382,10 @@ changes to languages because of Bugzilla reports.
|
|||
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.
|
||||
|
|
|
|||
|
|
@ -1401,8 +1401,10 @@ class OutputPage extends ContextSource {
|
|||
|
||||
/**
|
||||
* 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 ) {
|
||||
|
|
@ -1415,6 +1417,7 @@ class OutputPage extends ContextSource {
|
|||
$toUrlencoded = wfUrlencode( str_replace( ' ', '_', $to ) );
|
||||
$helpUrl = "//www.mediawiki.org/wiki/Special:MyLanguage/$toUrlencoded";
|
||||
}
|
||||
|
||||
$link = Html::rawElement(
|
||||
'a',
|
||||
array(
|
||||
|
|
|
|||
|
|
@ -376,6 +376,25 @@ abstract class Action {
|
|||
return $this->msg( strtolower( $this->getName() ) )->escaped();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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: lowercase action 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 ) {
|
||||
$msg = wfMessage( $wgContLang->lc( $this->getActionName() ) . '-helppage' );
|
||||
|
||||
if ( !$msg->isDisabled() ) {
|
||||
$helpUrl = Skin::makeUrl( $msg->plain() );
|
||||
$this->getOutput()->addHelpLink( $helpUrl, true );
|
||||
} else {
|
||||
$this->getOutput()->addHelpLink( $to, $overrideBaseUrl );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The main action entry point. Do all output for display and send it to the context
|
||||
* output. Do not use globals $wgOut, $wgRequest, etc, in implementations; use
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class DeleteAction extends FormlessAction {
|
|||
'mediawiki.ui.checkbox',
|
||||
) );
|
||||
}
|
||||
$out->addHelpLink( 'Help:Sysop deleting and undeleting' );
|
||||
$this->addHelpLink( 'Help:Sysop deleting and undeleting' );
|
||||
$this->page->delete();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1505,6 +1505,27 @@ class Article implements Page {
|
|||
'</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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -115,6 +115,6 @@ class CategoryPage extends Article {
|
|||
);
|
||||
$out = $this->getContext()->getOutput();
|
||||
$out->addHTML( $viewer->getHTML() );
|
||||
$out->addHelpLink( 'Help:Categories' );
|
||||
$this->addHelpLink( 'Help:Categories' );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -632,6 +632,26 @@ class SpecialPage {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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: lowercase 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 ) {
|
||||
global $wgContLang;
|
||||
$msg = $this->msg( $wgContLang->lc( $this->getName() ) . '-helppage' );
|
||||
|
||||
if ( !$msg->isDisabled() ) {
|
||||
$helpUrl = Skin::makeUrl( $msg->plain() );
|
||||
$this->getOutput()->addHelpLink( $helpUrl, true );
|
||||
} else {
|
||||
$this->getOutput()->addHelpLink( $to, $overrideBaseUrl );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the group that the special page belongs in on Special:SpecialPage
|
||||
* Use this method, instead of getGroupName to allow customization
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class SpecialAllMessages extends SpecialPage {
|
|||
|
||||
$this->outputHeader( 'allmessagestext' );
|
||||
$out->addModuleStyles( 'mediawiki.special' );
|
||||
$out->addHelpLink( 'Help:System message' );
|
||||
$this->addHelpLink( 'Help:System message' );
|
||||
|
||||
$this->table = new AllMessagesTablePager(
|
||||
$this,
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ class SpecialBlock extends FormSpecialPage {
|
|||
$msg = $this->alreadyBlocked ? 'ipb-change-block' : 'ipbsubmit';
|
||||
$form->setSubmitTextMsg( $msg );
|
||||
|
||||
$this->getOutput()->addHelpLink( 'Help:Blocking users' );
|
||||
$this->addHelpLink( 'Help:Blocking users' );
|
||||
|
||||
# Don't need to do anything if the form has been posted
|
||||
if ( !$this->getRequest()->wasPosted() && $this->preErrors ) {
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class SpecialDiff extends RedirectSpecialPage {
|
|||
$this->mAddedRedirectParams['diff'] = $parts[1];
|
||||
} else {
|
||||
// Wrong number of parameters, bail out
|
||||
$this->getOutput()->addHelpLink( 'Help:Diff' );
|
||||
$this->addHelpLink( 'Help:Diff' );
|
||||
throw new ErrorPageError( 'nopagetitle', 'nopagetext' );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ class SpecialEditTags extends UnlistedSpecialPage {
|
|||
$this->targetObj->getPrefixedText()
|
||||
) );
|
||||
|
||||
$out->addHelpLink( 'Help:Tags' );
|
||||
$this->addHelpLink( 'Help:Tags' );
|
||||
$out->addHTML( "<ul>" );
|
||||
|
||||
$numRevisions = 0;
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ class SpecialMergeHistory extends SpecialPage {
|
|||
'</form>'
|
||||
);
|
||||
|
||||
$out->addHelpLink( 'Help:Merge history' );
|
||||
$this->addHelpLink( 'Help:Merge history' );
|
||||
}
|
||||
|
||||
private function showHistory() {
|
||||
|
|
|
|||
|
|
@ -140,7 +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' );
|
||||
$this->addHelpLink( 'Help:Moving a page' );
|
||||
|
||||
$newTitle = $this->newTitle;
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class SpecialNewFiles extends IncludableSpecialPage {
|
|||
$this->outputHeader();
|
||||
|
||||
$out = $this->getOutput();
|
||||
$out->addHelpLink( 'Help:New images' );
|
||||
$this->addHelpLink( 'Help:New images' );
|
||||
|
||||
$pager = new NewFilesPager( $this->getContext(), $par );
|
||||
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ class SpecialNewpages extends IncludableSpecialPage {
|
|||
$this->showNavigation = !$this->including(); // Maybe changed in setup
|
||||
$this->setup( $par );
|
||||
|
||||
$out->addHelpLink( 'Help:New pages' );
|
||||
$this->addHelpLink( 'Help:New pages' );
|
||||
|
||||
if ( !$this->including() ) {
|
||||
// Settings
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class SpecialPreferences extends SpecialPage {
|
|||
);
|
||||
}
|
||||
|
||||
$out->addHelpLink( 'Help:Preferences' );
|
||||
$this->addHelpLink( 'Help:Preferences' );
|
||||
|
||||
$htmlForm = Preferences::getFormObject( $this->getUser(), $this->getContext() );
|
||||
$htmlForm->setSubmitCallback( array( 'Preferences', 'tryUISubmit' ) );
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ class SpecialRandomInCategory extends FormSpecialPage {
|
|||
}
|
||||
|
||||
protected function getFormFields() {
|
||||
$this->getOutput()->addHelpLink( 'Help:RandomInCategory' );
|
||||
$this->addHelpLink( 'Help:RandomInCategory' );
|
||||
|
||||
$form = array(
|
||||
'category' => array(
|
||||
|
|
|
|||
|
|
@ -368,7 +368,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
|
|||
$out->wrapWikiMsg( "<strong>$1</strong>", array( $this->typeLabels['selected'],
|
||||
$this->getLanguage()->formatNum( count( $this->ids ) ), $this->targetObj->getPrefixedText() ) );
|
||||
|
||||
$out->addHelpLink( 'Help:RevisionDelete' );
|
||||
$this->addHelpLink( 'Help:RevisionDelete' );
|
||||
$out->addHTML( "<ul>" );
|
||||
|
||||
$numRevisions = 0;
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class SpecialSpecialpages extends UnlistedSpecialPage {
|
|||
return;
|
||||
}
|
||||
|
||||
$out->addHelpLink( 'Help:Special pages' );
|
||||
$this->addHelpLink( 'Help:Special pages' );
|
||||
$this->outputPageList( $groups );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -791,7 +791,7 @@ class SpecialUndelete extends SpecialPage {
|
|||
return;
|
||||
}
|
||||
|
||||
$out->addHelpLink( 'Help:Undelete' );
|
||||
$this->addHelpLink( 'Help:Undelete' );
|
||||
if ( $this->mAllowed ) {
|
||||
$out->setPageTitle( $this->msg( 'undeletepage' ) );
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ class SpecialUpload extends SpecialPage {
|
|||
throw new ErrorPageError( 'uploaddisabled', 'uploaddisabledtext' );
|
||||
}
|
||||
|
||||
$this->getOutput()->addHelpLink( 'Help:Managing files' );
|
||||
$this->addHelpLink( 'Help:Managing files' );
|
||||
|
||||
# Check permissions
|
||||
$user = $this->getUser();
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ class UserrightsPage extends SpecialPage {
|
|||
|
||||
$out = $this->getOutput();
|
||||
$out->addModuleStyles( 'mediawiki.special' );
|
||||
$out->addHelpLink( 'Help:Assigning permissions' );
|
||||
$this->addHelpLink( 'Help:Assigning permissions' );
|
||||
|
||||
// show the general form
|
||||
if ( count( $available['add'] ) || count( $available['remove'] ) ) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue