Merge "registration: Support $wgMediaHandlers in ExtensionProcessor"
[lhc/web/wiklou.git] / includes / api / ApiQueryImageInfo.php
index 18da1e6..02846dc 100644 (file)
@@ -373,7 +373,9 @@ class ApiQueryImageInfo extends ApiQueryBase {
                        );
                }
                $version = $opts['version'];
-               $vals = array();
+               $vals = array(
+                       ApiResult::META_TYPE => 'assoc',
+               );
                // Timestamp is shown even if the file is revdelete'd in interface
                // so do same here.
                if ( isset( $prop['timestamp'] ) ) {
@@ -397,7 +399,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
 
                if ( $user || $userid ) {
                        if ( $file->isDeleted( File::DELETED_USER ) ) {
-                               $vals['userhidden'] = '';
+                               $vals['userhidden'] = true;
                                $anyHidden = true;
                        }
                        if ( $canShowField( File::DELETED_USER ) ) {
@@ -408,7 +410,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
                                        $vals['userid'] = $file->getUser( 'id' );
                                }
                                if ( !$file->getUser( 'id' ) ) {
-                                       $vals['anon'] = '';
+                                       $vals['anon'] = true;
                                }
                        }
                }
@@ -438,7 +440,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
 
                if ( $pcomment || $comment ) {
                        if ( $file->isDeleted( File::DELETED_COMMENT ) ) {
-                               $vals['commenthidden'] = '';
+                               $vals['commenthidden'] = true;
                                $anyHidden = true;
                        }
                        if ( $canShowField( File::DELETED_COMMENT ) ) {
@@ -469,7 +471,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
                }
 
                if ( $file->isDeleted( File::DELETED_FILE ) ) {
-                       $vals['filehidden'] = '';
+                       $vals['filehidden'] = true;
                        $anyHidden = true;
                }
 
@@ -599,7 +601,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
                                $retval[] = $r;
                        }
                }
-               $result->setIndexedTagName( $retval, 'metadata' );
+               ApiResult::setIndexedTagName( $retval, 'metadata' );
 
                return $retval;
        }
@@ -632,7 +634,8 @@ class ApiQueryImageInfo extends ApiQueryBase {
                        'prop' => array(
                                ApiBase::PARAM_ISMULTI => true,
                                ApiBase::PARAM_DFLT => 'timestamp|user',
-                               ApiBase::PARAM_TYPE => self::getPropertyNames()
+                               ApiBase::PARAM_TYPE => self::getPropertyNames(),
+                               ApiBase::PARAM_HELP_MSG_PER_VALUE => self::getPropertyMessages(),
                        ),
                        'limit' => array(
                                ApiBase::PARAM_TYPE => 'limit',
@@ -690,11 +693,43 @@ class ApiQueryImageInfo extends ApiQueryBase {
         * Returns all possible parameters to iiprop
         *
         * @param array $filter List of properties to filter out
-        *
         * @return array
         */
        public static function getPropertyNames( $filter = array() ) {
-               return array_diff( array_keys( self::getProperties() ), $filter );
+               return array_keys( self::getPropertyMessages( $filter ) );
+       }
+
+       /**
+        * Returns messages for all possible parameters to iiprop
+        *
+        * @param array $filter List of properties to filter out
+        * @return array
+        */
+       public static function getPropertyMessages( $filter = array() ) {
+               return array_diff_key(
+                       array(
+                               'timestamp' => 'apihelp-query+imageinfo-paramvalue-prop-timestamp',
+                               'user' => 'apihelp-query+imageinfo-paramvalue-prop-user',
+                               'userid' => 'apihelp-query+imageinfo-paramvalue-prop-userid',
+                               'comment' => 'apihelp-query+imageinfo-paramvalue-prop-comment',
+                               'parsedcomment' => 'apihelp-query+imageinfo-paramvalue-prop-parsedcomment',
+                               'canonicaltitle' => 'apihelp-query+imageinfo-paramvalue-prop-canonicaltitle',
+                               'url' => 'apihelp-query+imageinfo-paramvalue-prop-url',
+                               'size' => 'apihelp-query+imageinfo-paramvalue-prop-size',
+                               'dimensions' => 'apihelp-query+imageinfo-paramvalue-prop-dimensions',
+                               'sha1' => 'apihelp-query+imageinfo-paramvalue-prop-sha1',
+                               'mime' => 'apihelp-query+imageinfo-paramvalue-prop-mime',
+                               'thumbmime' => 'apihelp-query+imageinfo-paramvalue-prop-thumbmime',
+                               'mediatype' => 'apihelp-query+imageinfo-paramvalue-prop-mediatype',
+                               'metadata' => 'apihelp-query+imageinfo-paramvalue-prop-metadata',
+                               'commonmetadata' => 'apihelp-query+imageinfo-paramvalue-prop-commonmetadata',
+                               'extmetadata' => 'apihelp-query+imageinfo-paramvalue-prop-extmetadata',
+                               'archivename' => 'apihelp-query+imageinfo-paramvalue-prop-archivename',
+                               'bitdepth' => 'apihelp-query+imageinfo-paramvalue-prop-bitdepth',
+                               'uploadwarning' => 'apihelp-query+imageinfo-paramvalue-prop-uploadwarning',
+                       ),
+                       array_flip( $filter )
+               );
        }
 
        /**
@@ -749,7 +784,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
                );
        }
 
-       public function getExamplesMessages() {
+       protected function getExamplesMessages() {
                return array(
                        'action=query&titles=File:Albert%20Einstein%20Head.jpg&prop=imageinfo'
                                => 'apihelp-query+imageinfo-example-simple',
@@ -760,6 +795,6 @@ class ApiQueryImageInfo extends ApiQueryBase {
        }
 
        public function getHelpUrls() {
-               return 'https://www.mediawiki.org/wiki/API:Properties#imageinfo_.2F_ii';
+               return 'https://www.mediawiki.org/wiki/API:Imageinfo';
        }
 }