mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Gadgets
synced 2024-11-15 03:23:51 +00:00
Add edit link to gadget definition in Special:Gadgets
When using the Gadget definition: namespace, link to the definition pages from Special:Gadgets. Also change the wording of the links to edit the names of the gadgets, to disambiguate them. Change-Id: I327a4cfa9846edec60e1aaafc674cd66f4e0beae
This commit is contained in:
parent
2d86f9b62e
commit
6b74e170c0
|
@ -19,6 +19,8 @@
|
|||
"gadgets-definition": "",
|
||||
"gadgets-title": "Gadgets",
|
||||
"gadgets-pagetext": "Below is a list of special gadgets users can enable on their [[Special:Preferences#mw-prefsection-gadgets|preferences page]], as defined by the [[MediaWiki:Gadgets-definition|definitions]].\nThis overview provides easy access to the system message pages that define each gadget's description and code.",
|
||||
"gadgets-editdescription": "Edit description",
|
||||
"gadgets-viewdescription": "View description",
|
||||
"gadgets-uses": "Uses",
|
||||
"gadgets-required-rights": "Requires the following {{PLURAL:$2|right|rights}}:\n\n$1",
|
||||
"gadgets-required-skins": "Available on the {{PLURAL:$2|$1 skin|following skins: $1}}.",
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
"gadgets-definition": "{{notranslate}}",
|
||||
"gadgets-title": "{{Identical|Gadgets}}",
|
||||
"gadgets-pagetext": "Used as intro text in [[Special:Gadgets]].",
|
||||
"gadgets-editdescription": "Link for editing the gadget description shown in Special:Preferences. Used on [[Special:Gadgets]].",
|
||||
"gadgets-viewdescription": "Link for viewing the gadget description shown in Special:Preferences. Used on [[Special:Gadgets]] instead of {{msg-mw|Gadgets-editname}} when the user does not have permissions to edit.",
|
||||
"gadgets-uses": "This is used as a verb in third-person singular. It appears in front of a script name. Example: \"''Uses: Gadget-UTCLiveClock.js''\"\n\nSee [[meta:Special:Gadgets|Gadgets page in meta.wikimedia.org]]\n{{Identical|Use}}",
|
||||
"gadgets-required-rights": "Parameters:\n* $1 - a list in wikitext.\n* $2 - the number of items in list $1 for PLURAL use.",
|
||||
"gadgets-required-skins": "Parameters:\n* $1 - a comma separated list.\n* $2 - the number of items in list $1 for PLURAL use.",
|
||||
|
|
|
@ -105,6 +105,13 @@ class GadgetDefinitionNamespaceRepo extends GadgetRepo {
|
|||
$this->wanCache->touchCheckKey( $this->getGadgetIdsKey() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getGadgetDefinitionTitle( string $id ): ?Title {
|
||||
return Title::makeTitleSafe( NS_GADGET_DEFINITION, $id );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
* @throws InvalidArgumentException
|
||||
|
|
|
@ -66,6 +66,18 @@ abstract class GadgetRepo {
|
|||
public function handlePageDeletion( LinkTarget $target ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a gadget ID, return the title of the page where the gadget is
|
||||
* defined (or null if the given repo does not have per-gadget definition
|
||||
* pages).
|
||||
*
|
||||
* @param string $id
|
||||
* @return Title|null
|
||||
*/
|
||||
public function getGadgetDefinitionTitle( string $id ): ?Title {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of gadgets sorted by category
|
||||
*
|
||||
|
|
|
@ -63,9 +63,12 @@ class SpecialGadgets extends SpecialPage {
|
|||
|
||||
$listOpen = false;
|
||||
|
||||
$editInterfaceMessage = $this->getUser()->isAllowed( 'editinterface' )
|
||||
$editDefinitionMessage = $this->getUser()->isAllowed( 'gadgets-definition-edit' )
|
||||
? 'edit'
|
||||
: 'viewsource';
|
||||
$editInterfaceMessage = $this->getUser()->isAllowed( 'editinterface' )
|
||||
? 'gadgets-editdescription'
|
||||
: 'gadgets-viewdescription';
|
||||
|
||||
$linkRenderer = $this->getLinkRenderer();
|
||||
$skinFactory = $services->getSkinFactory();
|
||||
|
@ -99,6 +102,15 @@ class SpecialGadgets extends SpecialPage {
|
|||
}
|
||||
|
||||
$links = [];
|
||||
$definitionTitle = GadgetRepo::singleton()->getGadgetDefinitionTitle( $name );
|
||||
if ( $definitionTitle ) {
|
||||
$links[] = $linkRenderer->makeLink(
|
||||
$definitionTitle,
|
||||
$this->msg( $editDefinitionMessage )->text(),
|
||||
[],
|
||||
[ 'action' => 'edit' ]
|
||||
);
|
||||
}
|
||||
$links[] = $linkRenderer->makeLink(
|
||||
$t,
|
||||
$this->msg( $editInterfaceMessage )->text(),
|
||||
|
|
Loading…
Reference in a new issue