Merge "mediawiki.ui: Remove deployment hack"
[lhc/web/wiklou.git] / includes / actions / Action.php
index 1180c5e..ffdf516 100644 (file)
@@ -38,27 +38,30 @@ abstract class Action {
 
        /**
         * Page on which we're performing the action
+        * @since 1.17
         * @var WikiPage|Article|ImagePage|CategoryPage|Page $page
         */
        protected $page;
 
        /**
         * IContextSource if specified; otherwise we'll use the Context from the Page
+        * @since 1.17
         * @var IContextSource $context
         */
        protected $context;
 
        /**
         * The fields used to create the HTMLForm
-        * @var Array $fields
+        * @since 1.17
+        * @var array $fields
         */
        protected $fields;
 
        /**
         * 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
+        * @param string $action
+        * @param array $overrides
         * @return bool|null|string|callable
         */
        final private static function getClass( $action, array $overrides ) {
@@ -82,10 +85,11 @@ abstract class Action {
 
        /**
         * Get an appropriate Action subclass for the given action
-        * @param $action String
-        * @param $page Page
-        * @param $context IContextSource
-        * @return Action|bool|null false if the action is disabled, null
+        * @since 1.17
+        * @param string $action
+        * @param Page $page
+        * @param IContextSource $context
+        * @return Action|bool|null False if the action is disabled, null
         *     if it is not recognised
         */
        final public static function factory( $action, Page $page, IContextSource $context = null ) {
@@ -109,8 +113,8 @@ abstract class Action {
         * $wgActions will be replaced by "nosuchaction".
         *
         * @since 1.19
-        * @param $context IContextSource
-        * @return string: action name
+        * @param IContextSource $context
+        * @return string Action name
         */
        final public static function getActionName( IContextSource $context ) {
                global $wgActions;
@@ -152,9 +156,10 @@ abstract class Action {
 
        /**
         * Check if a given action is recognised, even if it's disabled
+        * @since 1.17
         *
-        * @param string $name name of an action
-        * @return Bool
+        * @param string $name Name of an action
+        * @return bool
         */
        final public static function exists( $name ) {
                return self::getClass( $name, array() ) !== null;
@@ -162,6 +167,7 @@ abstract class Action {
 
        /**
         * Get the IContextSource in use here
+        * @since 1.17
         * @return IContextSource
         */
        final public function getContext() {
@@ -169,7 +175,7 @@ abstract class Action {
                        return $this->context;
                } elseif ( $this->page instanceof Article ) {
                        // NOTE: $this->page can be a WikiPage, which does not have a context.
-                       wfDebug( __METHOD__ . ': no context known, falling back to Article\'s context.' );
+                       wfDebug( __METHOD__ . ": no context known, falling back to Article's context.\n" );
                        return $this->page->getContext();
                }
 
@@ -179,6 +185,7 @@ abstract class Action {
 
        /**
         * Get the WebRequest being used for this instance
+        * @since 1.17
         *
         * @return WebRequest
         */
@@ -188,6 +195,7 @@ abstract class Action {
 
        /**
         * Get the OutputPage being used for this instance
+        * @since 1.17
         *
         * @return OutputPage
         */
@@ -197,6 +205,7 @@ abstract class Action {
 
        /**
         * Shortcut to get the User being used for this instance
+        * @since 1.17
         *
         * @return User
         */
@@ -206,6 +215,7 @@ abstract class Action {
 
        /**
         * Shortcut to get the Skin being used for this instance
+        * @since 1.17
         *
         * @return Skin
         */
@@ -222,19 +232,10 @@ abstract class Action {
                return $this->getContext()->getLanguage();
        }
 
-       /**
-        * Shortcut to get the user Language being used for this instance
-        *
-        * @deprecated since 1.19 Use getLanguage instead
-        * @return Language
-        */
-       final public function getLang() {
-               wfDeprecated( __METHOD__, '1.19' );
-               return $this->getLanguage();
-       }
-
        /**
         * Shortcut to get the Title object from the page
+        * @since 1.17
+        *
         * @return Title
         */
        final public function getTitle() {
@@ -245,7 +246,7 @@ abstract class Action {
         * Get a Message object with context set
         * Parameters are the same as wfMessage()
         *
-        * @return Message object
+        * @return Message
         */
        final public function msg() {
                $params = func_get_args();
@@ -257,8 +258,8 @@ abstract class Action {
         *
         * Only public since 1.21
         *
-        * @param $page Page
-        * @param $context IContextSource
+        * @param Page $page
+        * @param IContextSource $context
         */
        public function __construct( Page $page, IContextSource $context = null ) {
                if ( $context === null ) {
@@ -273,14 +274,18 @@ abstract class Action {
 
        /**
         * Return the name of the action this object responds to
-        * @return String lowercase
+        * @since 1.17
+        *
+        * @return string Lowercase name
         */
        abstract public function getName();
 
        /**
         * Get the permission required to perform this action.  Often, but not always,
         * the same as the action name
-        * @return String|null
+        * @since 1.17
+        *
+        * @return string|null
         */
        public function getRestriction() {
                return null;
@@ -290,10 +295,10 @@ abstract class Action {
         * Checks if the given user (identified by an object) can perform this action.  Can be
         * overridden by sub-classes with more complicated permissions schemes.  Failures here
         * must throw subclasses of ErrorPageError
+        * @since 1.17
         *
-        * @param $user User: the user to check, or null to use the context user
+        * @param User $user The user to check, or null to use the context user
         * @throws UserBlockedError|ReadOnlyError|PermissionsError
-        * @return bool True on success
         */
        protected function checkCanExecute( User $user ) {
                $right = $this->getRestriction();
@@ -315,12 +320,13 @@ abstract class Action {
                if ( $this->requiresWrite() && wfReadOnly() ) {
                        throw new ReadOnlyError();
                }
-               return true;
        }
 
        /**
         * Whether this action requires the wiki not to be locked
-        * @return Bool
+        * @since 1.17
+        *
+        * @return bool
         */
        public function requiresWrite() {
                return true;
@@ -328,7 +334,9 @@ abstract class Action {
 
        /**
         * Whether this action can still be executed by a blocked user
-        * @return Bool
+        * @since 1.17
+        *
+        * @return bool
         */
        public function requiresUnblock() {
                return true;
@@ -337,6 +345,7 @@ abstract class Action {
        /**
         * Set output headers for noindexing etc.  This function will not be called through
         * the execute() entry point, so only put UI-related stuff in here.
+        * @since 1.17
         */
        protected function setHeaders() {
                $out = $this->getOutput();
@@ -349,7 +358,7 @@ abstract class Action {
        /**
         * Returns the name that goes in the \<h1\> page title
         *
-        * @return String
+        * @return string
         */
        protected function getPageTitle() {
                return $this->getTitle()->getPrefixedText();
@@ -357,8 +366,9 @@ abstract class Action {
 
        /**
         * Returns the description that goes below the \<h1\> tag
+        * @since 1.17
         *
-        * @return String
+        * @return string
         */
        protected function getDescription() {
                return $this->msg( strtolower( $this->getName() ) )->escaped();
@@ -368,13 +378,9 @@ abstract class Action {
         * The main action entry point.  Do all output for display and send it to the context
         * output.  Do not use globals $wgOut, $wgRequest, etc, in implementations; use
         * $this->getOutput(), etc.
+        * @since 1.17
+        *
         * @throws ErrorPageError
         */
        abstract public function show();
-
-       /**
-        * Execute the action in a silent fashion: do not display anything or release any errors.
-        * @return Bool whether execution was successful
-        */
-       abstract public function execute();
 }