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