From 05336e91adea31454215ebe10c7148f54b396c48 Mon Sep 17 00:00:00 2001 From: Bryan Tong Minh Date: Wed, 26 Aug 2009 17:30:36 +0000 Subject: [PATCH 1/1] Unify properties in ApiQueryAllimages, ApiQueryImageinfo and ApiUpload. --- includes/api/ApiQueryAllimages.php | 13 +----------- includes/api/ApiQueryImageInfo.php | 32 +++++++++++++++++++----------- includes/api/ApiUpload.php | 11 +--------- 3 files changed, 22 insertions(+), 34 deletions(-) diff --git a/includes/api/ApiQueryAllimages.php b/includes/api/ApiQueryAllimages.php index 88261afbe9..39a7ac73c1 100644 --- a/includes/api/ApiQueryAllimages.php +++ b/includes/api/ApiQueryAllimages.php @@ -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 ) diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php index 0a7e09b052..3494f9134c 100644 --- a/includes/api/ApiQueryImageInfo.php +++ b/includes/api/ApiQueryImageInfo.php @@ -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 ( diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php index af4c5719bc..7377040844 100644 --- a/includes/api/ApiUpload.php +++ b/includes/api/ApiUpload.php @@ -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() ); -- 2.20.1