Unify properties in ApiQueryAllimages, ApiQueryImageinfo and ApiUpload.
authorBryan Tong Minh <btongminh@users.mediawiki.org>
Wed, 26 Aug 2009 17:30:36 +0000 (17:30 +0000)
committerBryan Tong Minh <btongminh@users.mediawiki.org>
Wed, 26 Aug 2009 17:30:36 +0000 (17:30 +0000)
includes/api/ApiQueryAllimages.php
includes/api/ApiQueryImageInfo.php
includes/api/ApiUpload.php

index 88261af..39a7ac7 100644 (file)
@@ -168,18 +168,7 @@ class ApiQueryAllimages extends ApiQueryGeneratorBase {
                        'sha1' => null,
                        'sha1base36' => null,
                        'prop' => array (
-                               ApiBase :: PARAM_TYPE => array(
-                                       'timestamp',
-                                       'user',
-                                       'comment',
-                                       'url',
-                                       'size',
-                                       'dimensions', // Obsolete
-                                       'mime',
-                                       'sha1',
-                                       'metadata',
-                                       'bitdepth',
-                               ),
+                               ApiBase :: PARAM_TYPE => ApiQueryImageInfo::getPropertyNames(),
                                ApiBase :: PARAM_DFLT => 'timestamp|url',
                                ApiBase :: PARAM_ISMULTI => true
                        )
index 0a7e09b..3494f91 100644 (file)
@@ -250,18 +250,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
                        'prop' => array (
                                ApiBase :: PARAM_ISMULTI => true,
                                ApiBase :: PARAM_DFLT => 'timestamp|user',
-                               ApiBase :: PARAM_TYPE => array (
-                                       'timestamp',
-                                       'user',
-                                       'comment',
-                                       'url',
-                                       'size',
-                                       'sha1',
-                                       'mime',
-                                       'metadata',
-                                       'archivename',
-                                       'bitdepth',
-                               )
+                               ApiBase :: PARAM_TYPE => self::getPropertyNames()
                        ),
                        'limit' => array(
                                ApiBase :: PARAM_TYPE => 'limit',
@@ -287,6 +276,25 @@ class ApiQueryImageInfo extends ApiQueryBase {
                        'continue' => null,
                );
        }
+       
+       /**
+        * Returns all possible parameters to iiprop
+        */
+       public static function getPropertyNames() {
+               return array (
+                                       'timestamp',
+                                       'user',
+                                       'comment',
+                                       'url',
+                                       'size',
+                                       'dimensions', // For backwards compatibility with Allimages
+                                       'sha1',
+                                       'mime',
+                                       'metadata',
+                                       'archivename',
+                                       'bitdepth',
+                               );
+       }
 
        public function getParamDescription() {
                return array (
index af4c571..7377040 100644 (file)
@@ -275,16 +275,7 @@ class ApiUpload extends ApiBase {
                // Append imageinfo to the result
 
                //get all the image properties:
-               $imParam = Array('timestamp',
-                                       'user',
-                                       'comment',
-                                       'url',
-                                       'size',
-                                       'sha1',
-                                       'mime',
-                                       'metadata',
-                                       'archivename',
-                                       'bitdepth');
+               $imParam = ApiQueryImageInfo::getPropertyNames();
         $result['imageinfo'] = ApiQueryImageInfo::getInfo( $file,
                        array_flip( $imParam ),
             $this->getResult() );