| Index: branches/RL2/extensions/Gadgets/api/ApiQueryGadgets.php |
| — | — | @@ -33,6 +33,7 @@ |
| 34 | 34 | public function execute() { |
| 35 | 35 | $params = $this->extractRequestParams(); |
| 36 | 36 | $this->props = array_flip( $params['prop'] ); |
| | 37 | + $this->language = $params['language'] === null ? null : $params['language']; |
| 37 | 38 | $this->categories = isset( $params['categories'] ) |
| 38 | 39 | ? array_flip( $params['categories'] ) |
| 39 | 40 | : false; |
| — | — | @@ -90,8 +91,17 @@ |
| 91 | 92 | $row['definitiontimestamp'] = wfTimestamp( TS_ISO_8601, $g->getTimestamp() ); |
| 92 | 93 | } |
| 93 | 94 | if ( isset( $this->props['desc'] ) ) { |
| 94 | | - $row['desc'] = $g->getDescriptionMessage(); |
| | 95 | + $row['desc'] = $g->getDescriptionMessage( $this->language ); |
| 95 | 96 | } |
| | 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 | + } |
| 96 | 106 | $data[] = $row; |
| 97 | 107 | } |
| 98 | 108 | $result->setIndexedTagName( $data, 'gadget' ); |
| — | — | @@ -121,8 +131,12 @@ |
| 122 | 132 | 'timestamp', |
| 123 | 133 | 'definitiontimestamp', |
| 124 | 134 | 'desc', |
| | 135 | + 'desc-msgkey', |
| | 136 | + 'title', |
| | 137 | + 'title-msgkey', |
| 125 | 138 | ), |
| 126 | 139 | ), |
| | 140 | + 'language' => null, |
| 127 | 141 | 'categories' => array( |
| 128 | 142 | ApiBase::PARAM_ISMULTI => true, |
| 129 | 143 | ApiBase::PARAM_TYPE => 'string', |
| — | — | @@ -142,6 +156,7 @@ |
| 143 | 157 | } |
| 144 | 158 | |
| 145 | 159 | public function getParamDescription() { |
| | 160 | + $p = $this->getModulePrefix(); |
| 146 | 161 | return array( |
| 147 | 162 | 'prop' => array( |
| 148 | 163 | 'What gadget information to get:', |
| — | — | @@ -149,8 +164,12 @@ |
| 150 | 165 | ' json - JSON representation of the gadget metadata.', |
| 151 | 166 | ' timestamp - Last changed timestamp of the gadget module, including any files it references', |
| 152 | 167 | ' 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', |
| 154 | 172 | ), |
| | 173 | + 'language' => "Language code to use for {$p}prop=desc and {$p}prop=title. Defaults to the user language", |
| 155 | 174 | 'categories' => 'Gadgets from what categories to retrieve', |
| 156 | 175 | 'names' => 'Name(s) of gadgets to retrieve', |
| 157 | 176 | 'allowedonly' => 'List only gadgets allowed to current user', |