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