Merge "Slight improvements to FormSpecialPage behavior."
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 17 May 2013 17:29:01 +0000 (17:29 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 17 May 2013 17:29:01 +0000 (17:29 +0000)
1  2 
includes/SpecialPage.php

diff --combined includes/SpecialPage.php
@@@ -676,7 -676,7 +676,7 @@@ class SpecialPage 
                $func = $this->mFunction;
                // only load file if the function does not exist
                if ( !is_callable( $func ) && $this->mFile ) {
 -                      require_once( $this->mFile );
 +                      require_once $this->mFile;
                }
                $this->outputHeader();
                call_user_func( $func, $subPage, $this );
        /**
         * Shortcut to get user's language
         *
 -       * @deprecated 1.19 Use getLanguage instead
 +       * @deprecated since 1.19 Use getLanguage instead
         * @return Language
         * @since 1.18
         */
   * a new structure for SpecialPages
   */
  abstract class FormSpecialPage extends SpecialPage {
+       /**
+        * The sub-page of the special page.
+        * @var string
+        */
+       protected $par = null;
  
        /**
         * Get an HTMLForm descriptor array
                $form = new HTMLForm( $this->fields, $this->getContext(), $this->getMessagePrefix() );
                $form->setSubmitCallback( array( $this, 'onSubmit' ) );
                $form->setWrapperLegendMsg( $this->getMessagePrefix() . '-legend' );
-               $form->addHeaderText(
-                       $this->msg( $this->getMessagePrefix() . '-text' )->parseAsBlock() );
+               $headerMsg = $this->msg( $this->getMessagePrefix() . '-text' );
+               if ( !$headerMsg->disabled() ) {
+                       $form->addHeaderText( $headerMsg->parseAsBlock() );
+               }
  
                // Retain query parameters (uselang etc)
                $params = array_diff_key(
        /**
         * Do something exciting on successful processing of the form, most likely to show a
         * confirmation message
+        * @since 1.22 Default is to do nothing
         */
-       abstract public function onSuccess();
+       public function onSuccess() {}
  
        /**
         * Basic SpecialPage workflow: get a form, send it to the user; get some data back,
  
        /**
         * Maybe do something interesting with the subpage parameter
-        * @param $par String
+        * @param string $par
         */
-       protected function setParameter( $par ) {}
+       protected function setParameter( $par ) {
+               $this->par = $par;
+       }
  
        /**
         * Called from execute() to check if the given user can perform this action.