From 168f93e4a898d98a657534c7e47c31586c7a9bb1 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Tue, 20 May 2008 09:16:01 +0000 Subject: [PATCH] Unified aiprop and iiprop somewhat by adding iiprop=mime and aiprop=metadata. The size vs. dimensions discrepancy is weird, but won't be fixed for backwards compatibility. Also iiprop has user, comment and archivename because it handles file *revisions*, whereas allimages doesn't. --- RELEASE-NOTES | 1 + includes/api/ApiQueryAllimages.php | 11 +++++++++-- includes/api/ApiQueryImageInfo.php | 4 ++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index cc1957dd93..b74eb8c1e6 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/api/ApiQueryAllimages.php b/includes/api/ApiQueryAllimages.php index 44247ea38d..a658bcd471 100644 --- a/includes/api/ApiQueryAllimages.php +++ b/includes/api/ApiQueryAllimages.php @@ -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 diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php index bf59b44b43..0a134139de 100644 --- a/includes/api/ApiQueryImageInfo.php +++ b/includes/api/ApiQueryImageInfo.php @@ -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' ) -- 2.20.1