Merge "Add an interface for getting "standard" file metadata."
[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 if ( $this->haveData( 'languages' ) ) { ?>
32 <div id="languagelinks">
33 <p><?php $this->html( 'languages' ); ?></p>
34 </div>
35 <?php } ?>
36 <div id="userloginForm">
37 <form name="userlogin" class="mw-ui-vform" method="post" action="<?php $this->text( 'action' ); ?>">
38 <?php if ( $this->data['loggedin'] ) { ?>
39 <div class="warningbox">
40 <?php echo $this->getMsg( 'userlogin-loggedin' )->params( $this->data['loggedinuser'] )->parse(); ?>
41 </div>
42 <?php } ?>
43 <section class="mw-form-header">
44 <?php $this->html( 'header' ); /* extensions such as ConfirmEdit add form HTML here */ ?>
45 </section>
46
47 <?php if ( $this->data['message'] ) { ?>
48 <div class="<?php $this->text( 'messagetype' ); ?>box">
49 <?php if ( $this->data['messagetype'] == 'error' ) { ?>
50 <strong><?php $this->msg( 'loginerror' ); ?></strong>
51 <br />
52 <?php } ?>
53 <?php $this->html( 'message' ); ?>
54 </div>
55 <?php } ?>
56
57 <div>
58 <label for='wpName1'>
59 <?php
60 $this->msg( 'userlogin-yourname' );
61
62 if ( $this->data['secureLoginUrl'] ) {
63 echo Html::element( 'a', array(
64 'href' => $this->data['secureLoginUrl'],
65 'class' => 'mw-ui-flush-right mw-secure',
66 ), $this->getMsg( 'userlogin-signwithsecure' )->text() );
67 }
68 ?>
69 </label>
70 <?php
71 $extraAttrs = array();
72 echo Html::input( 'wpName', $this->data['name'], 'text', array(
73 'class' => 'loginText',
74 'id' => 'wpName1',
75 'tabindex' => '1',
76 'size' => '20',
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>
88 <label for='wpPassword1'>
89 <?php
90 $this->msg( 'userlogin-yourpassword' );
91
92 if ( $this->data['useemail'] && $this->data['canreset'] && $this->data['resetlink'] === true ) {
93 echo ' ' . Linker::link(
94 SpecialPage::getTitleFor( 'PasswordReset' ),
95 $this->getMsg( 'userlogin-resetpassword-link' )->parse(),
96 array( 'class' => 'mw-ui-flush-right' )
97 );
98 }
99 ?>
100 </label>
101 <?php
102 echo Html::input( 'wpPassword', null, 'password', array(
103 'class' => 'loginPassword',
104 'id' => 'wpPassword1',
105 'tabindex' => '2',
106 'size' => '20',
107 // Set focus to this field if username is filled in.
108 'autofocus' => (bool)$this->data['name'],
109 'placeholder' => $this->getMsg( 'userlogin-yourpassword-ph' )->text()
110 ) );
111 ?>
112 </div>
113
114 <?php
115 if ( isset( $this->data['usedomain'] ) && $this->data['usedomain'] ) {
116 $doms = "";
117 foreach ( $this->data['domainnames'] as $dom ) {
118 $doms .= "<option>" . htmlspecialchars( $dom ) . "</option>";
119 }
120 ?>
121 <div id="mw-user-domain-section">
122 <label for='wpDomain'><?php $this->msg( 'yourdomainname' ); ?></label>
123 <select name="wpDomain" value="<?php $this->text( 'domain' ); ?>" tabindex="3">
124 <?php echo $doms; ?>
125 </select>
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( 'login' )->text(), 'submit', array(
151 'id' => 'wpLoginAttempt',
152 'tabindex' => '6',
153 'class' => 'mw-ui-button mw-ui-big mw-ui-block mw-ui-primary'
154 ) );
155 ?>
156 </div>
157
158 <div id="mw-userlogin-help">
159 <?php echo $this->getMsg( 'userlogin-helplink' )->parse(); ?>
160 </div>
161 <?php if ( $this->haveData( 'createOrLoginHref' ) ) { ?>
162 <?php if ( $this->data['loggedin'] ) { ?>
163 <div id="mw-createaccount-another">
164 <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>
165 </div>
166 <?php } else { ?>
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 } ?>
172 <?php if ( $this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
173 <?php if ( $this->haveData( 'token' ) ) { ?><input type="hidden" name="wpLoginToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
174 <?php if ( $this->data['cansecurelogin'] ) {?><input type="hidden" name="wpForceHttps" value="<?php $this->text( 'stickhttps' ); ?>" /><?php } ?>
175 </form>
176 </div>
177 </div>
178 <?php
179
180 }
181 }