Index: trunk/phase3/includes/api/ApiParse.php |
— | — | @@ -52,7 +52,13 @@ |
53 | 53 | |
54 | 54 | // The parser needs $wgTitle to be set, apparently the |
55 | 55 | // $title parameter in Parser::parse isn't enough *sigh* |
56 | | - global $wgParser, $wgUser, $wgTitle, $wgEnableParserCache; |
| 56 | + global $wgParser, $wgUser, $wgTitle, $wgEnableParserCache, $wgLang; |
| 57 | + |
| 58 | + if ( isset( $params['uselang'] ) && $params['uselang'] != $wgLang->getCode() ) { |
| 59 | + $oldLang = $wgLang; //Backup wgLang |
| 60 | + $wgLang = Language::factory( $params['uselang'] ); |
| 61 | + } |
| 62 | + |
57 | 63 | $popts = new ParserOptions(); |
58 | 64 | $popts->setTidy( true ); |
59 | 65 | $popts->enableLimitReport(); |
— | — | @@ -204,6 +210,10 @@ |
205 | 211 | ); |
206 | 212 | $this->setIndexedTagNames( $result_array, $result_mapping ); |
207 | 213 | $result->addValue( null, $this->getModuleName(), $result_array ); |
| 214 | + |
| 215 | + if ( isset( $params['uselang'] ) ) { |
| 216 | + $wgLang = $oldLang; //Reset $wgLang to $oldLang |
| 217 | + } |
208 | 218 | } |
209 | 219 | |
210 | 220 | private function formatLangLinks( $links ) { |
— | — | @@ -299,14 +309,14 @@ |
300 | 310 | |
301 | 311 | public function getParamDescription() { |
302 | 312 | return array( |
303 | | - 'text' => 'Wikitext to parse', |
304 | | - 'summary' => 'Summary to parse', |
305 | | - 'redirects' => 'If the page parameter is set to a redirect, resolve it', |
306 | | - 'title' => 'Title of page the text belongs to', |
307 | | - 'page' => 'Parse the content of this page. Cannot be used together with text and title', |
308 | | - 'oldid' => 'Parse the content of this revision. Overrides page', |
| 313 | + 'text' => 'Wikitext to parse.', |
| 314 | + 'summary' => 'Summary to parse.', |
| 315 | + 'redirects' => 'If the page parameter is set to a redirect, resolve it.', |
| 316 | + 'title' => 'Title of page the text belongs to.', |
| 317 | + 'page' => 'Parse the content of this page. Cannot be used together with text and title.', |
| 318 | + 'oldid' => 'Parse the content of this revision. Overrides page.', |
309 | 319 | 'prop' => array( 'Which pieces of information to get.', |
310 | | - 'NOTE: Section tree is only generated if there are more than 4 sections, or if the __TOC__ keyword is present' |
| 320 | + 'NOTE: Section tree is only generated if there are more than 4 sections, or if the __TOC__ keyword is present.' |
311 | 321 | ), |
312 | 322 | 'pst' => array( 'Do a pre-save transform on the input before parsing it.', |
313 | 323 | 'Ignored if page or oldid is used.' |
— | — | @@ -314,6 +324,7 @@ |
315 | 325 | 'onlypst' => array( 'Do a PST on the input, but don\'t parse it.', |
316 | 326 | 'Returns PSTed wikitext. Ignored if page or oldid is used.' |
317 | 327 | ), |
| 328 | + 'uselang' => 'Which language to parse the request in.' |
318 | 329 | ); |
319 | 330 | } |
320 | 331 | |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -46,6 +46,7 @@ |
47 | 47 | |
48 | 48 | == API changes in 1.17 == |
49 | 49 | * (bug 22738) Allow filtering by action type on query=logevent |
| 50 | +* (bug 22764) uselang parameter for action=parse |
50 | 51 | |
51 | 52 | === Languages updated in 1.17 === |
52 | 53 | |