r32082 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r32081‎ | r32082 | r32083 >
Date:22:52, 17 March 2008
Author:raymond
Status:old
Tags:
Comment:
* Add a CSS id to the table
* Use proper XML function (where possible)
* Prettify for RTL wikis with classes from shared.css
Modified paths:
  • /trunk/extensions/PasswordReset/PasswordReset_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/PasswordReset/PasswordReset_body.php
@@ -47,31 +47,31 @@
4848
4949 if ( !is_object( $objUser ) || $userID == 0 ) {
5050 $validUser = false;
51 - $wgOut->addHTML( "<span style=\"color: red;\">" . wfMsg( 'passwordreset-invalidusername' ) . "</span><br />\n" );
 51+ $wgOut->addHTML( Xml::element( 'span', array( 'class' => 'error' ), wfMsg( 'passwordreset-invalidusername' ) ) . "\n" );
5252 } else {
5353 $validUser = true;
5454 }
5555 } else {
5656 $validUser = false;
57 - $wgOut->addHTML( "<span style=\"color: red;\">" . wfMsg( 'passwordreset-emptyusername' ) . "</span><br />\n" );
 57+ $wgOut->addHTML( Xml::element( 'span', array( 'class' => 'error' ), wfMsg( 'passwordreset-emptyusername' ) ) . "\n" );
5858 }
5959
6060 $newpass = $wgRequest->getText( 'newpass' );
6161 $confirmpass = $wgRequest->getText( 'confirmpass' );
6262
63 - if( ( $newpass == $confirmpass && strlen( $newpass ) > 0) || $disableuser) {
 63+ if( ( $newpass == $confirmpass && strlen( $newpass ) > 0 ) || $disableuser ) {
6464 //Passwords match
6565 $passMatch = true;
6666 } else {
6767 //Passwords DO NOT match
6868 $passMatch = false;
69 - $wgOut->addHTML( "<span style=\"color: red;\">" . wfMsg( 'passwordreset-nopassmatch' ) . "</span><br />\n" );
 69+ $wgOut->addHTML( Xml::element( 'span', array( 'class' => 'error' ), wfMsg( 'passwordreset-nopassmatch' ) ) . "\n" );
7070 }
7171
7272 if ( !$wgUser->matchEditToken( $wgRequest->getVal( 'token' ) ) ) {
7373 $validUser = false;
7474 $passMatch = false;
75 - $wgOut->addHTML( "<span style=\"color: red;\">" . wfMsg( 'passwordreset-badtoken' ) . "</span><br />\n" );
 75+ $wgOut->addHTML( Xml::element( 'span', array( 'class' => 'error' ), wfMsg( 'passwordreset-badtoken' ) ) . "\n" );
7676 }
7777 } else {
7878 $validUser = false;
@@ -79,9 +79,6 @@
8080 $newpass = '';
8181 }
8282
83 - $action = $wgTitle->escapeLocalUrl();
84 - $token = $wgUser->editToken();
85 -
8683 $wgOut->addHTML( "
8784 <script language=\"Javascript\">
8885 function disableUserClicked() {
@@ -94,37 +91,54 @@
9592 }
9693 return true;
9794 }
98 -</script>
99 -<form id='passwordresetform' method='post' action=\"$action\">
100 -<table>
101 - <tr>
102 - <td align='right'>" . wfMsg('passwordreset-username') . "</td>
103 - <td align='left'><input tabindex='1' type='text' size='20' name='username' id='username' value=\"$username_text\" onFocus=\"document.getElementById('username').select;\" /></td>
 95+</script>" .
 96+ Xml::openElement( 'form', array( 'method' => 'post', 'action' => $wgTitle->getLocalUrl(), 'id' => 'passwordresetform' ) ) .
 97+ Xml::openElement( 'table', array( 'id' => 'mw-passwordreset-table' ) ) .
 98+ "<tr>
 99+ <td class='mw-label'>" .
 100+ Xml::label( wfMsg( 'passwordreset-username' ), 'username' ) .
 101+ "</td>
 102+ <td class='mw-input'>
 103+ <input tabindex='1' type='text' size='20' name='username' id='username' value=\"$username_text\" onFocus=\"document.getElementById('username').select;\" />
 104+ </td>
104105 </tr>
105106 <tr>
106 - <td align='right'>" . wfMsg('passwordreset-newpass') . "</td>
107 - <td align='left'><input tabindex='2' type='password' size='20' name='newpass' id='newpass' value=\"$newpass\" onFocus=\"document.getElementById('newpass').select;\"{$passwordfielddisabled} /></td>
 107+ <td class='mw-label'>" .
 108+ Xml::label( wfMsg( 'passwordreset-newpass' ), 'newpass' ) .
 109+ "</td>
 110+ <td class='mw-input'>
 111+ <input tabindex='2' type='password' size='20' name='newpass' id='newpass' value=\"$newpass\" onFocus=\"document.getElementById('newpass').select;\"{$passwordfielddisabled} />
 112+ </td>
108113 </tr>
109114 <tr>
110 - <td align='right'>" . wfMsg('passwordreset-confirmpass') . "</td>
111 - <td align='left'><input tabindex='3' type='password' size='20' name='confirmpass' id='confirmpass' value=\"$confirmpass\" onFocus=\"document.getElementById('confirmpass').select;\"{$passwordfielddisabled} /></td>
 115+ <td class='mw-label'>" .
 116+ Xml::label( wfMsg( 'passwordreset-confirmpass' ), 'confirmpass' ) .
 117+ "</td>
 118+ <td class='mw-input'>
 119+ <input tabindex='3' type='password' size='20' name='confirmpass' id='confirmpass' value=\"$confirmpass\" onFocus=\"document.getElementById('confirmpass').select;\"{$passwordfielddisabled} />
 120+ </td>
112121 </tr>
113122 <tr>
114 - <td align='right'>" . wfMsg('passwordreset-disableuser') . "</td>
115 - <td align='left'><input tabindex='4' type='checkbox' name='disableuser' id='disableuser' onmouseup='return disableUserClicked();'{$disableuserchecked} /> " . wfMsg('passwordreset-disableuserexplain') . "</td>
 123+ <td class='mw-label'>" .
 124+ Xml::label( wfMsg( 'passwordreset-disableuser' ), 'disableuser' ) .
 125+ "</td>
 126+ <td class='mw-input'>
 127+ <input tabindex='4' type='checkbox' name='disableuser' id='disableuser' onmouseup='return disableUserClicked();'{$disableuserchecked} /> " . wfMsg('passwordreset-disableuserexplain') .
 128+ "</td>
116129 </tr>
117130 <tr>
118 - <td>&nbsp;</td>
119 - <td align='right'><input type='submit' name='submit' value=\"" . wfMsg('passwordreset-submit') . "\" /></td>
120 - </tr>
121 -</table>
122 -<input type='hidden' name='token' value='$token' />
123 -</form>"
 131+ <td></td>
 132+ <td class='mw-submit'>" .
 133+ Xml::submitButton( wfMsg( 'passwordreset-submit' ), array( 'name' => 'submit' ) ) .
 134+ "</td>
 135+ </tr>" .
 136+ Xml::closeElement( 'table' ) .
 137+ Xml::hidden( 'token', $wgUser->editToken() ) .
 138+ Xml::closeElement( 'form' )
124139 );
125140
126141 if ( $validUser && $passMatch ) {
127 - $wgOut->addWikiText ( "<hr />\n" );
128 - $wgOut->addWikiText ( $this->resetPassword( $userID, $newpass, $disableuser ) );
 142+ $wgOut->addWikiText ( Xml::tags( 'div', array( 'class' => 'successbox' ), $this->resetPassword( $userID, $newpass, $disableuser ) ) );
129143 } else {
130144 //Invalid user or passwords don't match - do nothing
131145 }

Status & tagging log