From 32ea54f472c6c1a41705df9d9ef3ee509f0c106f Mon Sep 17 00:00:00 2001 From: Max Semenik Date: Fri, 15 Apr 2011 19:41:47 +0000 Subject: [PATCH] Gadgets: store category information in class, added getters for description in different forms --- Gadgets_body.php | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/Gadgets_body.php b/Gadgets_body.php index adbd94a3..de556fa7 100644 --- a/Gadgets_body.php +++ b/Gadgets_body.php @@ -46,7 +46,7 @@ foreach( $thisSection as $gadget ) { if ( $gadget->isAllowed( $user ) ) { $gname = $gadget->getName(); - $available[wfMsgExt( "gadget-$gname", 'parseinline' )] = $gname; + $available[$gadget->getDescription()] = $gname; if ( $gadget->isEnabled( $user ) ) { $default[] = $gname; } @@ -190,7 +190,7 @@ class Gadget { /** * Increment this when changing class structure */ - const GADGET_CLASS_VERSION = 4; + const GADGET_CLASS_VERSION = 5; private $version = self::GADGET_CLASS_VERSION, $scripts = array(), @@ -200,7 +200,8 @@ class Gadget { $definition, $resourceLoaded = false, $requiredRights = array(), - $onByDefault = false; + $onByDefault = false, + $category; /** * Creates an instance of this class from definition in MediaWiki:Gadgets-definition @@ -261,6 +262,27 @@ class Gadget { 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 */ @@ -491,6 +513,7 @@ class Gadget { $gadget = self::newFromDefinition( $line ); if ( $gadget ) { $gadgets[$section][$gadget->getName()] = $gadget; + $gadget->category = $section; } } }