FU r106752: use "media-" instead of "images-" in container names. Long live books...
[lhc/web/wiklou.git] / includes / Action.php
index 951c74a..655598e 100644 (file)
@@ -27,7 +27,7 @@ abstract class Action {
 
        /**
         * Page on which we're performing the action
-        * @var Article
+        * @var Page
         */
        protected $page;
 
@@ -72,14 +72,15 @@ abstract class Action {
        /**
         * Get an appropriate Action subclass for the given action
         * @param $action String
-        * @param $page Article
+        * @param $page Page
+        * @param $context IContextSource
         * @return Action|false|null false if the action is disabled, null
         *     if it is not recognised
         */
-       public final static function factory( $action, Page $page ) {
+       public final static function factory( $action, Page $page, IContextSource $context = null ) {
                $class = self::getClass( $action, $page->getActionOverrides() );
                if ( $class ) {
-                       $obj = new $class( $page );
+                       $obj = new $class( $page, $context );
                        return $obj;
                }
                return $class;
@@ -158,6 +159,7 @@ abstract class Action {
         * @return Skin
         */
        public final function getLang() {
+               wfDeprecated( __METHOD__, '1.19' );
                return $this->getLanguage();
        }
 
@@ -183,10 +185,12 @@ abstract class Action {
        /**
         * Protected constructor: use Action::factory( $action, $page ) to actually build
         * these things in the real world
-        * @param Page $page
+        * @param $page Page
+        * @param $context IContextSource
         */
-       protected function __construct( Page $page ) {
+       protected function __construct( Page $page, IContextSource $context = null ) {
                $this->page = $page;
+               $this->context = $context;
        }
 
        /**
@@ -198,8 +202,11 @@ abstract class Action {
        /**
         * Get the permission required to perform this action.  Often, but not always,
         * the same as the action name
+        * @return String|null
         */
-       public abstract function getRestriction();
+       public function getRestriction() {
+               return null;
+       }
 
        /**
         * Checks if the given user (identified by an object) can perform this action.  Can be