mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Gadgets
synced 2024-11-28 09:10:07 +00:00
Gadgets: store category information in class, added getters for description in different forms
This commit is contained in:
parent
690382941b
commit
32ea54f472
|
@ -46,7 +46,7 @@
|
||||||
foreach( $thisSection as $gadget ) {
|
foreach( $thisSection as $gadget ) {
|
||||||
if ( $gadget->isAllowed( $user ) ) {
|
if ( $gadget->isAllowed( $user ) ) {
|
||||||
$gname = $gadget->getName();
|
$gname = $gadget->getName();
|
||||||
$available[wfMsgExt( "gadget-$gname", 'parseinline' )] = $gname;
|
$available[$gadget->getDescription()] = $gname;
|
||||||
if ( $gadget->isEnabled( $user ) ) {
|
if ( $gadget->isEnabled( $user ) ) {
|
||||||
$default[] = $gname;
|
$default[] = $gname;
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@ class Gadget {
|
||||||
/**
|
/**
|
||||||
* Increment this when changing class structure
|
* Increment this when changing class structure
|
||||||
*/
|
*/
|
||||||
const GADGET_CLASS_VERSION = 4;
|
const GADGET_CLASS_VERSION = 5;
|
||||||
|
|
||||||
private $version = self::GADGET_CLASS_VERSION,
|
private $version = self::GADGET_CLASS_VERSION,
|
||||||
$scripts = array(),
|
$scripts = array(),
|
||||||
|
@ -200,7 +200,8 @@ class Gadget {
|
||||||
$definition,
|
$definition,
|
||||||
$resourceLoaded = false,
|
$resourceLoaded = false,
|
||||||
$requiredRights = array(),
|
$requiredRights = array(),
|
||||||
$onByDefault = false;
|
$onByDefault = false,
|
||||||
|
$category;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an instance of this class from definition in MediaWiki:Gadgets-definition
|
* Creates an instance of this class from definition in MediaWiki:Gadgets-definition
|
||||||
|
@ -261,6 +262,27 @@ class Gadget {
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return String: Gadget description parsed into HTML
|
||||||
|
*/
|
||||||
|
public function getDescription() {
|
||||||
|
return wfMessage( "gadget-{$this->getName()}" )->parse();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return String: Wikitext of gadget description
|
||||||
|
*/
|
||||||
|
public function getRawDescription() {
|
||||||
|
return wfMessage( "gadget-{$this->getName()}" )->plain();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return String: Name of category (aka section) our gadget belongs to. Empty string if none.
|
||||||
|
*/
|
||||||
|
public function getCategory() {
|
||||||
|
return $this->category;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String: Name of ResourceLoader module for this gadget
|
* @return String: Name of ResourceLoader module for this gadget
|
||||||
*/
|
*/
|
||||||
|
@ -491,6 +513,7 @@ class Gadget {
|
||||||
$gadget = self::newFromDefinition( $line );
|
$gadget = self::newFromDefinition( $line );
|
||||||
if ( $gadget ) {
|
if ( $gadget ) {
|
||||||
$gadgets[$section][$gadget->getName()] = $gadget;
|
$gadgets[$section][$gadget->getName()] = $gadget;
|
||||||
|
$gadget->category = $section;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue