41 parent::__construct(
$query, $moduleName, $prefix );
52 'version' =>
$params[
'metadataversion'],
53 'language' =>
$params[
'extmetadatalanguage'],
54 'multilang' =>
$params[
'extmetadatamultilang'],
55 'extmetadatafilter' =>
$params[
'extmetadatafilter'],
56 'revdelUser' => $this->
getUser(),
60 $badFileContextTitle = Title::newFromText(
$params[
'badfilecontexttitle'] );
61 if ( !$badFileContextTitle ) {
63 $this->
dieWithError( [
'apierror-bad-badfilecontexttitle', $p ],
'invalid-title' );
66 $badFileContextTitle =
false;
69 $pageIds = $this->
getPageSet()->getGoodAndMissingTitlesByNamespace();
70 if ( !empty( $pageIds[
NS_FILE] ) ) {
76 $cont = explode(
'|',
$params[
'continue'] );
78 $fromTitle =
strval( $cont[0] );
79 $fromTimestamp = $cont[1];
81 foreach (
$titles as $key => $title ) {
82 if ( $title < $fromTitle ) {
91 $findTitles =
array_map(
function ( $title ) use ( $user ) {
105 foreach (
$titles as $title ) {
110 if ( !
isset( $images[$title] ) ) {
111 if (
isset( $prop[
'uploadwarning'] ) ||
isset( $prop[
'badfile'] ) ) {
115 $info[
'imagerepository'] =
'';
118 [
'query',
'pages', (
int)$pageId ],
119 'imagerepository',
''
129 if ( self::getTransformCount() >= self::TRANSFORM_LIMIT ) {
130 if ( count( $pageIds[
NS_FILE] ) == 1 ) {
133 $start ??
wfTimestamp( TS_ISO_8601, $img->getTimestamp() )
142 if ( !
isset( $info[
'imagerepository'] ) ) {
143 $info[
'imagerepository'] = $img->getRepoName();
145 if (
isset( $prop[
'badfile'] ) ) {
149 $fit = $result->addValue( [
'query',
'pages' ], (
int)$pageId, $info );
151 if ( count( $pageIds[
NS_FILE] ) == 1 ) {
158 $start ??
wfTimestamp( TS_ISO_8601, $img->getTimestamp() )
174 (
is_null( $start ) || $img->getTimestamp() <= $start ) &&
175 ( is_null(
$params[
'end'] ) || $img->getTimestamp() >=
$params[
'end'] )
180 static::getInfo( $img, $prop, $result,
181 $finalThumbParams, $opts
185 if ( count( $pageIds[
NS_FILE] ) == 1 ) {
188 wfTimestamp( TS_ISO_8601, $img->getTimestamp() ) );
199 $count = ( $gotOne ? 1 : 0 );
200 $oldies = $img->getHistory(
$params[
'limit'] - $count + 1, $start,
$params[
'end'] );
202 foreach ( $oldies as $oldie ) {
203 if ( ++$count >
$params[
'limit'] ) {
207 if ( count( $pageIds[
NS_FILE] ) == 1 ) {
209 wfTimestamp( TS_ISO_8601, $oldie->getTimestamp() ) );
215 static::getInfo( $oldie, $prop, $result,
216 $finalThumbParams, $opts
220 if ( count( $pageIds[
NS_FILE] ) == 1 ) {
222 wfTimestamp( TS_ISO_8601, $oldie->getTimestamp() ) );
243 if (
$params[
'urlwidth'] != -1 ) {
245 $scale[
'width'] =
$params[
'urlwidth'];
246 $scale[
'height'] =
$params[
'urlheight'];
251 $scale[
'height'] =
$params[
'urlheight'];
272 if ( $thumbParams ===
null ) {
276 if ( !
isset( $thumbParams[
'width'] ) &&
isset( $thumbParams[
'height'] ) ) {
281 if (
$image->getWidth() <= 0 ) {
282 $thumbParams[
'width'] =
max( $this->
getConfig()->
get(
'ThumbLimits' ) );
284 $thumbParams[
'width'] =
$image->getWidth();
288 if ( !$otherParams ) {
294 $h =
$image->getHandler();
301 $paramList = $h->parseParamString( $otherParams );
312 if (
isset( $paramList[
'width'] ) &&
isset( $thumbParams[
'width'] ) ) {
313 if ( (
int)$paramList[
'width'] != (
int)$thumbParams[
'width'] ) {
315 [
'apiwarn-urlparamwidth', $p, $paramList[
'width'], $thumbParams[
'width'] ]
320 foreach ( $paramList as $name =>
$value ) {
321 if ( !$h->validateParam( $name,
$value ) ) {
345 $h =
$image->getHandler();
352 if ( !$h->normaliseParams(
$image, $finalParams ) ) {
372 public static function getInfo( $file, $prop, $result, $thumbParams =
null, $opts =
false ) {
377 'version' => $opts ?:
'latest',
378 'language' => MediaWikiServices::getInstance()->getContentLanguage(),
379 'multilang' =>
false,
380 'extmetadatafilter' => [],
381 'revdelUser' =>
null,
384 $version = $opts[
'version'];
390 if (
isset( $prop[
'timestamp'] ) ) {
391 $vals[
'timestamp'] =
wfTimestamp( TS_ISO_8601, $file->getTimestamp() );
395 if (
isset( $opts[
'revdelUser'] ) && $opts[
'revdelUser'] ) {
396 $revdelUser = $opts[
'revdelUser'];
397 $canShowField =
function (
$field ) use ( $file, $revdelUser ) {
398 return $file->userCan( $field, $revdelUser );
401 $canShowField =
function (
$field ) use ( $file ) {
402 return !$file->isDeleted( $field );
406 $user =
isset( $prop[
'user'] );
407 $userid =
isset( $prop[
'userid'] );
409 if ( $user || $userid ) {
411 $vals[
'userhidden'] =
true;
416 $vals[
'user'] = $file->getUser();
419 $vals[
'userid'] = $file->getUser(
'id' );
421 if ( !$file->getUser(
'id' ) ) {
422 $vals[
'anon'] =
true;
429 if (
isset( $prop[
'size'] ) ||
isset( $prop[
'dimensions'] ) ) {
430 $vals[
'size'] = (
int)$file->getSize();
431 $vals[
'width'] = (
int)$file->getWidth();
432 $vals[
'height'] = (
int)$file->getHeight();
434 $pageCount = $file->pageCount();
435 if ( $pageCount !==
false ) {
436 $vals[
'pagecount'] = $pageCount;
440 $length = $file->getLength();
443 $vals[
'duration'] = (
float)$length;
447 $pcomment =
isset( $prop[
'parsedcomment'] );
448 $comment =
isset( $prop[
'comment'] );
450 if ( $pcomment || $comment ) {
452 $vals[
'commenthidden'] =
true;
458 $file->getDescription(
File::RAW ), $file->getTitle() );
461 $vals[
'comment'] = $file->getDescription(
File::RAW );
466 $canonicaltitle =
isset( $prop[
'canonicaltitle'] );
467 $url =
isset( $prop[
'url'] );
468 $sha1 =
isset( $prop[
'sha1'] );
469 $meta =
isset( $prop[
'metadata'] );
470 $extmetadata =
isset( $prop[
'extmetadata'] );
471 $commonmeta =
isset( $prop[
'commonmetadata'] );
472 $mime =
isset( $prop[
'mime'] );
473 $mediatype =
isset( $prop[
'mediatype'] );
474 $archive =
isset( $prop[
'archivename'] );
475 $bitdepth =
isset( $prop[
'bitdepth'] );
476 $uploadwarning =
isset( $prop[
'uploadwarning'] );
478 if ( $uploadwarning ) {
483 $vals[
'filehidden'] =
true;
488 $vals[
'suppressed'] =
true;
496 if ( $canonicaltitle ) {
497 $vals[
'canonicaltitle'] = $file->getTitle()->getPrefixedText();
501 if ( $file->exists() ) {
502 if ( !
is_null( $thumbParams ) ) {
503 $mto = $file->transform( $thumbParams );
504 self::$transformCount++;
505 if ( $mto && !$mto->isError() ) {
510 if ( $mto->getUrl() !== $file->getUrl() ) {
511 $vals[
'thumbwidth'] = (
int)$mto->getWidth();
512 $vals[
'thumbheight'] = (
int)$mto->getHeight();
514 $vals[
'thumbwidth'] = (
int)$file->getWidth();
515 $vals[
'thumbheight'] = (
int)$file->getHeight();
518 if (
isset( $prop[
'thumbmime'] ) && $file->getHandler() ) {
519 list( , $mime ) = $file->getHandler()->getThumbType(
520 $mto->getExtension(), $file->getMimeType(), $thumbParams );
521 $vals[
'thumbmime'] = $mime;
523 }
elseif ( $mto && $mto->isError() ) {
524 $vals[
'thumberror'] = $mto->toText();
529 $vals[
'filemissing'] =
true;
533 $shortDescriptionUrl = $file->getDescriptionShortUrl();
534 if ( $shortDescriptionUrl !==
null ) {
547 if ( $metadata && $version !==
'latest' ) {
548 $metadata = $file->convertMetadataVersion( $metadata, $version );
550 $vals[
'metadata'] = $metadata ? static::processMetaData( $metadata, $result ) :
null;
553 $metaArray = $file->getCommonMetaArray();
554 $vals[
'commonmetadata'] = $metaArray ? static::processMetaData( $metaArray, $result ) : [];
557 if ( $extmetadata ) {
563 $format->getContext()->setLanguage( $opts[
'language'] );
564 $extmetaArray = $format->fetchExtendedMetadata( $file );
565 if ( $opts[
'extmetadatafilter'] ) {
567 $extmetaArray,
array_flip( $opts[
'extmetadatafilter'] )
574 $vals[
'mime'] = $file->getMimeType();
578 $vals[
'mediatype'] = $file->getMediaType();
581 if ( $archive && $file->isOld() ) {
582 $vals[
'archivename'] = $file->getArchiveName();
586 $vals[
'bitdepth'] = $file->getBitDepth();
612 foreach ( $metadata as $key =>
$value ) {
618 $r[
'value'] = static::processMetaData(
$value, $result );
644 if ( $start ===
null ) {
645 $start = $img->getTimestamp();
648 return $img->getOriginalTitle()->getDBkey() .
'|' . $start;
676 'apihelp-query+imageinfo-param-urlwidth',
684 'metadataversion' => [
688 'extmetadatalanguage' => [
691 MediaWikiServices::getInstance()->getContentLanguage()->getCode(),
693 'extmetadatamultilang' => [
697 'extmetadatafilter' => [
705 'badfilecontexttitle' => [
711 'localonly' =>
false,
734 'timestamp' =>
'apihelp-query+imageinfo-paramvalue-prop-timestamp',
735 'user' =>
'apihelp-query+imageinfo-paramvalue-prop-user',
736 'userid' =>
'apihelp-query+imageinfo-paramvalue-prop-userid',
737 'comment' =>
'apihelp-query+imageinfo-paramvalue-prop-comment',
738 'parsedcomment' =>
'apihelp-query+imageinfo-paramvalue-prop-parsedcomment',
739 'canonicaltitle' =>
'apihelp-query+imageinfo-paramvalue-prop-canonicaltitle',
740 'url' =>
'apihelp-query+imageinfo-paramvalue-prop-url',
741 'size' =>
'apihelp-query+imageinfo-paramvalue-prop-size',
742 'dimensions' =>
'apihelp-query+imageinfo-paramvalue-prop-dimensions',
743 'sha1' =>
'apihelp-query+imageinfo-paramvalue-prop-sha1',
744 'mime' =>
'apihelp-query+imageinfo-paramvalue-prop-mime',
745 'thumbmime' =>
'apihelp-query+imageinfo-paramvalue-prop-thumbmime',
746 'mediatype' =>
'apihelp-query+imageinfo-paramvalue-prop-mediatype',
747 'metadata' =>
'apihelp-query+imageinfo-paramvalue-prop-metadata',
748 'commonmetadata' =>
'apihelp-query+imageinfo-paramvalue-prop-commonmetadata',
749 'extmetadata' =>
'apihelp-query+imageinfo-paramvalue-prop-extmetadata',
750 'archivename' =>
'apihelp-query+imageinfo-paramvalue-prop-archivename',
751 'bitdepth' =>
'apihelp-query+imageinfo-paramvalue-prop-bitdepth',
752 'uploadwarning' =>
'apihelp-query+imageinfo-paramvalue-prop-uploadwarning',
753 'badfile' =>
'apihelp-query+imageinfo-paramvalue-prop-badfile',
768 'timestamp' =>
' timestamp - Adds timestamp for the uploaded version',
769 'user' =>
' user - Adds the user who uploaded the image version',
770 'userid' =>
' userid - Add the user ID that uploaded the image version',
771 'comment' =>
' comment - Comment on the version',
772 'parsedcomment' =>
' parsedcomment - Parse the comment on the version',
773 'canonicaltitle' =>
' canonicaltitle - Adds the canonical title of the image file',
774 'url' =>
' url - Gives URL to the image and the description page',
775 'size' =>
' size - Adds the size of the image in bytes, ' .
776 'its height and its width. Page count and duration are added if applicable',
777 'dimensions' =>
' dimensions - Alias for size',
778 'sha1' =>
' sha1 - Adds SHA-1 hash for the image',
779 'mime' =>
' mime - Adds MIME type of the image',
780 'thumbmime' =>
' thumbmime - Adds MIME type of the image thumbnail' .
781 ' (requires url and param ' . $modulePrefix .
'urlwidth)',
782 'mediatype' =>
' mediatype - Adds the media type of the image',
783 'metadata' =>
' metadata - Lists Exif metadata for the version of the image',
784 'commonmetadata' =>
' commonmetadata - Lists file format generic metadata ' .
785 'for the version of the image',
786 'extmetadata' =>
' extmetadata - Lists formatted metadata combined ' .
787 'from multiple sources. Results are HTML formatted.',
788 'archivename' =>
' archivename - Adds the file name of the archive ' .
789 'version for non-latest versions',
790 'bitdepth' =>
' bitdepth - Adds the bit depth of the version',
791 'uploadwarning' =>
' uploadwarning - Used by the Special:Upload page to ' .
792 'get information about an existing file. Not intended for use outside MediaWiki core',
806 [
'What image information to get:' ],
813 'action=query&titles=File:Albert%20Einstein%20Head.jpg&prop=imageinfo'
814 =>
'apihelp-query+imageinfo-example-simple',
815 'action=query&titles=File:Test.jpg&prop=imageinfo&iilimit=50&' .
816 'iiend=2007-12-31T23:59:59Z&iiprop=timestamp|user|url'
817 =>
'apihelp-query+imageinfo-example-dated',
822 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Imageinfo';
unserialize( $serialized)
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
wfLocalFile( $title)
Get an object referring to a locally registered file.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
wfIsBadImage( $name, $contextTitle=false, $blacklist=null)
Determine if an image exists on the 'bad image list'.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
getModulePrefix()
Get parameter prefix (usually two letters or an empty string).
const PARAM_MAX2
(integer) Max value allowed for the parameter for users with the apihighlimits right,...
const PARAM_MAX
(integer) Max value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg...
const PARAM_MIN
(integer) Lowest value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
const LIMIT_BIG1
Fast query, standard limit.
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
addWarning( $msg, $code=null, $data=null)
Add a warning for this module.
const LIMIT_BIG2
Fast query, apihighlimits limit.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
This is a base class for all Query modules.
setContinueEnumParameter( $paramName, $paramValue)
Set a query-continue value.
addPageSubItem( $pageId, $item, $elemname=null)
Same as addPageSubItems(), but one element of $data at a time.
getPageSet()
Get the PageSet object to work on.
userCanSeeRevDel()
Check whether the current user has permission to view revision-deleted fields.
A query action to get image information and upload history.
checkParameterNormalise( $image, $finalParams)
Verify that the final image parameters can be normalised.
mergeThumbParams( $image, $thumbParams, $otherParams)
Validate and merge scale parameters with handler thumb parameters, give error if invalid.
__construct(ApiQuery $query, $moduleName, $prefix='ii')
getCacheMode( $params)
Get the cache mode for the data generated by this module.
getScale( $params)
From parameters, construct a 'scale' array.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
getHelpUrls()
Return links to more detailed help pages about the module.
static getProperties( $modulePrefix='')
Returns array key value pairs of properties and their descriptions.
static getPropertyNames( $filter=[])
Returns all possible parameters to iiprop.
static getPropertyDescriptions( $filter=[], $modulePrefix='')
Returns the descriptions for the properties provided by getPropertyNames()
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
getContinueStr( $img, $start=null)
static getInfo( $file, $prop, $result, $thumbParams=null, $opts=false)
Get result information for an image revision.
static getTransformCount()
Get the count of image transformations performed.
static getPropertyMessages( $filter=[])
Returns messages for all possible parameters to iiprop.
static processMetaData( $metadata, $result)
getExamplesMessages()
Returns usage examples for this module.
This is the main query class.
const META_TYPE
Key for the 'type' metadata item.
const META_BC_BOOLS
Key for the 'BC bools' metadata item.
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
static formatComment( $comment, $title=null, $local=false, $wikiId=null)
This function is called by all recent changes variants, by the page history, and by the user contribu...
static singleton()
Get a RepoGroup instance.
static getExistsWarning( $exists)
Formats a result of UploadBase::getExistsWarning as HTML This check is static and can be done pre-upl...
static getExistsWarning( $file)
Helper function that does various existence checks for a file.
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
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check $image
namespace and then decline to actually register it file or subcat img or subcat $title
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
return true to allow those checks to and false if checking is done & $user
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