Add CollationFa
[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 * @deprecated Will be removed when AuthManager lands.
24 * The login form will be generated via HTMLForm.
25 */
26
27 class UserloginTemplate extends BaseTemplate {
28
29 function execute() {
30 global $wgCookieExpiration;
31 $expirationDays = ceil( $wgCookieExpiration / ( 3600 * 24 ) );
32 ?>
33 <div class="mw-ui-container">
34 <div id="userloginprompt"><?php $this->msgWiki('loginprompt') ?></div>
35 <?php if ( $this->haveData( 'languages' ) ) { ?>
36 <div id="languagelinks">
37 <p><?php $this->html( 'languages' ); ?></p>
38 </div>
39 <?php } ?>
40 <div id="userloginForm">
41 <form name="userlogin" class="mw-ui-vform" method="post" action="<?php $this->text( 'action' ); ?>">
42 <?php if ( $this->data['loggedin'] ) { ?>
43 <div class="warningbox">
44 <?php echo $this->getMsg( 'userlogin-loggedin' )->params( $this->data['loggedinuser'] )->parse(); ?>
45 </div>
46 <?php } ?>
47 <section class="mw-form-header">
48 <?php $this->html( 'header' ); /* extensions such as ConfirmEdit add form HTML here */ ?>
49 </section>
50
51 <?php if ( $this->data['message'] ) { ?>
52 <div class="<?php $this->text( 'messagetype' ); ?>box">
53 <?php if ( $this->data['messagetype'] == 'error' ) { ?>
54 <strong><?php $this->msg( 'loginerror' ); ?></strong>
55 <br />
56 <?php } ?>
57 <?php $this->html( 'message' ); ?>
58 </div>
59 <?php } ?>
60
61 <?php if ( $this->data['formheader'] ) { ?>
62 <div class="mw-form-formheader">
63 <?php $this->html( 'formheader' ); /* extensions such as MobileFrontend add HTML here */ ?>
64 </div>
65 <?php } ?>
66 <div class="mw-ui-vform-field">
67 <label for="wpName1">
68 <?php
69 $this->msg( 'userlogin-yourname' );
70
71 if ( $this->data['secureLoginUrl'] ) {
72 echo Html::element( 'a', [
73 'href' => $this->data['secureLoginUrl'],
74 'class' => 'mw-ui-flush-right mw-secure',
75 ], $this->getMsg( 'userlogin-signwithsecure' )->text() );
76 }
77 ?>
78 </label>
79 <?php
80 echo Html::input( 'wpName', $this->data['name'], 'text', [
81 'class' => 'loginText mw-ui-input',
82 'id' => 'wpName1',
83 'tabindex' => '1',
84 // 'required' is blacklisted for now in Html.php due to browser issues.
85 // Keeping here in case that changes.
86 'required' => true,
87 // Set focus to this field if it's blank.
88 'autofocus' => !$this->data['name'],
89 'placeholder' => $this->getMsg( 'userlogin-yourname-ph' )->text()
90 ] );
91 ?>
92 </div>
93
94 <div class="mw-ui-vform-field">
95 <label for="wpPassword1">
96 <?php
97 $this->msg( 'userlogin-yourpassword' );
98 ?>
99 </label>
100 <?php
101 echo Html::input( 'wpPassword', null, 'password', [
102 'class' => 'loginPassword mw-ui-input',
103 'id' => 'wpPassword1',
104 'tabindex' => '2',
105 // Set focus to this field if username is filled in.
106 'autofocus' => (bool)$this->data['name'],
107 'placeholder' => $this->getMsg( 'userlogin-yourpassword-ph' )->text()
108 ] );
109 ?>
110 </div>
111
112 <?php
113 if ( isset( $this->data['usedomain'] ) && $this->data['usedomain'] ) {
114 $select = new XmlSelect( 'wpDomain', false, $this->data['domain'] );
115 $select->setAttribute( 'tabindex', 3 );
116 foreach ( $this->data['domainnames'] as $dom ) {
117 $select->addOption( $dom );
118 }
119 ?>
120 <div class="mw-ui-vform-field" id="mw-user-domain-section">
121 <label for="wpDomain"><?php $this->msg( 'yourdomainname' ); ?></label>
122 <?php echo $select->getHTML(); ?>
123 </div>
124 <?php } ?>
125
126 <?php
127 if ( $this->haveData( 'extrafields' ) ) {
128 echo $this->data['extrafields'];
129 }
130 ?>
131
132 <div class="mw-ui-vform-field">
133 <?php if ( $this->data['canremember'] ) { ?>
134 <div class="mw-ui-checkbox">
135 <input name="wpRemember" type="checkbox" value="1" id="wpRemember" tabindex="4"
136 <?php if ( $this->data['remember'] ) {
137 echo 'checked="checked"';
138 } ?>
139 ><label for="wpRemember">
140 <?php echo $this->getMsg( 'userlogin-remembermypassword' )->numParams( $expirationDays )->escaped(); ?></label>
141 </div>
142 <?php } ?>
143 </div>
144
145 <div class="mw-ui-vform-field">
146 <?php
147 $attrs = [
148 'id' => 'wpLoginAttempt',
149 'name' => 'wpLoginAttempt',
150 'tabindex' => '6',
151 ];
152 $modifiers = [
153 'mw-ui-progressive',
154 ];
155 echo Html::submitButton( $this->getMsg( 'pt-login-button' )->text(), $attrs, $modifiers );
156 ?>
157 </div>
158
159 <div class="mw-ui-vform-field mw-form-related-link-container" id="mw-userlogin-help">
160 <?php
161 echo Html::element(
162 'a',
163 [
164 'href' => Skin::makeInternalOrExternalUrl(
165 wfMessage( 'helplogin-url' )->inContentLanguage()->text()
166 ),
167 ],
168 $this->getMsg( 'userlogin-helplink2' )->text()
169 );
170 ?>
171 </div>
172 <?php
173
174 if ( $this->data['useemail'] && $this->data['canreset'] && $this->data['resetlink'] === true ) {
175 echo Html::rawElement(
176 'div',
177 [
178 'class' => 'mw-ui-vform-field mw-form-related-link-container',
179 ],
180 Linker::link(
181 SpecialPage::getTitleFor( 'PasswordReset' ),
182 $this->getMsg( 'userlogin-resetpassword-link' )->escaped()
183 )
184 );
185 }
186
187 if ( $this->haveData( 'createOrLoginHref' ) ) {
188 if ( $this->data['loggedin'] ) { ?>
189 <div class="mw-form-related-link-container mw-ui-vform-field">
190 <a href="<?php $this->text( 'createOrLoginHref' ); ?>" id="mw-createaccount-join" tabindex="7"><?php $this->msg( 'userlogin-createanother' ); ?></a>
191 </div>
192 <?php } else { ?>
193 <div id="mw-createaccount-cta" class="mw-ui-vform-field">
194 <?php $this->msg( 'userlogin-noaccount' ); ?><a href="<?php $this->text( 'createOrLoginHref' ); ?>" id="mw-createaccount-join" tabindex="7" class="mw-ui-button"><?php $this->msg( 'userlogin-joinproject' ); ?></a>
195 </div>
196 <?php
197 }
198 }
199
200 // Hidden fields
201 $fields = '';
202 if ( $this->haveData( 'uselang' ) ) {
203 $fields .= Html::hidden( 'uselang', $this->data['uselang'] );
204 }
205 if ( $this->haveData( 'token' ) ) {
206 $fields .= Html::hidden( 'wpLoginToken', $this->data['token'] );
207 }
208 if ( $this->data['cansecurelogin'] ) {
209 $fields .= Html::hidden( 'wpForceHttps', $this->data['stickhttps'] );
210 }
211 if ( $this->data['cansecurelogin'] && $this->haveData( 'fromhttp' ) ) {
212 $fields .= Html::hidden( 'wpFromhttp', $this->data['fromhttp'] );
213 }
214 echo $fields;
215
216 ?>
217 </form>
218 </div>
219 </div>
220 <?php
221
222 }
223 }