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