/extensions/SemanticSignup/includes/SES_SignupFields.php

https://github.com/ChuguluGames/mediawiki-svn · PHP · 199 lines · 171 code · 19 blank · 9 comment · 24 complexity · bd48a5ad92509b058771729c361d70c3 MD5 · raw file

  1. <?php
  2. /*
  3. * Created on 6 Jan 2009 by Serhii Kutnii
  4. */
  5. /*
  6. * Borrowed from standard UsercreateTemplate. Some minor changes have been made
  7. */
  8. class CreateUserFieldsTemplate extends QuickTemplate
  9. {
  10. function addInputItem( $name, $value, $type, $msg ) {
  11. $this->data['extraInput'][] = array(
  12. 'name' => $name,
  13. 'value' => $value,
  14. 'type' => $type,
  15. 'msg' => $msg,
  16. );
  17. }
  18. function execute() {
  19. ?>
  20. <div id="userlogin">
  21. <h2><?php $this->msg( 'createaccount' ) ?></h2>
  22. <p id="userloginlink"><?php $this->html( 'link' ) ?></p>
  23. <?php $this->html( 'header' ); /* pre-table point for form plugins... */ ?>
  24. <?php if ( @$this->haveData( 'languages' ) ) { ?><div id="languagelinks"><p><?php $this->html( 'languages' ); ?></p></div><?php } ?>
  25. <table>
  26. <tr>
  27. <td class="mw-label"><label for='wpName2'><?php $this->msg( 'yourname' ) ?></label></td>
  28. <td class="mw-input">
  29. <input type='text' class='loginText' name="wpName" id="wpName2"
  30. tabindex="1"
  31. size='20' />
  32. </td>
  33. </tr>
  34. <tr>
  35. <td class="mw-label"><label for='wpPassword2'><?php $this->msg( 'yourpassword' ) ?></label></td>
  36. <td class="mw-input">
  37. <input type='password' class='loginPassword' name="wpPassword" id="wpPassword2"
  38. tabindex="2"
  39. value="" size='20' />
  40. </td>
  41. </tr>
  42. <?php if ( $this->data['usedomain'] ) {
  43. $doms = "";
  44. foreach ( $this->data['domainnames'] as $dom ) {
  45. $doms .= "<option>" . htmlspecialchars( $dom ) . "</option>";
  46. }
  47. ?>
  48. <tr>
  49. <td class="mw-label"><?php $this->msg( 'yourdomainname' ) ?></td>
  50. <td class="mw-input">
  51. <select name="wpDomain" value="<?php $this->text( 'domain' ) ?>"
  52. tabindex="3">
  53. <?php echo $doms ?>
  54. </select>
  55. </td>
  56. </tr>
  57. <?php } ?>
  58. <tr>
  59. <td class="mw-label"><label for='wpRetype'><?php $this->msg( 'yourpasswordagain' ) ?></label></td>
  60. <td class="mw-input">
  61. <input type='password' class='loginPassword' name="wpRetype" id="wpRetype"
  62. tabindex="4"
  63. value=""
  64. size='20' />
  65. </td>
  66. </tr>
  67. <tr>
  68. <?php if ( $this->data['useemail'] ) { ?>
  69. <td class="mw-label"><label for='wpEmail'><?php $this->msg( 'youremail' ) ?></label></td>
  70. <td class="mw-input">
  71. <input type='text' class='loginText' name="wpEmail" id="wpEmail"
  72. tabindex="5"
  73. value="<?php $this->text( 'email' ) ?>" size='20' />
  74. <div class="prefsectiontip">
  75. <?php if ( $this->data['emailrequired'] ) {
  76. $this->msgWiki( 'prefs-help-email-required' );
  77. } else {
  78. $this->msgWiki( 'prefs-help-email' );
  79. } ?>
  80. </div>
  81. </td>
  82. <?php } ?>
  83. <?php if ( $this->data['userealname'] ) { ?>
  84. </tr>
  85. <tr>
  86. <td class="mw-label"><label for='wpRealName'><?php $this->msg( 'yourrealname' ) ?></label></td>
  87. <td class="mw-input">
  88. <input type='text' class='loginText' name="wpRealName" id="wpRealName"
  89. tabindex="6"
  90. size='20' />
  91. </td>
  92. <?php } ?>
  93. </tr>
  94. <tr>
  95. <td></td>
  96. </tr>
  97. <?php
  98. $tabIndex = 8;
  99. if ( isset( $this->data['extraInput'] ) && is_array( $this->data['extraInput'] ) ) {
  100. foreach ( $this->data['extraInput'] as $inputItem ) { ?>
  101. <tr>
  102. <?php
  103. if ( !empty( $inputItem['msg'] ) && $inputItem['type'] != 'checkbox' ) {
  104. ?><td class="mw-label"><label for="<?php
  105. echo htmlspecialchars( $inputItem['name'] ); ?>"><?php
  106. $this->msgWiki( $inputItem['msg'] ) ?></label><?php
  107. } else {
  108. ?><td><?php
  109. }
  110. ?></td>
  111. <td class="mw-input">
  112. <input type="<?php echo htmlspecialchars( $inputItem['type'] ) ?>" name="<?php
  113. echo htmlspecialchars( $inputItem['name'] ); ?>"
  114. tabindex="<?php echo $tabIndex++; ?>"
  115. value="<?php
  116. if ( $inputItem['type'] != 'checkbox' ) {
  117. echo htmlspecialchars( $inputItem['value'] );
  118. } else {
  119. echo '1';
  120. }
  121. ?>" id="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
  122. <?php
  123. if ( $inputItem['type'] == 'checkbox' && !empty( $inputItem['value'] ) )
  124. echo 'checked="checked"';
  125. ?> /> <?php
  126. if ( $inputItem['type'] == 'checkbox' && !empty( $inputItem['msg'] ) ) {
  127. ?>
  128. <label for="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"><?php
  129. $this->msg( $inputItem['msg'] ) ?></label><?php
  130. }
  131. ?>
  132. </td>
  133. </tr>
  134. <?php
  135. }
  136. }
  137. ?>
  138. <tr>
  139. <td></td>
  140. </tr>
  141. </table>
  142. <?php if ( @$this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
  143. </div>
  144. <div id="signupend"><?php $this->msgWiki( 'signupend' ); ?></div>
  145. <?php
  146. }
  147. }
  148. class SES_SignupFields {
  149. public static function render( $args, $parser ) {
  150. $args = func_get_args();
  151. $parser = array_shift( $args );
  152. $template = new CreateUserFieldsTemplate();
  153. $template->set( 'header', '' );
  154. global $wgEnableEmail, $wgAllowRealName, $wgEmailConfirmToEdit, $wgAuth, $wgUser;
  155. $template->set( 'link', '' ); // TODO
  156. $template->set( 'email', '' ); // TODO
  157. $template->set( 'createemail', $wgEnableEmail && $wgUser->isLoggedIn() );
  158. $template->set( 'userealname', $wgAllowRealName );
  159. $template->set( 'useemail', $wgEnableEmail );
  160. $template->set( 'emailrequired', $wgEmailConfirmToEdit );
  161. $template->set( 'canreset', $wgAuth->allowPasswordChange() );
  162. // $template->set( 'remember', $wgUser->getOption( 'rememberpassword' ) );
  163. global $wgLoginLanguageSelector;
  164. # Prepare language selection links as needed
  165. if ( $wgLoginLanguageSelector ) {
  166. $template->set( 'languages', $this->makeLanguageSelector() );
  167. }
  168. // Give authentication and captcha plugins a chance to modify the form
  169. $type = 'signup';
  170. $wgAuth->modifyUITemplate( $template, $type );
  171. ob_start();
  172. $template->execute();
  173. $text = ob_get_clean();
  174. return array(
  175. $text,
  176. 'noparse' => true,
  177. 'isHTML' => true
  178. );
  179. }
  180. }