Merge "Rebuild MessagesEn.php"
[lhc/web/wiklou.git] / includes / templates / UserloginAgora.php
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 * @ingroup Templates
20 */
21
22 /**
23 * @defgroup Templates Templates
24 */
25
26 /**
27 * New base template for Agora-look templates that provides helper methods for
28 * some Agora-specific layouts.
29 */
30 abstract class AgoraTemplate extends QuickTemplate {
31
32 /**
33 * Convenience function to build an Agora HTML checkbox nested inside a
34 * label. This arguably belongs in class Html, but then Agora clients
35 * would have to apply an Agora class to the label as well as attrs for the
36 * checkbox.
37 *
38 * @param $label string text for label
39 * @param $name string form element name
40 * @param $id
41 * @param $checked bool (default: false)
42 * @param $attribs array additional attributes for the input checkbox
43 *
44 * @return string HTML
45 * @see Xml:checkLabel
46 */
47 public static function labelledCheck( $label, $name, $id, $checked = false, $attribs = array() ) {
48 return Html::rawElement(
49 'label',
50 array(
51 'for' => $id,
52 'class' => 'mw-ui-checkbox-label'
53 ),
54 Xml::check(
55 $id,
56 $checked,
57 array( 'id' => $id ) + $attribs
58 ) .
59 $label
60 );
61 }
62
63 }
64
65 /**
66 * Html form for user login with new Agora appearance.
67 */
68
69 class UserloginTemplateAgora extends AgoraTemplate {
70
71 function execute() {
72 ?>
73 <div class="mw-ui-container">
74 <div id="userloginForm">
75 <form name="userlogin" method="post" action="<?php $this->text('action') ?>">
76 <?php $this->html('header'); /* pre-table point for form plugins... */ ?>
77 <?php if( $this->haveData( 'languages' ) ) { ?><div id="languagelinks"><p><?php $this->html('languages' ); ?></p></div><?php } ?>
78 <ul class="mw-ui-formlist">
79 <?php
80 // TODO is inside the form the right place for this?
81 if( $this->data['message'] ) {
82 ?>
83 <div class="<?php $this->text('messagetype') ?>box">
84 <?php if ( $this->data['messagetype'] == 'error' ) { ?>
85 <strong><?php $this->msg( 'loginerror' )?></strong><br />
86 <?php } ?>
87 <?php $this->html('message') ?>
88 </div>
89 <div class="visualClear"></div>
90 <?php } ?>
91
92 <li>
93 <label for='wpName1'>
94 <?php
95 $this->msg('userlogin-yourname');
96 if ( $this->data['secureLoginUrl'] ) {
97 echo Html::element( 'a', array(
98 'href' => $this->data['secureLoginUrl'],
99 'class' => 'mw-ui-flush-right mw-secure',
100 ), wfMessage( 'userlogin-signwithsecure' )->text() );
101 } ?>
102 </label>
103 <?php
104 echo Html::input( 'wpName', $this->data['name'], 'text', array(
105 'class' => 'loginText',
106 'id' => 'wpName1',
107 'tabindex' => '1',
108 'size' => '20',
109 'required',
110 'placeholder' => wfMessage( 'userlogin-yourname-ph' )->text()
111 # Can't do + array( 'autofocus' ) because + for arrays in PHP
112 # only works right for associative arrays! Thanks, PHP.
113 ) + ( $this->data['name'] ? array() : array( 'autofocus' => '' ) ) );
114 ?>
115 </li>
116 <li>
117 <label for='wpPassword1'>
118 <?php
119 $this->msg('userlogin-yourpassword');
120
121 if ( $this->data['useemail'] && $this->data['canreset'] ) {
122 if( $this->data['resetlink'] === true ){
123 echo Linker::link(
124 SpecialPage::getTitleFor( 'PasswordReset' ),
125 wfMessage( 'userlogin-resetlink' )->parse(),
126 array( 'class' => 'mw-ui-flush-right' )
127 );
128 } elseif( $this->data['resetlink'] === null ) {
129 /* TODO (spage 2013-02-26) no idea what class to use for this,
130 * it doesn't belong in the label.
131 */
132 echo Html::input(
133 'wpMailmypassword',
134 wfMessage( 'mailmypassword' )->text(),
135 'submit', array(
136 'id' => 'wpMailmypassword',
137 'tabindex' => '10'
138 )
139 );
140 }
141 } ?>
142 </label>
143 <?php
144 echo Html::input( 'wpPassword', null, 'password', array(
145 'class' => 'loginPassword',
146 'id' => 'wpPassword1',
147 'tabindex' => '2',
148 'size' => '20',
149 'placeholder' => wfMessage( 'userlogin-yourpassword-ph' )->text()
150 ) + ( $this->data['name'] ? array( 'autofocus' ) : array() ) ); ?>
151 </li>
152 <?php if( isset( $this->data['usedomain'] ) && $this->data['usedomain'] ) {
153 $doms = "";
154 foreach( $this->data['domainnames'] as $dom ) {
155 $doms .= "<option>" . htmlspecialchars( $dom ) . "</option>";
156 }
157 ?>
158 <li id="mw-user-domain-section">
159 <label for='wpDomain' class="pos-above"><?php $this->msg( 'yourdomain' ) ?></label>
160 <select name="wpDomain" value="<?php $this->text( 'domain' ) ?>"
161 tabindex="3">
162 <?php echo $doms ?>
163 </select>
164 </li>
165 <?php }
166
167 if( $this->haveData( 'extrafields' ) ) {
168 echo $this->data['extrafields'];
169 } ?>
170
171 <li>
172 <?php if( $this->data['canremember'] ) {
173 global $wgCookieExpiration;
174 $expirationDays = ceil( $wgCookieExpiration / ( 3600 * 24 ) );
175 echo $this->labelledCheck(
176 wfMessage( 'userlogin-remembermypassword' )->numParams( $expirationDays )->text(),
177 'wpRemember',
178 'wpRemember',
179 $this->data['remember']
180 );
181 } ?>
182 </li>
183 <?php if( $this->data['cansecurelogin'] ) { ?>
184 <li>
185 <?php
186 echo Xml::checkLabel(
187 wfMessage( 'securelogin-stick-https' )->text(),
188 'wpStickHTTPS',
189 'wpStickHTTPS',
190 $this->data['stickHTTPS'],
191 array( 'tabindex' => '9' )
192 );
193 ?>
194 </li>
195 <?php } ?>
196 <li>
197 <?php
198 echo Html::input( 'wpLoginAttempt', wfMessage( 'login' )->text(), 'submit', array(
199 'id' => 'wpLoginAttempt',
200 'tabindex' => '9',
201 'class' => 'mw-ui-button big block primary'
202 ) );
203 ?>
204 </li>
205 <li style="text-align: center;">
206 <?php echo wfMessage( 'userlogin-helplink' )->parse() ?>
207 </li>
208 <li>
209 <?php if( $this->haveData( 'createOrLoginHref' ) ) { ?>
210 <div id="createaccount-cta">
211 <h3 id="userloginlink"><?php $this->msg( 'userlogin-noaccount' ) ?><a href="<?php $this->text( 'createOrLoginHref' ) ?>" id="mw-joinproject" class="mw-ui-button constructive" style="width: auto; display: inline-block;"><?php $this->msg( 'userlogin-joinproject' ) ?></a></h3>
212 </div>
213 <?php } ?>
214 </li>
215 </ul>
216 <input type="hidden" id="useAgora" name="useAgora" value="1" />
217 <?php if( $this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
218 <?php if( $this->haveData( 'token' ) ) { ?><input type="hidden" name="wpLoginToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
219 </form>
220 </div>
221 </div>
222 <?php
223
224 } // end execute()
225 }