r33495 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r33494‎ | r33495 | r33496 >
Date:17:26, 17 April 2008
Author:raymond
Status:old
Tags:
Comment:
* Tweaks for sections date/time and search of SpecialPreferences:
** Fix aligning for RTL wikis: Use existing CSS classes
** Move hardcoded superscript number 1 into 'timezonetext' message. The counterpart is in 'timezoneoffset' since ages.
** Use XML functions for these sections
Modified paths:
  • /trunk/phase3/includes/SpecialPreferences.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesDe.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialPreferences.php
@@ -474,7 +474,7 @@
475475 }
476476
477477 function addRow($td1, $td2) {
478 - return "<tr><td align='right'>$td1</td><td align='left'>$td2</td></tr>";
 478+ return "<tr><td class='mw-label'>$td1</td><td class='mw-input'>$td2</td></tr>";
479479 }
480480
481481 /**
@@ -870,40 +870,63 @@
871871 # Date/Time
872872 #
873873
874 - $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg( 'datetime' ) . "</legend>\n" );
 874+ $wgOut->addHTML(
 875+ Xml::openElement( 'fieldset' ) .
 876+ Xml::element( 'legend', null, wfMsg( 'datetime' ) ) . "\n"
 877+ );
875878
876879 if ($dateopts) {
877 - $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg( 'dateformat' ) . "</legend>\n" );
 880+ $wgOut->addHTML(
 881+ Xml::openElement( 'fieldset' ) .
 882+ Xml::element( 'legend', null, wfMsg( 'dateformat' ) ) . "\n"
 883+ );
878884 $idCnt = 0;
879885 $epoch = '20010115161234'; # Wikipedia day
880886 foreach( $dateopts as $key ) {
881887 if( $key == 'default' ) {
882 - $formatted = wfMsgHtml( 'datedefault' );
 888+ $formatted = wfMsg( 'datedefault' );
883889 } else {
884 - $formatted = htmlspecialchars( $wgLang->timeanddate( $epoch, false, $key ) );
 890+ $formatted = $wgLang->timeanddate( $epoch, false, $key );
885891 }
886 - ($key == $this->mDate) ? $checked = ' checked="checked"' : $checked = '';
887 - $wgOut->addHTML( "<div><input type='radio' name=\"wpDate\" id=\"wpDate$idCnt\" ".
888 - "value=\"$key\"$checked /> <label for=\"wpDate$idCnt\">$formatted</label></div>\n" );
 892+ $checked = ( $key == $this->mDate ) ? true : false;
 893+ $wgOut->addHTML(
 894+ Xml::tags( 'div', null,
 895+ Xml::radioLabel( $formatted, 'wpDate', $key, "wpDate$idCnt", $checked )
 896+ ) . "\n"
 897+ );
889898 $idCnt++;
890899 }
891 - $wgOut->addHTML( "</fieldset>\n" );
 900+ $wgOut->addHTML( Xml::closeElement( 'fieldset' ) . "\n" );
892901 }
893902
894903 $nowlocal = $wgLang->time( $now = wfTimestampNow(), true );
895904 $nowserver = $wgLang->time( $now, false );
896905
897 - $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'timezonelegend' ). '</legend><table>' .
 906+ $wgOut->addHTML(
 907+ Xml::openElement( 'fieldset' ) .
 908+ Xml::element( 'legend', null, wfMsg( 'timezonelegend' ) ) .
 909+ Xml::openElement( 'table' ) .
898910 $this->addRow( wfMsg( 'servertime' ), $nowserver ) .
899911 $this->addRow( wfMsg( 'localtime' ), $nowlocal ) .
900912 $this->addRow(
901 - '<label for="wpHourDiff">' . wfMsg( 'timezoneoffset' ) . '</label>',
902 - "<input type='text' name='wpHourDiff' id='wpHourDiff' value=\"" . htmlspecialchars( $this->mHourDiff ) . "\" size='6' />"
903 - ) . "<tr><td colspan='2'>
904 - <input type='button' value=\"" . wfMsg( 'guesstimezone' ) ."\"
905 - onclick='javascript:guessTimezone()' id='guesstimezonebutton' style='display:none;' />
906 - </td></tr></table><div class='prefsectiontip'>¹" . wfMsg( 'timezonetext' ) . "</div></fieldset>
907 - </fieldset>\n\n" );
 913+ Xml::label( wfMsg( 'timezoneoffset' ), 'wpHourDiff' ),
 914+ Xml::input( 'wpHourDiff', 6, $this->mHourDiff, array( 'class' => 'wpHourDiff' ) ) ) .
 915+ "<tr>
 916+ <td></td>
 917+ <td class='mw-submit'>" .
 918+ Xml::element( 'input',
 919+ array( 'type' => 'button',
 920+ 'value' => wfMsg( 'guesstimezone' ),
 921+ 'onclick' => 'javascript:guessTimezone()',
 922+ 'id' => 'guesstimezonebutton',
 923+ 'style' => 'display:none;' ) ) .
 924+ "</td>
 925+ </tr>" .
 926+ Xml::closeElement( 'table' ) .
 927+ Xml::element( 'div', array( 'class' => 'prefsectiontip' ), wfMsg( 'timezonetext' ) ).
 928+ Xml::closeElement( 'fieldset' ) .
 929+ Xml::closeElement( 'fieldset' ) . "\n\n"
 930+ );
908931
909932 # Editing
910933 #
@@ -980,30 +1003,39 @@
9811004 # Search
9821005 $ajaxsearch = $wgAjaxSearch ?
9831006 $this->addRow(
984 - wfLabel( wfMsg( 'useajaxsearch' ), 'wpUseAjaxSearch' ),
985 - wfCheck( 'wpUseAjaxSearch', $this->mUseAjaxSearch, array( 'id' => 'wpUseAjaxSearch' ) )
 1007+ Xml::label( wfMsg( 'useajaxsearch' ), 'wpUseAjaxSearch' ),
 1008+ Xml::check( 'wpUseAjaxSearch', $this->mUseAjaxSearch, array( 'id' => 'wpUseAjaxSearch' ) )
9861009 ) : '';
9871010 $mwsuggest = $wgEnableMWSuggest ?
9881011 $this->addRow(
989 - wfLabel( wfMsg( 'mwsuggest-disable' ), 'wpDisableMWSuggest' ),
990 - wfCheck( 'wpDisableMWSuggest', $this->mDisableMWSuggest, array( 'id' => 'wpDisableMWSuggest' ) )
 1012+ Xml::label( wfMsg( 'mwsuggest-disable' ), 'wpDisableMWSuggest' ),
 1013+ Xml::check( 'wpDisableMWSuggest', $this->mDisableMWSuggest, array( 'id' => 'wpDisableMWSuggest' ) )
9911014 ) : '';
992 - $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'searchresultshead' ) . '</legend><table>' .
993 - $ajaxsearch .
 1015+ $wgOut->addHTML(
 1016+ Xml::openElement( 'fieldset' ) .
 1017+ Xml::element( 'legend', null, wfMsg( 'searchresultshead' ) ) .
 1018+ Xml::openElement( 'table' ) .
 1019+ $ajaxsearch .
9941020 $this->addRow(
995 - wfLabel( wfMsg( 'resultsperpage' ), 'wpSearch' ),
996 - wfInput( 'wpSearch', 4, $this->mSearch, array( 'id' => 'wpSearch' ) )
 1021+ Xml::label( wfMsg( 'resultsperpage' ), 'wpSearch' ),
 1022+ Xml::input( 'wpSearch', 4, $this->mSearch, array( 'id' => 'wpSearch' ) )
9971023 ) .
9981024 $this->addRow(
999 - wfLabel( wfMsg( 'contextlines' ), 'wpSearchLines' ),
1000 - wfInput( 'wpSearchLines', 4, $this->mSearchLines, array( 'id' => 'wpSearchLines' ) )
 1025+ Xml::label( wfMsg( 'contextlines' ), 'wpSearchLines' ),
 1026+ Xml::input( 'wpSearchLines', 4, $this->mSearchLines, array( 'id' => 'wpSearchLines' ) )
10011027 ) .
10021028 $this->addRow(
1003 - wfLabel( wfMsg( 'contextchars' ), 'wpSearchChars' ),
1004 - wfInput( 'wpSearchChars', 4, $this->mSearchChars, array( 'id' => 'wpSearchChars' ) )
 1029+ Xml::label( wfMsg( 'contextchars' ), 'wpSearchChars' ),
 1030+ Xml::input( 'wpSearchChars', 4, $this->mSearchChars, array( 'id' => 'wpSearchChars' ) )
10051031 ) .
1006 - $mwsuggest.
1007 - "</table><fieldset><legend>" . wfMsg( 'defaultns' ) . "</legend>$ps</fieldset></fieldset>" );
 1032+ $mwsuggest .
 1033+ Xml::closeElement( 'table' ) .
 1034+ Xml::openElement( 'fieldset' ) .
 1035+ Xml::element( 'legend', null, wfMsg( 'defaultns' ) ) .
 1036+ $ps .
 1037+ Xml::closeElement( 'fieldset' ) .
 1038+ Xml::closeElement( 'fieldset' )
 1039+ );
10081040
10091041 # Misc
10101042 #
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1389,7 +1389,7 @@
13901390 'recentchangescount' => 'Number of edits to show in recent changes:',
13911391 'savedprefs' => 'Your preferences have been saved.',
13921392 'timezonelegend' => 'Time zone',
1393 -'timezonetext' => 'The number of hours your local time differs from server time (UTC).',
 1393+'timezonetext' => '¹The number of hours your local time differs from server time (UTC).',
13941394 'localtime' => 'Local time',
13951395 'timezoneoffset' => 'Offset¹',
13961396 'servertime' => 'Server time',
Index: trunk/phase3/languages/messages/MessagesDe.php
@@ -1021,7 +1021,7 @@
10221022 'recentchangescount' => 'Anzahl der Einträge in „Letzte Änderungen“:',
10231023 'savedprefs' => 'Deine Einstellungen wurden gespeichert.',
10241024 'timezonelegend' => 'Zeitzone',
1025 -'timezonetext' => 'Gib die Anzahl der Stunden ein, die zwischen deiner Zeitzone und UTC liegen.',
 1025+'timezonetext' => '¹Gib die Anzahl der Stunden ein, die zwischen deiner Zeitzone und UTC liegen.',
10261026 'localtime' => 'Ortszeit:',
10271027 'timezoneoffset' => 'Unterschied¹:',
10281028 'servertime' => 'Aktuelle Zeit auf dem Server:',

Follow-up revisions

RevisionCommit summaryAuthorDate
r33502Fix error from r33495: class -> id. Thanks to Nikerabbit.raymond18:15, 17 April 2008
r34874Allow wikisyntax in message....raymond18:14, 15 May 2008
r35471Add (bug 4871) Hardcoded superscript in time zone preferences moved to messag...raymond09:09, 28 May 2008

Status & tagging log