Merge "Check validity and availability of usernames during signup via AJAX"
[lhc/web/wiklou.git] / includes / api / ApiImageRotate.php
index ebdbedd..b8e16ab 100644 (file)
  */
 
 class ApiImageRotate extends ApiBase {
-
        private $mPageSet = null;
 
-       public function __construct( $main, $action ) {
-               parent::__construct( $main, $action );
-       }
-
        /**
         * Add all items from $values into the result
         * @param array $result output
@@ -38,31 +33,28 @@ class ApiImageRotate extends ApiBase {
         */
        private static function addValues( array &$result, $values, $flag = null, $name = null ) {
                foreach ( $values as $val ) {
-                       if( $val instanceof Title ) {
+                       if ( $val instanceof Title ) {
                                $v = array();
                                ApiQueryBase::addTitleInfo( $v, $val );
-                       } elseif( $name !== null ) {
+                       } elseif ( $name !== null ) {
                                $v = array( $name => $val );
                        } else {
                                $v = $val;
                        }
-                       if( $flag !== null ) {
+                       if ( $flag !== null ) {
                                $v[$flag] = '';
                        }
                        $result[] = $v;
                }
        }
 
-
        public function execute() {
                $params = $this->extractRequestParams();
                $rotation = $params['rotation'];
-               $user = $this->getUser();
 
                $pageSet = $this->getPageSet();
                $pageSet->execute();
 
-               $result = array();
                $result = array();
 
                self::addValues( $result, $pageSet->getInvalidTitles(), 'invalid', 'title' );
@@ -149,12 +141,14 @@ class ApiImageRotate extends ApiBase {
                if ( $this->mPageSet === null ) {
                        $this->mPageSet = new ApiPageSet( $this, 0, NS_FILE );
                }
+
                return $this->mPageSet;
        }
 
        /**
         * Checks that the user has permissions to perform rotations.
-        * @param $user User The user to check.
+        * @param User $user The user to check
+        * @param Title $title
         * @return string|null Permission error message, or null if there is no error
         */
        protected function checkPermissions( $user, $title ) {
@@ -166,6 +160,7 @@ class ApiImageRotate extends ApiBase {
                if ( $permissionErrors ) {
                        // Just return the first error
                        $msg = $this->parseMsg( $permissionErrors[0] );
+
                        return $msg['info'];
                }
 
@@ -181,7 +176,6 @@ class ApiImageRotate extends ApiBase {
        }
 
        public function getAllowedParams( $flags = 0 ) {
-               $pageSet = $this->getPageSet();
                $result = array(
                        'rotation' => array(
                                ApiBase::PARAM_TYPE => array( '90', '180', '270' ),
@@ -195,19 +189,21 @@ class ApiImageRotate extends ApiBase {
                if ( $flags ) {
                        $result += $this->getPageSet()->getFinalParams( $flags );
                }
+
                return $result;
        }
 
        public function getParamDescription() {
                $pageSet = $this->getPageSet();
-               return $pageSet->getParamDescription() + array(
+
+               return $pageSet->getFinalParamDescription() + array(
                        'rotation' => 'Degrees to rotate image clockwise',
                        'token' => 'Edit token. You can get one of these through action=tokens',
                );
        }
 
        public function getDescription() {
-               return 'Rotate one or more images';
+               return 'Rotate one or more images.';
        }
 
        public function needsToken() {
@@ -220,9 +216,10 @@ class ApiImageRotate extends ApiBase {
 
        public function getPossibleErrors() {
                $pageSet = $this->getPageSet();
+
                return array_merge(
                        parent::getPossibleErrors(),
-                       $pageSet->getPossibleErrors()
+                       $pageSet->getFinalPossibleErrors()
                );
        }