MediaWiki  REL1_24
Usercreate.php
Go to the documentation of this file.
00001 <?php
00002 // @codingStandardsIgnoreFile
00025 class UsercreateTemplate extends BaseTemplate {
00030     function addInputItem( $name, $value, $type, $msg, $helptext = false ) {
00031         $this->data['extraInput'][] = array(
00032             'name' => $name,
00033             'value' => $value,
00034             'type' => $type,
00035             'msg' => $msg,
00036             'helptext' => $helptext,
00037         );
00038     }
00039 
00040     function execute() {
00041         global $wgCookieExpiration;
00042         $expirationDays = ceil( $wgCookieExpiration / ( 3600 * 24 ) );
00043 ?>
00044 <div class="mw-ui-container">
00045     <?php if ( $this->haveData( 'languages' ) ) { ?>
00046         <div id="languagelinks">
00047             <p><?php $this->html( 'languages' ); ?></p>
00048         </div>
00049     <?php }
00050           if ( !wfMessage( 'signupstart' )->isDisabled() ) { ?>
00051         <div id="signupstart"><?php $this->msgWiki( 'signupstart' ); ?></div>
00052     <?php } ?>
00053     <div id="userloginForm">
00054         <form name="userlogin2" id="userlogin2" class="mw-ui-vform" method="post" action="<?php $this->text( 'action' ); ?>">
00055             <section class="mw-form-header">
00056                 <?php $this->html( 'header' ); /* extensions such as ConfirmEdit add form HTML here */ ?>
00057             </section>
00058             <!-- This element is used by the mediawiki.special.userlogin.signup.js module. -->
00059             <div
00060                 id="mw-createacct-status-area"
00061                 <?php if ( $this->data['message'] ) { ?>
00062                     class="<?php echo $this->data['messagetype']; ?>box"
00063                 <?php } else { ?>
00064                     style="display: none;"
00065                 <?php } ?>
00066             >
00067             <?php if ( $this->data['message'] ) { ?>
00068                     <?php if ( $this->data['messagetype'] == 'error' ) { ?>
00069                         <strong><?php $this->msg( 'createacct-error' ); ?></strong>
00070                         <br />
00071                     <?php } ?>
00072                     <?php $this->html( 'message' ); ?>
00073             <?php } ?>
00074             </div>
00075 
00076             <div class="mw-ui-vform-field">
00077                 <label for='wpName2'>
00078                     <?php $this->msg( 'userlogin-yourname' ); ?>
00079 
00080                     <span class="mw-ui-flush-right"><?php echo $this->getMsg( 'createacct-helpusername' )->parse(); ?></span>
00081                 </label>
00082                 <?php
00083                 echo Html::input( 'wpName', $this->data['name'], 'text', array(
00084                     'class' => 'mw-ui-input loginText',
00085                     'id' => 'wpName2',
00086                     'tabindex' => '1',
00087                     'size' => '20',
00088                     'required',
00089                     'placeholder' => $this->getMsg( $this->data['loggedin'] ?
00090                         'createacct-another-username-ph' : 'userlogin-yourname-ph' )->text(),
00091                 ) );
00092                 ?>
00093             </div>
00094 
00095             <div class="mw-ui-vform-field">
00096                 <?php if ( $this->data['createemail'] ) { ?>
00097                     <div class="mw-ui-checkbox">
00098                         <input name="wpCreateaccountMail" type="checkbox" value="1" id="wpCreateaccountMail" tabindex="2"
00099                             <?php if ( $this->data['createemailset'] ) {
00100                                 echo 'checked="checked"';
00101                             } ?>
00102                         ><label for="wpCreateaccountMail">
00103                             <?php $this->msg( 'createaccountmail' ); ?>
00104                         </label>
00105                     </div>
00106                 <?php } ?>
00107             </div>
00108 
00109             <div class="mw-ui-vform-field mw-row-password">
00110                 <label for='wpPassword2'><?php $this->msg( 'userlogin-yourpassword' ); ?></label>
00111                 <?php
00112                 echo Html::input( 'wpPassword', null, 'password', array(
00113                     'class' => 'mw-ui-input loginPassword',
00114                     'id' => 'wpPassword2',
00115                     'tabindex' => '3',
00116                     'size' => '20',
00117                     'required',
00118                     'placeholder' => $this->getMsg( 'createacct-yourpassword-ph' )->text()
00119                 ) + User::passwordChangeInputAttribs() );
00120                 ?>
00121             </div>
00122 
00123             <?php
00124             if ( $this->data['usedomain'] ) {
00125                 $select = new XmlSelect( 'wpDomain', false, $this->data['domain'] );
00126                 $select->setAttribute( 'tabindex', 4 );
00127                 foreach ( $this->data['domainnames'] as $dom ) {
00128                     $select->addOption( $dom );
00129                 }
00130             ?>
00131                 <div class="mw-ui-vform-field" id="mw-user-domain-section">
00132                     <label for="wpDomain"><?php $this->msg( 'yourdomainname' ); ?></label>
00133                     <div>
00134                         <?php echo $select->getHTML(); ?>
00135                     </div>
00136                 </div>
00137             <?php } ?>
00138 
00139             <div class="mw-ui-vform-field mw-row-password">
00140                 <label for='wpRetype'><?php $this->msg( 'createacct-yourpasswordagain' ); ?></label>
00141                 <?php
00142                 echo Html::input( 'wpRetype', null, 'password', array(
00143                     'class' => 'mw-ui-input loginPassword',
00144                     'id' => 'wpRetype',
00145                     'tabindex' => '5',
00146                     'size' => '20',
00147                     'required',
00148                     'placeholder' => $this->getMsg( 'createacct-yourpasswordagain-ph' )->text()
00149                     ) + User::passwordChangeInputAttribs() );
00150                 ?>
00151             </div>
00152 
00153             <div class="mw-ui-vform-field">
00154                 <?php if ( $this->data['useemail'] ) { ?>
00155                     <label for='wpEmail'>
00156                         <?php
00157                             $this->msg( $this->data['emailrequired'] ?
00158                                 'createacct-emailrequired' :
00159                                 'createacct-emailoptional'
00160                             );
00161                         ?>
00162                     </label>
00163                     <?php
00164                         echo Html::input( 'wpEmail', $this->data['email'], 'email', array(
00165                             'class' => 'mw-ui-input loginText',
00166                             'id' => 'wpEmail',
00167                             'tabindex' => '6',
00168                             'size' => '20',
00169                             'required' => $this->data['emailrequired'],
00170                             'placeholder' => $this->getMsg( $this->data['loggedin'] ?
00171                                 'createacct-another-email-ph' : 'createacct-email-ph' )->text()
00172                         ) );
00173                     ?>
00174                 <?php } ?>
00175             </div>
00176 
00177             <?php if ( $this->data['userealname'] ) { ?>
00178                 <div class="mw-ui-vform-field">
00179                     <label for='wpRealName'><?php $this->msg( 'createacct-realname' ); ?></label>
00180                     <input type='text' class='mw-ui-input loginText' name="wpRealName" id="wpRealName"
00181                         tabindex="7"
00182                         value="<?php $this->text( 'realname' ); ?>" size='20' />
00183                     <div class="prefsectiontip">
00184                         <?php $this->msgWiki( $this->data['loggedin'] ? 'createacct-another-realname-tip' : 'prefs-help-realname' ); ?>
00185                     </div>
00186                 </div>
00187             <?php } ?>
00188 
00189             <?php if ( $this->data['usereason'] ) { ?>
00190                 <div class="mw-ui-vform-field">
00191                     <label for='wpReason'><?php $this->msg( 'createacct-reason' ); ?></label>
00192                     <?php echo Html::input( 'wpReason', $this->data['reason'], 'text', array(
00193                         'class' => 'mw-ui-input loginText',
00194                         'id' => 'wpReason',
00195                         'tabindex' => '8',
00196                         'size' => '20',
00197                         'placeholder' => $this->getMsg( 'createacct-reason-ph' )->text()
00198                     ) ); ?>
00199                 </div>
00200             <?php } ?>
00201 
00202             <?php
00203             $tabIndex = 9;
00204             if ( isset( $this->data['extraInput'] ) && is_array( $this->data['extraInput'] ) ) {
00205                 foreach ( $this->data['extraInput'] as $inputItem ) { ?>
00206                     <div class="mw-ui-vform-field">
00207                         <?php
00208                         // If it's a checkbox, output the whole thing (assume it has a msg).
00209                         if ( $inputItem['type'] == 'checkbox' ) {
00210                         ?>
00211                             <div class="mw-ui-checkbox">
00212                                 <input
00213                                     name="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
00214                                     id="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
00215                                     type="checkbox" value="1"
00216                                     tabindex="<?php echo $tabIndex++; ?>"
00217                                     <?php if ( !empty( $inputItem['value'] ) ) {
00218                                         echo 'checked="checked"';
00219                                     } ?>
00220                                 ><label for="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"></label>
00221                             </div><?php $this->msgHtml( $inputItem['msg'] ); ?>
00222                         <?php
00223                         } else {
00224                             // Not a checkbox.
00225                             // TODO (bug 31909) support other input types, e.g. select boxes.
00226                         ?>
00227                             <?php if ( !empty( $inputItem['msg'] ) ) { ?>
00228                                 <label for="<?php echo htmlspecialchars( $inputItem['name'] ); ?>">
00229                                     <?php $this->msgWiki( $inputItem['msg'] ); ?>
00230                                 </label>
00231                             <?php } ?>
00232                             <input
00233                                 type="<?php echo htmlspecialchars( $inputItem['type'] ); ?>"
00234                                 class="mw-ui-input"
00235                                 name="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
00236                                 tabindex="<?php echo $tabIndex++; ?>"
00237                                 value="<?php echo htmlspecialchars( $inputItem['value'] ); ?>"
00238                                 id="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
00239                             />
00240                         <?php } ?>
00241                         <?php if ( $inputItem['helptext'] !== false ) { ?>
00242                             <div class="prefsectiontip">
00243                                 <?php $this->msgWiki( $inputItem['helptext'] ); ?>
00244                             </div>
00245                         <?php } ?>
00246                     </div>
00247                 <?php
00248                 }
00249             }
00250 
00251             // JS attempts to move the image CAPTCHA below this part of the form,
00252             // so skip one index.
00253             $tabIndex++;
00254             ?>
00255             <div class="mw-ui-vform-field mw-submit">
00256                 <?php
00257                 echo Html::input(
00258                     'wpCreateaccount',
00259                     $this->getMsg( $this->data['loggedin'] ? 'createacct-another-submit' : 'createacct-submit' ),
00260                     'submit',
00261                     array(
00262                         'class' => "mw-ui-button mw-ui-big mw-ui-block mw-ui-constructive",
00263                         'id' => 'wpCreateaccount',
00264                         'tabindex' => $tabIndex++
00265                     )
00266                 );
00267                 ?>
00268             </div>
00269             <?php if ( $this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
00270             <?php if ( $this->haveData( 'token' ) ) { ?><input type="hidden" name="wpCreateaccountToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
00271         </form>
00272         <?php if ( !wfMessage( 'signupend' )->isDisabled() ) { ?>
00273             <div id="signupend"><?php $this->html( 'signupend' ); ?></div>
00274         <?php } ?>
00275     </div>
00276     <div class="mw-createacct-benefits-container">
00277         <h2><?php $this->msg( 'createacct-benefit-heading' ); ?></h2>
00278         <div class="mw-createacct-benefits-list">
00279             <?php
00280             for ( $benefitIdx = 1; $benefitIdx <= $this->data['benefitCount']; $benefitIdx++ ) {
00281                 // Pass each benefit's head text (by default a number) as a parameter to the body's message for PLURAL handling.
00282                 $headUnescaped = $this->getMsg( "createacct-benefit-head$benefitIdx" )->text();
00283             ?>
00284                 <div class="mw-number-text <?php $this->msg( "createacct-benefit-icon$benefitIdx" ); ?>">
00285                     <h3><?php $this->msg( "createacct-benefit-head$benefitIdx" ); ?></h3>
00286                     <p><?php echo $this->getMsg( "createacct-benefit-body$benefitIdx" )->params( $headUnescaped )->escaped(); ?></p>
00287                 </div>
00288             <?php } ?>
00289         </div>
00290     </div>
00291 </div>
00292 <?php
00293 
00294     }
00295 }