Templates:Captcha position modified,extend functionality added to QuickTemplate
authorSumit Asthana <asthana.sumit23@gmail.com>
Tue, 13 Jan 2015 21:02:36 +0000 (02:32 +0530)
committerSumit Asthana <asthana.sumit23@gmail.com>
Tue, 20 Jan 2015 13:54:26 +0000 (19:24 +0530)
The ConfirmEdit extension presently inserts captcha in the header of Usercreate
and Userlogin templates. The js,if enabled places the captcha before submit
button.  A separate 'extrafields' placeholder for captcha is added just before
submit button in Usercreate.php so that captcha position remains consistent,
even if js is disabled.  An extend method added to QuickTemplate to append any
data to existing field, rather than setting it with fresh data. Particular use
for 'extrafields' in Usercreate and Userlogin.

Bug: T85192
Change-Id: I82c68814e79cbc5aa250a308862c59fcbb6fd527

RELEASE-NOTES-1.25
includes/skins/QuickTemplate.php
includes/templates/Usercreate.php

index 1ba6e97..2e937e2 100644 (file)
@@ -128,6 +128,9 @@ production.
   on action=info about a file page does not list file links anymore.
 * (T78637) Search bar is not autofocused unless it is empty so that proper scrolling using arrow keys is possible.
 * (T50853) Database::makeList() modified to handle 'NULL' separately when building IN clause
+* (T85192) Captcha position modified in Usercreate template. As a result:
+** extrafields parameter added to Usercreate.php to insert additional data
+** 'extend' method added to QuickTemplate to append additional values to any field of data array
 
 === Action API changes in 1.25 ===
 * (T67403) XML tag highlighting is now only performed for formats
index b28dc51..905e537 100644 (file)
@@ -50,6 +50,20 @@ abstract class QuickTemplate {
                $this->data[$name] = $value;
        }
 
+       /**
+       * extends the value of data with name $name with the value $value
+       * @since 1.25
+       * @param string $name
+       * @param mixed $value
+       */
+       public function extend( $name, $value ) {
+               if ( $this->haveData( $name ) ) {
+                       $this->data[$name] = $this->data[$name] . $value;
+               } else {
+                       $this->data[$name] = $value;
+               }
+       }
+
        /**
         * Gets the template data requested
         * @since 1.22
index d783c6a..b185cb3 100644 (file)
@@ -53,7 +53,7 @@ class UsercreateTemplate extends BaseTemplate {
        <div id="userloginForm">
                <form name="userlogin2" id="userlogin2" class="mw-ui-vform" method="post" action="<?php $this->text( 'action' ); ?>">
                        <section class="mw-form-header">
-                               <?php $this->html( 'header' ); /* extensions such as ConfirmEdit add form HTML here */ ?>
+                               <?php $this->html( 'header' ); ?>
                        </section>
                        <!-- This element is used by the mediawiki.special.userlogin.signup.js module. -->
                        <div
@@ -248,8 +248,11 @@ class UsercreateTemplate extends BaseTemplate {
                                }
                        }
 
-                       // JS attempts to move the image CAPTCHA below this part of the form,
-                       // so skip one index.
+                       // A separate placeholder for any inserting any extrafields, e.g used by ConfirmEdit extension
+                       if ( $this->haveData( 'extrafields' ) ) {
+                               echo $this->data['extrafields'];
+                       }
+                       // skip one index.
                        $tabIndex++;
                        ?>
                        <div class="mw-ui-vform-field mw-submit">