Unified aiprop and iiprop somewhat by adding iiprop=mime and aiprop=metadata. The...
authorRoan Kattouw <catrope@users.mediawiki.org>
Tue, 20 May 2008 09:16:01 +0000 (09:16 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Tue, 20 May 2008 09:16:01 +0000 (09:16 +0000)
RELEASE-NOTES
includes/api/ApiQueryAllimages.php
includes/api/ApiQueryImageInfo.php

index cc1957d..b74eb8c 100644 (file)
@@ -350,6 +350,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 14021) Removed titles= support from list=backlinks (has been obsolete for ages)
 * (bug 13829) Expose parse tree via action=expandtemplates
 * (bug 13606) Allow deletion of images
+* Added iiprop=mime and aiprop=metadata
 
 === Languages updated in 1.13 ===
 
index 44247ea..a658bcd 100644 (file)
@@ -53,7 +53,7 @@ class ApiQueryAllimages extends ApiQueryGeneratorBase {
 
        private function run($resultPageSet = null) {
                $repo = RepoGroup::singleton()->getLocalRepo();
-               if ( !is_a( $repo, 'LocalRepo' ) )
+               if ( !$repo instanceof LocalRepo )
                        $this->dieUsage('Local file repository does not support querying all images', 'unsupportedrepo');
 
                $db = $this->getDB();
@@ -124,6 +124,12 @@ class ApiQueryAllimages extends ApiQueryGeneratorBase {
                                        $item['timestamp'] = wfTimestamp(TS_ISO_8601, $file->getTimestamp());
                                if(isset($prop['url']))
                                        $item['url'] = $file->getFullUrl();
+                               if(isset($prop['metadata']))
+                               {
+                                       $metadata = unserialize($file->getMetadata()); 
+                                       $item['metadata'] = $metadata ? $metadata : null;
+                                       $this->getResult()->setIndexedTagName_recursive($item['metadata'], 'meta');
+                               }
                                $data[] = $item;
                        } else {
                                $data[] = Title::makeTitle( NS_IMAGE, $row->img_name );
@@ -173,7 +179,8 @@ class ApiQueryAllimages extends ApiQueryGeneratorBase {
                                        'size',
                                        'dimensions',
                                        'mime',
-                                       'sha1'
+                                       'sha1',
+                                       'metadata'
                                ),
                                ApiBase :: PARAM_DFLT => 'timestamp|url',
                                ApiBase :: PARAM_ISMULTI => true
index bf59b44..0a13413 100644 (file)
@@ -49,6 +49,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
                $this->fld_url = isset($prop['url']);
                $this->fld_size = isset($prop['size']);
                $this->fld_sha1 = isset($prop['sha1']);
+               $this->fld_mime = isset($prop['mime']);
                $this->fld_metadata = isset($prop['metadata']);
                $this->fld_archivename = isset($prop['archivename']);
 
@@ -140,6 +141,8 @@ class ApiQueryImageInfo extends ApiQueryBase {
                        $vals['comment'] = $f->getDescription();
                if($this->fld_sha1)
                        $vals['sha1'] = wfBaseConvert($f->getSha1(), 36, 16, 40);
+               if($this->fld_mime)
+                       $vals['mime'] = $f->getMimeType();
                if($this->fld_metadata) {
                        $metadata = unserialize($f->getMetadata());
                        $vals['metadata'] = $metadata ? $metadata : null;
@@ -163,6 +166,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
                                        'url',
                                        'size',
                                        'sha1',
+                                       'mime',
                                        'metadata',
                                        'archivename'
                                )