Merge "Add tests for API's assert={user|bot}"
[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 <?php if ( $this->haveData( 'languages' ) ) { ?>
33 <div id="languagelinks">
34 <p><?php $this->html( 'languages' ); ?></p>
35 </div>
36 <?php } ?>
37 <div id="userloginForm">
38 <form name="userlogin" class="mw-ui-vform" method="post" action="<?php $this->text( 'action' ); ?>">
39 <?php if ( $this->data['loggedin'] ) { ?>
40 <div class="warningbox">
41 <?php echo $this->getMsg( 'userlogin-loggedin' )->params( $this->data['loggedinuser'] )->parse(); ?>
42 </div>
43 <?php } ?>
44 <section class="mw-form-header">
45 <?php $this->html( 'header' ); /* extensions such as ConfirmEdit add form HTML here */ ?>
46 </section>
47
48 <?php if ( $this->data['message'] ) { ?>
49 <div class="<?php $this->text( 'messagetype' ); ?>box">
50 <?php if ( $this->data['messagetype'] == 'error' ) { ?>
51 <strong><?php $this->msg( 'loginerror' ); ?></strong>
52 <br />
53 <?php } ?>
54 <?php $this->html( 'message' ); ?>
55 </div>
56 <?php } ?>
57
58 <div>
59 <label for='wpName1'>
60 <?php
61 $this->msg( 'userlogin-yourname' );
62
63 if ( $this->data['secureLoginUrl'] ) {
64 echo Html::element( 'a', array(
65 'href' => $this->data['secureLoginUrl'],
66 'class' => 'mw-ui-flush-right mw-secure',
67 ), $this->getMsg( 'userlogin-signwithsecure' )->text() );
68 }
69 ?>
70 </label>
71 <?php
72 $extraAttrs = array();
73 echo Html::input( 'wpName', $this->data['name'], 'text', array(
74 'class' => 'loginText',
75 'id' => 'wpName1',
76 'tabindex' => '1',
77 'size' => '20',
78 // 'required' is blacklisted for now in Html.php due to browser issues.
79 // Keeping here in case that changes.
80 'required' => true,
81 // Set focus to this field if it's blank.
82 'autofocus' => !$this->data['name'],
83 'placeholder' => $this->getMsg( 'userlogin-yourname-ph' )->text()
84 ) );
85 ?>
86 </div>
87
88 <div>
89 <label for='wpPassword1'>
90 <?php
91 $this->msg( 'userlogin-yourpassword' );
92
93 if ( $this->data['useemail'] && $this->data['canreset'] && $this->data['resetlink'] === true ) {
94 echo ' ' . Linker::link(
95 SpecialPage::getTitleFor( 'PasswordReset' ),
96 $this->getMsg( 'userlogin-resetpassword-link' )->parse(),
97 array( 'class' => 'mw-ui-flush-right' )
98 );
99 }
100 ?>
101 </label>
102 <?php
103 echo Html::input( 'wpPassword', null, 'password', array(
104 'class' => 'loginPassword',
105 'id' => 'wpPassword1',
106 'tabindex' => '2',
107 'size' => '20',
108 // Set focus to this field if username is filled in.
109 'autofocus' => (bool)$this->data['name'],
110 'placeholder' => $this->getMsg( 'userlogin-yourpassword-ph' )->text()
111 ) );
112 ?>
113 </div>
114
115 <?php
116 if ( isset( $this->data['usedomain'] ) && $this->data['usedomain'] ) {
117 $select = new XmlSelect( 'wpDomain', false, $this->data['domain'] );
118 $select->setAttribute( 'tabindex', 3 );
119 foreach ( $this->data['domainnames'] as $dom ) {
120 $select->addOption( $dom );
121 }
122 ?>
123 <div id="mw-user-domain-section">
124 <label for='wpDomain'><?php $this->msg( 'yourdomainname' ); ?></label>
125 <?php echo $select->getHTML(); ?>
126 </div>
127 <?php } ?>
128
129 <?php
130 if ( $this->haveData( 'extrafields' ) ) {
131 echo $this->data['extrafields'];
132 }
133 ?>
134
135 <div>
136 <?php if ( $this->data['canremember'] ) { ?>
137 <label class="mw-ui-checkbox-label">
138 <input name="wpRemember" type="checkbox" value="1" id="wpRemember" tabindex="4"
139 <?php if ( $this->data['remember'] ) {
140 echo 'checked="checked"';
141 } ?>
142 >
143 <?php echo $this->getMsg( 'userlogin-remembermypassword' )->numParams( $expirationDays )->escaped(); ?>
144 </label>
145 <?php } ?>
146 </div>
147
148 <div>
149 <?php
150 echo Html::input( 'wpLoginAttempt', $this->getMsg( 'pt-login-button' )->text(), 'submit', array(
151 'id' => 'wpLoginAttempt',
152 'tabindex' => '6',
153 'class' => 'mw-ui-button mw-ui-big mw-ui-block mw-ui-constructive'
154 ) );
155 ?>
156 </div>
157 <div id="mw-userlogin-help">
158 <?php
159 echo Html::element(
160 'a',
161 array(
162 'href' => Skin::makeInternalOrExternalUrl(
163 wfMessage( 'helplogin-url' )->inContentLanguage()->text()
164 ),
165 ),
166 $this->getMsg( 'userlogin-helplink2' )->text()
167 );
168 ?>
169 </div>
170 <?php if ( $this->haveData( 'createOrLoginHref' ) ) { ?>
171 <?php if ( $this->data['loggedin'] ) { ?>
172 <div id="mw-createaccount-another">
173 <a href="<?php $this->text( 'createOrLoginHref' ); ?>" id="mw-createaccount-join" tabindex="7" class="mw-ui-button"><?php $this->msg( 'userlogin-createanother' ); ?></a>
174 </div>
175 <?php } else { ?>
176 <div id="mw-createaccount-cta">
177 <?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>
178 </div>
179 <?php } ?>
180 <?php } ?>
181 <?php if ( $this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
182 <?php if ( $this->haveData( 'token' ) ) { ?><input type="hidden" name="wpLoginToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
183 <?php if ( $this->data['cansecurelogin'] ) {?><input type="hidden" name="wpForceHttps" value="<?php $this->text( 'stickhttps' ); ?>" /><?php } ?>
184 </form>
185 </div>
186 </div>
187 <?php
188
189 }
190 }