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.
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.
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
23 * @defgroup Templates Templates
27 * New base template for Agora-look templates that provides helper methods for
28 * some Agora-specific layouts.
30 abstract class AgoraTemplate
extends QuickTemplate
{
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
38 * @param $label string text for label
39 * @param $name string form element name
41 * @param $checked bool (default: false)
42 * @param $attribs array additional attributes for the input checkbox
47 public static function labelledCheck( $label, $name, $id, $checked = false, $attribs = array() ) {
48 return Html
::rawElement(
52 'class' => 'mw-ui-checkbox-label'
57 array( 'id' => $id ) +
$attribs
66 * Html form for user login with new Agora appearance.
69 class UserloginTemplateAgora
extends AgoraTemplate
{
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">
80 // TODO is inside the form the right place for this?
81 if( $this->data
['message'] ) {
83 <div
class="<?php $this->text('messagetype') ?>box">
84 <?php
if ( $this->data
['messagetype'] == 'error' ) { ?
>
85 <strong
><?php
$this->msg( 'loginerror' )?
></strong
><br
/>
87 <?php
$this->html('message') ?
>
89 <div
class="visualClear"></div
>
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() );
104 echo Html
::input( 'wpName', $this->data
['name'], 'text', array(
105 'class' => 'loginText',
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' => '' ) ) );
117 <label
for='wpPassword1'>
119 $this->msg('userlogin-yourpassword');
121 if ( $this->data
['useemail'] && $this->data
['canreset'] ) {
122 if( $this->data
['resetlink'] === true ){
124 SpecialPage
::getTitleFor( 'PasswordReset' ),
125 wfMessage( 'userlogin-resetlink' )->parse(),
126 array( 'class' => 'mw-ui-flush-right' )
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.
134 wfMessage( 'mailmypassword' )->text(),
136 'id' => 'wpMailmypassword',
144 echo Html
::input( 'wpPassword', null, 'password', array(
145 'class' => 'loginPassword',
146 'id' => 'wpPassword1',
149 'placeholder' => wfMessage( 'userlogin-yourpassword-ph' )->text()
150 ) +
( $this->data
['name'] ?
array( 'autofocus' ) : array() ) ); ?
>
152 <?php
if( isset( $this->data
['usedomain'] ) && $this->data
['usedomain'] ) {
154 foreach( $this->data
['domainnames'] as $dom ) {
155 $doms .= "<option>" . htmlspecialchars( $dom ) . "</option>";
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' ) ?>"
167 if( $this->haveData( 'extrafields' ) ) {
168 echo $this->data
['extrafields'];
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(),
179 $this->data
['remember']
183 <?php
if( $this->data
['cansecurelogin'] ) { ?
>
186 echo Xml
::checkLabel(
187 wfMessage( 'securelogin-stick-https' )->text(),
190 $this->data
['stickHTTPS'],
191 array( 'tabindex' => '9' )
198 echo Html
::input( 'wpLoginAttempt', wfMessage( 'login' )->text(), 'submit', array(
199 'id' => 'wpLoginAttempt',
201 'class' => 'mw-ui-button big block primary'
205 <li style
="text-align: center;">
206 <?php
echo wfMessage( 'userlogin-helplink' )->parse() ?
>
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
>
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
} ?
>