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