Use Html::input() for login form
authorAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 21 Aug 2009 21:35:34 +0000 (21:35 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 21 Aug 2009 21:35:34 +0000 (21:35 +0000)
This fixes some invalid HTML output in r54567, and also makes the output
look more consistent and prettier.

includes/templates/Userlogin.php

index b853c8a..7a17300 100644 (file)
@@ -12,8 +12,6 @@ if( !defined( 'MEDIAWIKI' ) ) die( -1 );
  */
 class UserloginTemplate extends QuickTemplate {
        function execute() {
-               global $wgHtml5;
-
                if( $this->data['message'] ) {
 ?>
        <div class="<?php $this->text('messagetype') ?>box">
@@ -37,21 +35,29 @@ class UserloginTemplate extends QuickTemplate {
                <tr>
                        <td class="mw-label"><label for='wpName1'><?php $this->msg('yourname') ?></label></td>
                        <td class="mw-input">
-                               <input type='text' class='loginText' name="wpName" id="wpName1"
-                                       tabindex="1"
-                                       value="<?php $this->text('name'); ?>" size='20'<?php
-if ( $wgHtml5 ) {
-       echo ' required="" autofocus=""';
-}
-?>" />
+                               <?php
+                       echo Html::input( 'wpName', $this->data['name'], 'text', array(
+                               'class' => 'loginText',
+                               'id' => 'wpName1',
+                               'tabindex' => '1',
+                               'size' => '20',
+                               'required',
+                               'autofocus'
+                       ) ); ?>
+
                        </td>
                </tr>
                <tr>
                        <td class="mw-label"><label for='wpPassword1'><?php $this->msg('yourpassword') ?></label></td>
                        <td class="mw-input">
-                               <input type='password' class='loginPassword' name="wpPassword" id="wpPassword1"
-                                       tabindex="2"
-                                       value="" size='20' />
+                               <?php
+                       echo Html::input( 'wpPassword', null, 'password', array(
+                               'class' => 'loginPassword',
+                               'id' => 'wpPassword1',
+                               'tabindex' => '2',
+                               'size' => '20'
+                       ) ); ?>
+
                        </td>
                </tr>
        <?php if( $this->data['usedomain'] ) {
@@ -74,21 +80,32 @@ if ( $wgHtml5 ) {
                <tr>
                        <td></td>
                        <td class="mw-input">
-                               <input type='checkbox' name="wpRemember"
-                                       tabindex="4"
-                                       value="1" id="wpRemember"
-                                       <?php if( $this->data['remember'] ) { ?>checked="checked"<?php } ?>
-                                       /> <label for="wpRemember"><?php $this->msg('remembermypassword') ?></label>
+                               <?php
+               echo Html::input( 'wpRemember', '1', 'checkbox', array(
+                       'tabindex' => '4',
+                       'id' => 'wpRemember'
+               ) + ( $this->data['remember'] ? array( 'checked' ) : array() ) ); ?>
+
+                               <label for="wpRemember"><?php $this->msg('remembermypassword') ?></label>
                        </td>
                </tr>
-               <?php } ?>
+<?php } ?>
                <tr>
                        <td></td>
                        <td class="mw-submit">
-                               <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"
-                                       tabindex="6"
-                                                                       value="<?php $this->msg('mailmypassword') ?>" />
-                               <?php } ?>
+                               <?php
+               echo Html::input( 'wpLoginAttempt', wfMsg( 'login' ), 'submit', array(
+                       'id' => 'wpLoginAttempt',
+                       'tabindex' => '5'
+               ) );
+               if ( $this->data['useemail'] && $this->data['canreset'] ) {
+                       echo '&nbsp;';
+                       echo Html::input( 'wpMailmypassword', wfMsg( 'mailmypassword' ), 'submit', array(
+                               'id' => 'wpMailmypassword',
+                               'tabindex' => '6'
+                       ) );
+               } ?>
+
                        </td>
                </tr>
        </table>
@@ -115,7 +132,7 @@ class UsercreateTemplate extends QuickTemplate {
        }
        
        function execute() {
-               global $wgHtml5, $wgMinimalPasswordLength;
+               global $wgMinimalPasswordLength;
 
                if( $this->data['message'] ) {
 ?>
@@ -138,25 +155,26 @@ class UsercreateTemplate extends QuickTemplate {
                <tr>
                        <td class="mw-label"><label for='wpName2'><?php $this->msg('yourname') ?></label></td>
                        <td class="mw-input">
-                               <input type='text' class='loginText' name="wpName" id="wpName2"
-                                       tabindex="1"
-                                       value="<?php $this->text('name') ?>" size='20'<?php
-if ( $wgHtml5 ) {
-       echo ' required=""';
-}
-?> />
+                               <?php
+                       echo Html::input( 'wpName', $this->data['name'], 'text', array(
+                               'class' => 'loginText',
+                               'id' => 'wpName2',
+                               'tabindex' => '1',
+                               'size' => '20',
+                               'required'
+                       ) ); ?>
                        </td>
                </tr>
                <tr>
                        <td class="mw-label"><label for='wpPassword2'><?php $this->msg('yourpassword') ?></label></td>
                        <td class="mw-input">
-                               <input type='password' class='loginPassword' name="wpPassword" id="wpPassword2"
-                                       tabindex="2"
-                                       value="" size='20'<?php
-if ( $wgHtml5 && $wgMinimalPasswordLength > 0 ) {
-       echo ' required=""';
-}
-?> />
+<?php
+                       echo Html::input( 'wpPassword', null, 'password', array(
+                               'class' => 'loginPassword',
+                               'id' => 'wpPassword2',
+                               'tabindex' => '2',
+                               'size' => '20'
+                       ) + ( $wgMinimalPasswordLength > 0 ? array( 'required' ) : array() ) ); ?>
                        </td>
                </tr>
        <?php if( $this->data['usedomain'] ) {
@@ -178,23 +196,26 @@ if ( $wgHtml5 && $wgMinimalPasswordLength > 0 ) {
                <tr>
                        <td class="mw-label"><label for='wpRetype'><?php $this->msg('yourpasswordagain') ?></label></td>
                        <td class="mw-input">
-                               <input type='password' class='loginPassword' name="wpRetype" id="wpRetype"
-                                       tabindex="4"
-                                       value=""
-                                       size='20'<?php
-if ( $wgHtml5 && $wgMinimalPasswordLength > 0 ) {
-       echo ' required=""';
-}
-?> />
+                               <?php
+               echo Html::input( 'wpRetype', null, 'password', array(
+                       'class' => 'loginPassword',
+                       'id' => 'wpRetype',
+                       'tabindex' => '4',
+                       'size' => '20'
+               ) + ( $wgMinimalPasswordLength > 0 ? array( 'required' ) : array() ) ); ?>
                        </td>
                </tr>
                <tr>
                        <?php if( $this->data['useemail'] ) { ?>
                                <td class="mw-label"><label for='wpEmail'><?php $this->msg('youremail') ?></label></td>
                                <td class="mw-input">
-                                       <input type='<?php echo $wgHtml5 ? 'email' : 'text' ?>' class='loginText' name="wpEmail" id="wpEmail"
-                                               tabindex="5"
-                                               value="<?php $this->text('email') ?>" size='20' />
+                                       <?php
+               echo Html::input( 'wpEmail', $this->data['email'], 'email', array(
+                       'class' => 'loginText',
+                       'id' => 'wpEmail',
+                       'tabindex' => '5',
+                       'size' => '20'
+               ) ); ?>
                                        <div class="prefsectiontip">
                                                <?php if( $this->data['emailrequired'] ) {
                                                                        $this->msgWiki('prefs-help-email-required');