Merge "(bug 42915) make MovePage aware of whether redirects are supported."
[lhc/web/wiklou.git] / includes / api / ApiQueryImageInfo.php
1 <?php
2 /**
3 *
4 *
5 * Created on July 6, 2007
6 *
7 * Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
8 *
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.
13 *
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.
18 *
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
23 *
24 * @file
25 */
26
27 /**
28 * A query action to get image information and upload history.
29 *
30 * @ingroup API
31 */
32 class ApiQueryImageInfo extends ApiQueryBase {
33
34 public function __construct( $query, $moduleName, $prefix = 'ii' ) {
35 // We allow a subclass to override the prefix, to create a related API module.
36 // Some other parts of MediaWiki construct this with a null $prefix, which used to be ignored when this only took two arguments
37 if ( is_null( $prefix ) ) {
38 $prefix = 'ii';
39 }
40 parent::__construct( $query, $moduleName, $prefix );
41 }
42
43 public function execute() {
44 $params = $this->extractRequestParams();
45
46 $prop = array_flip( $params['prop'] );
47
48 $scale = $this->getScale( $params );
49
50 $pageIds = $this->getPageSet()->getAllTitlesByNamespace();
51 if ( !empty( $pageIds[NS_FILE] ) ) {
52 $titles = array_keys( $pageIds[NS_FILE] );
53 asort( $titles ); // Ensure the order is always the same
54
55 $skip = false;
56 if ( !is_null( $params['continue'] ) ) {
57 $skip = true;
58 $cont = explode( '|', $params['continue'] );
59 if ( count( $cont ) != 2 ) {
60 $this->dieUsage( 'Invalid continue param. You should pass the original ' .
61 'value returned by the previous query', '_badcontinue' );
62 }
63 $fromTitle = strval( $cont[0] );
64 $fromTimestamp = $cont[1];
65 // Filter out any titles before $fromTitle
66 foreach ( $titles as $key => $title ) {
67 if ( $title < $fromTitle ) {
68 unset( $titles[$key] );
69 } else {
70 break;
71 }
72 }
73 }
74
75 $result = $this->getResult();
76 //search only inside the local repo
77 if( $params['localonly'] ) {
78 $images = RepoGroup::singleton()->getLocalRepo()->findFiles( $titles );
79 } else {
80 $images = RepoGroup::singleton()->findFiles( $titles );
81 }
82 $resolveRedirects = $this->getPageSet()->isResolvingRedirects();
83 foreach ( $images as $img ) {
84 // Skip redirects
85 if ( $img->getOriginalTitle()->isRedirect() && !$resolveRedirects ) {
86 continue;
87 }
88
89 $start = $skip ? $fromTimestamp : $params['start'];
90 $pageId = $pageIds[NS_FILE][ $img->getTitle()->getDBkey() ];
91
92 $fit = $result->addValue(
93 array( 'query', 'pages', intval( $pageId ) ),
94 'imagerepository', $img->getRepoName()
95 );
96 if ( !$fit ) {
97 if ( count( $pageIds[NS_FILE] ) == 1 ) {
98 // The user is screwed. imageinfo can't be solely
99 // responsible for exceeding the limit in this case,
100 // so set a query-continue that just returns the same
101 // thing again. When the violating queries have been
102 // out-continued, the result will get through
103 $this->setContinueEnumParameter( 'start',
104 wfTimestamp( TS_ISO_8601, $img->getTimestamp() ) );
105 } else {
106 $this->setContinueEnumParameter( 'continue',
107 $this->getContinueStr( $img ) );
108 }
109 break;
110 }
111
112 // Check if we can make the requested thumbnail, and get transform parameters.
113 $finalThumbParams = $this->mergeThumbParams( $img, $scale, $params['urlparam'] );
114
115 // Get information about the current version first
116 // Check that the current version is within the start-end boundaries
117 $gotOne = false;
118 if (
119 ( is_null( $start ) || $img->getTimestamp() <= $start ) &&
120 ( is_null( $params['end'] ) || $img->getTimestamp() >= $params['end'] )
121 ) {
122 $gotOne = true;
123
124 $fit = $this->addPageSubItem( $pageId,
125 self::getInfo( $img, $prop, $result,
126 $finalThumbParams, $params['metadataversion'] ) );
127 if ( !$fit ) {
128 if ( count( $pageIds[NS_FILE] ) == 1 ) {
129 // See the 'the user is screwed' comment above
130 $this->setContinueEnumParameter( 'start',
131 wfTimestamp( TS_ISO_8601, $img->getTimestamp() ) );
132 } else {
133 $this->setContinueEnumParameter( 'continue',
134 $this->getContinueStr( $img ) );
135 }
136 break;
137 }
138 }
139
140 // Now get the old revisions
141 // Get one more to facilitate query-continue functionality
142 $count = ( $gotOne ? 1 : 0 );
143 $oldies = $img->getHistory( $params['limit'] - $count + 1, $start, $params['end'] );
144 foreach ( $oldies as $oldie ) {
145 if ( ++$count > $params['limit'] ) {
146 // We've reached the extra one which shows that there are additional pages to be had. Stop here...
147 // Only set a query-continue if there was only one title
148 if ( count( $pageIds[NS_FILE] ) == 1 ) {
149 $this->setContinueEnumParameter( 'start',
150 wfTimestamp( TS_ISO_8601, $oldie->getTimestamp() ) );
151 }
152 break;
153 }
154 $fit = $this->addPageSubItem( $pageId,
155 self::getInfo( $oldie, $prop, $result,
156 $finalThumbParams, $params['metadataversion'] ) );
157 if ( !$fit ) {
158 if ( count( $pageIds[NS_FILE] ) == 1 ) {
159 $this->setContinueEnumParameter( 'start',
160 wfTimestamp( TS_ISO_8601, $oldie->getTimestamp() ) );
161 } else {
162 $this->setContinueEnumParameter( 'continue',
163 $this->getContinueStr( $oldie ) );
164 }
165 break;
166 }
167 }
168 if ( !$fit ) {
169 break;
170 }
171 $skip = false;
172 }
173
174 $data = $this->getResultData();
175 foreach ( $data['query']['pages'] as $pageid => $arr ) {
176 if ( is_array( $arr ) && !isset( $arr['imagerepository'] ) ) {
177 $result->addValue(
178 array( 'query', 'pages', $pageid ),
179 'imagerepository', ''
180 );
181 }
182 // The above can't fail because it doesn't increase the result size
183 }
184 }
185 }
186
187 /**
188 * From parameters, construct a 'scale' array
189 * @param $params Array: Parameters passed to api.
190 * @return Array or Null: key-val array of 'width' and 'height', or null
191 */
192 public function getScale( $params ) {
193 $p = $this->getModulePrefix();
194
195 // Height and width.
196 if ( $params['urlheight'] != -1 && $params['urlwidth'] == -1 ) {
197 $this->dieUsage( "{$p}urlheight cannot be used without {$p}urlwidth", "{$p}urlwidth" );
198 }
199
200 if ( $params['urlwidth'] != -1 ) {
201 $scale = array();
202 $scale['width'] = $params['urlwidth'];
203 $scale['height'] = $params['urlheight'];
204 } else {
205 $scale = null;
206 if ( $params['urlparam'] ) {
207 $this->dieUsage( "{$p}urlparam requires {$p}urlwidth", "urlparam_no_width" );
208 }
209 return $scale;
210 }
211
212 return $scale;
213 }
214
215 /** Validate and merge scale parameters with handler thumb parameters, give error if invalid.
216 *
217 * We do this later than getScale, since we need the image
218 * to know which handler, since handlers can make their own parameters.
219 * @param File $image Image that params are for.
220 * @param Array $thumbParams thumbnail parameters from getScale
221 * @param String $otherParams of otherParams (iiurlparam).
222 * @return Array of parameters for transform.
223 */
224 protected function mergeThumbParams ( $image, $thumbParams, $otherParams ) {
225 if ( !$otherParams ) {
226 return $thumbParams;
227 }
228 $p = $this->getModulePrefix();
229
230 $h = $image->getHandler();
231 if ( !$h ) {
232 $this->setWarning( 'Could not create thumbnail because ' .
233 $image->getName() . ' does not have an associated image handler' );
234 return $thumbParams;
235 }
236
237 $paramList = $h->parseParamString( $otherParams );
238 if ( !$paramList ) {
239 // Just set a warning (instead of dieUsage), as in many cases
240 // we could still render the image using width and height parameters,
241 // and this type of thing could happen between different versions of
242 // handlers.
243 $this->setWarning( "Could not parse {$p}urlparam for " . $image->getName()
244 . '. Using only width and height' );
245 return $thumbParams;
246 }
247
248 if ( isset( $paramList['width'] ) ) {
249 if ( intval( $paramList['width'] ) != intval( $thumbParams['width'] ) ) {
250 $this->dieUsage( "{$p}urlparam had width of {$paramList['width']} but "
251 . "{$p}urlwidth was {$thumbParams['width']}", "urlparam_urlwidth_mismatch" );
252 }
253 }
254
255 foreach ( $paramList as $name => $value ) {
256 if ( !$h->validateParam( $name, $value ) ) {
257 $this->dieUsage( "Invalid value for {$p}urlparam ($name=$value)", "urlparam" );
258 }
259 }
260
261 return $thumbParams + $paramList;
262 }
263
264 /**
265 * Get result information for an image revision
266 *
267 * @param $file File object
268 * @param $prop Array of properties to get (in the keys)
269 * @param $result ApiResult object
270 * @param $thumbParams Array containing 'width' and 'height' items, or null
271 * @param $version string Version of image metadata (for things like jpeg which have different versions).
272 * @return Array: result array
273 */
274 static function getInfo( $file, $prop, $result, $thumbParams = null, $version = 'latest' ) {
275 $vals = array();
276 // Timestamp is shown even if the file is revdelete'd in interface
277 // so do same here.
278 if ( isset( $prop['timestamp'] ) ) {
279 $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $file->getTimestamp() );
280 }
281
282 $user = isset( $prop['user'] );
283 $userid = isset( $prop['userid'] );
284
285 if ( $user || $userid ) {
286 if ( $file->isDeleted( File::DELETED_USER ) ) {
287 $vals['userhidden'] = '';
288 } else {
289 if ( $user ) {
290 $vals['user'] = $file->getUser();
291 }
292 if ( $userid ) {
293 $vals['userid'] = $file->getUser( 'id' );
294 }
295 if ( !$file->getUser( 'id' ) ) {
296 $vals['anon'] = '';
297 }
298 }
299 }
300
301 // This is shown even if the file is revdelete'd in interface
302 // so do same here.
303 if ( isset( $prop['size'] ) || isset( $prop['dimensions'] ) ) {
304 $vals['size'] = intval( $file->getSize() );
305 $vals['width'] = intval( $file->getWidth() );
306 $vals['height'] = intval( $file->getHeight() );
307
308 $pageCount = $file->pageCount();
309 if ( $pageCount !== false ) {
310 $vals['pagecount'] = $pageCount;
311 }
312 }
313
314 $pcomment = isset( $prop['parsedcomment'] );
315 $comment = isset( $prop['comment'] );
316
317 if ( $pcomment || $comment ) {
318 if ( $file->isDeleted( File::DELETED_COMMENT ) ) {
319 $vals['commenthidden'] = '';
320 } else {
321 if ( $pcomment ) {
322 $vals['parsedcomment'] = Linker::formatComment(
323 $file->getDescription(), $file->getTitle() );
324 }
325 if ( $comment ) {
326 $vals['comment'] = $file->getDescription();
327 }
328 }
329 }
330
331 $url = isset( $prop['url'] );
332 $sha1 = isset( $prop['sha1'] );
333 $meta = isset( $prop['metadata'] );
334 $mime = isset( $prop['mime'] );
335 $mediatype = isset( $prop['mediatype'] );
336 $archive = isset( $prop['archivename'] );
337 $bitdepth = isset( $prop['bitdepth'] );
338
339 if ( ( $url || $sha1 || $meta || $mime || $mediatype || $archive || $bitdepth )
340 && $file->isDeleted( File::DELETED_FILE ) ) {
341 $vals['filehidden'] = '';
342
343 //Early return, tidier than indenting all following things one level
344 return $vals;
345 }
346
347 if ( $url ) {
348 if ( !is_null( $thumbParams ) ) {
349 $mto = $file->transform( $thumbParams );
350 if ( $mto && !$mto->isError() ) {
351 $vals['thumburl'] = wfExpandUrl( $mto->getUrl(), PROTO_CURRENT );
352
353 // bug 23834 - If the URL's are the same, we haven't resized it, so shouldn't give the wanted
354 // thumbnail sizes for the thumbnail actual size
355 if ( $mto->getUrl() !== $file->getUrl() ) {
356 $vals['thumbwidth'] = intval( $mto->getWidth() );
357 $vals['thumbheight'] = intval( $mto->getHeight() );
358 } else {
359 $vals['thumbwidth'] = intval( $file->getWidth() );
360 $vals['thumbheight'] = intval( $file->getHeight() );
361 }
362
363 if ( isset( $prop['thumbmime'] ) && $file->getHandler() ) {
364 list( $ext, $mime ) = $file->getHandler()->getThumbType(
365 $mto->getExtension(), $file->getMimeType(), $thumbParams );
366 $vals['thumbmime'] = $mime;
367 }
368 } elseif ( $mto && $mto->isError() ) {
369 $vals['thumberror'] = $mto->toText();
370 }
371 }
372 $vals['url'] = wfExpandUrl( $file->getFullURL(), PROTO_CURRENT );
373 $vals['descriptionurl'] = wfExpandUrl( $file->getDescriptionUrl(), PROTO_CURRENT );
374 }
375
376 if ( $sha1 ) {
377 $vals['sha1'] = wfBaseConvert( $file->getSha1(), 36, 16, 40 );
378 }
379
380 if ( $meta ) {
381 wfSuppressWarnings();
382 $metadata = unserialize( $file->getMetadata() );
383 wfRestoreWarnings();
384 if ( $metadata && $version !== 'latest' ) {
385 $metadata = $file->convertMetadataVersion( $metadata, $version );
386 }
387 $vals['metadata'] = $metadata ? self::processMetaData( $metadata, $result ) : null;
388 }
389
390 if ( $mime ) {
391 $vals['mime'] = $file->getMimeType();
392 }
393
394 if ( $mediatype ) {
395 $vals['mediatype'] = $file->getMediaType();
396 }
397
398 if ( $archive && $file->isOld() ) {
399 $vals['archivename'] = $file->getArchiveName();
400 }
401
402 if ( $bitdepth ) {
403 $vals['bitdepth'] = $file->getBitDepth();
404 }
405
406 return $vals;
407 }
408
409 /**
410 *
411 * @param $metadata Array
412 * @param $result ApiResult
413 * @return Array
414 */
415 public static function processMetaData( $metadata, $result ) {
416 $retval = array();
417 if ( is_array( $metadata ) ) {
418 foreach ( $metadata as $key => $value ) {
419 $r = array( 'name' => $key );
420 if ( is_array( $value ) ) {
421 $r['value'] = self::processMetaData( $value, $result );
422 } else {
423 $r['value'] = $value;
424 }
425 $retval[] = $r;
426 }
427 }
428 $result->setIndexedTagName( $retval, 'metadata' );
429 return $retval;
430 }
431
432 public function getCacheMode( $params ) {
433 return 'public';
434 }
435
436 /**
437 * @param $img File
438 * @return string
439 */
440 protected function getContinueStr( $img ) {
441 return $img->getOriginalTitle()->getText() .
442 '|' . $img->getTimestamp();
443 }
444
445 public function getAllowedParams() {
446 return array(
447 'prop' => array(
448 ApiBase::PARAM_ISMULTI => true,
449 ApiBase::PARAM_DFLT => 'timestamp|user',
450 ApiBase::PARAM_TYPE => self::getPropertyNames()
451 ),
452 'limit' => array(
453 ApiBase::PARAM_TYPE => 'limit',
454 ApiBase::PARAM_DFLT => 1,
455 ApiBase::PARAM_MIN => 1,
456 ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
457 ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
458 ),
459 'start' => array(
460 ApiBase::PARAM_TYPE => 'timestamp'
461 ),
462 'end' => array(
463 ApiBase::PARAM_TYPE => 'timestamp'
464 ),
465 'urlwidth' => array(
466 ApiBase::PARAM_TYPE => 'integer',
467 ApiBase::PARAM_DFLT => -1
468 ),
469 'urlheight' => array(
470 ApiBase::PARAM_TYPE => 'integer',
471 ApiBase::PARAM_DFLT => -1
472 ),
473 'metadataversion' => array(
474 ApiBase::PARAM_TYPE => 'string',
475 ApiBase::PARAM_DFLT => '1',
476 ),
477 'urlparam' => array(
478 ApiBase::PARAM_DFLT => '',
479 ApiBase::PARAM_TYPE => 'string',
480 ),
481 'continue' => null,
482 'localonly' => false,
483 );
484 }
485
486 /**
487 * Returns all possible parameters to iiprop
488 *
489 * @param array $filter List of properties to filter out
490 *
491 * @return Array
492 */
493 public static function getPropertyNames( $filter = array() ) {
494 return array_diff( array_keys( self::getProperties() ), $filter );
495 }
496
497 /**
498 * Returns array key value pairs of properties and their descriptions
499 *
500 * @return array
501 */
502 private static function getProperties( $modulePrefix = '' ) {
503 return array(
504 'timestamp' => ' timestamp - Adds timestamp for the uploaded version',
505 'user' => ' user - Adds the user who uploaded the image version',
506 'userid' => ' userid - Add the user ID that uploaded the image version',
507 'comment' => ' comment - Comment on the version',
508 'parsedcomment' => ' parsedcomment - Parse the comment on the version',
509 'url' => ' url - Gives URL to the image and the description page',
510 'size' => ' size - Adds the size of the image in bytes and the height, width and page count (if applicable)',
511 'dimensions' => ' dimensions - Alias for size', // For backwards compatibility with Allimages
512 'sha1' => ' sha1 - Adds SHA-1 hash for the image',
513 'mime' => ' mime - Adds MIME type of the image',
514 'thumbmime' => ' thumbmime - Adds MIME type of the image thumbnail' .
515 ' (requires url and param ' . $modulePrefix . 'urlwidth)',
516 'mediatype' => ' mediatype - Adds the media type of the image',
517 'metadata' => ' metadata - Lists EXIF metadata for the version of the image',
518 'archivename' => ' archivename - Adds the file name of the archive version for non-latest versions',
519 'bitdepth' => ' bitdepth - Adds the bit depth of the version',
520 );
521 }
522
523 /**
524 * Returns the descriptions for the properties provided by getPropertyNames()
525 *
526 * @param array $filter List of properties to filter out
527 *
528 * @return array
529 */
530 public static function getPropertyDescriptions( $filter = array(), $modulePrefix = '' ) {
531 return array_merge(
532 array( 'What image information to get:' ),
533 array_values( array_diff_key( self::getProperties( $modulePrefix ), array_flip( $filter ) ) )
534 );
535 }
536
537 /**
538 * Return the API documentation for the parameters.
539 * @return Array parameter documentation.
540 */
541 public function getParamDescription() {
542 $p = $this->getModulePrefix();
543 return array(
544 'prop' => self::getPropertyDescriptions( array(), $p ),
545 'urlwidth' => array( "If {$p}prop=url is set, a URL to an image scaled to this width will be returned.",
546 'Only the current version of the image can be scaled' ),
547 'urlheight' => "Similar to {$p}urlwidth. Cannot be used without {$p}urlwidth",
548 'urlparam' => array( "A handler specific parameter string. For example, pdf's ",
549 "might use 'page15-100px'. {$p}urlwidth must be used and be consistent with {$p}urlparam" ),
550 'limit' => 'How many image revisions to return',
551 'start' => 'Timestamp to start listing from',
552 'end' => 'Timestamp to stop listing at',
553 'metadataversion' => array( "Version of metadata to use. if 'latest' is specified, use latest version.",
554 "Defaults to '1' for backwards compatibility" ),
555 'continue' => 'If the query response includes a continue value, use it here to get another page of results',
556 'localonly' => 'Look only for files in the local repository',
557 );
558 }
559
560 public static function getResultPropertiesFiltered( $filter = array() ) {
561 $props = array(
562 'timestamp' => array(
563 'timestamp' => 'timestamp'
564 ),
565 'user' => array(
566 'userhidden' => 'boolean',
567 'user' => 'string',
568 'anon' => 'boolean'
569 ),
570 'userid' => array(
571 'userhidden' => 'boolean',
572 'userid' => 'integer',
573 'anon' => 'boolean'
574 ),
575 'size' => array(
576 'size' => 'integer',
577 'width' => 'integer',
578 'height' => 'integer',
579 'pagecount' => array(
580 ApiBase::PROP_TYPE => 'integer',
581 ApiBase::PROP_NULLABLE => true
582 )
583 ),
584 'dimensions' => array(
585 'size' => 'integer',
586 'width' => 'integer',
587 'height' => 'integer',
588 'pagecount' => array(
589 ApiBase::PROP_TYPE => 'integer',
590 ApiBase::PROP_NULLABLE => true
591 )
592 ),
593 'comment' => array(
594 'commenthidden' => 'boolean',
595 'comment' => array(
596 ApiBase::PROP_TYPE => 'string',
597 ApiBase::PROP_NULLABLE => true
598 )
599 ),
600 'parsedcomment' => array(
601 'commenthidden' => 'boolean',
602 'parsedcomment' => array(
603 ApiBase::PROP_TYPE => 'string',
604 ApiBase::PROP_NULLABLE => true
605 )
606 ),
607 'url' => array(
608 'filehidden' => 'boolean',
609 'thumburl' => array(
610 ApiBase::PROP_TYPE => 'string',
611 ApiBase::PROP_NULLABLE => true
612 ),
613 'thumbwidth' => array(
614 ApiBase::PROP_TYPE => 'integer',
615 ApiBase::PROP_NULLABLE => true
616 ),
617 'thumbheight' => array(
618 ApiBase::PROP_TYPE => 'integer',
619 ApiBase::PROP_NULLABLE => true
620 ),
621 'thumberror' => array(
622 ApiBase::PROP_TYPE => 'string',
623 ApiBase::PROP_NULLABLE => true
624 ),
625 'url' => array(
626 ApiBase::PROP_TYPE => 'string',
627 ApiBase::PROP_NULLABLE => true
628 ),
629 'descriptionurl' => array(
630 ApiBase::PROP_TYPE => 'string',
631 ApiBase::PROP_NULLABLE => true
632 )
633 ),
634 'sha1' => array(
635 'filehidden' => 'boolean',
636 'sha1' => array(
637 ApiBase::PROP_TYPE => 'string',
638 ApiBase::PROP_NULLABLE => true
639 )
640 ),
641 'mime' => array(
642 'filehidden' => 'boolean',
643 'mime' => array(
644 ApiBase::PROP_TYPE => 'string',
645 ApiBase::PROP_NULLABLE => true
646 )
647 ),
648 'thumbmime' => array(
649 'filehidden' => 'boolean',
650 'thumbmime' => array(
651 ApiBase::PROP_TYPE => 'string',
652 ApiBase::PROP_NULLABLE => true
653 )
654 ),
655 'mediatype' => array(
656 'filehidden' => 'boolean',
657 'mediatype' => array(
658 ApiBase::PROP_TYPE => 'string',
659 ApiBase::PROP_NULLABLE => true
660 )
661 ),
662 'archivename' => array(
663 'filehidden' => 'boolean',
664 'archivename' => array(
665 ApiBase::PROP_TYPE => 'string',
666 ApiBase::PROP_NULLABLE => true
667 )
668 ),
669 'bitdepth' => array(
670 'filehidden' => 'boolean',
671 'bitdepth' => array(
672 ApiBase::PROP_TYPE => 'integer',
673 ApiBase::PROP_NULLABLE => true
674 )
675 ),
676 );
677 return array_diff_key( $props, array_flip( $filter ) );
678 }
679
680 public function getResultProperties() {
681 return self::getResultPropertiesFiltered();
682 }
683
684 public function getDescription() {
685 return 'Returns image information and upload history';
686 }
687
688 public function getPossibleErrors() {
689 $p = $this->getModulePrefix();
690 return array_merge( parent::getPossibleErrors(), array(
691 array( 'code' => "{$p}urlwidth", 'info' => "{$p}urlheight cannot be used without {$p}urlwidth" ),
692 array( 'code' => 'urlparam', 'info' => "Invalid value for {$p}urlparam" ),
693 array( 'code' => 'urlparam_no_width', 'info' => "{$p}urlparam requires {$p}urlwidth" ),
694 array( 'code' => 'urlparam_urlwidth_mismatch', 'info' => "The width set in {$p}urlparm doesnt't " .
695 "match the one in {$p}urlwidth" ),
696 ) );
697 }
698
699 public function getExamples() {
700 return array(
701 'api.php?action=query&titles=File:Albert%20Einstein%20Head.jpg&prop=imageinfo',
702 'api.php?action=query&titles=File:Test.jpg&prop=imageinfo&iilimit=50&iiend=20071231235959&iiprop=timestamp|user|url',
703 );
704 }
705
706 public function getHelpUrls() {
707 return 'https://www.mediawiki.org/wiki/API:Properties#imageinfo_.2F_ii';
708 }
709
710 public function getVersion() {
711 return __CLASS__ . ': $Id$';
712 }
713 }