5 * Created on July 6, 2007
7 * Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 * http://www.gnu.org/copyleft/gpl.html
28 * A query action to get image information and upload history.
32 class ApiQueryImageInfo
extends ApiQueryBase
{
33 const TRANSFORM_LIMIT
= 50;
34 private static $transformCount = 0;
36 public function __construct( ApiQuery
$query, $moduleName, $prefix = 'ii' ) {
37 // We allow a subclass to override the prefix, to create a related API
38 // module. Some other parts of MediaWiki construct this with a null
39 // $prefix, which used to be ignored when this only took two arguments
40 if ( is_null( $prefix ) ) {
43 parent
::__construct( $query, $moduleName, $prefix );
46 public function execute() {
47 $params = $this->extractRequestParams();
49 $prop = array_flip( $params['prop'] );
51 $scale = $this->getScale( $params );
54 'version' => $params['metadataversion'],
55 'language' => $params['extmetadatalanguage'],
56 'multilang' => $params['extmetadatamultilang'],
57 'extmetadatafilter' => $params['extmetadatafilter'],
58 'revdelUser' => $this->getUser(),
61 $pageIds = $this->getPageSet()->getAllTitlesByNamespace();
62 if ( !empty( $pageIds[NS_FILE
] ) ) {
63 $titles = array_keys( $pageIds[NS_FILE
] );
64 asort( $titles ); // Ensure the order is always the same
67 if ( !is_null( $params['continue'] ) ) {
68 $cont = explode( '|', $params['continue'] );
69 $this->dieContinueUsageIf( count( $cont ) != 2 );
70 $fromTitle = strval( $cont[0] );
71 $fromTimestamp = $cont[1];
72 // Filter out any titles before $fromTitle
73 foreach ( $titles as $key => $title ) {
74 if ( $title < $fromTitle ) {
75 unset( $titles[$key] );
82 $user = $this->getUser();
83 $findTitles = array_map( function ( $title ) use ( $user ) {
90 if ( $params['localonly'] ) {
91 $images = RepoGroup
::singleton()->getLocalRepo()->findFiles( $findTitles );
93 $images = RepoGroup
::singleton()->findFiles( $findTitles );
96 $result = $this->getResult();
97 foreach ( $titles as $title ) {
98 $pageId = $pageIds[NS_FILE
][$title];
99 $start = $title === $fromTitle ?
$fromTimestamp : $params['start'];
101 if ( !isset( $images[$title] ) ) {
102 if ( isset( $prop['uploadwarning'] ) ) {
103 // Uploadwarning needs info about non-existing files
104 $images[$title] = wfLocalFile( $title );
107 array( 'query', 'pages', intval( $pageId ) ),
108 'imagerepository', ''
110 // The above can't fail because it doesn't increase the result size
115 /** @var $img File */
116 $img = $images[$title];
118 if ( self
::getTransformCount() >= self
::TRANSFORM_LIMIT
) {
119 if ( count( $pageIds[NS_FILE
] ) == 1 ) {
120 // See the 'the user is screwed' comment below
121 $this->setContinueEnumParameter( 'start',
122 $start !== null ?
$start : wfTimestamp( TS_ISO_8601
, $img->getTimestamp() )
125 $this->setContinueEnumParameter( 'continue',
126 $this->getContinueStr( $img, $start ) );
131 $fit = $result->addValue(
132 array( 'query', 'pages', intval( $pageId ) ),
133 'imagerepository', $img->getRepoName()
136 if ( count( $pageIds[NS_FILE
] ) == 1 ) {
137 // The user is screwed. imageinfo can't be solely
138 // responsible for exceeding the limit in this case,
139 // so set a query-continue that just returns the same
140 // thing again. When the violating queries have been
141 // out-continued, the result will get through
142 $this->setContinueEnumParameter( 'start',
143 $start !== null ?
$start : wfTimestamp( TS_ISO_8601
, $img->getTimestamp() )
146 $this->setContinueEnumParameter( 'continue',
147 $this->getContinueStr( $img, $start ) );
152 // Check if we can make the requested thumbnail, and get transform parameters.
153 $finalThumbParams = $this->mergeThumbParams( $img, $scale, $params['urlparam'] );
155 // Get information about the current version first
156 // Check that the current version is within the start-end boundaries
159 ( is_null( $start ) ||
$img->getTimestamp() <= $start ) &&
160 ( is_null( $params['end'] ) ||
$img->getTimestamp() >= $params['end'] )
164 $fit = $this->addPageSubItem( $pageId,
165 self
::getInfo( $img, $prop, $result,
166 $finalThumbParams, $opts
170 if ( count( $pageIds[NS_FILE
] ) == 1 ) {
171 // See the 'the user is screwed' comment above
172 $this->setContinueEnumParameter( 'start',
173 wfTimestamp( TS_ISO_8601
, $img->getTimestamp() ) );
175 $this->setContinueEnumParameter( 'continue',
176 $this->getContinueStr( $img ) );
182 // Now get the old revisions
183 // Get one more to facilitate query-continue functionality
184 $count = ( $gotOne ?
1 : 0 );
185 $oldies = $img->getHistory( $params['limit'] - $count +
1, $start, $params['end'] );
186 /** @var $oldie File */
187 foreach ( $oldies as $oldie ) {
188 if ( ++
$count > $params['limit'] ) {
189 // We've reached the extra one which shows that there are
190 // additional pages to be had. Stop here...
191 // Only set a query-continue if there was only one title
192 if ( count( $pageIds[NS_FILE
] ) == 1 ) {
193 $this->setContinueEnumParameter( 'start',
194 wfTimestamp( TS_ISO_8601
, $oldie->getTimestamp() ) );
198 $fit = self
::getTransformCount() < self
::TRANSFORM_LIMIT
&&
199 $this->addPageSubItem( $pageId,
200 self
::getInfo( $oldie, $prop, $result,
201 $finalThumbParams, $opts
205 if ( count( $pageIds[NS_FILE
] ) == 1 ) {
206 $this->setContinueEnumParameter( 'start',
207 wfTimestamp( TS_ISO_8601
, $oldie->getTimestamp() ) );
209 $this->setContinueEnumParameter( 'continue',
210 $this->getContinueStr( $oldie ) );
223 * From parameters, construct a 'scale' array
224 * @param array $params Parameters passed to api.
225 * @return array|null Key-val array of 'width' and 'height', or null
227 public function getScale( $params ) {
228 $p = $this->getModulePrefix();
230 if ( $params['urlwidth'] != -1 ) {
232 $scale['width'] = $params['urlwidth'];
233 $scale['height'] = $params['urlheight'];
234 } elseif ( $params['urlheight'] != -1 ) {
235 // Height is specified but width isn't
236 // Don't set $scale['width']; this signals mergeThumbParams() to fill it with the image's width
238 $scale['height'] = $params['urlheight'];
241 if ( $params['urlparam'] ) {
242 $this->dieUsage( "{$p}urlparam requires {$p}urlwidth", "urlparam_no_width" );
249 /** Validate and merge scale parameters with handler thumb parameters, give error if invalid.
251 * We do this later than getScale, since we need the image
252 * to know which handler, since handlers can make their own parameters.
253 * @param File $image Image that params are for.
254 * @param array $thumbParams Thumbnail parameters from getScale
255 * @param string $otherParams String of otherParams (iiurlparam).
256 * @return array Array of parameters for transform.
258 protected function mergeThumbParams( $image, $thumbParams, $otherParams ) {
259 global $wgThumbLimits;
261 if ( !isset( $thumbParams['width'] ) && isset( $thumbParams['height'] ) ) {
262 // We want to limit only by height in this situation, so pass the
263 // image's full width as the limiting width. But some file types
264 // don't have a width of their own, so pick something arbitrary so
265 // thumbnailing the default icon works.
266 if ( $image->getWidth() <= 0 ) {
267 $thumbParams['width'] = max( $wgThumbLimits );
269 $thumbParams['width'] = $image->getWidth();
273 if ( !$otherParams ) {
276 $p = $this->getModulePrefix();
278 $h = $image->getHandler();
280 $this->setWarning( 'Could not create thumbnail because ' .
281 $image->getName() . ' does not have an associated image handler' );
286 $paramList = $h->parseParamString( $otherParams );
288 // Just set a warning (instead of dieUsage), as in many cases
289 // we could still render the image using width and height parameters,
290 // and this type of thing could happen between different versions of
292 $this->setWarning( "Could not parse {$p}urlparam for " . $image->getName()
293 . '. Using only width and height' );
298 if ( isset( $paramList['width'] ) ) {
299 if ( intval( $paramList['width'] ) != intval( $thumbParams['width'] ) ) {
300 $this->setWarning( "Ignoring width value set in {$p}urlparam ({$paramList['width']}) "
301 . "in favor of width value derived from {$p}urlwidth/{$p}urlheight "
302 . "({$thumbParams['width']})" );
306 foreach ( $paramList as $name => $value ) {
307 if ( !$h->validateParam( $name, $value ) ) {
308 $this->dieUsage( "Invalid value for {$p}urlparam ($name=$value)", "urlparam" );
312 return $thumbParams +
$paramList;
316 * Get result information for an image revision
319 * @param array $prop Array of properties to get (in the keys)
320 * @param ApiResult $result
321 * @param array $thumbParams Containing 'width' and 'height' items, or null
322 * @param array|bool|string $opts Options for data fetching.
323 * This is an array consisting of the keys:
324 * 'version': The metadata version for the metadata option
325 * 'language': The language for extmetadata property
326 * 'multilang': Return all translations in extmetadata property
327 * 'revdelUser': User to use when checking whether to show revision-deleted fields.
328 * @return array Result array
330 static function getInfo( $file, $prop, $result, $thumbParams = null, $opts = false ) {
335 if ( !$opts ||
is_string( $opts ) ) {
337 'version' => $opts ?
: 'latest',
338 'language' => $wgContLang,
339 'multilang' => false,
340 'extmetadatafilter' => array(),
341 'revdelUser' => null,
344 $version = $opts['version'];
346 // Timestamp is shown even if the file is revdelete'd in interface
348 if ( isset( $prop['timestamp'] ) ) {
349 $vals['timestamp'] = wfTimestamp( TS_ISO_8601
, $file->getTimestamp() );
352 // Handle external callers who don't pass revdelUser
353 if ( isset( $opts['revdelUser'] ) && $opts['revdelUser'] ) {
354 $revdelUser = $opts['revdelUser'];
355 $canShowField = function ( $field ) use ( $file, $revdelUser ) {
356 return $file->userCan( $field, $revdelUser );
359 $canShowField = function ( $field ) use ( $file ) {
360 return !$file->isDeleted( $field );
364 $user = isset( $prop['user'] );
365 $userid = isset( $prop['userid'] );
367 if ( $user ||
$userid ) {
368 if ( $file->isDeleted( File
::DELETED_USER
) ) {
369 $vals['userhidden'] = '';
372 if ( $canShowField( File
::DELETED_USER
) ) {
374 $vals['user'] = $file->getUser();
377 $vals['userid'] = $file->getUser( 'id' );
379 if ( !$file->getUser( 'id' ) ) {
385 // This is shown even if the file is revdelete'd in interface
387 if ( isset( $prop['size'] ) ||
isset( $prop['dimensions'] ) ) {
388 $vals['size'] = intval( $file->getSize() );
389 $vals['width'] = intval( $file->getWidth() );
390 $vals['height'] = intval( $file->getHeight() );
392 $pageCount = $file->pageCount();
393 if ( $pageCount !== false ) {
394 $vals['pagecount'] = $pageCount;
398 $pcomment = isset( $prop['parsedcomment'] );
399 $comment = isset( $prop['comment'] );
401 if ( $pcomment ||
$comment ) {
402 if ( $file->isDeleted( File
::DELETED_COMMENT
) ) {
403 $vals['commenthidden'] = '';
406 if ( $canShowField( File
::DELETED_COMMENT
) ) {
408 $vals['parsedcomment'] = Linker
::formatComment(
409 $file->getDescription( File
::RAW
), $file->getTitle() );
412 $vals['comment'] = $file->getDescription( File
::RAW
);
417 $canonicaltitle = isset( $prop['canonicaltitle'] );
418 $url = isset( $prop['url'] );
419 $sha1 = isset( $prop['sha1'] );
420 $meta = isset( $prop['metadata'] );
421 $extmetadata = isset( $prop['extmetadata'] );
422 $commonmeta = isset( $prop['commonmetadata'] );
423 $mime = isset( $prop['mime'] );
424 $mediatype = isset( $prop['mediatype'] );
425 $archive = isset( $prop['archivename'] );
426 $bitdepth = isset( $prop['bitdepth'] );
427 $uploadwarning = isset( $prop['uploadwarning'] );
429 if ( $uploadwarning ) {
430 $vals['html'] = SpecialUpload
::getExistsWarning( UploadBase
::getExistsWarning( $file ) );
433 if ( $file->isDeleted( File
::DELETED_FILE
) ) {
434 $vals['filehidden'] = '';
438 if ( $anyHidden && $file->isDeleted( File
::DELETED_RESTRICTED
) ) {
439 $vals['suppressed'] = true;
442 if ( !$canShowField( File
::DELETED_FILE
) ) {
443 //Early return, tidier than indenting all following things one level
447 if ( $canonicaltitle ) {
448 $vals['canonicaltitle'] = $file->getTitle()->getPrefixedText();
452 if ( !is_null( $thumbParams ) ) {
453 $mto = $file->transform( $thumbParams );
454 self
::$transformCount++
;
455 if ( $mto && !$mto->isError() ) {
456 $vals['thumburl'] = wfExpandUrl( $mto->getUrl(), PROTO_CURRENT
);
458 // bug 23834 - If the URL's are the same, we haven't resized it, so shouldn't give the wanted
459 // thumbnail sizes for the thumbnail actual size
460 if ( $mto->getUrl() !== $file->getUrl() ) {
461 $vals['thumbwidth'] = intval( $mto->getWidth() );
462 $vals['thumbheight'] = intval( $mto->getHeight() );
464 $vals['thumbwidth'] = intval( $file->getWidth() );
465 $vals['thumbheight'] = intval( $file->getHeight() );
468 if ( isset( $prop['thumbmime'] ) && $file->getHandler() ) {
469 list( , $mime ) = $file->getHandler()->getThumbType(
470 $mto->getExtension(), $file->getMimeType(), $thumbParams );
471 $vals['thumbmime'] = $mime;
473 } elseif ( $mto && $mto->isError() ) {
474 $vals['thumberror'] = $mto->toText();
477 $vals['url'] = wfExpandUrl( $file->getFullURL(), PROTO_CURRENT
);
478 $vals['descriptionurl'] = wfExpandUrl( $file->getDescriptionUrl(), PROTO_CURRENT
);
482 $vals['sha1'] = wfBaseConvert( $file->getSha1(), 36, 16, 40 );
486 wfSuppressWarnings();
487 $metadata = unserialize( $file->getMetadata() );
489 if ( $metadata && $version !== 'latest' ) {
490 $metadata = $file->convertMetadataVersion( $metadata, $version );
492 $vals['metadata'] = $metadata ? self
::processMetaData( $metadata, $result ) : null;
495 $metaArray = $file->getCommonMetaArray();
496 $vals['commonmetadata'] = $metaArray ? self
::processMetaData( $metaArray, $result ) : array();
499 if ( $extmetadata ) {
500 // Note, this should return an array where all the keys
501 // start with a letter, and all the values are strings.
502 // Thus there should be no issue with format=xml.
503 $format = new FormatMetadata
;
504 $format->setSingleLanguage( !$opts['multilang'] );
505 $format->getContext()->setLanguage( $opts['language'] );
506 $extmetaArray = $format->fetchExtendedMetadata( $file );
507 if ( $opts['extmetadatafilter'] ) {
508 $extmetaArray = array_intersect_key(
509 $extmetaArray, array_flip( $opts['extmetadatafilter'] )
512 $vals['extmetadata'] = $extmetaArray;
516 $vals['mime'] = $file->getMimeType();
520 $vals['mediatype'] = $file->getMediaType();
523 if ( $archive && $file->isOld() ) {
524 $vals['archivename'] = $file->getArchiveName();
528 $vals['bitdepth'] = $file->getBitDepth();
535 * Get the count of image transformations performed
537 * If this is >= TRANSFORM_LIMIT, you should probably stop processing images.
541 static function getTransformCount() {
542 return self
::$transformCount;
547 * @param array $metadata
548 * @param ApiResult $result
551 public static function processMetaData( $metadata, $result ) {
553 if ( is_array( $metadata ) ) {
554 foreach ( $metadata as $key => $value ) {
555 $r = array( 'name' => $key );
556 if ( is_array( $value ) ) {
557 $r['value'] = self
::processMetaData( $value, $result );
559 $r['value'] = $value;
564 $result->setIndexedTagName( $retval, 'metadata' );
569 public function getCacheMode( $params ) {
570 if ( $this->userCanSeeRevDel() ) {
579 * @param null|string $start
582 protected function getContinueStr( $img, $start = null ) {
583 if ( $start === null ) {
584 $start = $img->getTimestamp();
587 return $img->getOriginalTitle()->getDBkey() . '|' . $start;
590 public function getAllowedParams() {
595 ApiBase
::PARAM_ISMULTI
=> true,
596 ApiBase
::PARAM_DFLT
=> 'timestamp|user',
597 ApiBase
::PARAM_TYPE
=> self
::getPropertyNames()
600 ApiBase
::PARAM_TYPE
=> 'limit',
601 ApiBase
::PARAM_DFLT
=> 1,
602 ApiBase
::PARAM_MIN
=> 1,
603 ApiBase
::PARAM_MAX
=> ApiBase
::LIMIT_BIG1
,
604 ApiBase
::PARAM_MAX2
=> ApiBase
::LIMIT_BIG2
607 ApiBase
::PARAM_TYPE
=> 'timestamp'
610 ApiBase
::PARAM_TYPE
=> 'timestamp'
613 ApiBase
::PARAM_TYPE
=> 'integer',
614 ApiBase
::PARAM_DFLT
=> -1
616 'urlheight' => array(
617 ApiBase
::PARAM_TYPE
=> 'integer',
618 ApiBase
::PARAM_DFLT
=> -1
620 'metadataversion' => array(
621 ApiBase
::PARAM_TYPE
=> 'string',
622 ApiBase
::PARAM_DFLT
=> '1',
624 'extmetadatalanguage' => array(
625 ApiBase
::PARAM_TYPE
=> 'string',
626 ApiBase
::PARAM_DFLT
=> $wgContLang->getCode(),
628 'extmetadatamultilang' => array(
629 ApiBase
::PARAM_TYPE
=> 'boolean',
630 ApiBase
::PARAM_DFLT
=> false,
632 'extmetadatafilter' => array(
633 ApiBase
::PARAM_TYPE
=> 'string',
634 ApiBase
::PARAM_ISMULTI
=> true,
637 ApiBase
::PARAM_DFLT
=> '',
638 ApiBase
::PARAM_TYPE
=> 'string',
641 'localonly' => false,
646 * Returns all possible parameters to iiprop
648 * @param array $filter List of properties to filter out
652 public static function getPropertyNames( $filter = array() ) {
653 return array_diff( array_keys( self
::getProperties() ), $filter );
657 * Returns array key value pairs of properties and their descriptions
659 * @param string $modulePrefix
662 private static function getProperties( $modulePrefix = '' ) {
664 'timestamp' => ' timestamp - Adds timestamp for the uploaded version',
665 'user' => ' user - Adds the user who uploaded the image version',
666 'userid' => ' userid - Add the user ID that uploaded the image version',
667 'comment' => ' comment - Comment on the version',
668 'parsedcomment' => ' parsedcomment - Parse the comment on the version',
669 'canonicaltitle' => ' canonicaltitle - Adds the canonical title of the image file',
670 'url' => ' url - Gives URL to the image and the description page',
671 'size' => ' size - Adds the size of the image in bytes ' .
672 'and the height, width and page count (if applicable)',
673 'dimensions' => ' dimensions - Alias for size', // B/C with Allimages
674 'sha1' => ' sha1 - Adds SHA-1 hash for the image',
675 'mime' => ' mime - Adds MIME type of the image',
676 'thumbmime' => ' thumbmime - Adds MIME type of the image thumbnail' .
677 ' (requires url and param ' . $modulePrefix . 'urlwidth)',
678 'mediatype' => ' mediatype - Adds the media type of the image',
679 'metadata' => ' metadata - Lists Exif metadata for the version of the image',
680 'commonmetadata' => ' commonmetadata - Lists file format generic metadata ' .
681 'for the version of the image',
682 'extmetadata' => ' extmetadata - Lists formatted metadata combined ' .
683 'from multiple sources. Results are HTML formatted.',
684 'archivename' => ' archivename - Adds the file name of the archive ' .
685 'version for non-latest versions',
686 'bitdepth' => ' bitdepth - Adds the bit depth of the version',
687 'uploadwarning' => ' uploadwarning - Used by the Special:Upload page to ' .
688 'get information about an existing file. Not intended for use outside MediaWiki core',
693 * Returns the descriptions for the properties provided by getPropertyNames()
695 * @param array $filter List of properties to filter out
696 * @param string $modulePrefix
699 public static function getPropertyDescriptions( $filter = array(), $modulePrefix = '' ) {
701 array( 'What image information to get:' ),
702 array_values( array_diff_key( self
::getProperties( $modulePrefix ), array_flip( $filter ) ) )
707 * Return the API documentation for the parameters.
708 * @return array Parameter documentation.
710 public function getParamDescription() {
711 $p = $this->getModulePrefix();
714 'prop' => self
::getPropertyDescriptions( array(), $p ),
716 "If {$p}prop=url is set, a URL to an image scaled to this width will be returned.",
717 'For performance reasons if this option is used, ' .
718 'no more than ' . self
::TRANSFORM_LIMIT
. ' scaled images will be returned.'
720 'urlheight' => "Similar to {$p}urlwidth.",
721 'urlparam' => array( "A handler specific parameter string. For example, pdf's ",
722 "might use 'page15-100px'. {$p}urlwidth must be used and be consistent with {$p}urlparam" ),
723 'limit' => 'How many image revisions to return per image',
724 'start' => 'Timestamp to start listing from',
725 'end' => 'Timestamp to stop listing at',
727 => array( "Version of metadata to use. if 'latest' is specified, use latest version.",
728 "Defaults to '1' for backwards compatibility" ),
729 'extmetadatalanguage' => array(
730 'What language to fetch extmetadata in. This affects both which',
731 'translation to fetch, if multiple are available, as well as how things',
732 'like numbers and various values are formatted.'
734 'extmetadatamultilang'
735 =>'If translations for extmetadata property are available, fetch all of them.',
737 => "If specified and non-empty, only these keys will be returned for {$p}prop=extmetadata",
738 'continue' => 'If the query response includes a continue value, ' .
739 'use it here to get another page of results',
740 'localonly' => 'Look only for files in the local repository',
744 public static function getResultPropertiesFiltered( $filter = array() ) {
746 'timestamp' => array(
747 'timestamp' => 'timestamp'
750 'userhidden' => 'boolean',
755 'userhidden' => 'boolean',
756 'userid' => 'integer',
761 'width' => 'integer',
762 'height' => 'integer',
763 'pagecount' => array(
764 ApiBase
::PROP_TYPE
=> 'integer',
765 ApiBase
::PROP_NULLABLE
=> true
768 'dimensions' => array(
770 'width' => 'integer',
771 'height' => 'integer',
772 'pagecount' => array(
773 ApiBase
::PROP_TYPE
=> 'integer',
774 ApiBase
::PROP_NULLABLE
=> true
778 'commenthidden' => 'boolean',
780 ApiBase
::PROP_TYPE
=> 'string',
781 ApiBase
::PROP_NULLABLE
=> true
784 'parsedcomment' => array(
785 'commenthidden' => 'boolean',
786 'parsedcomment' => array(
787 ApiBase
::PROP_TYPE
=> 'string',
788 ApiBase
::PROP_NULLABLE
=> true
791 'canonicaltitle' => array(
792 'canonicaltitle' => array(
793 ApiBase
::PROP_TYPE
=> 'string',
794 ApiBase
::PROP_NULLABLE
=> true
798 'filehidden' => 'boolean',
800 ApiBase
::PROP_TYPE
=> 'string',
801 ApiBase
::PROP_NULLABLE
=> true
803 'thumbwidth' => array(
804 ApiBase
::PROP_TYPE
=> 'integer',
805 ApiBase
::PROP_NULLABLE
=> true
807 'thumbheight' => array(
808 ApiBase
::PROP_TYPE
=> 'integer',
809 ApiBase
::PROP_NULLABLE
=> true
811 'thumberror' => array(
812 ApiBase
::PROP_TYPE
=> 'string',
813 ApiBase
::PROP_NULLABLE
=> true
816 ApiBase
::PROP_TYPE
=> 'string',
817 ApiBase
::PROP_NULLABLE
=> true
819 'descriptionurl' => array(
820 ApiBase
::PROP_TYPE
=> 'string',
821 ApiBase
::PROP_NULLABLE
=> true
825 'filehidden' => 'boolean',
827 ApiBase
::PROP_TYPE
=> 'string',
828 ApiBase
::PROP_NULLABLE
=> true
832 'filehidden' => 'boolean',
834 ApiBase
::PROP_TYPE
=> 'string',
835 ApiBase
::PROP_NULLABLE
=> true
838 'thumbmime' => array(
839 'filehidden' => 'boolean',
840 'thumbmime' => array(
841 ApiBase
::PROP_TYPE
=> 'string',
842 ApiBase
::PROP_NULLABLE
=> true
845 'mediatype' => array(
846 'filehidden' => 'boolean',
847 'mediatype' => array(
848 ApiBase
::PROP_TYPE
=> 'string',
849 ApiBase
::PROP_NULLABLE
=> true
852 'archivename' => array(
853 'filehidden' => 'boolean',
854 'archivename' => array(
855 ApiBase
::PROP_TYPE
=> 'string',
856 ApiBase
::PROP_NULLABLE
=> true
860 'filehidden' => 'boolean',
862 ApiBase
::PROP_TYPE
=> 'integer',
863 ApiBase
::PROP_NULLABLE
=> true
868 return array_diff_key( $props, array_flip( $filter ) );
871 public function getResultProperties() {
872 return self
::getResultPropertiesFiltered();
875 public function getDescription() {
876 return 'Returns image information and upload history.';
879 public function getPossibleErrors() {
880 $p = $this->getModulePrefix();
882 return array_merge( parent
::getPossibleErrors(), array(
883 array( 'code' => "{$p}urlwidth", 'info' => "{$p}urlheight cannot be used without {$p}urlwidth" ),
884 array( 'code' => 'urlparam', 'info' => "Invalid value for {$p}urlparam" ),
885 array( 'code' => 'urlparam_no_width', 'info' => "{$p}urlparam requires {$p}urlwidth" ),
889 public function getExamples() {
891 'api.php?action=query&titles=File:Albert%20Einstein%20Head.jpg&prop=imageinfo',
892 'api.php?action=query&titles=File:Test.jpg&prop=imageinfo&iilimit=50&' .
893 'iiend=20071231235959&iiprop=timestamp|user|url',
897 public function getHelpUrls() {
898 return 'https://www.mediawiki.org/wiki/API:Properties#imageinfo_.2F_ii';