http://www.mediawiki.org/wiki/Special:Code/MediaWiki/95974
Revision: 95974
Author: catrope
Date: 2011-09-01 12:49:27 +0000 (Thu, 01 Sep 2011)
Log Message:
-----------
RL2: Add desc-msgkey, title and title-msgkey properties to list=gadgets, and
add a language parameter
Modified Paths:
--------------
branches/RL2/extensions/Gadgets/api/ApiQueryGadgets.php
Modified: branches/RL2/extensions/Gadgets/api/ApiQueryGadgets.php
===================================================================
--- branches/RL2/extensions/Gadgets/api/ApiQueryGadgets.php 2011-09-01
12:48:18 UTC (rev 95973)
+++ branches/RL2/extensions/Gadgets/api/ApiQueryGadgets.php 2011-09-01
12:49:27 UTC (rev 95974)
@@ -33,6 +33,7 @@
public function execute() {
$params = $this->extractRequestParams();
$this->props = array_flip( $params['prop'] );
+ $this->language = $params['language'] === null ? null :
$params['language'];
$this->categories = isset( $params['categories'] )
? array_flip( $params['categories'] )
: false;
@@ -90,8 +91,17 @@
$row['definitiontimestamp'] = wfTimestamp(
TS_ISO_8601, $g->getTimestamp() );
}
if ( isset( $this->props['desc'] ) ) {
- $row['desc'] = $g->getDescriptionMessage();
+ $row['desc'] = $g->getDescriptionMessage(
$this->language );
}
+ if ( isset( $this->props['desc-msgkey'] ) ) {
+ $row['desc-msgkey'] =
$g->getDescriptionMessageKey();
+ }
+ if ( isset( $this->props['title'] ) ) {
+ $row['title'] = $g->getTitleMessage(
$this->language );
+ }
+ if ( isset( $this->props['title-msgkey'] ) ) {
+ $row['title-msgkey'] = $g->getTitleMessageKey();
+ }
$data[] = $row;
}
$result->setIndexedTagName( $data, 'gadget' );
@@ -121,8 +131,12 @@
'timestamp',
'definitiontimestamp',
'desc',
+ 'desc-msgkey',
+ 'title',
+ 'title-msgkey',
),
),
+ 'language' => null,
'categories' => array(
ApiBase::PARAM_ISMULTI => true,
ApiBase::PARAM_TYPE => 'string',
@@ -142,6 +156,7 @@
}
public function getParamDescription() {
+ $p = $this->getModulePrefix();
return array(
'prop' => array(
'What gadget information to get:',
@@ -149,8 +164,12 @@
' json - JSON representation of the
gadget metadata.',
' timestamp - Last changed timestamp of
the gadget module, including any files it references',
' definitiontimestamp - Last changed timestamp
of the gadget metadata',
- ' desc - Gadget description
transformed into HTML (can be slow, use only if really needed)',
+ ' desc - Gadget description
translated in the given language and transformed into HTML (can be slow, use
only if really needed)',
+ ' desc-msgkey - Message key used for the
Gadget description',
+ ' title - Gadget title translated in
the given language',
+ ' title-msgkey - Message key used for the
Gadget title',
),
+ 'language' => "Language code to use for {$p}prop=desc
and {$p}prop=title. Defaults to the user language",
'categories' => 'Gadgets from what categories to
retrieve',
'names' => 'Name(s) of gadgets to retrieve',
'allowedonly' => 'List only gadgets allowed to current
user',
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs