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 if ( !isset( $thumbParams['width'] ) && isset( $thumbParams['height'] ) ) {
260 // We want to limit only by height in this situation, so pass the
261 // image's full width as the limiting width. But some file types
262 // don't have a width of their own, so pick something arbitrary so
263 // thumbnailing the default icon works.
264 if ( $image->getWidth() <= 0 ) {
265 $thumbParams['width'] = max( $this->getConfig()->get( 'ThumbLimits' ) );
267 $thumbParams['width'] = $image->getWidth();
271 if ( !$otherParams ) {
274 $p = $this->getModulePrefix();
276 $h = $image->getHandler();
278 $this->setWarning( 'Could not create thumbnail because ' .
279 $image->getName() . ' does not have an associated image handler' );
284 $paramList = $h->parseParamString( $otherParams );
286 // Just set a warning (instead of dieUsage), as in many cases
287 // we could still render the image using width and height parameters,
288 // and this type of thing could happen between different versions of
290 $this->setWarning( "Could not parse {$p}urlparam for " . $image->getName()
291 . '. Using only width and height' );
296 if ( isset( $paramList['width'] ) ) {
297 if ( intval( $paramList['width'] ) != intval( $thumbParams['width'] ) ) {
298 $this->setWarning( "Ignoring width value set in {$p}urlparam ({$paramList['width']}) "
299 . "in favor of width value derived from {$p}urlwidth/{$p}urlheight "
300 . "({$thumbParams['width']})" );
304 foreach ( $paramList as $name => $value ) {
305 if ( !$h->validateParam( $name, $value ) ) {
306 $this->dieUsage( "Invalid value for {$p}urlparam ($name=$value)", "urlparam" );
310 return $thumbParams +
$paramList;
314 * Get result information for an image revision
317 * @param array $prop Array of properties to get (in the keys)
318 * @param ApiResult $result
319 * @param array $thumbParams Containing 'width' and 'height' items, or null
320 * @param array|bool|string $opts Options for data fetching.
321 * This is an array consisting of the keys:
322 * 'version': The metadata version for the metadata option
323 * 'language': The language for extmetadata property
324 * 'multilang': Return all translations in extmetadata property
325 * 'revdelUser': User to use when checking whether to show revision-deleted fields.
326 * @return array Result array
328 static function getInfo( $file, $prop, $result, $thumbParams = null, $opts = false ) {
333 if ( !$opts ||
is_string( $opts ) ) {
335 'version' => $opts ?
: 'latest',
336 'language' => $wgContLang,
337 'multilang' => false,
338 'extmetadatafilter' => array(),
339 'revdelUser' => null,
342 $version = $opts['version'];
344 // Timestamp is shown even if the file is revdelete'd in interface
346 if ( isset( $prop['timestamp'] ) ) {
347 $vals['timestamp'] = wfTimestamp( TS_ISO_8601
, $file->getTimestamp() );
350 // Handle external callers who don't pass revdelUser
351 if ( isset( $opts['revdelUser'] ) && $opts['revdelUser'] ) {
352 $revdelUser = $opts['revdelUser'];
353 $canShowField = function ( $field ) use ( $file, $revdelUser ) {
354 return $file->userCan( $field, $revdelUser );
357 $canShowField = function ( $field ) use ( $file ) {
358 return !$file->isDeleted( $field );
362 $user = isset( $prop['user'] );
363 $userid = isset( $prop['userid'] );
365 if ( $user ||
$userid ) {
366 if ( $file->isDeleted( File
::DELETED_USER
) ) {
367 $vals['userhidden'] = '';
370 if ( $canShowField( File
::DELETED_USER
) ) {
372 $vals['user'] = $file->getUser();
375 $vals['userid'] = $file->getUser( 'id' );
377 if ( !$file->getUser( 'id' ) ) {
383 // This is shown even if the file is revdelete'd in interface
385 if ( isset( $prop['size'] ) ||
isset( $prop['dimensions'] ) ) {
386 $vals['size'] = intval( $file->getSize() );
387 $vals['width'] = intval( $file->getWidth() );
388 $vals['height'] = intval( $file->getHeight() );
390 $pageCount = $file->pageCount();
391 if ( $pageCount !== false ) {
392 $vals['pagecount'] = $pageCount;
396 $pcomment = isset( $prop['parsedcomment'] );
397 $comment = isset( $prop['comment'] );
399 if ( $pcomment ||
$comment ) {
400 if ( $file->isDeleted( File
::DELETED_COMMENT
) ) {
401 $vals['commenthidden'] = '';
404 if ( $canShowField( File
::DELETED_COMMENT
) ) {
406 $vals['parsedcomment'] = Linker
::formatComment(
407 $file->getDescription( File
::RAW
), $file->getTitle() );
410 $vals['comment'] = $file->getDescription( File
::RAW
);
415 $canonicaltitle = isset( $prop['canonicaltitle'] );
416 $url = isset( $prop['url'] );
417 $sha1 = isset( $prop['sha1'] );
418 $meta = isset( $prop['metadata'] );
419 $extmetadata = isset( $prop['extmetadata'] );
420 $commonmeta = isset( $prop['commonmetadata'] );
421 $mime = isset( $prop['mime'] );
422 $mediatype = isset( $prop['mediatype'] );
423 $archive = isset( $prop['archivename'] );
424 $bitdepth = isset( $prop['bitdepth'] );
425 $uploadwarning = isset( $prop['uploadwarning'] );
427 if ( $uploadwarning ) {
428 $vals['html'] = SpecialUpload
::getExistsWarning( UploadBase
::getExistsWarning( $file ) );
431 if ( $file->isDeleted( File
::DELETED_FILE
) ) {
432 $vals['filehidden'] = '';
436 if ( $anyHidden && $file->isDeleted( File
::DELETED_RESTRICTED
) ) {
437 $vals['suppressed'] = true;
440 if ( !$canShowField( File
::DELETED_FILE
) ) {
441 //Early return, tidier than indenting all following things one level
445 if ( $canonicaltitle ) {
446 $vals['canonicaltitle'] = $file->getTitle()->getPrefixedText();
450 if ( !is_null( $thumbParams ) ) {
451 $mto = $file->transform( $thumbParams );
452 self
::$transformCount++
;
453 if ( $mto && !$mto->isError() ) {
454 $vals['thumburl'] = wfExpandUrl( $mto->getUrl(), PROTO_CURRENT
);
456 // bug 23834 - If the URL's are the same, we haven't resized it, so shouldn't give the wanted
457 // thumbnail sizes for the thumbnail actual size
458 if ( $mto->getUrl() !== $file->getUrl() ) {
459 $vals['thumbwidth'] = intval( $mto->getWidth() );
460 $vals['thumbheight'] = intval( $mto->getHeight() );
462 $vals['thumbwidth'] = intval( $file->getWidth() );
463 $vals['thumbheight'] = intval( $file->getHeight() );
466 if ( isset( $prop['thumbmime'] ) && $file->getHandler() ) {
467 list( , $mime ) = $file->getHandler()->getThumbType(
468 $mto->getExtension(), $file->getMimeType(), $thumbParams );
469 $vals['thumbmime'] = $mime;
471 } elseif ( $mto && $mto->isError() ) {
472 $vals['thumberror'] = $mto->toText();
475 $vals['url'] = wfExpandUrl( $file->getFullURL(), PROTO_CURRENT
);
476 $vals['descriptionurl'] = wfExpandUrl( $file->getDescriptionUrl(), PROTO_CURRENT
);
480 $vals['sha1'] = wfBaseConvert( $file->getSha1(), 36, 16, 40 );
484 wfSuppressWarnings();
485 $metadata = unserialize( $file->getMetadata() );
487 if ( $metadata && $version !== 'latest' ) {
488 $metadata = $file->convertMetadataVersion( $metadata, $version );
490 $vals['metadata'] = $metadata ? self
::processMetaData( $metadata, $result ) : null;
493 $metaArray = $file->getCommonMetaArray();
494 $vals['commonmetadata'] = $metaArray ? self
::processMetaData( $metaArray, $result ) : array();
497 if ( $extmetadata ) {
498 // Note, this should return an array where all the keys
499 // start with a letter, and all the values are strings.
500 // Thus there should be no issue with format=xml.
501 $format = new FormatMetadata
;
502 $format->setSingleLanguage( !$opts['multilang'] );
503 $format->getContext()->setLanguage( $opts['language'] );
504 $extmetaArray = $format->fetchExtendedMetadata( $file );
505 if ( $opts['extmetadatafilter'] ) {
506 $extmetaArray = array_intersect_key(
507 $extmetaArray, array_flip( $opts['extmetadatafilter'] )
510 $vals['extmetadata'] = $extmetaArray;
514 $vals['mime'] = $file->getMimeType();
518 $vals['mediatype'] = $file->getMediaType();
521 if ( $archive && $file->isOld() ) {
522 $vals['archivename'] = $file->getArchiveName();
526 $vals['bitdepth'] = $file->getBitDepth();
533 * Get the count of image transformations performed
535 * If this is >= TRANSFORM_LIMIT, you should probably stop processing images.
539 static function getTransformCount() {
540 return self
::$transformCount;
545 * @param array $metadata
546 * @param ApiResult $result
549 public static function processMetaData( $metadata, $result ) {
551 if ( is_array( $metadata ) ) {
552 foreach ( $metadata as $key => $value ) {
553 $r = array( 'name' => $key );
554 if ( is_array( $value ) ) {
555 $r['value'] = self
::processMetaData( $value, $result );
557 $r['value'] = $value;
562 $result->setIndexedTagName( $retval, 'metadata' );
567 public function getCacheMode( $params ) {
568 if ( $this->userCanSeeRevDel() ) {
577 * @param null|string $start
580 protected function getContinueStr( $img, $start = null ) {
581 if ( $start === null ) {
582 $start = $img->getTimestamp();
585 return $img->getOriginalTitle()->getDBkey() . '|' . $start;
588 public function getAllowedParams() {
593 ApiBase
::PARAM_ISMULTI
=> true,
594 ApiBase
::PARAM_DFLT
=> 'timestamp|user',
595 ApiBase
::PARAM_TYPE
=> self
::getPropertyNames()
598 ApiBase
::PARAM_TYPE
=> 'limit',
599 ApiBase
::PARAM_DFLT
=> 1,
600 ApiBase
::PARAM_MIN
=> 1,
601 ApiBase
::PARAM_MAX
=> ApiBase
::LIMIT_BIG1
,
602 ApiBase
::PARAM_MAX2
=> ApiBase
::LIMIT_BIG2
605 ApiBase
::PARAM_TYPE
=> 'timestamp'
608 ApiBase
::PARAM_TYPE
=> 'timestamp'
611 ApiBase
::PARAM_TYPE
=> 'integer',
612 ApiBase
::PARAM_DFLT
=> -1
614 'urlheight' => array(
615 ApiBase
::PARAM_TYPE
=> 'integer',
616 ApiBase
::PARAM_DFLT
=> -1
618 'metadataversion' => array(
619 ApiBase
::PARAM_TYPE
=> 'string',
620 ApiBase
::PARAM_DFLT
=> '1',
622 'extmetadatalanguage' => array(
623 ApiBase
::PARAM_TYPE
=> 'string',
624 ApiBase
::PARAM_DFLT
=> $wgContLang->getCode(),
626 'extmetadatamultilang' => array(
627 ApiBase
::PARAM_TYPE
=> 'boolean',
628 ApiBase
::PARAM_DFLT
=> false,
630 'extmetadatafilter' => array(
631 ApiBase
::PARAM_TYPE
=> 'string',
632 ApiBase
::PARAM_ISMULTI
=> true,
635 ApiBase
::PARAM_DFLT
=> '',
636 ApiBase
::PARAM_TYPE
=> 'string',
639 'localonly' => false,
644 * Returns all possible parameters to iiprop
646 * @param array $filter List of properties to filter out
650 public static function getPropertyNames( $filter = array() ) {
651 return array_diff( array_keys( self
::getProperties() ), $filter );
655 * Returns array key value pairs of properties and their descriptions
657 * @param string $modulePrefix
660 private static function getProperties( $modulePrefix = '' ) {
662 'timestamp' => ' timestamp - Adds timestamp for the uploaded version',
663 'user' => ' user - Adds the user who uploaded the image version',
664 'userid' => ' userid - Add the user ID that uploaded the image version',
665 'comment' => ' comment - Comment on the version',
666 'parsedcomment' => ' parsedcomment - Parse the comment on the version',
667 'canonicaltitle' => ' canonicaltitle - Adds the canonical title of the image file',
668 'url' => ' url - Gives URL to the image and the description page',
669 'size' => ' size - Adds the size of the image in bytes ' .
670 'and the height, width and page count (if applicable)',
671 'dimensions' => ' dimensions - Alias for size', // B/C with Allimages
672 'sha1' => ' sha1 - Adds SHA-1 hash for the image',
673 'mime' => ' mime - Adds MIME type of the image',
674 'thumbmime' => ' thumbmime - Adds MIME type of the image thumbnail' .
675 ' (requires url and param ' . $modulePrefix . 'urlwidth)',
676 'mediatype' => ' mediatype - Adds the media type of the image',
677 'metadata' => ' metadata - Lists Exif metadata for the version of the image',
678 'commonmetadata' => ' commonmetadata - Lists file format generic metadata ' .
679 'for the version of the image',
680 'extmetadata' => ' extmetadata - Lists formatted metadata combined ' .
681 'from multiple sources. Results are HTML formatted.',
682 'archivename' => ' archivename - Adds the file name of the archive ' .
683 'version for non-latest versions',
684 'bitdepth' => ' bitdepth - Adds the bit depth of the version',
685 'uploadwarning' => ' uploadwarning - Used by the Special:Upload page to ' .
686 'get information about an existing file. Not intended for use outside MediaWiki core',
691 * Returns the descriptions for the properties provided by getPropertyNames()
693 * @param array $filter List of properties to filter out
694 * @param string $modulePrefix
697 public static function getPropertyDescriptions( $filter = array(), $modulePrefix = '' ) {
699 array( 'What image information to get:' ),
700 array_values( array_diff_key( self
::getProperties( $modulePrefix ), array_flip( $filter ) ) )
705 * Return the API documentation for the parameters.
706 * @return array Parameter documentation.
708 public function getParamDescription() {
709 $p = $this->getModulePrefix();
712 'prop' => self
::getPropertyDescriptions( array(), $p ),
714 "If {$p}prop=url is set, a URL to an image scaled to this width will be returned.",
715 'For performance reasons if this option is used, ' .
716 'no more than ' . self
::TRANSFORM_LIMIT
. ' scaled images will be returned.'
718 'urlheight' => "Similar to {$p}urlwidth.",
719 'urlparam' => array( "A handler specific parameter string. For example, pdf's ",
720 "might use 'page15-100px'. {$p}urlwidth must be used and be consistent with {$p}urlparam" ),
721 'limit' => 'How many image revisions to return per image',
722 'start' => 'Timestamp to start listing from',
723 'end' => 'Timestamp to stop listing at',
725 => array( "Version of metadata to use. if 'latest' is specified, use latest version.",
726 "Defaults to '1' for backwards compatibility" ),
727 'extmetadatalanguage' => array(
728 'What language to fetch extmetadata in. This affects both which',
729 'translation to fetch, if multiple are available, as well as how things',
730 'like numbers and various values are formatted.'
732 'extmetadatamultilang'
733 =>'If translations for extmetadata property are available, fetch all of them.',
735 => "If specified and non-empty, only these keys will be returned for {$p}prop=extmetadata",
736 'continue' => 'If the query response includes a continue value, ' .
737 'use it here to get another page of results',
738 'localonly' => 'Look only for files in the local repository',
742 public static function getResultPropertiesFiltered( $filter = array() ) {
744 'timestamp' => array(
745 'timestamp' => 'timestamp'
748 'userhidden' => 'boolean',
753 'userhidden' => 'boolean',
754 'userid' => 'integer',
759 'width' => 'integer',
760 'height' => 'integer',
761 'pagecount' => array(
762 ApiBase
::PROP_TYPE
=> 'integer',
763 ApiBase
::PROP_NULLABLE
=> true
766 'dimensions' => array(
768 'width' => 'integer',
769 'height' => 'integer',
770 'pagecount' => array(
771 ApiBase
::PROP_TYPE
=> 'integer',
772 ApiBase
::PROP_NULLABLE
=> true
776 'commenthidden' => 'boolean',
778 ApiBase
::PROP_TYPE
=> 'string',
779 ApiBase
::PROP_NULLABLE
=> true
782 'parsedcomment' => array(
783 'commenthidden' => 'boolean',
784 'parsedcomment' => array(
785 ApiBase
::PROP_TYPE
=> 'string',
786 ApiBase
::PROP_NULLABLE
=> true
789 'canonicaltitle' => array(
790 'canonicaltitle' => array(
791 ApiBase
::PROP_TYPE
=> 'string',
792 ApiBase
::PROP_NULLABLE
=> true
796 'filehidden' => 'boolean',
798 ApiBase
::PROP_TYPE
=> 'string',
799 ApiBase
::PROP_NULLABLE
=> true
801 'thumbwidth' => array(
802 ApiBase
::PROP_TYPE
=> 'integer',
803 ApiBase
::PROP_NULLABLE
=> true
805 'thumbheight' => array(
806 ApiBase
::PROP_TYPE
=> 'integer',
807 ApiBase
::PROP_NULLABLE
=> true
809 'thumberror' => array(
810 ApiBase
::PROP_TYPE
=> 'string',
811 ApiBase
::PROP_NULLABLE
=> true
814 ApiBase
::PROP_TYPE
=> 'string',
815 ApiBase
::PROP_NULLABLE
=> true
817 'descriptionurl' => array(
818 ApiBase
::PROP_TYPE
=> 'string',
819 ApiBase
::PROP_NULLABLE
=> true
823 'filehidden' => 'boolean',
825 ApiBase
::PROP_TYPE
=> 'string',
826 ApiBase
::PROP_NULLABLE
=> true
830 'filehidden' => 'boolean',
832 ApiBase
::PROP_TYPE
=> 'string',
833 ApiBase
::PROP_NULLABLE
=> true
836 'thumbmime' => array(
837 'filehidden' => 'boolean',
838 'thumbmime' => array(
839 ApiBase
::PROP_TYPE
=> 'string',
840 ApiBase
::PROP_NULLABLE
=> true
843 'mediatype' => array(
844 'filehidden' => 'boolean',
845 'mediatype' => array(
846 ApiBase
::PROP_TYPE
=> 'string',
847 ApiBase
::PROP_NULLABLE
=> true
850 'archivename' => array(
851 'filehidden' => 'boolean',
852 'archivename' => array(
853 ApiBase
::PROP_TYPE
=> 'string',
854 ApiBase
::PROP_NULLABLE
=> true
858 'filehidden' => 'boolean',
860 ApiBase
::PROP_TYPE
=> 'integer',
861 ApiBase
::PROP_NULLABLE
=> true
866 return array_diff_key( $props, array_flip( $filter ) );
869 public function getResultProperties() {
870 return self
::getResultPropertiesFiltered();
873 public function getDescription() {
874 return 'Returns image information and upload history.';
877 public function getPossibleErrors() {
878 $p = $this->getModulePrefix();
880 return array_merge( parent
::getPossibleErrors(), array(
881 array( 'code' => "{$p}urlwidth", 'info' => "{$p}urlheight cannot be used without {$p}urlwidth" ),
882 array( 'code' => 'urlparam', 'info' => "Invalid value for {$p}urlparam" ),
883 array( 'code' => 'urlparam_no_width', 'info' => "{$p}urlparam requires {$p}urlwidth" ),
887 public function getExamples() {
889 'api.php?action=query&titles=File:Albert%20Einstein%20Head.jpg&prop=imageinfo',
890 'api.php?action=query&titles=File:Test.jpg&prop=imageinfo&iilimit=50&' .
891 'iiend=20071231235959&iiprop=timestamp|user|url',
895 public function getHelpUrls() {
896 return 'https://www.mediawiki.org/wiki/API:Properties#imageinfo_.2F_ii';