Follow-up r89568: use local context instead of $wgOut
[lhc/web/wiklou.git] / includes / SpecialPage.php
index 809c500..872a493 100644 (file)
@@ -31,7 +31,7 @@ class SpecialPage {
 
        // The canonical name of this special page
        // Also used for the default <h1> heading, @see getDescription()
-       /*private*/ var $mName;
+       protected $mName;
 
        // The local name of this special page
        private $mLocalName;
@@ -57,7 +57,7 @@ class SpecialPage {
 
        /**
         * Current request context
-        * @var RequestContext
+        * @var IContextSource
         */
        protected $mContext;
 
@@ -226,28 +226,15 @@ class SpecialPage {
         * page, and true if it was successful.
         *
         * @param $title          Title object
-        * @param $context        RequestContext
+        * @param $context        IContextSource
         * @param $including      Bool output is being captured for use in {{special:whatever}}
         * @return Bool
         * @deprecated since 1.18 call SpecialPageFactory method directly
         */
-       public static function executePath( &$title, RequestContext &$context, $including = false ) {
+       public static function executePath( &$title, IContextSource &$context, $including = false ) {
                return SpecialPageFactory::executePath( $title, $context, $including );
        }
 
-       /**
-        * Just like executePath() except it returns the HTML instead of outputting it
-        * Returns false if there was no such special page, or a title object if it was
-        * a redirect.
-        *
-        * @param $title Title
-        * @return String: HTML fragment
-        * @deprecated since 1.18 call SpecialPageFactory method directly
-        */
-       static function capturePath( &$title ) {
-               return SpecialPageFactory::capturePath( $title );
-       }
-
        /**
         * Get the local name for a specified canonical name
         *
@@ -545,7 +532,7 @@ class SpecialPage {
                if ( $this->userCanExecute( $this->getUser() ) ) {
                        $func = $this->mFunction;
                        // only load file if the function does not exist
-                       if(!is_callable($func) and $this->mFile) {
+                       if( !is_callable($func) && $this->mFile ) {
                                require_once( $this->mFile );
                        }
                        $this->outputHeader();
@@ -605,7 +592,7 @@ class SpecialPage {
        /**
         * Sets the context this SpecialPage is executed in
         *
-        * @param $context RequestContext
+        * @param $context IContextSource
         * @since 1.18
         */
        public function setContext( $context ) {
@@ -615,11 +602,11 @@ class SpecialPage {
        /**
         * Gets the context this SpecialPage is executed in
         *
-        * @return RequestContext
+        * @return IContextSource
         * @since 1.18
         */
        public function getContext() {
-               if ( $this->mContext instanceof RequestContext ) {
+               if ( $this->mContext instanceof IContextSource ) {
                        return $this->mContext;
                } else {
                        wfDebug( __METHOD__ . " called and \$mContext is null. Return RequestContext::getMain(); for sanity\n" );
@@ -648,7 +635,7 @@ class SpecialPage {
        }
 
        /**
-        * Shortcut to get the skin being used for this instance
+        * Shortcut to get the User executing this instance
         *
         * @return User
         * @since 1.18
@@ -671,7 +658,7 @@ class SpecialPage {
         * Shortcut to get user's language
         *
         * @return Language
-        * @since 1.19
+        * @since 1.18
         */
        public function getLang() {
                return $this->getContext()->getLang();
@@ -688,15 +675,13 @@ class SpecialPage {
        }
 
        /**
-        * Wrapper around wfMessage that sets the current context. Currently this
-        * is only the title.
+        * Wrapper around wfMessage that sets the current context.
         *
         * @return Message
         * @see wfMessage
         */
        public function msg( /* $args */ ) {
-               return call_user_func_array( 'wfMessage',
-                       func_get_args() )->title( $this->getFullTitle() );
+               return call_user_func_array( array( $this->getContext(), 'msg' ), func_get_args() );
        }
 
        /**
@@ -705,14 +690,14 @@ class SpecialPage {
         * @param $params array
         */
        protected function addFeedLinks( $params ) {
-               global $wgFeedClasses, $wgOut;
+               global $wgFeedClasses;
 
                $feedTemplate = wfScript( 'api' ) . '?';
 
                foreach( $wgFeedClasses as $format => $class ) {
                        $theseParams = $params + array( 'feedformat' => $format );
                        $url = $feedTemplate . wfArrayToCGI( $theseParams );
-                       $wgOut->addFeedLink( $format, $url );
+                       $this->getOutput()->addFeedLink( $format, $url );
                }
        }
 }
@@ -750,9 +735,6 @@ abstract class FormSpecialPage extends SpecialPage {
        protected function getForm() {
                $this->fields = $this->getFormFields();
 
-               // Give hooks a chance to alter the form, adding extra fields or text etc
-               wfRunHooks( "Special{$this->getName()}ModifyFormFields", array( &$this->fields ) );
-
                $form = new HTMLForm( $this->fields, $this->getContext() );
                $form->setSubmitCallback( array( $this, 'onSubmit' ) );
                $form->setWrapperLegend( wfMessage( strtolower( $this->getName() ) . '-legend' ) );
@@ -858,8 +840,7 @@ abstract class FormSpecialPage extends SpecialPage {
  * Shortcut to construct a special page which is unlisted by default
  * @ingroup SpecialPage
  */
-class UnlistedSpecialPage extends SpecialPage
-{
+class UnlistedSpecialPage extends SpecialPage {
        function __construct( $name, $restriction = '', $function = false, $file = 'default' ) {
                parent::__construct( $name, $restriction, false, $function, $file );
        }
@@ -873,8 +854,7 @@ class UnlistedSpecialPage extends SpecialPage
  * Shortcut to construct an includable special  page
  * @ingroup SpecialPage
  */
-class IncludableSpecialPage extends SpecialPage
-{
+class IncludableSpecialPage extends SpecialPage {
        function __construct(
                $name, $restriction = '', $listed = true, $function = false, $file = 'default'
        ) {