Index: trunk/extensions/Translate/TranslateHooks.php |
— | — | @@ -275,15 +275,16 @@ |
276 | 276 | |
277 | 277 | ksort( $languages ); |
278 | 278 | |
279 | | - $selector = new HTMLSelector( 'languagefilter', 'languagefilter', $selected ); |
280 | | - $selector->addOption( wfMessage( 'translate-search-nofilter' ), '-' ); |
| 279 | + $selector = new XmlSelect( 'languagefilter', 'languagefilter' ); |
| 280 | + $selector->setDefault( $selected ); |
| 281 | + $selector->addOption( wfMessage( 'translate-search-nofilter' )->text(), '-' ); |
281 | 282 | foreach ( $languages as $code => $name ) { |
282 | 283 | $selector->addOption( "$code - $name", $code ); |
283 | 284 | } |
284 | 285 | |
285 | 286 | $selector = $selector->getHTML(); |
286 | 287 | |
287 | | - $label = Xml::label( wfMessage( 'translate-search-languagefilter' ), 'languagefilter' ) . ' '; |
| 288 | + $label = Xml::label( wfMessage( 'translate-search-languagefilter' )->text(), 'languagefilter' ) . ' '; |
288 | 289 | $params = array( 'id' => 'mw-searchoptions' ); |
289 | 290 | |
290 | 291 | $form = Xml::fieldset( false, false, $params ) . |
Index: trunk/extensions/Translate/_autoload.php |
— | — | @@ -20,7 +20,6 @@ |
21 | 21 | $wgAutoloadClasses['TaskOptions'] = $dir . 'TranslateTasks.php'; |
22 | 22 | |
23 | 23 | $wgAutoloadClasses['TranslateUtils'] = $dir . 'TranslateUtils.php'; |
24 | | -$wgAutoloadClasses['HTMLSelector'] = $dir . 'TranslateUtils.php'; |
25 | 24 | |
26 | 25 | $wgAutoloadClasses['TranslateHooks'] = $dir . 'TranslateHooks.php'; |
27 | 26 | |
Index: trunk/extensions/Translate/specials/SpecialMagic.php |
— | — | @@ -87,7 +87,7 @@ |
88 | 88 | * @return \string HTML5-compatible select-element. |
89 | 89 | */ |
90 | 90 | protected function moduleSelector( $selectedId ) { |
91 | | - $selector = new HTMLSelector( 'module', 'module', $selectedId ); |
| 91 | + $selector = new XmlSelect( 'module', 'module', $selectedId ); |
92 | 92 | foreach ( $this->aModules as $code ) { |
93 | 93 | $selector->addOption( wfMsg( 'translate-magic-' . $code ), $code ); |
94 | 94 | } |
Index: trunk/extensions/Translate/specials/SpecialMessageGroupStats.php |
— | — | @@ -55,7 +55,7 @@ |
56 | 56 | /// @todo duplicated code |
57 | 57 | protected function groupSelector( $default ) { |
58 | 58 | $groups = MessageGroups::getAllGroups(); |
59 | | - $selector = new HTMLSelector( 'group', 'group', $default ); |
| 59 | + $selector = new XmlSelect( 'group', 'group', $default ); |
60 | 60 | |
61 | 61 | foreach ( $groups as $id => $class ) { |
62 | 62 | if ( MessageGroups::getGroup( $id )->exists() ) { |
Index: trunk/extensions/Translate/TranslateUtils.php |
— | — | @@ -209,7 +209,8 @@ |
210 | 210 | |
211 | 211 | ksort( $languages ); |
212 | 212 | |
213 | | - $selector = new HTMLSelector( 'language', 'language', $selectedId ); |
| 213 | + $selector = new XmlSelect( 'language', 'language' ); |
| 214 | + $selector->setDefault( $selectedId ); |
214 | 215 | foreach ( $languages as $code => $name ) { |
215 | 216 | $selector->addOption( "$code - $name", $code ); |
216 | 217 | } |
— | — | @@ -321,70 +322,3 @@ |
322 | 323 | } |
323 | 324 | |
324 | 325 | } |
325 | | - |
326 | | -/** |
327 | | - * Yet another class for building html selectors. |
328 | | - */ |
329 | | -class HTMLSelector { |
330 | | - /// \list{String} \<option> elements. |
331 | | - private $options = array(); |
332 | | - /// \string The selected value. |
333 | | - private $selected = false; |
334 | | - /// \array Extra html attributes. |
335 | | - private $attributes = array(); |
336 | | - |
337 | | - /** |
338 | | - * @param $name \string |
339 | | - * @param $id \string Default false. |
340 | | - * @param $selected \string Default false. |
341 | | - */ |
342 | | - public function __construct( $name = false, $id = false, $selected = false ) { |
343 | | - if ( $name ) { |
344 | | - $this->setAttribute( 'name', $name ); |
345 | | - } |
346 | | - |
347 | | - if ( $id ) { |
348 | | - $this->setAttribute( 'id', $id ); |
349 | | - } |
350 | | - |
351 | | - if ( $selected ) { |
352 | | - $this->selected = $selected; |
353 | | - } |
354 | | - } |
355 | | - |
356 | | - /** |
357 | | - * Set selected value. |
358 | | - * @param $selected \string Default false. |
359 | | - */ |
360 | | - public function setSelected( $selected ) { |
361 | | - $this->selected = $selected; |
362 | | - } |
363 | | - |
364 | | - /** |
365 | | - * Set html attribute. |
366 | | - * @param $name \string Attribute name. |
367 | | - * @param $value \string Attribute value. |
368 | | - */ |
369 | | - public function setAttribute( $name, $value ) { |
370 | | - $this->attributes[$name] = $value; |
371 | | - } |
372 | | - |
373 | | - /** |
374 | | - * Add an option. |
375 | | - * @param $name \string Display name. |
376 | | - * @param $value \string Option value. Uses $name if not given. |
377 | | - * @param $selected \string Default selected value. Uses object value if not given. |
378 | | - */ |
379 | | - public function addOption( $name, $value = false, $selected = false ) { |
380 | | - $selected = $selected ? $selected : $this->selected; |
381 | | - $value = $value ? $value : $name; |
382 | | - $this->options[] = Xml::option( $name, $value, $value === $selected ); |
383 | | - } |
384 | | - |
385 | | - /** |
386 | | - * @return \string Html for the selector. |
387 | | - */ |
388 | | - public function getHTML() { |
389 | | - return Xml::tags( 'select', $this->attributes, implode( "\n", $this->options ) ); |
390 | | - } |
391 | | -} |