Fix fatal, use Message::isDisabled()
[lhc/web/wiklou.git] / includes / SpecialPage.php
index 46d4304..665ca4a 100644 (file)
@@ -445,7 +445,10 @@ class SpecialPage {
         * @return Mixed
         * @deprecated since 1.18
         */
-       function name( $x = null ) { wfDeprecated( __METHOD__, '1.18' ); return wfSetVar( $this->mName, $x ); }
+       function name( $x = null ) {
+               wfDeprecated( __METHOD__, '1.18' );
+               return wfSetVar( $this->mName, $x );
+       }
 
        /**
         * These mutators are very evil, as the relevant variables should not mutate.  So
@@ -454,7 +457,10 @@ class SpecialPage {
         * @return Mixed
         * @deprecated since 1.18
         */
-       function restriction( $x = null ) { wfDeprecated( __METHOD__, '1.18' ); return wfSetVar( $this->mRestriction, $x ); }
+       function restriction( $x = null ) {
+               wfDeprecated( __METHOD__, '1.18' );
+               return wfSetVar( $this->mRestriction, $x );
+       }
 
        /**
         * These mutators are very evil, as the relevant variables should not mutate.  So
@@ -463,7 +469,10 @@ class SpecialPage {
         * @return Mixed
         * @deprecated since 1.18
         */
-       function func( $x = null ) { wfDeprecated( __METHOD__, '1.18' ); return wfSetVar( $this->mFunction, $x ); }
+       function func( $x = null ) {
+               wfDeprecated( __METHOD__, '1.18' );
+               return wfSetVar( $this->mFunction, $x );
+       }
 
        /**
         * These mutators are very evil, as the relevant variables should not mutate.  So
@@ -472,7 +481,10 @@ class SpecialPage {
         * @return Mixed
         * @deprecated since 1.18
         */
-       function file( $x = null ) { wfDeprecated( __METHOD__, '1.18' ); return wfSetVar( $this->mFile, $x ); }
+       function file( $x = null ) {
+               wfDeprecated( __METHOD__, '1.18' );
+               return wfSetVar( $this->mFile, $x );
+       }
 
        /**
         * These mutators are very evil, as the relevant variables should not mutate.  So
@@ -481,7 +493,10 @@ class SpecialPage {
         * @return Mixed
         * @deprecated since 1.18
         */
-       function includable( $x = null ) { wfDeprecated( __METHOD__, '1.18' ); return wfSetVar( $this->mIncludable, $x ); }
+       function includable( $x = null ) {
+               wfDeprecated( __METHOD__, '1.18' );
+               return wfSetVar( $this->mIncludable, $x );
+       }
 
        /**
         * Whether the special page is being evaluated via transclusion
@@ -661,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 );
@@ -782,7 +797,7 @@ class SpecialPage {
        /**
         * Shortcut to get user's language
         *
-        * @deprecated 1.19 Use getLanguage instead
+        * @deprecated since 1.19 Use getLanguage instead
         * @return Language
         * @since 1.18
         */
@@ -842,11 +857,11 @@ class SpecialPage {
        protected function addFeedLinks( $params ) {
                global $wgFeedClasses;
 
-               $feedTemplate = wfScript( 'api' ) . '?';
+               $feedTemplate = wfScript( 'api' );
 
                foreach ( $wgFeedClasses as $format => $class ) {
                        $theseParams = $params + array( 'feedformat' => $format );
-                       $url = $feedTemplate . wfArrayToCgi( $theseParams );
+                       $url = wfAppendQuery( $feedTemplate, $theseParams );
                        $this->getOutput()->addFeedLink( $format, $url );
                }
        }
@@ -909,6 +924,11 @@ class SpecialPage {
  * 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
@@ -917,11 +937,20 @@ abstract class FormSpecialPage extends SpecialPage {
        abstract protected function getFormFields();
 
        /**
-        * Add pre- or post-text to the form
+        * Add pre-text to the form
         * @return String HTML which will be sent to $form->addPreText()
         */
-       protected function preText() { return ''; }
-       protected function postText() { return ''; }
+       protected function preText() {
+               return '';
+       }
+
+       /**
+        * Add post-text to the form
+        * @return String HTML which will be sent to $form->addPostText()
+        */
+       protected function postText() {
+               return '';
+       }
 
        /**
         * Play with the HTMLForm if you need to more substantially
@@ -948,9 +977,12 @@ abstract class FormSpecialPage extends SpecialPage {
 
                $form = new HTMLForm( $this->fields, $this->getContext(), $this->getMessagePrefix() );
                $form->setSubmitCallback( array( $this, 'onSubmit' ) );
-               $form->setWrapperLegend( $this->msg( $this->getMessagePrefix() . '-legend' ) );
-               $form->addHeaderText(
-                       $this->msg( $this->getMessagePrefix() . '-text' )->parseAsBlock() );
+               $form->setWrapperLegendMsg( $this->getMessagePrefix() . '-legend' );
+
+               $headerMsg = $this->msg( $this->getMessagePrefix() . '-text' );
+               if ( !$headerMsg->isDisabled() ) {
+                       $form->addHeaderText( $headerMsg->parseAsBlock() );
+               }
 
                // Retain query parameters (uselang etc)
                $params = array_diff_key(
@@ -977,8 +1009,9 @@ abstract class FormSpecialPage extends SpecialPage {
        /**
         * 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,
@@ -1000,9 +1033,11 @@ abstract class FormSpecialPage extends SpecialPage {
 
        /**
         * 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.
@@ -1093,10 +1128,9 @@ abstract class RedirectSpecialPage extends UnlistedSpecialPage {
                        $url = $redirect->getFullURL( $query );
                        $this->getOutput()->redirect( $url );
                        return $redirect;
-               // Redirect to index.php with query parameters
                } elseif ( $redirect === true ) {
-                       global $wgScript;
-                       $url = $wgScript . '?' . wfArrayToCgi( $query );
+                       // Redirect to index.php with query parameters
+                       $url = wfAppendQuery( wfScript( 'index' ), $query );
                        $this->getOutput()->redirect( $url );
                        return $redirect;
                } else {
@@ -1270,9 +1304,9 @@ abstract class RedirectSpecialArticle extends RedirectSpecialPage {
                        'action',
                        'redirect', 'rdfrom',
                        # Options for preloaded edits
-                       'preload', 'editintro', 'preloadtitle', 'summary',
+                       'preload', 'editintro', 'preloadtitle', 'summary', 'nosummary',
                        # Options for overriding user settings
-                       'preview', 'internaledit', 'externaledit', 'mode',
+                       'preview', 'internaledit', 'externaledit', 'mode', 'minor', 'watchthis',
                        # Options for history/diffs
                        'section', 'oldid', 'diff', 'dir',
                        'limit', 'offset', 'feed',