$scale = $this->getScale( $params );
- $opts = array(
+ $opts = [
'version' => $params['metadataversion'],
'language' => $params['extmetadatalanguage'],
'multilang' => $params['extmetadatamultilang'],
'extmetadatafilter' => $params['extmetadatafilter'],
'revdelUser' => $this->getUser(),
- );
+ ];
$pageIds = $this->getPageSet()->getGoodAndMissingTitlesByNamespace();
if ( !empty( $pageIds[NS_FILE] ) ) {
$user = $this->getUser();
$findTitles = array_map( function ( $title ) use ( $user ) {
- return array(
+ return [
'title' => $title,
'private' => $user,
- );
+ ];
}, $titles );
if ( $params['localonly'] ) {
$images[$title] = wfLocalFile( $title );
} else {
$result->addValue(
- array( 'query', 'pages', intval( $pageId ) ),
+ [ 'query', 'pages', intval( $pageId ) ],
'imagerepository', ''
);
// The above can't fail because it doesn't increase the result size
}
$fit = $result->addValue(
- array( 'query', 'pages', intval( $pageId ) ),
+ [ 'query', 'pages', intval( $pageId ) ],
'imagerepository', $img->getRepoName()
);
if ( !$fit ) {
* @return array|null Key-val array of 'width' and 'height', or null
*/
public function getScale( $params ) {
- $p = $this->getModulePrefix();
-
if ( $params['urlwidth'] != -1 ) {
- $scale = array();
+ $scale = [];
$scale['width'] = $params['urlwidth'];
$scale['height'] = $params['urlheight'];
} elseif ( $params['urlheight'] != -1 ) {
// Height is specified but width isn't
// Don't set $scale['width']; this signals mergeThumbParams() to fill it with the image's width
- $scale = array();
+ $scale = [];
$scale['height'] = $params['urlheight'];
} else {
if ( $params['urlparam'] ) {
// Audio files might not have a width/height.
- $scale = array();
+ $scale = [];
} else {
$scale = null;
}
* 'revdelUser': User to use when checking whether to show revision-deleted fields.
* @return array Result array
*/
- static function getInfo( $file, $prop, $result, $thumbParams = null, $opts = false ) {
+ public static function getInfo( $file, $prop, $result, $thumbParams = null, $opts = false ) {
global $wgContLang;
$anyHidden = false;
if ( !$opts || is_string( $opts ) ) {
- $opts = array(
+ $opts = [
'version' => $opts ?: 'latest',
'language' => $wgContLang,
'multilang' => false,
- 'extmetadatafilter' => array(),
+ 'extmetadatafilter' => [],
'revdelUser' => null,
- );
+ ];
}
$version = $opts['version'];
- $vals = array(
+ $vals = [
ApiResult::META_TYPE => 'assoc',
- );
+ ];
// Timestamp is shown even if the file is revdelete'd in interface
// so do same here.
if ( isset( $prop['timestamp'] ) ) {
}
$vals['url'] = wfExpandUrl( $file->getFullUrl(), PROTO_CURRENT );
$vals['descriptionurl'] = wfExpandUrl( $file->getDescriptionUrl(), PROTO_CURRENT );
+
+ $shortDescriptionUrl = $file->getDescriptionShortUrl();
+ if ( $shortDescriptionUrl !== null ) {
+ $vals['descriptionshorturl'] = wfExpandUrl( $shortDescriptionUrl, PROTO_CURRENT );
+ }
}
if ( $sha1 ) {
- $vals['sha1'] = wfBaseConvert( $file->getSha1(), 36, 16, 40 );
+ $vals['sha1'] = Wikimedia\base_convert( $file->getSha1(), 36, 16, 40 );
}
if ( $meta ) {
}
if ( $commonmeta ) {
$metaArray = $file->getCommonMetaArray();
- $vals['commonmetadata'] = $metaArray ? self::processMetaData( $metaArray, $result ) : array();
+ $vals['commonmetadata'] = $metaArray ? self::processMetaData( $metaArray, $result ) : [];
}
if ( $extmetadata ) {
* @return array
*/
public static function processMetaData( $metadata, $result ) {
- $retval = array();
+ $retval = [];
if ( is_array( $metadata ) ) {
foreach ( $metadata as $key => $value ) {
- $r = array(
+ $r = [
'name' => $key,
- ApiResult::META_BC_BOOLS => array( 'value' ),
- );
+ ApiResult::META_BC_BOOLS => [ 'value' ],
+ ];
if ( is_array( $value ) ) {
$r['value'] = self::processMetaData( $value, $result );
} else {
public function getAllowedParams() {
global $wgContLang;
- return array(
- 'prop' => array(
+ return [
+ 'prop' => [
ApiBase::PARAM_ISMULTI => true,
ApiBase::PARAM_DFLT => 'timestamp|user',
ApiBase::PARAM_TYPE => self::getPropertyNames(),
ApiBase::PARAM_HELP_MSG_PER_VALUE => self::getPropertyMessages(),
- ),
- 'limit' => array(
+ ],
+ 'limit' => [
ApiBase::PARAM_TYPE => 'limit',
ApiBase::PARAM_DFLT => 1,
ApiBase::PARAM_MIN => 1,
ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
- ),
- 'start' => array(
+ ],
+ 'start' => [
ApiBase::PARAM_TYPE => 'timestamp'
- ),
- 'end' => array(
+ ],
+ 'end' => [
ApiBase::PARAM_TYPE => 'timestamp'
- ),
- 'urlwidth' => array(
+ ],
+ 'urlwidth' => [
ApiBase::PARAM_TYPE => 'integer',
ApiBase::PARAM_DFLT => -1,
- ApiBase::PARAM_HELP_MSG => array(
+ ApiBase::PARAM_HELP_MSG => [
'apihelp-query+imageinfo-param-urlwidth',
ApiQueryImageInfo::TRANSFORM_LIMIT,
- ),
- ),
- 'urlheight' => array(
+ ],
+ ],
+ 'urlheight' => [
ApiBase::PARAM_TYPE => 'integer',
ApiBase::PARAM_DFLT => -1
- ),
- 'metadataversion' => array(
+ ],
+ 'metadataversion' => [
ApiBase::PARAM_TYPE => 'string',
ApiBase::PARAM_DFLT => '1',
- ),
- 'extmetadatalanguage' => array(
+ ],
+ 'extmetadatalanguage' => [
ApiBase::PARAM_TYPE => 'string',
ApiBase::PARAM_DFLT => $wgContLang->getCode(),
- ),
- 'extmetadatamultilang' => array(
+ ],
+ 'extmetadatamultilang' => [
ApiBase::PARAM_TYPE => 'boolean',
ApiBase::PARAM_DFLT => false,
- ),
- 'extmetadatafilter' => array(
+ ],
+ 'extmetadatafilter' => [
ApiBase::PARAM_TYPE => 'string',
ApiBase::PARAM_ISMULTI => true,
- ),
- 'urlparam' => array(
+ ],
+ 'urlparam' => [
ApiBase::PARAM_DFLT => '',
ApiBase::PARAM_TYPE => 'string',
- ),
- 'continue' => array(
+ ],
+ 'continue' => [
ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
- ),
+ ],
'localonly' => false,
- );
+ ];
}
/**
* @param array $filter List of properties to filter out
* @return array
*/
- public static function getPropertyNames( $filter = array() ) {
+ public static function getPropertyNames( $filter = [] ) {
return array_keys( self::getPropertyMessages( $filter ) );
}
* @param array $filter List of properties to filter out
* @return array
*/
- public static function getPropertyMessages( $filter = array() ) {
+ public static function getPropertyMessages( $filter = [] ) {
return array_diff_key(
- array(
+ [
'timestamp' => 'apihelp-query+imageinfo-paramvalue-prop-timestamp',
'user' => 'apihelp-query+imageinfo-paramvalue-prop-user',
'userid' => 'apihelp-query+imageinfo-paramvalue-prop-userid',
'archivename' => 'apihelp-query+imageinfo-paramvalue-prop-archivename',
'bitdepth' => 'apihelp-query+imageinfo-paramvalue-prop-bitdepth',
'uploadwarning' => 'apihelp-query+imageinfo-paramvalue-prop-uploadwarning',
- ),
+ ],
array_flip( $filter )
);
}
* @return array
*/
private static function getProperties( $modulePrefix = '' ) {
- return array(
+ return [
'timestamp' => ' timestamp - Adds timestamp for the uploaded version',
'user' => ' user - Adds the user who uploaded the image version',
'userid' => ' userid - Add the user ID that uploaded the image version',
'bitdepth' => ' bitdepth - Adds the bit depth of the version',
'uploadwarning' => ' uploadwarning - Used by the Special:Upload page to ' .
'get information about an existing file. Not intended for use outside MediaWiki core',
- );
+ ];
}
/**
* @param string $modulePrefix
* @return array
*/
- public static function getPropertyDescriptions( $filter = array(), $modulePrefix = '' ) {
+ public static function getPropertyDescriptions( $filter = [], $modulePrefix = '' ) {
return array_merge(
- array( 'What image information to get:' ),
+ [ 'What image information to get:' ],
array_values( array_diff_key( self::getProperties( $modulePrefix ), array_flip( $filter ) ) )
);
}
protected function getExamplesMessages() {
- return array(
+ return [
'action=query&titles=File:Albert%20Einstein%20Head.jpg&prop=imageinfo'
=> 'apihelp-query+imageinfo-example-simple',
'action=query&titles=File:Test.jpg&prop=imageinfo&iilimit=50&' .
'iiend=2007-12-31T23:59:59Z&iiprop=timestamp|user|url'
=> 'apihelp-query+imageinfo-example-dated',
- );
+ ];
}
public function getHelpUrls() {