36 if ( is_null( $prefix ) ) {
39 parent::__construct(
$query, $moduleName, $prefix );
45 $prop = array_flip(
$params[
'prop'] );
50 'version' =>
$params[
'metadataversion'],
51 'language' =>
$params[
'extmetadatalanguage'],
52 'multilang' =>
$params[
'extmetadatamultilang'],
53 'extmetadatafilter' =>
$params[
'extmetadatafilter'],
54 'revdelUser' => $this->
getUser(),
57 if ( isset(
$params[
'badfilecontexttitle'] ) ) {
58 $badFileContextTitle = Title::newFromText(
$params[
'badfilecontexttitle'] );
59 if ( !$badFileContextTitle ) {
60 $this->
dieUsage(
'Invalid title in badfilecontexttitle parameter',
'invalid-title' );
63 $badFileContextTitle =
false;
66 $pageIds = $this->
getPageSet()->getGoodAndMissingTitlesByNamespace();
67 if ( !empty( $pageIds[
NS_FILE] ) ) {
72 if ( !is_null(
$params[
'continue'] ) ) {
73 $cont = explode(
'|',
$params[
'continue'] );
75 $fromTitle = strval( $cont[0] );
76 $fromTimestamp = $cont[1];
78 foreach (
$titles as $key => $title ) {
79 if ( $title < $fromTitle ) {
88 $findTitles = array_map(
function ( $title ) use ( $user ) {
102 foreach (
$titles as $title ) {
105 $start = $title === $fromTitle ? $fromTimestamp :
$params[
'start'];
107 if ( !isset( $images[$title] ) ) {
108 if ( isset( $prop[
'uploadwarning'] ) || isset( $prop[
'badfile'] ) ) {
112 $info[
'imagerepository'] =
'';
115 [
'query',
'pages', intval( $pageId ) ],
116 'imagerepository',
''
126 if ( self::getTransformCount() >= self::TRANSFORM_LIMIT ) {
127 if ( count( $pageIds[
NS_FILE] ) == 1 ) {
130 $start !==
null ? $start :
wfTimestamp( TS_ISO_8601, $img->getTimestamp() )
139 if ( !isset( $info[
'imagerepository'] ) ) {
140 $info[
'imagerepository'] = $img->getRepoName();
142 if ( isset( $prop[
'badfile'] ) ) {
143 $info[
'badfile'] = (bool)
wfIsBadImage( $title, $badFileContextTitle );
146 $fit = $result->addValue( [
'query',
'pages' ], intval( $pageId ), $info );
148 if ( count( $pageIds[
NS_FILE] ) == 1 ) {
155 $start !==
null ? $start :
wfTimestamp( TS_ISO_8601, $img->getTimestamp() )
171 ( is_null( $start ) || $img->getTimestamp() <= $start ) &&
172 ( is_null(
$params[
'end'] ) || $img->getTimestamp() >=
$params[
'end'] )
177 static::getInfo( $img, $prop, $result,
178 $finalThumbParams, $opts
182 if ( count( $pageIds[
NS_FILE] ) == 1 ) {
185 wfTimestamp( TS_ISO_8601, $img->getTimestamp() ) );
196 $count = ( $gotOne ? 1 : 0 );
197 $oldies = $img->getHistory(
$params[
'limit'] - $count + 1, $start,
$params[
'end'] );
199 foreach ( $oldies as $oldie ) {
200 if ( ++$count >
$params[
'limit'] ) {
204 if ( count( $pageIds[
NS_FILE] ) == 1 ) {
206 wfTimestamp( TS_ISO_8601, $oldie->getTimestamp() ) );
212 static::getInfo( $oldie, $prop, $result,
213 $finalThumbParams, $opts
217 if ( count( $pageIds[
NS_FILE] ) == 1 ) {
219 wfTimestamp( TS_ISO_8601, $oldie->getTimestamp() ) );
240 if (
$params[
'urlwidth'] != -1 ) {
242 $scale[
'width'] =
$params[
'urlwidth'];
243 $scale[
'height'] =
$params[
'urlheight'];
244 } elseif (
$params[
'urlheight'] != -1 ) {
248 $scale[
'height'] =
$params[
'urlheight'];
271 if ( $thumbParams ===
null ) {
275 if ( !isset( $thumbParams[
'width'] ) && isset( $thumbParams[
'height'] ) ) {
280 if (
$image->getWidth() <= 0 ) {
281 $thumbParams[
'width'] = max( $this->
getConfig()->
get(
'ThumbLimits' ) );
283 $thumbParams[
'width'] =
$image->getWidth();
287 if ( !$otherParams ) {
293 $h =
$image->getHandler();
300 $paramList = $h->parseParamString( $otherParams );
311 if ( isset( $paramList[
'width'] ) && isset( $thumbParams[
'width'] ) ) {
312 if ( intval( $paramList[
'width'] ) != intval( $thumbParams[
'width'] ) ) {
314 [
'apiwarn-urlparamwidth', $p, $paramList[
'width'], $thumbParams[
'width'] ]
319 foreach ( $paramList as $name =>
$value ) {
320 if ( !$h->validateParam( $name,
$value ) ) {
327 $finalParams = $thumbParams + $paramList;
344 $h =
$image->getHandler();
351 if ( !$h->normaliseParams(
$image, $finalParams ) ) {
371 public static function getInfo( $file, $prop, $result, $thumbParams =
null, $opts =
false ) {
376 if ( !$opts || is_string( $opts ) ) {
378 'version' => $opts ?:
'latest',
380 'multilang' =>
false,
381 'extmetadatafilter' => [],
382 'revdelUser' =>
null,
385 $version = $opts[
'version'];
391 if ( isset( $prop[
'timestamp'] ) ) {
392 $vals[
'timestamp'] =
wfTimestamp( TS_ISO_8601, $file->getTimestamp() );
396 if ( isset( $opts[
'revdelUser'] ) && $opts[
'revdelUser'] ) {
397 $revdelUser = $opts[
'revdelUser'];
398 $canShowField =
function ( $field ) use ( $file, $revdelUser ) {
399 return $file->userCan( $field, $revdelUser );
402 $canShowField =
function ( $field ) use ( $file ) {
403 return !$file->isDeleted( $field );
407 $user = isset( $prop[
'user'] );
408 $userid = isset( $prop[
'userid'] );
410 if ( $user || $userid ) {
412 $vals[
'userhidden'] =
true;
417 $vals[
'user'] = $file->getUser();
420 $vals[
'userid'] = $file->getUser(
'id' );
422 if ( !$file->getUser(
'id' ) ) {
423 $vals[
'anon'] =
true;
430 if ( isset( $prop[
'size'] ) || isset( $prop[
'dimensions'] ) ) {
431 $vals[
'size'] = intval( $file->getSize() );
432 $vals[
'width'] = intval( $file->getWidth() );
433 $vals[
'height'] = intval( $file->getHeight() );
435 $pageCount = $file->pageCount();
436 if ( $pageCount !==
false ) {
437 $vals[
'pagecount'] = $pageCount;
441 $length = $file->getLength();
444 $vals[
'duration'] = (float)$length;
448 $pcomment = isset( $prop[
'parsedcomment'] );
449 $comment = isset( $prop[
'comment'] );
451 if ( $pcomment || $comment ) {
453 $vals[
'commenthidden'] =
true;
459 $file->getDescription(
File::RAW ), $file->getTitle() );
462 $vals[
'comment'] = $file->getDescription(
File::RAW );
467 $canonicaltitle = isset( $prop[
'canonicaltitle'] );
468 $url = isset( $prop[
'url'] );
469 $sha1 = isset( $prop[
'sha1'] );
470 $meta = isset( $prop[
'metadata'] );
471 $extmetadata = isset( $prop[
'extmetadata'] );
472 $commonmeta = isset( $prop[
'commonmetadata'] );
473 $mime = isset( $prop[
'mime'] );
474 $mediatype = isset( $prop[
'mediatype'] );
475 $archive = isset( $prop[
'archivename'] );
476 $bitdepth = isset( $prop[
'bitdepth'] );
477 $uploadwarning = isset( $prop[
'uploadwarning'] );
479 if ( $uploadwarning ) {
484 $vals[
'filehidden'] =
true;
489 $vals[
'suppressed'] =
true;
497 if ( $canonicaltitle ) {
498 $vals[
'canonicaltitle'] = $file->getTitle()->getPrefixedText();
502 if ( $file->exists() ) {
503 if ( !is_null( $thumbParams ) ) {
504 $mto = $file->transform( $thumbParams );
505 self::$transformCount++;
506 if ( $mto && !$mto->isError() ) {
511 if ( $mto->getUrl() !== $file->getUrl() ) {
512 $vals[
'thumbwidth'] = intval( $mto->getWidth() );
513 $vals[
'thumbheight'] = intval( $mto->getHeight() );
515 $vals[
'thumbwidth'] = intval( $file->getWidth() );
516 $vals[
'thumbheight'] = intval( $file->getHeight() );
519 if ( isset( $prop[
'thumbmime'] ) && $file->getHandler() ) {
520 list( ,
$mime ) = $file->getHandler()->getThumbType(
521 $mto->getExtension(), $file->getMimeType(), $thumbParams );
522 $vals[
'thumbmime'] =
$mime;
524 } elseif ( $mto && $mto->isError() ) {
525 $vals[
'thumberror'] = $mto->toText();
530 $vals[
'filemissing'] =
true;
534 $shortDescriptionUrl = $file->getDescriptionShortUrl();
535 if ( $shortDescriptionUrl !==
null ) {
541 $vals[
'sha1'] = Wikimedia\base_convert( $file->getSha1(), 36, 16, 40 );
545 Wikimedia\suppressWarnings();
547 Wikimedia\restoreWarnings();
548 if ( $metadata && $version !==
'latest' ) {
549 $metadata = $file->convertMetadataVersion( $metadata, $version );
551 $vals[
'metadata'] = $metadata ? static::processMetaData( $metadata, $result ) :
null;
554 $metaArray = $file->getCommonMetaArray();
555 $vals[
'commonmetadata'] = $metaArray ? static::processMetaData( $metaArray, $result ) : [];
558 if ( $extmetadata ) {
564 $format->getContext()->setLanguage( $opts[
'language'] );
565 $extmetaArray = $format->fetchExtendedMetadata( $file );
566 if ( $opts[
'extmetadatafilter'] ) {
567 $extmetaArray = array_intersect_key(
568 $extmetaArray, array_flip( $opts[
'extmetadatafilter'] )
571 $vals[
'extmetadata'] = $extmetaArray;
575 $vals[
'mime'] = $file->getMimeType();
579 $vals[
'mediatype'] = $file->getMediaType();
582 if ( $archive && $file->isOld() ) {
583 $vals[
'archivename'] = $file->getArchiveName();
587 $vals[
'bitdepth'] = $file->getBitDepth();
612 if ( is_array( $metadata ) ) {
613 foreach ( $metadata as $key =>
$value ) {
618 if ( is_array(
$value ) ) {
619 $r[
'value'] = static::processMetaData(
$value, $result );
645 if ( $start ===
null ) {
646 $start = $img->getTimestamp();
649 return $img->getOriginalTitle()->getDBkey() .
'|' . $start;
679 'apihelp-query+imageinfo-param-urlwidth',
687 'metadataversion' => [
691 'extmetadatalanguage' => [
695 'extmetadatamultilang' => [
699 'extmetadatafilter' => [
707 'badfilecontexttitle' => [
713 'localonly' =>
false,
724 return array_keys( static::getPropertyMessages( $filter ) );
734 return array_diff_key(
736 'timestamp' =>
'apihelp-query+imageinfo-paramvalue-prop-timestamp',
737 'user' =>
'apihelp-query+imageinfo-paramvalue-prop-user',
738 'userid' =>
'apihelp-query+imageinfo-paramvalue-prop-userid',
739 'comment' =>
'apihelp-query+imageinfo-paramvalue-prop-comment',
740 'parsedcomment' =>
'apihelp-query+imageinfo-paramvalue-prop-parsedcomment',
741 'canonicaltitle' =>
'apihelp-query+imageinfo-paramvalue-prop-canonicaltitle',
742 'url' =>
'apihelp-query+imageinfo-paramvalue-prop-url',
743 'size' =>
'apihelp-query+imageinfo-paramvalue-prop-size',
744 'dimensions' =>
'apihelp-query+imageinfo-paramvalue-prop-dimensions',
745 'sha1' =>
'apihelp-query+imageinfo-paramvalue-prop-sha1',
746 'mime' =>
'apihelp-query+imageinfo-paramvalue-prop-mime',
747 'thumbmime' =>
'apihelp-query+imageinfo-paramvalue-prop-thumbmime',
748 'mediatype' =>
'apihelp-query+imageinfo-paramvalue-prop-mediatype',
749 'metadata' =>
'apihelp-query+imageinfo-paramvalue-prop-metadata',
750 'commonmetadata' =>
'apihelp-query+imageinfo-paramvalue-prop-commonmetadata',
751 'extmetadata' =>
'apihelp-query+imageinfo-paramvalue-prop-extmetadata',
752 'archivename' =>
'apihelp-query+imageinfo-paramvalue-prop-archivename',
753 'bitdepth' =>
'apihelp-query+imageinfo-paramvalue-prop-bitdepth',
754 'uploadwarning' =>
'apihelp-query+imageinfo-paramvalue-prop-uploadwarning',
755 'badfile' =>
'apihelp-query+imageinfo-paramvalue-prop-badfile',
757 array_flip( $filter )
770 'timestamp' =>
' timestamp - Adds timestamp for the uploaded version',
771 'user' =>
' user - Adds the user who uploaded the image version',
772 'userid' =>
' userid - Add the user ID that uploaded the image version',
773 'comment' =>
' comment - Comment on the version',
774 'parsedcomment' =>
' parsedcomment - Parse the comment on the version',
775 'canonicaltitle' =>
' canonicaltitle - Adds the canonical title of the image file',
776 'url' =>
' url - Gives URL to the image and the description page',
777 'size' =>
' size - Adds the size of the image in bytes, ' .
778 'its height and its width. Page count and duration are added if applicable',
779 'dimensions' =>
' dimensions - Alias for size',
780 'sha1' =>
' sha1 - Adds SHA-1 hash for the image',
781 'mime' =>
' mime - Adds MIME type of the image',
782 'thumbmime' =>
' thumbmime - Adds MIME type of the image thumbnail' .
783 ' (requires url and param ' . $modulePrefix .
'urlwidth)',
784 'mediatype' =>
' mediatype - Adds the media type of the image',
785 'metadata' =>
' metadata - Lists Exif metadata for the version of the image',
786 'commonmetadata' =>
' commonmetadata - Lists file format generic metadata ' .
787 'for the version of the image',
788 'extmetadata' =>
' extmetadata - Lists formatted metadata combined ' .
789 'from multiple sources. Results are HTML formatted.',
790 'archivename' =>
' archivename - Adds the file name of the archive ' .
791 'version for non-latest versions',
792 'bitdepth' =>
' bitdepth - Adds the bit depth of the version',
793 'uploadwarning' =>
' uploadwarning - Used by the Special:Upload page to ' .
794 'get information about an existing file. Not intended for use outside MediaWiki core',
808 [
'What image information to get:' ],
809 array_values( array_diff_key( static::getProperties( $modulePrefix ), array_flip( $filter ) ) )
815 'action=query&titles=File:Albert%20Einstein%20Head.jpg&prop=imageinfo'
816 =>
'apihelp-query+imageinfo-example-simple',
817 'action=query&titles=File:Test.jpg&prop=imageinfo&iilimit=50&' .
818 'iiend=2007-12-31T23:59:59Z&iiprop=timestamp|user|url'
819 =>
'apihelp-query+imageinfo-example-dated',
824 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Imageinfo';
unserialize( $serialized)
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.
extractRequestParams( $parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user,...
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.
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.
dieUsage( $description, $errorCode, $httpRespCode=0, $extradata=null)
Throw an ApiUsageException, which will (if uncaught) call the main module's error handler and die wit...
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 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 local content language as $wgContLang
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 local account incomplete not yet checked for validity & $retval
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub 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
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 local account $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
if( $ext=='php'|| $ext=='php5') $mime