Index: trunk/extensions/Translate/specials/SpecialTranslate.php |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | * @file |
7 | 7 | * @author Niklas Laxström |
8 | 8 | * @author Siebrand Mazeland |
9 | | - * @copyright Copyright © 2006-2010 Niklas Laxström, Siebrand Mazeland |
| 9 | + * @copyright Copyright © 2006-2011 Niklas Laxström, Siebrand Mazeland |
10 | 10 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
11 | 11 | */ |
12 | 12 | |
— | — | @@ -45,6 +45,7 @@ |
46 | 46 | |
47 | 47 | $this->setHeaders(); |
48 | 48 | |
| 49 | + //@todo Move to api or so |
49 | 50 | if ( $parameters === 'editpage' ) { |
50 | 51 | $editpage = TranslationEditPage::newFromRequest( $wgRequest ); |
51 | 52 | |
— | — | @@ -80,9 +81,7 @@ |
81 | 82 | $this->options['group'] = $this->defaults['group']; |
82 | 83 | } |
83 | 84 | |
84 | | - /** |
85 | | - * Show errors nicely. |
86 | | - */ |
| 85 | + // Show errors nicely. |
87 | 86 | $wgOut->addHTML( $this->settingsForm( $errors ) ); |
88 | 87 | |
89 | 88 | if ( count( $errors ) ) { |
— | — | @@ -103,9 +102,7 @@ |
104 | 103 | } |
105 | 104 | } |
106 | 105 | |
107 | | - /** |
108 | | - * Proceed. |
109 | | - */ |
| 106 | + // Proceed. |
110 | 107 | $taskOptions = new TaskOptions( |
111 | 108 | $this->options['language'], |
112 | 109 | $this->options['limit'], |
— | — | @@ -113,9 +110,7 @@ |
114 | 111 | array( $this, 'cbAddPagingNumbers' ) |
115 | 112 | ); |
116 | 113 | |
117 | | - /** |
118 | | - * Initialise and get output. |
119 | | - */ |
| 114 | + // Initialise and get output. |
120 | 115 | $this->task->init( $this->group, $taskOptions ); |
121 | 116 | $output = $this->task->execute(); |
122 | 117 | |
— | — | @@ -217,39 +212,40 @@ |
218 | 213 | } |
219 | 214 | |
220 | 215 | $form = |
221 | | - Xml::openElement( 'fieldset', array( 'class' => 'mw-sp-translate-settings' ) ) . |
222 | | - Xml::element( 'legend', null, wfMsg( 'translate-page-settings-legend' ) ) . |
223 | | - Xml::openElement( 'form', array( 'action' => $wgScript, 'method' => 'get' ) ) . |
| 216 | + Html::openElement( 'fieldset', array( 'class' => 'mw-sp-translate-settings' ) ) . |
| 217 | + Html::element( 'legend', null, wfMsg( 'translate-page-settings-legend' ) ) . |
| 218 | + Html::openElement( 'form', array( 'action' => $wgScript, 'method' => 'get' ) ) . |
224 | 219 | Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . |
225 | | - Xml::openElement( 'table' ) . |
| 220 | + Html::openElement( 'table' ) . |
226 | 221 | implode( "", $options ) . |
227 | 222 | self::optionRow( $button, ' ' ) . |
228 | | - Xml::closeElement( 'table' ) . |
229 | | - Xml::closeElement( 'form' ) . |
230 | | - Xml::closeElement( 'fieldset' ); |
| 223 | + Html::closeElement( 'table' ) . |
| 224 | + Html::closeElement( 'form' ) . |
| 225 | + Html::closeElement( 'fieldset' ); |
231 | 226 | return $form; |
232 | 227 | } |
233 | 228 | |
234 | 229 | /** |
235 | | - * @param $label |
236 | | - * @param $option |
237 | | - * @param $error null |
| 230 | + * @param $label string |
| 231 | + * @param $option string |
| 232 | + * @param $error string Html |
238 | 233 | * @return string |
239 | 234 | */ |
240 | 235 | private static function optionRow( $label, $option, $error = null ) { |
241 | 236 | return |
242 | | - Xml::openElement( 'tr' ) . |
243 | | - Xml::tags( 'td', null, $label ) . |
244 | | - Xml::tags( 'td', null, $option ) . |
245 | | - ( $error ? Xml::tags( 'td', array( 'class' => 'mw-sp-translate-error' ), $error ) : '' ) . |
246 | | - Xml::closeElement( 'tr' ); |
| 237 | + Html::openElement( 'tr' ) . |
| 238 | + Html::rawElement( 'td', null, $label ) . |
| 239 | + Html::rawElement( 'td', null, $option ) . |
| 240 | + ( $error ? Html::rawElement( 'td', array( 'class' => 'mw-sp-translate-error' ), $error ) : '' ) . |
| 241 | + Html::closeElement( 'tr' ); |
247 | 242 | } |
248 | 243 | |
249 | 244 | /* Selectors ahead */ |
250 | 245 | |
251 | 246 | protected function groupSelector() { |
252 | 247 | $groups = MessageGroups::getAllGroups(); |
253 | | - $selector = new HTMLSelector( 'group', 'group', $this->options['group'] ); |
| 248 | + $selector = new XmlSelect( 'group', 'group' ); |
| 249 | + $selector->setDefault( $this->options['group'] ); |
254 | 250 | |
255 | 251 | foreach ( $groups as $id => $class ) { |
256 | 252 | if ( MessageGroups::getGroup( $id )->exists() ) { |
— | — | @@ -261,7 +257,8 @@ |
262 | 258 | } |
263 | 259 | |
264 | 260 | protected function taskSelector( $pageTranslation = false ) { |
265 | | - $selector = new HTMLSelector( 'task', 'task', $this->options['task'] ); |
| 261 | + $selector = new XmlSelect( 'task', 'task' ); |
| 262 | + $selector->setDefault( $this->options['task'] ); |
266 | 263 | |
267 | 264 | $isPageTranslation = $this->group instanceof WikiPageMessageGroup; |
268 | 265 | foreach ( TranslateTasks::getTasks( $isPageTranslation ) as $id ) { |
— | — | @@ -285,7 +282,8 @@ |
286 | 283 | global $wgLang; |
287 | 284 | |
288 | 285 | $items = array( 100, 1000, 5000 ); |
289 | | - $selector = new HTMLSelector( 'limit', 'limit', $this->options['limit'] ); |
| 286 | + $selector = new XmlSelect( 'limit', 'limit' ); |
| 287 | + $selector->setDefault( $this->options['limit'] ); |
290 | 288 | |
291 | 289 | foreach ( $items as $count ) { |
292 | 290 | $selector->addOption( wfMsgExt( 'translate-page-limit-option', 'parsemag', $wgLang->formatNum( $count ) ), $count ); |
— | — | @@ -318,13 +316,9 @@ |
319 | 317 | $allInThisPage = $start === 1 && $total <= $this->options['limit']; |
320 | 318 | |
321 | 319 | if ( $this->paging['count'] === 0 ) { |
322 | | - $navigation = wfMsgExt( 'translate-page-showing-none', array( 'parseinline' ) ); |
| 320 | + $navigation = wfMessage( 'translate-page-showing-none' )->parse(); |
323 | 321 | } elseif ( $allInThisPage ) { |
324 | | - $navigation = wfMsgExt( |
325 | | - 'translate-page-showing-all', |
326 | | - array( 'parseinline' ), |
327 | | - $wgLang->formatNum( $total ) |
328 | | - ); |
| 322 | + $navigation = wfMessage( 'translate-page-showing-all', $wgLang->formatNum( $total ) )->parse(); |
329 | 323 | } else { |
330 | 324 | $previous = wfMsg( 'translate-prev' ); |
331 | 325 | if ( $this->options['offset'] > 0 ) { |
— | — | @@ -362,23 +356,21 @@ |
363 | 357 | } |
364 | 358 | |
365 | 359 | return |
366 | | - Xml::openElement( 'fieldset' ) . |
367 | | - Xml::element( 'legend', null, wfMsg( 'translate-page-navigation-legend' ) ) . |
| 360 | + Html::openElement( 'fieldset' ) . |
| 361 | + Html::element( 'legend', null, wfMsg( 'translate-page-navigation-legend' ) ) . |
368 | 362 | $navigation . |
369 | | - Xml::closeElement( 'fieldset' ); |
| 363 | + Html::closeElement( 'fieldset' ); |
370 | 364 | } |
371 | 365 | |
372 | 366 | private function makeOffsetLink( $label, $offset ) { |
373 | | - global $wgUser; |
| 367 | + $linker = $linker = class_exists( 'DummyLinker' ) ? new DummyLinker : new Linker; |
374 | 368 | |
375 | | - $skin = $wgUser->getSkin(); |
376 | | - |
377 | 369 | $query = array_merge( |
378 | 370 | $this->nondefaults, |
379 | 371 | array( 'offset' => $offset ) |
380 | 372 | ); |
381 | 373 | |
382 | | - $link = $skin->link( |
| 374 | + $link = $linker->link( |
383 | 375 | $this->getTitle(), |
384 | 376 | $label, |
385 | 377 | array(), |
— | — | @@ -389,17 +381,13 @@ |
390 | 382 | } |
391 | 383 | |
392 | 384 | protected function getGroupDescription( MessageGroup $group ) { |
393 | | - global $wgOut; |
394 | | - |
395 | 385 | $description = $group->getDescription(); |
396 | | - |
397 | | - if ( $description === null ) { |
398 | | - return null; |
| 386 | + if ( $description !== null ) { |
| 387 | + global $wgOut; |
| 388 | + return $wgOut->parse( $description, false ); |
399 | 389 | } |
400 | 390 | |
401 | | - $description = $wgOut->parse( $description, false ); |
402 | | - |
403 | | - return $description; |
| 391 | + return ''; |
404 | 392 | } |
405 | 393 | |
406 | 394 | public function groupInformation() { |
— | — | @@ -415,7 +403,7 @@ |
416 | 404 | } |
417 | 405 | |
418 | 406 | public function formatGroupInformation( $blocks, $level = 2 ) { |
419 | | - global $wgUser, $wgLang; |
| 407 | + global $wgLang; |
420 | 408 | |
421 | 409 | if ( is_array( $blocks ) ) { |
422 | 410 | $block = array_shift( $blocks ); |
— | — | @@ -433,7 +421,9 @@ |
434 | 422 | 'language' => $code |
435 | 423 | ); |
436 | 424 | |
437 | | - $label = $wgUser->getSkin()->link( |
| 425 | + $linker = class_exists( 'DummyLinker' ) ? new DummyLinker : new Linker; |
| 426 | + |
| 427 | + $label = $linker->link( |
438 | 428 | $title, |
439 | 429 | htmlspecialchars( $block->getLabel() ), |
440 | 430 | array(), |
— | — | @@ -446,7 +436,7 @@ |
447 | 437 | $subid = Sanitizer::escapeId( "mw-subgroup-$id" ); |
448 | 438 | |
449 | 439 | if ( $hasSubblocks ) { |
450 | | - $msg = wfMsgExt( 'translate-showsub', 'parsemag', $wgLang->formatNum( count( $blocks ) ) ); |
| 440 | + $msg = wfMessage( 'translate-showsub', $wgLang->formatNum( count( $blocks ) ) )->text(); |
451 | 441 | $target = TranslationHelpers::jQueryPathId( $subid ); |
452 | 442 | $desc .= Html::element( 'a', array( 'onclick' => "jQuery($target).toggle()", 'class' => 'mw-sp-showmore' ), $msg ); |
453 | 443 | } |