r95992 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95991‎ | r95992 | r95993 >
Date:14:45, 1 September 2011
Author:catrope
Status:ok (Comments)
Tags:
Comment:
RL2: In list=gagetcategories, rename the desc-raw property to title, and kill desc. Also put in the proper logic for the category message (which needs to be factored out)
Modified paths:
  • /branches/RL2/extensions/Gadgets/api/ApiQueryGadgetCategories.php (modified) (history)

Diff [purge]

Index: branches/RL2/extensions/Gadgets/api/ApiQueryGadgetCategories.php
@@ -33,6 +33,7 @@
3434 $this->neededNames = isset( $params['names'] )
3535 ? array_flip( $params['names'] )
3636 : false;
 37+ $this->language = $params['language'];
3738
3839 $this->getMain()->setCacheMode( 'public' );
3940
@@ -58,13 +59,19 @@
5960 if ( isset( $this->props['name'] ) ) {
6061 $row['name'] = $category;
6162 }
62 - if ( $category !== "" ) {
63 - if ( isset( $this->props['desc'] ) ) {
64 - // TODO: Put message into the repo too, with fallback behavior
65 - $row['desc'] = wfMessage( "gadgetcategory-$category" )->parse();
 63+ if ( isset( $this->props['title'] ) ) {
 64+ // TODO: Put all this logic in the repo class
 65+ $message = $category === '' ? 'gadgetmanager-uncategorized' : "gadgetcategory-$category";
 66+ $message = wfMessage( $message );
 67+ if ( $this->language !== null ) {
 68+ $message = $message->inLanguage( $this->language );
6669 }
67 - if ( isset( $this->props['desc-raw'] ) ) {
68 - $row['desc-raw'] = wfMessage( "gadgetcategory-$category" )->plain();
 70+ if ( !$message->exists() ) {
 71+ global $wgLang;
 72+ $lang = $this->language === null ? $wgLang : Language::factory( $lang );
 73+ $row['title'] = $lang->ucfirst( $category );
 74+ } else {
 75+ $row['title'] = $message->plain();
6976 }
7077 }
7178 if ( isset( $this->props['members'] ) ) {
@@ -84,8 +91,7 @@
8592 ApiBase::PARAM_ISMULTI => true,
8693 ApiBase::PARAM_TYPE => array(
8794 'name',
88 - 'desc',
89 - 'desc-raw',
 95+ 'title',
9096 'members',
9197 ),
9298 ),
@@ -93,6 +99,7 @@
94100 ApiBase::PARAM_TYPE => 'string',
95101 ApiBase::PARAM_ISMULTI => true,
96102 ),
 103+ 'language' => null,
97104 );
98105 }
99106
@@ -101,15 +108,16 @@
102109 }
103110
104111 public function getParamDescription() {
 112+ $p = $this->getModulePrefix();
105113 return array(
106114 'prop' => array(
107115 'What gadget category information to get:',
108116 ' name - Internal category name',
109 - ' desc - Category description transformed into HTML (can be slow, use only if really needed)',
110 - ' desc-raw - Category description in raw wikitext',
 117+ ' title - Category title, translated in the given language',
111118 ' members - Number of gadgets in category',
112119 ),
113120 'names' => 'Name(s) of gadgets to retrieve',
 121+ 'language' => "Language to use for {$p}prop=title",
114122 );
115123 }
116124

Follow-up revisions

RevisionCommit summaryAuthorDate
r96755Fix E_NOTICE about undefined variable....krinkle22:49, 10 September 2011

Comments

#Comment by Krinkle (talk | contribs)   22:48, 10 September 2011
 PHP Notice:  Undefined variable: lang in /Users/krinkle/Sites/mediawiki/branches/RL2/extensions/Gadgets/api/ApiQueryGadgetCategories.php on line 71, referer: [http://localhost/mw/trunk/phase3/index.php/Special:GadgetManager http://localhost/mw/trunk/phase3/index.php/Special:GadgetManager]


OK otherwise.

#Comment by Krinkle (talk | contribs)   22:49, 10 September 2011

Fixed in r96755.

Status & tagging log