FU 97704: I was thinking the space was already added in this case
[lhc/web/wiklou.git] / includes / Action.php
index 5fbb5d1..b165721 100644 (file)
@@ -32,8 +32,8 @@ abstract class Action {
        protected $page;
 
        /**
-        * RequestContext if specified; otherwise we'll use the Context from the Page
-        * @var RequestContext
+        * IContextSource if specified; otherwise we'll use the Context from the Page
+        * @var IContextSource
         */
        protected $context;
 
@@ -47,9 +47,10 @@ abstract class Action {
         * Get the Action subclass which should be used to handle this action, false if
         * the action is disabled, or null if it's not recognised
         * @param $action String
+        * @param $overrides Array
         * @return bool|null|string
         */
-       private final static function getClass( $action ) {
+       private final static function getClass( $action, array $overrides ) {
                global $wgActions;
                $action = strtolower( $action );
 
@@ -59,13 +60,11 @@ abstract class Action {
 
                if ( $wgActions[$action] === false ) {
                        return false;
-               }
-
-               elseif ( $wgActions[$action] === true ) {
+               } elseif ( $wgActions[$action] === true && isset( $overrides[$action] ) ) {
+                       return $overrides[$action];
+               elseif ( $wgActions[$action] === true ) {
                        return ucfirst( $action ) . 'Action';
-               }
-
-               else {
+               } else {
                        return $wgActions[$action];
                }
        }
@@ -77,8 +76,8 @@ abstract class Action {
         * @return Action|false|null false if the action is disabled, null
         *     if it is not recognised
         */
-       public final static function factory( $action, Article $page ) {
-               $class = self::getClass( $action );
+       public final static function factory( $action, Page $page ) {
+               $class = self::getClass( $action, $page->getActionOverrides() );
                if ( $class ) {
                        $obj = new $class( $page );
                        return $obj;
@@ -93,15 +92,15 @@ abstract class Action {
         * @return Bool
         */
        public final static function exists( $name ) {
-               return self::getClass( $name ) !== null;
+               return self::getClass( $name, array() ) !== null;
        }
 
        /**
-        * Get the RequestContext in use here
-        * @return RequestContext
+        * Get the IContextSource in use here
+        * @return IContextSource
         */
        protected final function getContext() {
-               if ( $this->context instanceof RequestContext ) {
+               if ( $this->context instanceof IContextSource ) {
                        return $this->context;
                }
                return $this->page->getContext();
@@ -163,9 +162,9 @@ abstract class Action {
        /**
         * Protected constructor: use Action::factory( $action, $page ) to actually build
         * these things in the real world
-        * @param Article $page
+        * @param Page $page
         */
-       protected function __construct( Article $page ) {
+       protected function __construct( Page $page ) {
                $this->page = $page;
        }
 
@@ -227,7 +226,7 @@ abstract class Action {
        protected function setHeaders() {
                $out = $this->getOutput();
                $out->setRobotPolicy( "noindex,nofollow" );
-               $out->setPageTitle( $this->getTitle()->getPrefixedText() );
+               $out->setPageTitle( $this->getPageTitle() );
                $this->getOutput()->setSubtitle( $this->getDescription() );
                $out->setArticleRelated( true );
        }
@@ -237,6 +236,15 @@ abstract class Action {
         *
         * @return String
         */
+       protected function getPageTitle() {
+               return $this->getTitle()->getPrefixedText();
+       }
+
+       /**
+        * Returns the description that goes below the \<h1\> tag
+        *
+        * @return String
+        */
        protected function getDescription() {
                return wfMsg( strtolower( $this->getName() ) );
        }