r55444 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55443‎ | r55444 | r55445 >
Date:21:35, 21 August 2009
Author:simetrical
Status:ok
Tags:
Comment:
Use Html::input() for login form

This fixes some invalid HTML output in r54567, and also makes the output
look more consistent and prettier.
Modified paths:
  • /trunk/phase3/includes/templates/Userlogin.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/templates/Userlogin.php
@@ -12,8 +12,6 @@
1313 */
1414 class UserloginTemplate extends QuickTemplate {
1515 function execute() {
16 - global $wgHtml5;
17 -
1816 if( $this->data['message'] ) {
1917 ?>
2018 <div class="<?php $this->text('messagetype') ?>box">
@@ -37,21 +35,29 @@
3836 <tr>
3937 <td class="mw-label"><label for='wpName1'><?php $this->msg('yourname') ?></label></td>
4038 <td class="mw-input">
41 - <input type='text' class='loginText' name="wpName" id="wpName1"
42 - tabindex="1"
43 - value="<?php $this->text('name'); ?>" size='20'<?php
44 -if ( $wgHtml5 ) {
45 - echo ' required="" autofocus=""';
46 -}
47 -?>" />
 39+ <?php
 40+ echo Html::input( 'wpName', $this->data['name'], 'text', array(
 41+ 'class' => 'loginText',
 42+ 'id' => 'wpName1',
 43+ 'tabindex' => '1',
 44+ 'size' => '20',
 45+ 'required',
 46+ 'autofocus'
 47+ ) ); ?>
 48+
4849 </td>
4950 </tr>
5051 <tr>
5152 <td class="mw-label"><label for='wpPassword1'><?php $this->msg('yourpassword') ?></label></td>
5253 <td class="mw-input">
53 - <input type='password' class='loginPassword' name="wpPassword" id="wpPassword1"
54 - tabindex="2"
55 - value="" size='20' />
 54+ <?php
 55+ echo Html::input( 'wpPassword', null, 'password', array(
 56+ 'class' => 'loginPassword',
 57+ 'id' => 'wpPassword1',
 58+ 'tabindex' => '2',
 59+ 'size' => '20'
 60+ ) ); ?>
 61+
5662 </td>
5763 </tr>
5864 <?php if( $this->data['usedomain'] ) {
@@ -74,21 +80,32 @@
7581 <tr>
7682 <td></td>
7783 <td class="mw-input">
78 - <input type='checkbox' name="wpRemember"
79 - tabindex="4"
80 - value="1" id="wpRemember"
81 - <?php if( $this->data['remember'] ) { ?>checked="checked"<?php } ?>
82 - /> <label for="wpRemember"><?php $this->msg('remembermypassword') ?></label>
 84+ <?php
 85+ echo Html::input( 'wpRemember', '1', 'checkbox', array(
 86+ 'tabindex' => '4',
 87+ 'id' => 'wpRemember'
 88+ ) + ( $this->data['remember'] ? array( 'checked' ) : array() ) ); ?>
 89+
 90+ <label for="wpRemember"><?php $this->msg('remembermypassword') ?></label>
8391 </td>
8492 </tr>
85 - <?php } ?>
 93+<?php } ?>
8694 <tr>
8795 <td></td>
8896 <td class="mw-submit">
89 - <input type='submit' name="wpLoginattempt" id="wpLoginattempt" tabindex="5" value="<?php $this->msg('login') ?>" />&nbsp;<?php if( $this->data['useemail'] && $this->data['canreset']) { ?><input type='submit' name="wpMailmypassword" id="wpMailmypassword"
90 - tabindex="6"
91 - value="<?php $this->msg('mailmypassword') ?>" />
92 - <?php } ?>
 97+ <?php
 98+ echo Html::input( 'wpLoginAttempt', wfMsg( 'login' ), 'submit', array(
 99+ 'id' => 'wpLoginAttempt',
 100+ 'tabindex' => '5'
 101+ ) );
 102+ if ( $this->data['useemail'] && $this->data['canreset'] ) {
 103+ echo '&nbsp;';
 104+ echo Html::input( 'wpMailmypassword', wfMsg( 'mailmypassword' ), 'submit', array(
 105+ 'id' => 'wpMailmypassword',
 106+ 'tabindex' => '6'
 107+ ) );
 108+ } ?>
 109+
93110 </td>
94111 </tr>
95112 </table>
@@ -115,7 +132,7 @@
116133 }
117134
118135 function execute() {
119 - global $wgHtml5, $wgMinimalPasswordLength;
 136+ global $wgMinimalPasswordLength;
120137
121138 if( $this->data['message'] ) {
122139 ?>
@@ -138,25 +155,26 @@
139156 <tr>
140157 <td class="mw-label"><label for='wpName2'><?php $this->msg('yourname') ?></label></td>
141158 <td class="mw-input">
142 - <input type='text' class='loginText' name="wpName" id="wpName2"
143 - tabindex="1"
144 - value="<?php $this->text('name') ?>" size='20'<?php
145 -if ( $wgHtml5 ) {
146 - echo ' required=""';
147 -}
148 -?> />
 159+ <?php
 160+ echo Html::input( 'wpName', $this->data['name'], 'text', array(
 161+ 'class' => 'loginText',
 162+ 'id' => 'wpName2',
 163+ 'tabindex' => '1',
 164+ 'size' => '20',
 165+ 'required'
 166+ ) ); ?>
149167 </td>
150168 </tr>
151169 <tr>
152170 <td class="mw-label"><label for='wpPassword2'><?php $this->msg('yourpassword') ?></label></td>
153171 <td class="mw-input">
154 - <input type='password' class='loginPassword' name="wpPassword" id="wpPassword2"
155 - tabindex="2"
156 - value="" size='20'<?php
157 -if ( $wgHtml5 && $wgMinimalPasswordLength > 0 ) {
158 - echo ' required=""';
159 -}
160 -?> />
 172+<?php
 173+ echo Html::input( 'wpPassword', null, 'password', array(
 174+ 'class' => 'loginPassword',
 175+ 'id' => 'wpPassword2',
 176+ 'tabindex' => '2',
 177+ 'size' => '20'
 178+ ) + ( $wgMinimalPasswordLength > 0 ? array( 'required' ) : array() ) ); ?>
161179 </td>
162180 </tr>
163181 <?php if( $this->data['usedomain'] ) {
@@ -178,23 +196,26 @@
179197 <tr>
180198 <td class="mw-label"><label for='wpRetype'><?php $this->msg('yourpasswordagain') ?></label></td>
181199 <td class="mw-input">
182 - <input type='password' class='loginPassword' name="wpRetype" id="wpRetype"
183 - tabindex="4"
184 - value=""
185 - size='20'<?php
186 -if ( $wgHtml5 && $wgMinimalPasswordLength > 0 ) {
187 - echo ' required=""';
188 -}
189 -?> />
 200+ <?php
 201+ echo Html::input( 'wpRetype', null, 'password', array(
 202+ 'class' => 'loginPassword',
 203+ 'id' => 'wpRetype',
 204+ 'tabindex' => '4',
 205+ 'size' => '20'
 206+ ) + ( $wgMinimalPasswordLength > 0 ? array( 'required' ) : array() ) ); ?>
190207 </td>
191208 </tr>
192209 <tr>
193210 <?php if( $this->data['useemail'] ) { ?>
194211 <td class="mw-label"><label for='wpEmail'><?php $this->msg('youremail') ?></label></td>
195212 <td class="mw-input">
196 - <input type='<?php echo $wgHtml5 ? 'email' : 'text' ?>' class='loginText' name="wpEmail" id="wpEmail"
197 - tabindex="5"
198 - value="<?php $this->text('email') ?>" size='20' />
 213+ <?php
 214+ echo Html::input( 'wpEmail', $this->data['email'], 'email', array(
 215+ 'class' => 'loginText',
 216+ 'id' => 'wpEmail',
 217+ 'tabindex' => '5',
 218+ 'size' => '20'
 219+ ) ); ?>
199220 <div class="prefsectiontip">
200221 <?php if( $this->data['emailrequired'] ) {
201222 $this->msgWiki('prefs-help-email-required');

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r54567Start using some HTML 5 form features...simetrical03:32, 7 August 2009

Status & tagging log