Merge "wpUndidRevision should be passed along during 'preview' and 'diff'"
[lhc/web/wiklou.git] / includes / templates / Userlogin.php
1 <?php
2 /**
3 * Html form for user login (since 1.22 with VForm appearance).
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup Templates
22 */
23
24 class UserloginTemplate extends BaseTemplate {
25
26 function execute() {
27 global $wgCookieExpiration;
28 $expirationDays = ceil( $wgCookieExpiration / ( 3600 * 24 ) );
29 ?>
30 <div class="mw-ui-container">
31 <?php
32 if ( $this->haveData( 'languages' ) ) {
33 ?>
34 <div id="languagelinks">
35 <p><?php $this->html( 'languages' ); ?></p>
36 </div>
37 <?php
38 }
39 ?>
40 <div id="userloginForm">
41 <form name="userlogin" class="mw-ui-vform" method="post" action="<?php $this->text( 'action' ); ?>">
42 <section class="mw-form-header">
43 <?php $this->html( 'header' ); /* extensions such as ConfirmEdit add form HTML here */ ?>
44 </section>
45 <?php
46
47 if ( $this->data['message'] ) {
48 ?>
49 <div class="<?php $this->text( 'messagetype' ); ?>box">
50 <?php
51 if ( $this->data['messagetype'] == 'error' ) {
52 ?>
53 <strong><?php $this->msg( 'loginerror' ) ?></strong><br />
54 <?php
55 }
56 $this->html( 'message' );
57 ?>
58 </div>
59 <?php
60 }
61 ?>
62 <div>
63 <label for='wpName1'>
64 <?php
65 $this->msg( 'userlogin-yourname' );
66 if ( $this->data['secureLoginUrl'] ) {
67 echo Html::element( 'a', array(
68 'href' => $this->data['secureLoginUrl'],
69 'class' => 'mw-ui-flush-right mw-secure',
70 ), $this->getMsg( 'userlogin-signwithsecure' )->text() );
71 } ?>
72 </label>
73 <?php
74 $extraAttrs = array();
75 // Set focus to this field if its blank.
76 if ( !$this->data['name'] ) {
77 $extraAttrs['autofocus'] = '';
78 }
79 echo Html::input( 'wpName', $this->data['name'], 'text', array(
80 'class' => 'loginText',
81 'id' => 'wpName1',
82 'tabindex' => '1',
83 'size' => '20',
84 // 'required' is blacklisted for now in Html.php due to browser issues.
85 // Keeping here in case that changes
86 'required',
87 'placeholder' => $this->getMsg( 'userlogin-yourname-ph' )->text()
88 ) + $extraAttrs );
89 ?>
90 </div>
91 <div>
92 <label for='wpPassword1'>
93 <?php
94 $this->msg( 'userlogin-yourpassword' );
95
96 if ( $this->data['useemail'] && $this->data['canreset'] && $this->data['resetlink'] === true ) {
97 echo " ", Linker::link(
98 SpecialPage::getTitleFor( 'PasswordReset' ),
99 $this->getMsg( 'userlogin-resetpassword-link' )->parse(),
100 array( 'class' => 'mw-ui-flush-right' )
101 );
102 }
103 ?>
104 </label>
105 <?php
106 $extraAttrs = array();
107 // Set focus to this field if username is filled in.
108 if ( $this->data['name'] ) {
109 $extraAttrs['autofocus'] = '';
110 }
111 echo Html::input( 'wpPassword', null, 'password', array(
112 'class' => 'loginPassword',
113 'id' => 'wpPassword1',
114 'tabindex' => '2',
115 'size' => '20',
116 'placeholder' => $this->getMsg( 'userlogin-yourpassword-ph' )->text()
117 ) + $extraAttrs );
118 ?>
119 </div>
120 <?php
121 if ( isset( $this->data['usedomain'] ) && $this->data['usedomain'] ) {
122 $doms = "";
123 foreach ( $this->data['domainnames'] as $dom ) {
124 $doms .= "<option>" . htmlspecialchars( $dom ) . "</option>";
125 }
126 ?>
127 <div id="mw-user-domain-section">
128 <label for='wpDomain'><?php $this->msg( 'yourdomainname' ); ?></label>
129 <select name="wpDomain" value="<?php $this->text( 'domain' ); ?>"
130 tabindex="3">
131 <?php echo $doms ?>
132 </select>
133 </div>
134 <?php }
135
136 if ( $this->haveData( 'extrafields' ) ) {
137 echo $this->data['extrafields'];
138 } ?>
139
140 <div>
141
142 <?php if ( $this->data['canremember'] ) { ?>
143 <label class="mw-ui-checkbox-label">
144 <input name="wpRemember" type="checkbox" value="1" id="wpRemember" tabindex="4"
145 <?php if ( $this->data['remember'] ) {
146 echo 'checked="checked"';
147 } ?>
148 >
149 <?php echo $this->getMsg( 'userlogin-remembermypassword' )->numParams( $expirationDays )->escaped(); ?>
150 </label>
151 <?php } ?>
152 </div>
153
154 <div>
155 <?php
156 echo Html::input( 'wpLoginAttempt', $this->getMsg( 'login' )->text(), 'submit', array(
157 'id' => 'wpLoginAttempt',
158 'tabindex' => '6',
159 'class' => 'mw-ui-button mw-ui-big mw-ui-block mw-ui-primary'
160 ) );
161 ?>
162 </div>
163 <div id="mw-userlogin-help">
164 <?php echo $this->getMsg( 'userlogin-helplink' )->parse(); ?>
165 </div>
166 <?php if ( $this->haveData( 'createOrLoginHref' ) ) { ?>
167 <div id="mw-createaccount-cta">
168 <h3 id="mw-userloginlink"><?php $this->msg( 'userlogin-noaccount' ); ?><a href="<?php $this->text( 'createOrLoginHref' ); ?>" id="mw-createaccount-join" tabindex="7" class="mw-ui-button mw-ui-constructive"><?php $this->msg( 'userlogin-joinproject' ); ?></a></h3>
169 </div>
170 <?php } ?>
171 <?php if ( $this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
172 <?php if ( $this->haveData( 'token' ) ) { ?><input type="hidden" name="wpLoginToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
173 <?php if ( $this->data['cansecurelogin'] ) {?><input type="hidden" name="wpForceHttps" value="<?php $this->text( 'stickhttps' ); ?>" /><?php } ?>
174 </form>
175 </div>
176 </div>
177 <?php
178 }
179 }