MediaWiki  1.23.2
ApiQueryImageInfo.php
Go to the documentation of this file.
1 <?php
33  const TRANSFORM_LIMIT = 50;
34  private static $transformCount = 0;
35 
36  public function __construct( $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 ) ) {
41  $prefix = 'ii';
42  }
43  parent::__construct( $query, $moduleName, $prefix );
44  }
45 
46  public function execute() {
47  $params = $this->extractRequestParams();
48 
49  $prop = array_flip( $params['prop'] );
50 
51  $scale = $this->getScale( $params );
52 
53  $opts = array(
54  'version' => $params['metadataversion'],
55  'language' => $params['extmetadatalanguage'],
56  'multilang' => $params['extmetadatamultilang'],
57  'extmetadatafilter' => $params['extmetadatafilter'],
58  'revdelUser' => $this->getUser(),
59  );
60 
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
65 
66  $fromTitle = null;
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] );
76  } else {
77  break;
78  }
79  }
80  }
81 
82  $user = $this->getUser();
83  $findTitles = array_map( function ( $title ) use ( $user ) {
84  return array(
85  'title' => $title,
86  'private' => $user,
87  );
88  }, $titles );
89 
90  if ( $params['localonly'] ) {
91  $images = RepoGroup::singleton()->getLocalRepo()->findFiles( $findTitles );
92  } else {
93  $images = RepoGroup::singleton()->findFiles( $findTitles );
94  }
95 
96  $result = $this->getResult();
97  foreach ( $titles as $title ) {
98  $pageId = $pageIds[NS_FILE][$title];
99  $start = $title === $fromTitle ? $fromTimestamp : $params['start'];
100 
101  if ( !isset( $images[$title] ) ) {
102  if ( isset( $prop['uploadwarning'] ) ) {
103  // Uploadwarning needs info about non-existing files
104  $images[$title] = wfLocalFile( $title );
105  } else {
106  $result->addValue(
107  array( 'query', 'pages', intval( $pageId ) ),
108  'imagerepository', ''
109  );
110  // The above can't fail because it doesn't increase the result size
111  continue;
112  }
113  }
114 
116  $img = $images[$title];
117 
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() )
123  );
124  } else {
125  $this->setContinueEnumParameter( 'continue',
126  $this->getContinueStr( $img, $start ) );
127  }
128  break;
129  }
130 
131  $fit = $result->addValue(
132  array( 'query', 'pages', intval( $pageId ) ),
133  'imagerepository', $img->getRepoName()
134  );
135  if ( !$fit ) {
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() )
144  );
145  } else {
146  $this->setContinueEnumParameter( 'continue',
147  $this->getContinueStr( $img, $start ) );
148  }
149  break;
150  }
151 
152  // Check if we can make the requested thumbnail, and get transform parameters.
153  $finalThumbParams = $this->mergeThumbParams( $img, $scale, $params['urlparam'] );
154 
155  // Get information about the current version first
156  // Check that the current version is within the start-end boundaries
157  $gotOne = false;
158  if (
159  ( is_null( $start ) || $img->getTimestamp() <= $start ) &&
160  ( is_null( $params['end'] ) || $img->getTimestamp() >= $params['end'] )
161  ) {
162  $gotOne = true;
163 
164  $fit = $this->addPageSubItem( $pageId,
165  self::getInfo( $img, $prop, $result,
166  $finalThumbParams, $opts
167  )
168  );
169  if ( !$fit ) {
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() ) );
174  } else {
175  $this->setContinueEnumParameter( 'continue',
176  $this->getContinueStr( $img ) );
177  }
178  break;
179  }
180  }
181 
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'] );
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() ) );
195  }
196  break;
197  }
198  $fit = self::getTransformCount() < self::TRANSFORM_LIMIT &&
199  $this->addPageSubItem( $pageId,
200  self::getInfo( $oldie, $prop, $result,
201  $finalThumbParams, $opts
202  )
203  );
204  if ( !$fit ) {
205  if ( count( $pageIds[NS_FILE] ) == 1 ) {
206  $this->setContinueEnumParameter( 'start',
207  wfTimestamp( TS_ISO_8601, $oldie->getTimestamp() ) );
208  } else {
209  $this->setContinueEnumParameter( 'continue',
210  $this->getContinueStr( $oldie ) );
211  }
212  break;
213  }
214  }
215  if ( !$fit ) {
216  break;
217  }
218  }
219  }
220  }
221 
227  public function getScale( $params ) {
228  $p = $this->getModulePrefix();
229 
230  if ( $params['urlwidth'] != -1 ) {
231  $scale = array();
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
237  $scale = array();
238  $scale['height'] = $params['urlheight'];
239  } else {
240  $scale = null;
241  if ( $params['urlparam'] ) {
242  $this->dieUsage( "{$p}urlparam requires {$p}urlwidth", "urlparam_no_width" );
243  }
244  }
245 
246  return $scale;
247  }
248 
258  protected function mergeThumbParams( $image, $thumbParams, $otherParams ) {
259  global $wgThumbLimits;
260 
261  if ( !isset( $thumbParams['width'] ) && isset( $thumbParams['height'] ) ) {
262  // We want to limit only by height in this situation, so pass the
263  // image's full width as the limiting width. But some file types
264  // don't have a width of their own, so pick something arbitrary so
265  // thumbnailing the default icon works.
266  if ( $image->getWidth() <= 0 ) {
267  $thumbParams['width'] = max( $wgThumbLimits );
268  } else {
269  $thumbParams['width'] = $image->getWidth();
270  }
271  }
272 
273  if ( !$otherParams ) {
274  return $thumbParams;
275  }
276  $p = $this->getModulePrefix();
277 
278  $h = $image->getHandler();
279  if ( !$h ) {
280  $this->setWarning( 'Could not create thumbnail because ' .
281  $image->getName() . ' does not have an associated image handler' );
282 
283  return $thumbParams;
284  }
285 
286  $paramList = $h->parseParamString( $otherParams );
287  if ( !$paramList ) {
288  // Just set a warning (instead of dieUsage), as in many cases
289  // we could still render the image using width and height parameters,
290  // and this type of thing could happen between different versions of
291  // handlers.
292  $this->setWarning( "Could not parse {$p}urlparam for " . $image->getName()
293  . '. Using only width and height' );
294 
295  return $thumbParams;
296  }
297 
298  if ( isset( $paramList['width'] ) ) {
299  if ( intval( $paramList['width'] ) != intval( $thumbParams['width'] ) ) {
300  $this->setWarning( "Ignoring width value set in {$p}urlparam ({$paramList['width']}) "
301  . "in favor of width value derived from {$p}urlwidth/{$p}urlheight "
302  . "({$thumbParams['width']})" );
303  }
304  }
305 
306  foreach ( $paramList as $name => $value ) {
307  if ( !$h->validateParam( $name, $value ) ) {
308  $this->dieUsage( "Invalid value for {$p}urlparam ($name=$value)", "urlparam" );
309  }
310  }
311 
312  return $thumbParams + $paramList;
313  }
314 
330  static function getInfo( $file, $prop, $result, $thumbParams = null, $opts = false ) {
332 
333  $anyHidden = false;
334 
335  if ( !$opts || is_string( $opts ) ) {
336  $opts = array(
337  'version' => $opts ?: 'latest',
338  'language' => $wgContLang,
339  'multilang' => false,
340  'extmetadatafilter' => array(),
341  'revdelUser' => null,
342  );
343  }
344  $version = $opts['version'];
345  $vals = array();
346  // Timestamp is shown even if the file is revdelete'd in interface
347  // so do same here.
348  if ( isset( $prop['timestamp'] ) ) {
349  $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $file->getTimestamp() );
350  }
351 
352  // Handle external callers who don't pass revdelUser
353  if ( isset( $opts['revdelUser'] ) && $opts['revdelUser'] ) {
354  $revdelUser = $opts['revdelUser'];
355  $canShowField = function ( $field ) use ( $file, $revdelUser ) {
356  return $file->userCan( $field, $revdelUser );
357  };
358  } else {
359  $canShowField = function ( $field ) use ( $file ) {
360  return !$file->isDeleted( $field );
361  };
362  }
363 
364  $user = isset( $prop['user'] );
365  $userid = isset( $prop['userid'] );
366 
367  if ( $user || $userid ) {
368  if ( $file->isDeleted( File::DELETED_USER ) ) {
369  $vals['userhidden'] = '';
370  $anyHidden = true;
371  }
372  if ( $canShowField( File::DELETED_USER ) ) {
373  if ( $user ) {
374  $vals['user'] = $file->getUser();
375  }
376  if ( $userid ) {
377  $vals['userid'] = $file->getUser( 'id' );
378  }
379  if ( !$file->getUser( 'id' ) ) {
380  $vals['anon'] = '';
381  }
382  }
383  }
384 
385  // This is shown even if the file is revdelete'd in interface
386  // so do same here.
387  if ( isset( $prop['size'] ) || isset( $prop['dimensions'] ) ) {
388  $vals['size'] = intval( $file->getSize() );
389  $vals['width'] = intval( $file->getWidth() );
390  $vals['height'] = intval( $file->getHeight() );
391 
392  $pageCount = $file->pageCount();
393  if ( $pageCount !== false ) {
394  $vals['pagecount'] = $pageCount;
395  }
396  }
397 
398  $pcomment = isset( $prop['parsedcomment'] );
399  $comment = isset( $prop['comment'] );
400 
401  if ( $pcomment || $comment ) {
402  if ( $file->isDeleted( File::DELETED_COMMENT ) ) {
403  $vals['commenthidden'] = '';
404  $anyHidden = true;
405  }
406  if ( $canShowField( File::DELETED_COMMENT ) ) {
407  if ( $pcomment ) {
408  $vals['parsedcomment'] = Linker::formatComment(
409  $file->getDescription( File::RAW ), $file->getTitle() );
410  }
411  if ( $comment ) {
412  $vals['comment'] = $file->getDescription( File::RAW );
413  }
414  }
415  }
416 
417  $canonicaltitle = isset( $prop['canonicaltitle'] );
418  $url = isset( $prop['url'] );
419  $sha1 = isset( $prop['sha1'] );
420  $meta = isset( $prop['metadata'] );
421  $extmetadata = isset( $prop['extmetadata'] );
422  $commonmeta = isset( $prop['commonmetadata'] );
423  $mime = isset( $prop['mime'] );
424  $mediatype = isset( $prop['mediatype'] );
425  $archive = isset( $prop['archivename'] );
426  $bitdepth = isset( $prop['bitdepth'] );
427  $uploadwarning = isset( $prop['uploadwarning'] );
428 
429  if ( $uploadwarning ) {
431  }
432 
433  if ( $file->isDeleted( File::DELETED_FILE ) ) {
434  $vals['filehidden'] = '';
435  $anyHidden = true;
436  }
437 
438  if ( $anyHidden && $file->isDeleted( File::DELETED_RESTRICTED ) ) {
439  $vals['suppressed'] = true;
440  }
441 
442  if ( !$canShowField( File::DELETED_FILE ) ) {
443  //Early return, tidier than indenting all following things one level
444  return $vals;
445  }
446 
447  if ( $canonicaltitle ) {
448  $vals['canonicaltitle'] = $file->getTitle()->getPrefixedText();
449  }
450 
451  if ( $url ) {
452  if ( !is_null( $thumbParams ) ) {
453  $mto = $file->transform( $thumbParams );
454  self::$transformCount++;
455  if ( $mto && !$mto->isError() ) {
456  $vals['thumburl'] = wfExpandUrl( $mto->getUrl(), PROTO_CURRENT );
457 
458  // bug 23834 - If the URL's are the same, we haven't resized it, so shouldn't give the wanted
459  // thumbnail sizes for the thumbnail actual size
460  if ( $mto->getUrl() !== $file->getUrl() ) {
461  $vals['thumbwidth'] = intval( $mto->getWidth() );
462  $vals['thumbheight'] = intval( $mto->getHeight() );
463  } else {
464  $vals['thumbwidth'] = intval( $file->getWidth() );
465  $vals['thumbheight'] = intval( $file->getHeight() );
466  }
467 
468  if ( isset( $prop['thumbmime'] ) && $file->getHandler() ) {
469  list( , $mime ) = $file->getHandler()->getThumbType(
470  $mto->getExtension(), $file->getMimeType(), $thumbParams );
471  $vals['thumbmime'] = $mime;
472  }
473  } elseif ( $mto && $mto->isError() ) {
474  $vals['thumberror'] = $mto->toText();
475  }
476  }
477  $vals['url'] = wfExpandUrl( $file->getFullURL(), PROTO_CURRENT );
478  $vals['descriptionurl'] = wfExpandUrl( $file->getDescriptionUrl(), PROTO_CURRENT );
479  }
480 
481  if ( $sha1 ) {
482  $vals['sha1'] = wfBaseConvert( $file->getSha1(), 36, 16, 40 );
483  }
484 
485  if ( $meta ) {
487  $metadata = unserialize( $file->getMetadata() );
489  if ( $metadata && $version !== 'latest' ) {
490  $metadata = $file->convertMetadataVersion( $metadata, $version );
491  }
492  $vals['metadata'] = $metadata ? self::processMetaData( $metadata, $result ) : null;
493  }
494  if ( $commonmeta ) {
495  $metaArray = $file->getCommonMetaArray();
496  $vals['commonmetadata'] = $metaArray ? self::processMetaData( $metaArray, $result ) : array();
497  }
498 
499  if ( $extmetadata ) {
500  // Note, this should return an array where all the keys
501  // start with a letter, and all the values are strings.
502  // Thus there should be no issue with format=xml.
503  $format = new FormatMetadata;
504  $format->setSingleLanguage( !$opts['multilang'] );
505  $format->getContext()->setLanguage( $opts['language'] );
506  $extmetaArray = $format->fetchExtendedMetadata( $file );
507  if ( $opts['extmetadatafilter'] ) {
508  $extmetaArray = array_intersect_key(
509  $extmetaArray, array_flip( $opts['extmetadatafilter'] )
510  );
511  }
512  $vals['extmetadata'] = $extmetaArray;
513  }
514 
515  if ( $mime ) {
516  $vals['mime'] = $file->getMimeType();
517  }
518 
519  if ( $mediatype ) {
520  $vals['mediatype'] = $file->getMediaType();
521  }
522 
523  if ( $archive && $file->isOld() ) {
524  $vals['archivename'] = $file->getArchiveName();
525  }
526 
527  if ( $bitdepth ) {
528  $vals['bitdepth'] = $file->getBitDepth();
529  }
530 
531  return $vals;
532  }
533 
541  static function getTransformCount() {
542  return self::$transformCount;
543  }
544 
551  public static function processMetaData( $metadata, $result ) {
552  $retval = array();
553  if ( is_array( $metadata ) ) {
554  foreach ( $metadata as $key => $value ) {
555  $r = array( 'name' => $key );
556  if ( is_array( $value ) ) {
557  $r['value'] = self::processMetaData( $value, $result );
558  } else {
559  $r['value'] = $value;
560  }
561  $retval[] = $r;
562  }
563  }
564  $result->setIndexedTagName( $retval, 'metadata' );
565 
566  return $retval;
567  }
568 
569  public function getCacheMode( $params ) {
570  if ( $this->userCanSeeRevDel() ) {
571  return 'private';
572  }
573 
574  return 'public';
575  }
576 
582  protected function getContinueStr( $img, $start = null ) {
583  if ( $start === null ) {
584  $start = $img->getTimestamp();
585  }
586 
587  return $img->getOriginalTitle()->getDBkey() . '|' . $start;
588  }
589 
590  public function getAllowedParams() {
592 
593  return array(
594  'prop' => array(
595  ApiBase::PARAM_ISMULTI => true,
596  ApiBase::PARAM_DFLT => 'timestamp|user',
597  ApiBase::PARAM_TYPE => self::getPropertyNames()
598  ),
599  'limit' => array(
600  ApiBase::PARAM_TYPE => 'limit',
601  ApiBase::PARAM_DFLT => 1,
602  ApiBase::PARAM_MIN => 1,
605  ),
606  'start' => array(
607  ApiBase::PARAM_TYPE => 'timestamp'
608  ),
609  'end' => array(
610  ApiBase::PARAM_TYPE => 'timestamp'
611  ),
612  'urlwidth' => array(
613  ApiBase::PARAM_TYPE => 'integer',
614  ApiBase::PARAM_DFLT => -1
615  ),
616  'urlheight' => array(
617  ApiBase::PARAM_TYPE => 'integer',
618  ApiBase::PARAM_DFLT => -1
619  ),
620  'metadataversion' => array(
621  ApiBase::PARAM_TYPE => 'string',
622  ApiBase::PARAM_DFLT => '1',
623  ),
624  'extmetadatalanguage' => array(
625  ApiBase::PARAM_TYPE => 'string',
626  ApiBase::PARAM_DFLT => $wgContLang->getCode(),
627  ),
628  'extmetadatamultilang' => array(
629  ApiBase::PARAM_TYPE => 'boolean',
630  ApiBase::PARAM_DFLT => false,
631  ),
632  'extmetadatafilter' => array(
633  ApiBase::PARAM_TYPE => 'string',
634  ApiBase::PARAM_ISMULTI => true,
635  ),
636  'urlparam' => array(
637  ApiBase::PARAM_DFLT => '',
638  ApiBase::PARAM_TYPE => 'string',
639  ),
640  'continue' => null,
641  'localonly' => false,
642  );
643  }
644 
652  public static function getPropertyNames( $filter = array() ) {
653  return array_diff( array_keys( self::getProperties() ), $filter );
654  }
655 
662  private static function getProperties( $modulePrefix = '' ) {
663  return array(
664  'timestamp' => ' timestamp - Adds timestamp for the uploaded version',
665  'user' => ' user - Adds the user who uploaded the image version',
666  'userid' => ' userid - Add the user ID that uploaded the image version',
667  'comment' => ' comment - Comment on the version',
668  'parsedcomment' => ' parsedcomment - Parse the comment on the version',
669  'canonicaltitle' => ' canonicaltitle - Adds the canonical title of the image file',
670  'url' => ' url - Gives URL to the image and the description page',
671  'size' => ' size - Adds the size of the image in bytes ' .
672  'and the height, width and page count (if applicable)',
673  'dimensions' => ' dimensions - Alias for size', // B/C with Allimages
674  'sha1' => ' sha1 - Adds SHA-1 hash for the image',
675  'mime' => ' mime - Adds MIME type of the image',
676  'thumbmime' => ' thumbmime - Adds MIME type of the image thumbnail' .
677  ' (requires url and param ' . $modulePrefix . 'urlwidth)',
678  'mediatype' => ' mediatype - Adds the media type of the image',
679  'metadata' => ' metadata - Lists Exif metadata for the version of the image',
680  'commonmetadata' => ' commonmetadata - Lists file format generic metadata ' .
681  'for the version of the image',
682  'extmetadata' => ' extmetadata - Lists formatted metadata combined ' .
683  'from multiple sources. Results are HTML formatted.',
684  'archivename' => ' archivename - Adds the file name of the archive ' .
685  'version for non-latest versions',
686  'bitdepth' => ' bitdepth - Adds the bit depth of the version',
687  'uploadwarning' => ' uploadwarning - Used by the Special:Upload page to ' .
688  'get information about an existing file. Not intended for use outside MediaWiki core',
689  );
690  }
691 
699  public static function getPropertyDescriptions( $filter = array(), $modulePrefix = '' ) {
700  return array_merge(
701  array( 'What image information to get:' ),
702  array_values( array_diff_key( self::getProperties( $modulePrefix ), array_flip( $filter ) ) )
703  );
704  }
705 
710  public function getParamDescription() {
711  $p = $this->getModulePrefix();
712 
713  return array(
714  'prop' => self::getPropertyDescriptions( array(), $p ),
715  'urlwidth' => array(
716  "If {$p}prop=url is set, a URL to an image scaled to this width will be returned.",
717  'For performance reasons if this option is used, ' .
718  'no more than ' . self::TRANSFORM_LIMIT . ' scaled images will be returned.'
719  ),
720  'urlheight' => "Similar to {$p}urlwidth.",
721  'urlparam' => array( "A handler specific parameter string. For example, pdf's ",
722  "might use 'page15-100px'. {$p}urlwidth must be used and be consistent with {$p}urlparam" ),
723  'limit' => 'How many image revisions to return per image',
724  'start' => 'Timestamp to start listing from',
725  'end' => 'Timestamp to stop listing at',
726  'metadataversion'
727  => array( "Version of metadata to use. if 'latest' is specified, use latest version.",
728  "Defaults to '1' for backwards compatibility" ),
729  'extmetadatalanguage' => array(
730  'What language to fetch extmetadata in. This affects both which',
731  'translation to fetch, if multiple are available, as well as how things',
732  'like numbers and various values are formatted.'
733  ),
734  'extmetadatamultilang'
735  =>'If translations for extmetadata property are available, fetch all of them.',
736  'extmetadatafilter'
737  => "If specified and non-empty, only these keys will be returned for {$p}prop=extmetadata",
738  'continue' => 'If the query response includes a continue value, ' .
739  'use it here to get another page of results',
740  'localonly' => 'Look only for files in the local repository',
741  );
742  }
743 
744  public static function getResultPropertiesFiltered( $filter = array() ) {
745  $props = array(
746  'timestamp' => array(
747  'timestamp' => 'timestamp'
748  ),
749  'user' => array(
750  'userhidden' => 'boolean',
751  'user' => 'string',
752  'anon' => 'boolean'
753  ),
754  'userid' => array(
755  'userhidden' => 'boolean',
756  'userid' => 'integer',
757  'anon' => 'boolean'
758  ),
759  'size' => array(
760  'size' => 'integer',
761  'width' => 'integer',
762  'height' => 'integer',
763  'pagecount' => array(
764  ApiBase::PROP_TYPE => 'integer',
765  ApiBase::PROP_NULLABLE => true
766  )
767  ),
768  'dimensions' => array(
769  'size' => 'integer',
770  'width' => 'integer',
771  'height' => 'integer',
772  'pagecount' => array(
773  ApiBase::PROP_TYPE => 'integer',
774  ApiBase::PROP_NULLABLE => true
775  )
776  ),
777  'comment' => array(
778  'commenthidden' => 'boolean',
779  'comment' => array(
780  ApiBase::PROP_TYPE => 'string',
781  ApiBase::PROP_NULLABLE => true
782  )
783  ),
784  'parsedcomment' => array(
785  'commenthidden' => 'boolean',
786  'parsedcomment' => array(
787  ApiBase::PROP_TYPE => 'string',
788  ApiBase::PROP_NULLABLE => true
789  )
790  ),
791  'canonicaltitle' => array(
792  'canonicaltitle' => array(
793  ApiBase::PROP_TYPE => 'string',
794  ApiBase::PROP_NULLABLE => true
795  )
796  ),
797  'url' => array(
798  'filehidden' => 'boolean',
799  'thumburl' => array(
800  ApiBase::PROP_TYPE => 'string',
801  ApiBase::PROP_NULLABLE => true
802  ),
803  'thumbwidth' => array(
804  ApiBase::PROP_TYPE => 'integer',
805  ApiBase::PROP_NULLABLE => true
806  ),
807  'thumbheight' => array(
808  ApiBase::PROP_TYPE => 'integer',
809  ApiBase::PROP_NULLABLE => true
810  ),
811  'thumberror' => array(
812  ApiBase::PROP_TYPE => 'string',
813  ApiBase::PROP_NULLABLE => true
814  ),
815  'url' => array(
816  ApiBase::PROP_TYPE => 'string',
817  ApiBase::PROP_NULLABLE => true
818  ),
819  'descriptionurl' => array(
820  ApiBase::PROP_TYPE => 'string',
821  ApiBase::PROP_NULLABLE => true
822  )
823  ),
824  'sha1' => array(
825  'filehidden' => 'boolean',
826  'sha1' => array(
827  ApiBase::PROP_TYPE => 'string',
828  ApiBase::PROP_NULLABLE => true
829  )
830  ),
831  'mime' => array(
832  'filehidden' => 'boolean',
833  'mime' => array(
834  ApiBase::PROP_TYPE => 'string',
835  ApiBase::PROP_NULLABLE => true
836  )
837  ),
838  'thumbmime' => array(
839  'filehidden' => 'boolean',
840  'thumbmime' => array(
841  ApiBase::PROP_TYPE => 'string',
842  ApiBase::PROP_NULLABLE => true
843  )
844  ),
845  'mediatype' => array(
846  'filehidden' => 'boolean',
847  'mediatype' => array(
848  ApiBase::PROP_TYPE => 'string',
849  ApiBase::PROP_NULLABLE => true
850  )
851  ),
852  'archivename' => array(
853  'filehidden' => 'boolean',
854  'archivename' => array(
855  ApiBase::PROP_TYPE => 'string',
856  ApiBase::PROP_NULLABLE => true
857  )
858  ),
859  'bitdepth' => array(
860  'filehidden' => 'boolean',
861  'bitdepth' => array(
862  ApiBase::PROP_TYPE => 'integer',
863  ApiBase::PROP_NULLABLE => true
864  )
865  ),
866  );
867 
868  return array_diff_key( $props, array_flip( $filter ) );
869  }
870 
871  public function getResultProperties() {
873  }
874 
875  public function getDescription() {
876  return 'Returns image information and upload history.';
877  }
878 
879  public function getPossibleErrors() {
880  $p = $this->getModulePrefix();
881 
882  return array_merge( parent::getPossibleErrors(), array(
883  array( 'code' => "{$p}urlwidth", 'info' => "{$p}urlheight cannot be used without {$p}urlwidth" ),
884  array( 'code' => 'urlparam', 'info' => "Invalid value for {$p}urlparam" ),
885  array( 'code' => 'urlparam_no_width', 'info' => "{$p}urlparam requires {$p}urlwidth" ),
886  ) );
887  }
888 
889  public function getExamples() {
890  return array(
891  'api.php?action=query&titles=File:Albert%20Einstein%20Head.jpg&prop=imageinfo',
892  'api.php?action=query&titles=File:Test.jpg&prop=imageinfo&iilimit=50&' .
893  'iiend=20071231235959&iiprop=timestamp|user|url',
894  );
895  }
896 
897  public function getHelpUrls() {
898  return 'https://www.mediawiki.org/wiki/API:Properties#imageinfo_.2F_ii';
899  }
900 }
ApiQueryImageInfo\getParamDescription
getParamDescription()
Return the API documentation for the parameters.
Definition: ApiQueryImageInfo.php:710
ApiQueryImageInfo\getContinueStr
getContinueStr( $img, $start=null)
Definition: ApiQueryImageInfo.php:582
$result
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. $title:Title object for the current page $request:WebRequest $ignoreRedirect:boolean to skip redirect check $target:Title/string of redirect target $article:Article object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) $article:article(object) being checked 'IsTrustedProxy':Override the result of wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of User::isValidEmailAddr(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetMagic':DEPRECATED, use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetSpecialPageAliases':DEPRECATED, use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Associative array mapping language codes to prefixed links of the form "language:title". & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
Definition: hooks.txt:1528
RepoGroup\singleton
static singleton()
Get a RepoGroup instance.
Definition: RepoGroup.php:53
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
File\DELETED_USER
const DELETED_USER
Definition: File.php:54
$mime
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead where the first element is the message key and the remaining elements are used as parameters to the message based on mime etc Preferred in most cases over UploadVerification object with all info about the upload string $mime
Definition: hooks.txt:2573
File\DELETED_RESTRICTED
const DELETED_RESTRICTED
Definition: File.php:55
ApiQueryImageInfo\mergeThumbParams
mergeThumbParams( $image, $thumbParams, $otherParams)
Validate and merge scale parameters with handler thumb parameters, give error if invalid.
Definition: ApiQueryImageInfo.php:258
File\RAW
const RAW
Definition: File.php:70
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:2483
ApiBase\PARAM_TYPE
const PARAM_TYPE
Definition: ApiBase.php:50
ApiBase\getResult
getResult()
Get the result object.
Definition: ApiBase.php:205
wfSuppressWarnings
wfSuppressWarnings( $end=false)
Reference-counted warning suppression.
Definition: GlobalFunctions.php:2387
ApiQueryImageInfo\$transformCount
static $transformCount
Definition: ApiQueryImageInfo.php:34
NS_FILE
const NS_FILE
Definition: Defines.php:85
$params
$params
Definition: styleTest.css.php:40
ApiQueryImageInfo\getPropertyNames
static getPropertyNames( $filter=array())
Returns all possible parameters to iiprop.
Definition: ApiQueryImageInfo.php:652
ApiQueryImageInfo
A query action to get image information and upload history.
Definition: ApiQueryImageInfo.php:32
$wgContLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
Definition: design.txt:56
Linker\formatComment
static formatComment( $comment, $title=null, $local=false)
This function is called by all recent changes variants, by the page history, and by the user contribu...
Definition: Linker.php:1254
ApiQueryImageInfo\getExamples
getExamples()
Returns usage examples for this module.
Definition: ApiQueryImageInfo.php:889
ApiQueryImageInfo\getInfo
static getInfo( $file, $prop, $result, $thumbParams=null, $opts=false)
Get result information for an image revision.
Definition: ApiQueryImageInfo.php:330
ContextSource\getUser
getUser()
Get the User object.
Definition: ContextSource.php:132
SpecialUpload\getExistsWarning
static getExistsWarning( $exists)
Formats a result of UploadBase::getExistsWarning as HTML This check is static and can be done pre-upl...
Definition: SpecialUpload.php:663
FormatMetadata\setSingleLanguage
setSingleLanguage( $val)
Trigger only outputting single language for multilanguage fields.
Definition: FormatMetadata.php:62
ApiQueryImageInfo\getTransformCount
static getTransformCount()
Get the count of image transformations performed.
Definition: ApiQueryImageInfo.php:541
ApiQueryImageInfo\getResultPropertiesFiltered
static getResultPropertiesFiltered( $filter=array())
Definition: ApiQueryImageInfo.php:744
ApiQueryImageInfo\execute
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
Definition: ApiQueryImageInfo.php:46
ApiBase\PARAM_MIN
const PARAM_MIN
Definition: ApiBase.php:56
ApiQueryImageInfo\getProperties
static getProperties( $modulePrefix='')
Returns array key value pairs of properties and their descriptions.
Definition: ApiQueryImageInfo.php:662
File\DELETED_COMMENT
const DELETED_COMMENT
Definition: File.php:53
$titles
linkcache txt The LinkCache class maintains a list of article titles and the information about whether or not the article exists in the database This is used to mark up links when displaying a page If the same link appears more than once on any page then it only has to be looked up once In most cases link lookups are done in batches with the LinkBatch class or the equivalent in so the link cache is mostly useful for short snippets of parsed and for links in the navigation areas of the skin The link cache was formerly used to track links used in a document for the purposes of updating the link tables This application is now deprecated To create a you can use the following $titles
Definition: linkcache.txt:17
wfRestoreWarnings
wfRestoreWarnings()
Restore error level to previous value.
Definition: GlobalFunctions.php:2417
ApiQueryBase
This is a base class for all Query modules.
Definition: ApiQueryBase.php:34
ApiBase\LIMIT_BIG1
const LIMIT_BIG1
Definition: ApiBase.php:78
TS_ISO_8601
const TS_ISO_8601
ISO 8601 format with no timezone: 1986-02-09T20:00:00Z.
Definition: GlobalFunctions.php:2448
PROTO_CURRENT
const PROTO_CURRENT
Definition: Defines.php:270
ApiBase\PARAM_MAX
const PARAM_MAX
Definition: ApiBase.php:52
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
ApiQueryImageInfo\processMetaData
static processMetaData( $metadata, $result)
Definition: ApiQueryImageInfo.php:551
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
$comment
$comment
Definition: importImages.php:107
ApiBase\PROP_TYPE
const PROP_TYPE
Definition: ApiBase.php:74
list
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
ApiBase\getModulePrefix
getModulePrefix()
Get parameter prefix (usually two letters or an empty string).
Definition: ApiBase.php:165
ApiQueryImageInfo\TRANSFORM_LIMIT
const TRANSFORM_LIMIT
Definition: ApiQueryImageInfo.php:33
ApiBase\extractRequestParams
extractRequestParams( $parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user,...
Definition: ApiBase.php:687
ApiQueryImageInfo\getPossibleErrors
getPossibleErrors()
Definition: ApiQueryImageInfo.php:879
$title
presenting them properly to the user as errors is done by the caller $title
Definition: hooks.txt:1324
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:336
$value
$value
Definition: styleTest.css.php:45
ApiBase\dieContinueUsageIf
dieContinueUsageIf( $condition)
Die with the $prefix.
Definition: ApiBase.php:1965
ApiBase\dieUsage
dieUsage( $description, $errorCode, $httpRespCode=0, $extradata=null)
Throw a UsageException, which will (if uncaught) call the main module's error handler and die with an...
Definition: ApiBase.php:1363
ApiQueryImageInfo\__construct
__construct( $query, $moduleName, $prefix='ii')
Constructor.
Definition: ApiQueryImageInfo.php:36
ApiBase\PROP_NULLABLE
const PROP_NULLABLE
Definition: ApiBase.php:76
$version
$version
Definition: parserTests.php:86
UploadBase\getExistsWarning
static getExistsWarning( $file)
Helper function that does various existence checks for a file.
Definition: UploadBase.php:1554
ApiQueryBase\getPageSet
getPageSet()
Get the PageSet object to work on.
Definition: ApiQueryBase.php:441
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:237
$file
if(PHP_SAPI !='cli') $file
Definition: UtfNormalTest2.php:30
FormatMetadata
Format Image metadata values into a human readable form.
Definition: FormatMetadata.php:49
$count
$count
Definition: UtfNormalTest2.php:96
ApiQueryImageInfo\getAllowedParams
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
Definition: ApiQueryImageInfo.php:590
ApiBase\setWarning
setWarning( $warning)
Set warning section for this module.
Definition: ApiBase.php:245
ApiBase\LIMIT_BIG2
const LIMIT_BIG2
Definition: ApiBase.php:79
ApiQueryImageInfo\getResultProperties
getResultProperties()
Returns possible properties in the result, grouped by the value of the prop parameter that shows them...
Definition: ApiQueryImageInfo.php:871
ApiQueryImageInfo\getDescription
getDescription()
Returns the description string for this module.
Definition: ApiQueryImageInfo.php:875
wfBaseConvert
wfBaseConvert( $input, $sourceBase, $destBase, $pad=1, $lowercase=true, $engine='auto')
Convert an arbitrarily-long digit string from one numeric base to another, optionally zero-padding to...
Definition: GlobalFunctions.php:3368
ApiBase\PARAM_DFLT
const PARAM_DFLT
Definition: ApiBase.php:46
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
ApiBase\PARAM_ISMULTI
const PARAM_ISMULTI
Definition: ApiBase.php:48
ApiBase\PARAM_MAX2
const PARAM_MAX2
Definition: ApiBase.php:54
ApiQueryImageInfo\getScale
getScale( $params)
From parameters, construct a 'scale' array.
Definition: ApiQueryImageInfo.php:227
File\DELETED_FILE
const DELETED_FILE
Definition: File.php:52
ApiQueryBase\setContinueEnumParameter
setContinueEnumParameter( $paramName, $paramValue)
Set a query-continue value.
Definition: ApiQueryBase.php:404
ApiQueryImageInfo\getHelpUrls
getHelpUrls()
Definition: ApiQueryImageInfo.php:897
$query
return true to allow those checks to and false if checking is done use this to change the tables headers temp or archived zone change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition: hooks.txt:1105
wfLocalFile
wfLocalFile( $title)
Get an object referring to a locally registered file.
Definition: GlobalFunctions.php:3704
ApiQueryBase\userCanSeeRevDel
userCanSeeRevDel()
Check whether the current user has permission to view revision-deleted fields.
Definition: ApiQueryBase.php:618
ApiQueryBase\addPageSubItem
addPageSubItem( $pageId, $item, $elemname=null)
Same as addPageSubItems(), but one element of $data at a time.
Definition: ApiQueryBase.php:383
$retval
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account incomplete not yet checked for validity & $retval
Definition: hooks.txt:237
ApiQueryImageInfo\getPropertyDescriptions
static getPropertyDescriptions( $filter=array(), $modulePrefix='')
Returns the descriptions for the properties provided by getPropertyNames()
Definition: ApiQueryImageInfo.php:699
wfExpandUrl
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
Definition: GlobalFunctions.php:497
ApiQueryImageInfo\getCacheMode
getCacheMode( $params)
Get the cache mode for the data generated by this module.
Definition: ApiQueryImageInfo.php:569