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