r95751 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95750‎ | r95751 | r95752 >
Date:10:19, 30 August 2011
Author:catrope
Status:ok
Tags:
Comment:
RL2: Rename 'section' to 'category' throughout, except in SpecialGadgets (broken), the tests (broken) and SpecialGadgetManager (which Timo is rewriting)
Modified paths:
  • /branches/RL2/extensions/Gadgets/GadgetHooks.php (modified) (history)
  • /branches/RL2/extensions/Gadgets/api/ApiQueryGadgetCategories.php (modified) (history)
  • /branches/RL2/extensions/Gadgets/api/ApiQueryGadgets.php (modified) (history)
  • /branches/RL2/extensions/Gadgets/backend/Gadget.php (modified) (history)

Diff [purge]

Index: branches/RL2/extensions/Gadgets/GadgetHooks.php
@@ -40,29 +40,29 @@
4141 $repo = new LocalGadgetRepo( array() );
4242
4343 $gadgets = $repo->getGadgetNames();
44 - $sections = array(); // array( section => array( desc => name ) )
 44+ $categories = array(); // array( category => array( desc => name ) )
4545 $default = array(); // array of Gadget names
4646 foreach ( $gadgets as $name ) {
4747 $gadget = $repo->getGadget( $name );
4848 if ( !$gadget->isAllowed( $user ) || $gadget->isHidden() ) {
4949 continue;
5050 }
51 - $section = $gadget->getSection();
 51+ $category = $gadget->getCategory();
5252
53 - // Add the Gadget to the right section
 53+ // Add the Gadget to the right category
5454 $description = wfMessage( $gadget->getDescriptionMsg() )->parse();
55 - $sections[$section][$description] = $name;
 55+ $categories[$category][$description] = $name;
5656 // Add the Gadget to the default list if enabled
5757 if ( $gadget->isEnabledForUser( $user ) ) {
5858 $default[] = $name;
5959 }
6060 }
6161
62 - $options = array(); // array( desc1 => name1, section1 => array( desc2 => name2 ) )
63 - foreach ( $sections as $section => $gadgets ) {
64 - if ( $section !== '' ) {
65 - $sectionMsg = wfMsgExt( "gadget-section-$section", 'parseinline' );
66 - $options[$sectionMsg] = $gadgets;
 62+ $options = array(); // array( desc1 => name1, category1 => array( desc2 => name2 ) )
 63+ foreach ( $categories as $category => $gadgets ) {
 64+ if ( $category !== '' ) {
 65+ $categoryMsg = wfMsgExt( "gadgetcategory-$category", 'parseinline' );
 66+ $options[$categoryMsg] = $gadgets;
6767 } else {
6868 $options += $gadgets;
6969 }
Index: branches/RL2/extensions/Gadgets/backend/Gadget.php
@@ -13,8 +13,10 @@
1414 * "hidden": false,
1515 * // Whether this gadget is shared
1616 * "shared": true,
17 - * // The key of the section this gadget belongs to. The section title message key is gadgetsection-$section-title
18 - * "section": "key of gadget section",
 17+ * // The key of the category this gadget belongs to
 18+ * // Interface message is "gadgetcategory-{category}"
 19+ * // If this is an empty string, the gadget is uncategorized
 20+ * "category": "maintenance-tools"
1921 * },
2022 * "module": {
2123 * // Scripts and styles are pages in NS_GADGET
@@ -126,11 +128,11 @@
127129 }
128130
129131 /**
130 - * Get the section (also called category) this gadget is in.
131 - * @return string Section key or empty string if not in any section
 132+ * Get the name of the category this gadget is in.
 133+ * @return string Category key or empty string if not in any category
132134 */
133 - public function getSection() {
134 - return $this->settings['section'];
 135+ public function getCategory() {
 136+ return $this->settings['category'];
135137 }
136138
137139 /**
Index: branches/RL2/extensions/Gadgets/api/ApiQueryGadgets.php
@@ -90,7 +90,7 @@
9191 $row['desc-raw'] = $row['desc'] = wfMessage( $g->getDescriptionMsg() )->plain();
9292 }
9393 if ( isset( $this->props['category'] ) ) {
94 - $row['category'] = $g->getSection(); // TODO: clean up category vs. section mess in favor category
 94+ $row['category'] = $g->getCategory();
9595 }
9696 if ( isset( $this->props['resourceloader'] ) /*&& $g->supportsResourceLoader()*/ ) {
9797 // Everything supports resourceloader now :D
@@ -132,7 +132,7 @@
133133 && ( !$this->listAllowed || $gadget->isAllowed( $wgUser ) )
134134 && ( !$this->listEnabled || $gadget->isEnabled( $wgUser ) )
135135 && ( !$this->listShared || $gadget->isShared() )
136 - && ( !$this->categories || isset( $this->categories[$g->getSection()] ) );
 136+ && ( !$this->categories || isset( $this->categories[$g->getCategory()] ) );
137137 }
138138
139139 public function getAllowedParams() {
Index: branches/RL2/extensions/Gadgets/api/ApiQueryGadgetCategories.php
@@ -52,10 +52,10 @@
5353 }
5454 if ( $category !== "" ) {
5555 if ( isset( $this->props['desc'] ) ) {
56 - $row['desc'] = wfMessage( "gadget-section-$category" )->parse();
 56+ $row['desc'] = wfMessage( "gadgetcategory-$category" )->parse();
5757 }
5858 if ( isset( $this->props['desc-raw'] ) ) {
59 - $row['desc-raw'] = wfMessage( "gadget-section-$category" )->plain();
 59+ $row['desc-raw'] = wfMessage( "gadgetcategory-$category" )->plain();
6060 }
6161 }
6262 if ( isset( $this->props['members'] ) ) {

Status & tagging log