r95974 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95973‎ | r95974 | r95975 >
Date:12:49, 1 September 2011
Author:catrope
Status:ok
Tags:
Comment:
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) (history)

Diff [purge]

Index: branches/RL2/extensions/Gadgets/api/ApiQueryGadgets.php
@@ -33,6 +33,7 @@
3434 public function execute() {
3535 $params = $this->extractRequestParams();
3636 $this->props = array_flip( $params['prop'] );
 37+ $this->language = $params['language'] === null ? null : $params['language'];
3738 $this->categories = isset( $params['categories'] )
3839 ? array_flip( $params['categories'] )
3940 : false;
@@ -90,8 +91,17 @@
9192 $row['definitiontimestamp'] = wfTimestamp( TS_ISO_8601, $g->getTimestamp() );
9293 }
9394 if ( isset( $this->props['desc'] ) ) {
94 - $row['desc'] = $g->getDescriptionMessage();
 95+ $row['desc'] = $g->getDescriptionMessage( $this->language );
9596 }
 97+ if ( isset( $this->props['desc-msgkey'] ) ) {
 98+ $row['desc-msgkey'] = $g->getDescriptionMessageKey();
 99+ }
 100+ if ( isset( $this->props['title'] ) ) {
 101+ $row['title'] = $g->getTitleMessage( $this->language );
 102+ }
 103+ if ( isset( $this->props['title-msgkey'] ) ) {
 104+ $row['title-msgkey'] = $g->getTitleMessageKey();
 105+ }
96106 $data[] = $row;
97107 }
98108 $result->setIndexedTagName( $data, 'gadget' );
@@ -121,8 +131,12 @@
122132 'timestamp',
123133 'definitiontimestamp',
124134 'desc',
 135+ 'desc-msgkey',
 136+ 'title',
 137+ 'title-msgkey',
125138 ),
126139 ),
 140+ 'language' => null,
127141 'categories' => array(
128142 ApiBase::PARAM_ISMULTI => true,
129143 ApiBase::PARAM_TYPE => 'string',
@@ -142,6 +156,7 @@
143157 }
144158
145159 public function getParamDescription() {
 160+ $p = $this->getModulePrefix();
146161 return array(
147162 'prop' => array(
148163 'What gadget information to get:',
@@ -149,8 +164,12 @@
150165 ' json - JSON representation of the gadget metadata.',
151166 ' timestamp - Last changed timestamp of the gadget module, including any files it references',
152167 ' definitiontimestamp - Last changed timestamp of the gadget metadata',
153 - ' desc - Gadget description transformed into HTML (can be slow, use only if really needed)',
 168+ ' desc - Gadget description translated in the given language and transformed into HTML (can be slow, use only if really needed)',
 169+ ' desc-msgkey - Message key used for the Gadget description',
 170+ ' title - Gadget title translated in the given language',
 171+ ' title-msgkey - Message key used for the Gadget title',
154172 ),
 173+ 'language' => "Language code to use for {$p}prop=desc and {$p}prop=title. Defaults to the user language",
155174 'categories' => 'Gadgets from what categories to retrieve',
156175 'names' => 'Name(s) of gadgets to retrieve',
157176 'allowedonly' => 'List only gadgets allowed to current user',

Status & tagging log