Implement extension registration from an extension.json file
[mediawiki.git] / includes / templates / Userlogin.php
blob69266c8de3627dc0d8f6f10240e8f76c2170508e
1 <?php
2 // @codingStandardsIgnoreFile
3 /**
4 * Html form for user login (since 1.22 with VForm appearance).
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.
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.
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
21 * @file
22 * @ingroup Templates
25 class UserloginTemplate extends BaseTemplate {
27 function execute() {
28 global $wgCookieExpiration;
29 $expirationDays = ceil( $wgCookieExpiration / ( 3600 * 24 ) );
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>
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 } ?>
59 <div class="mw-ui-vform-field">
60 <label for='wpName1'>
61 <?php
62 $this->msg( 'userlogin-yourname' );
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() );
71 </label>
72 <?php
73 $extraAttrs = array();
74 echo Html::input( 'wpName', $this->data['name'], 'text', array(
75 'class' => 'loginText mw-ui-input',
76 'id' => 'wpName1',
77 'tabindex' => '1',
78 'size' => '20',
79 // 'required' is blacklisted for now in Html.php due to browser issues.
80 // Keeping here in case that changes.
81 'required' => true,
82 // Set focus to this field if it's blank.
83 'autofocus' => !$this->data['name'],
84 'placeholder' => $this->getMsg( 'userlogin-yourname-ph' )->text()
85 ) );
87 </div>
89 <div class="mw-ui-vform-field">
90 <label for='wpPassword1'>
91 <?php
92 $this->msg( 'userlogin-yourpassword' );
94 </label>
95 <?php
96 echo Html::input( 'wpPassword', null, 'password', array(
97 'class' => 'loginPassword mw-ui-input',
98 'id' => 'wpPassword1',
99 'tabindex' => '2',
100 'size' => '20',
101 // Set focus to this field if username is filled in.
102 'autofocus' => (bool)$this->data['name'],
103 'placeholder' => $this->getMsg( 'userlogin-yourpassword-ph' )->text()
104 ) );
106 </div>
108 <?php
109 if ( isset( $this->data['usedomain'] ) && $this->data['usedomain'] ) {
110 $select = new XmlSelect( 'wpDomain', false, $this->data['domain'] );
111 $select->setAttribute( 'tabindex', 3 );
112 foreach ( $this->data['domainnames'] as $dom ) {
113 $select->addOption( $dom );
116 <div class="mw-ui-vform-field" id="mw-user-domain-section">
117 <label for='wpDomain'><?php $this->msg( 'yourdomainname' ); ?></label>
118 <?php echo $select->getHTML(); ?>
119 </div>
120 <?php } ?>
122 <?php
123 if ( $this->haveData( 'extrafields' ) ) {
124 echo $this->data['extrafields'];
128 <div class="mw-ui-vform-field">
129 <?php if ( $this->data['canremember'] ) { ?>
130 <div class="mw-ui-checkbox">
131 <input name="wpRemember" type="checkbox" value="1" id="wpRemember" tabindex="4"
132 <?php if ( $this->data['remember'] ) {
133 echo 'checked="checked"';
134 } ?>
135 ><label for="wpRemember">
136 <?php echo $this->getMsg( 'userlogin-remembermypassword' )->numParams( $expirationDays )->escaped(); ?></label>
137 </div>
138 <?php } ?>
139 </div>
141 <div class="mw-ui-vform-field">
142 <?php
143 $attrs = array(
144 'id' => 'wpLoginAttempt',
145 'name' => 'wpLoginAttempt',
146 'tabindex' => '6',
148 $modifiers = array(
149 'mw-ui-big', 'mw-ui-block', 'mw-ui-constructive',
151 echo Html::submitButton( $this->getMsg( 'pt-login-button' )->text(), $attrs, $modifiers );
153 </div>
155 <div class="mw-ui-vform-field mw-form-related-link-container" id="mw-userlogin-help">
156 <?php
157 echo Html::element(
158 'a',
159 array(
160 'href' => Skin::makeInternalOrExternalUrl(
161 wfMessage( 'helplogin-url' )->inContentLanguage()->text()
164 $this->getMsg( 'userlogin-helplink2' )->text()
167 </div>
168 <?php
169 if ( $this->haveData( 'createOrLoginHref' ) ) {
170 if ( $this->data['useemail'] && $this->data['canreset'] && $this->data['resetlink'] === true ) {
171 echo Html::openElement( 'div',
172 array(
173 'class' => 'mw-ui-vform-field mw-form-related-link-container',
176 Linker::link(
177 SpecialPage::getTitleFor( 'PasswordReset' ),
178 $this->getMsg( 'userlogin-resetpassword-link' )->parse()
180 Html::closeElement( 'div' );
182 if ( $this->data['loggedin'] ) { ?>
183 <div id="mw-createaccount-another" class="mw-form-related-link-container mw-ui-vform-field">
184 <a href="<?php $this->text( 'createOrLoginHref' ); ?>" id="mw-createaccount-join" tabindex="7"><?php $this->msg( 'userlogin-createanother' ); ?></a>
185 </div>
186 <?php } else { ?>
187 <div id="mw-createaccount-cta" class="mw-form-related-link-container mw-ui-vform-field">
188 <?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>
189 </div>
190 <?php } ?>
191 <?php } ?>
192 <?php if ( $this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
193 <?php if ( $this->haveData( 'token' ) ) { ?><input type="hidden" name="wpLoginToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
194 <?php if ( $this->data['cansecurelogin'] ) {?><input type="hidden" name="wpForceHttps" value="<?php $this->text( 'stickhttps' ); ?>" /><?php } ?>
195 <?php if ( $this->data['cansecurelogin'] && $this->haveData( 'fromhttp' )) {?><input type="hidden" name="wpFromhttp" value="<?php $this->text( 'fromhttp' ); ?>" /><?php } ?>
196 </form>
197 </div>
198 </div>
199 <?php