* Xmlify a little
authorNiklas Laxström <nikerabbit@users.mediawiki.org>
Mon, 27 Nov 2006 19:49:48 +0000 (19:49 +0000)
committerNiklas Laxström <nikerabbit@users.mediawiki.org>
Mon, 27 Nov 2006 19:49:48 +0000 (19:49 +0000)
includes/SpecialPreferences.php

index ec1a957..b7f275d 100644 (file)
@@ -612,16 +612,15 @@ class PreferencesForm {
                 * with an Afrikaans interface since it's first in the list.
                 */
                $selectedLang = isset( $languages[$this->mUserLanguage] ) ? $this->mUserLanguage : $wgContLanguageCode;
-               $selbox = null;
-               foreach($languages as $code => $name) {
-                       global $IP;
-                       $sel = ($code == $selectedLang)? ' selected="selected"' : '';
-                       $selbox .= "<option value=\"$code\"$sel>$code - $name</option>\n";
+               $options = "\n";
+               foreach( $languages as $code => $name ) {
+                       $selected = ($code == $selectedLang);
+                       $options .= Xml::option( "$code - $name", $code, $selected ) . "\n";
                }
                $wgOut->addHTML(
                        $this->addRow(
                                '<label for="wpUserLanguage">' . wfMsg('yourlanguage') . '</label>',
-                               "<select name='wpUserLanguage' id='wpUserLanguage'>$selbox</select>"
+                               "<select name='wpUserLanguage' id='wpUserLanguage'>$options</select>"
                        )
                );
 
@@ -638,15 +637,16 @@ class PreferencesForm {
                                }
                        }
 
-                       $selbox = null;
-                       foreach($variantArray as $code => $name) {
-                               $sel = $code == $this->mUserVariant ? 'selected="selected"' : '';
-                               $selbox .= "<option value=\"$code\" $sel>$code - $name</option>";
+                       $options = "\n";
+                       foreach( $variantArray as $code => $name ) {
+                               $selected = ($code == $this->mUserVariant);
+                               $options .= Xml::option( "$code - $name", $code, $selected ) . "\n";
                        }
 
                        if(count($variantArray) > 1) {
                                $wgOut->addHtml(
-                                       $this->addRow( wfMsg( 'yourvariant' ), "<select name='wpUserVariant'>$selbox</select>" )
+                                       $this->addRow( wfMsg( 'yourvariant' ),
+                                               "<select name='wpUserVariant'>$options</select>" )
                                );
                        }
                }
@@ -768,24 +768,41 @@ class PreferencesForm {
 
                # Files
                #
-               $wgOut->addHTML("<fieldset>
-                       <legend>" . wfMsg( 'files' ) . "</legend>
-                       <div><label for='wpImageSize'>" . wfMsg('imagemaxsize') . "</label> <select id='wpImageSize' name='wpImageSize'>");
+               $wgOut->addHTML(
+                       "<fieldset>\n" . Xml::element( 'legend', null, wfMsg( 'files' ) ) . "\n"
+               );
 
                $imageLimitOptions = null;
                foreach ( $wgImageLimits as $index => $limits ) {
-                       $selected = ($index == $this->mImageSize) ? 'selected="selected"' : '';
-                       $imageLimitOptions .= "<option value=\"{$index}\" {$selected}>{$limits[0]}×{$limits[1]}". wfMsgHtml('unit-pixel') ."</option>\n";
+                       $selected = ($index == $this->mImageSize);
+                       $imageLimitOptions .= Xml::option( "{$limits[0]}×{$limits[1]}" .
+                               wfMsg('unit-pixel'), $index, $selected );
                }
 
+               $imageSizeId = 'wpImageSize';
+               $wgOut->addHTML(
+                       "<div>" . Xml::label( wfMsg('imagemaxsize'), $imageSizeId ) . " " .
+                       Xml::openElement( 'select', array( 'name' => $imageSizeId, 'id' => $imageSizeId ) ) .
+                               $imageLimitOptions .
+                       Xml::closeElement( 'select' ) . "</div>\n"
+               );
+
                $imageThumbOptions = null;
-               $wgOut->addHTML( "{$imageLimitOptions}</select></div>
-                       <div><label for='wpThumbSize'>" . wfMsg('thumbsize') . "</label> <select name='wpThumbSize' id='wpThumbSize'>");
                foreach ( $wgThumbLimits as $index => $size ) {
-                       $selected = ($index == $this->mThumbSize) ? 'selected="selected"' : '';
-                       $imageThumbOptions .= "<option value=\"{$index}\" {$selected}>{$size}". wfMsgHtml('unit-pixel') ."</option>\n";
+                       $selected = ($index == $this->mThumbSize);
+                       $imageThumbOptions .= Xml::option($size . wfMsg('unit-pixel'), $index,
+                               $selected);
                }
-               $wgOut->addHTML( "{$imageThumbOptions}</select></div></fieldset>\n\n");
+
+               $thumbSizeId = 'wpThumbSize';
+               $wgOut->addHTML(
+                       "<div>" . Xml::label( wfMsg('thumbsize'), $thumbSizeId ) . " " .
+                       Xml::openElement( 'select', array( 'name' => $thumbSizeId, 'id' => $thumbSizeId ) ) .
+                               $imageThumbOptions .
+                       Xml::closeElement( 'select' ) . "</div>\n"
+               );
+
+               $wgOut->addHTML( "</fieldset>\n\n" );
 
                # Date format
                #