http://www.mediawiki.org/wiki/Special:Code/MediaWiki/95992
Revision: 95992
Author: catrope
Date: 2011-09-01 14:45:09 +0000 (Thu, 01 Sep 2011)
Log Message:
-----------
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: branches/RL2/extensions/Gadgets/api/ApiQueryGadgetCategories.php
===================================================================
--- branches/RL2/extensions/Gadgets/api/ApiQueryGadgetCategories.php
2011-09-01 14:40:56 UTC (rev 95991)
+++ branches/RL2/extensions/Gadgets/api/ApiQueryGadgetCategories.php
2011-09-01 14:45:09 UTC (rev 95992)
@@ -33,6 +33,7 @@
$this->neededNames = isset( $params['names'] )
? array_flip( $params['names'] )
: false;
+ $this->language = $params['language'];
$this->getMain()->setCacheMode( 'public' );
@@ -58,13 +59,19 @@
if ( isset( $this->props['name'] ) ) {
$row['name'] = $category;
}
- if ( $category !== "" ) {
- if ( isset( $this->props['desc'] ) ) {
- // TODO: Put message into the
repo too, with fallback behavior
- $row['desc'] = wfMessage(
"gadgetcategory-$category" )->parse();
+ if ( isset( $this->props['title'] ) ) {
+ // TODO: Put all this logic in the repo
class
+ $message = $category === '' ?
'gadgetmanager-uncategorized' : "gadgetcategory-$category";
+ $message = wfMessage( $message );
+ if ( $this->language !== null ) {
+ $message =
$message->inLanguage( $this->language );
}
- if ( isset( $this->props['desc-raw'] )
) {
- $row['desc-raw'] = wfMessage(
"gadgetcategory-$category" )->plain();
+ if ( !$message->exists() ) {
+ global $wgLang;
+ $lang = $this->language ===
null ? $wgLang : Language::factory( $lang );
+ $row['title'] = $lang->ucfirst(
$category );
+ } else {
+ $row['title'] =
$message->plain();
}
}
if ( isset( $this->props['members'] ) ) {
@@ -84,8 +91,7 @@
ApiBase::PARAM_ISMULTI => true,
ApiBase::PARAM_TYPE => array(
'name',
- 'desc',
- 'desc-raw',
+ 'title',
'members',
),
),
@@ -93,6 +99,7 @@
ApiBase::PARAM_TYPE => 'string',
ApiBase::PARAM_ISMULTI => true,
),
+ 'language' => null,
);
}
@@ -101,15 +108,16 @@
}
public function getParamDescription() {
+ $p = $this->getModulePrefix();
return array(
'prop' => array(
'What gadget category information to get:',
' name - Internal category name',
- ' desc - Category description transformed
into HTML (can be slow, use only if really needed)',
- ' desc-raw - Category description in raw
wikitext',
+ ' title - Category title, translated in the
given language',
' members - Number of gadgets in category',
),
'names' => 'Name(s) of gadgets to retrieve',
+ 'language' => "Language to use for {$p}prop=title",
);
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs