diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2014-12-27 15:41:37 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2014-12-31 11:43:28 +0100 |
commit | c1f9b1f7b1b77776192048005dcc66dcf3df2bfb (patch) | |
tree | 2b38796e738dd74cb42ecd9bfd151803108386bc /includes/filerepo/file/ForeignAPIFile.php | |
parent | b88ab0086858470dd1f644e64cb4e4f62bb2be9b (diff) |
Update to MediaWiki 1.24.1
Diffstat (limited to 'includes/filerepo/file/ForeignAPIFile.php')
-rw-r--r-- | includes/filerepo/file/ForeignAPIFile.php | 53 |
1 files changed, 39 insertions, 14 deletions
diff --git a/includes/filerepo/file/ForeignAPIFile.php b/includes/filerepo/file/ForeignAPIFile.php index ed96d446..3d5d5d60 100644 --- a/includes/filerepo/file/ForeignAPIFile.php +++ b/includes/filerepo/file/ForeignAPIFile.php @@ -33,9 +33,9 @@ class ForeignAPIFile extends File { protected $repoClass = 'ForeignApiRepo'; /** - * @param $title - * @param $repo ForeignApiRepo - * @param $info + * @param Title|string|bool $title + * @param ForeignApiRepo $repo + * @param array $info * @param bool $exists */ function __construct( $title, $repo, $info, $exists = false ) { @@ -48,8 +48,8 @@ class ForeignAPIFile extends File { } /** - * @param $title Title - * @param $repo ForeignApiRepo + * @param Title $title + * @param ForeignApiRepo $repo * @return ForeignAPIFile|null */ static function newFromTitle( Title $title, $repo ) { @@ -57,7 +57,10 @@ class ForeignAPIFile extends File { 'titles' => 'File:' . $title->getDBkey(), 'iiprop' => self::getProps(), 'prop' => 'imageinfo', - 'iimetadataversion' => MediaHandler::getMetadataVersion() + 'iimetadataversion' => MediaHandler::getMetadataVersion(), + // extmetadata is language-dependant, accessing the current language here + // would be problematic, so we just get them all + 'iiextmetadatamultilang' => 1, ) ); $info = $repo->getImageInfo( $data ); @@ -75,6 +78,7 @@ class ForeignAPIFile extends File { } else { $img = new self( $title, $repo, $info, true ); } + return $img; } else { return null; @@ -86,7 +90,7 @@ class ForeignAPIFile extends File { * @return string */ static function getProps() { - return 'timestamp|user|comment|url|size|sha1|metadata|mime|mediatype'; + return 'timestamp|user|comment|url|size|sha1|metadata|mime|mediatype|extmetadata'; } // Dummy functions... @@ -130,6 +134,7 @@ class ForeignAPIFile extends File { ); if ( $thumbUrl === false ) { global $wgLang; + return $this->repo->getThumbError( $this->getName(), $width, @@ -138,13 +143,14 @@ class ForeignAPIFile extends File { $wgLang->getCode() ); } + return $this->handler->getTransform( $this, 'bogus', $thumbUrl, $params ); } // Info we can get from API... /** - * @param $page int + * @param int $page * @return int|number */ public function getWidth( $page = 1 ) { @@ -152,7 +158,7 @@ class ForeignAPIFile extends File { } /** - * @param $page int + * @param int $page * @return int */ public function getHeight( $page = 1 ) { @@ -166,11 +172,24 @@ class ForeignAPIFile extends File { if ( isset( $this->mInfo['metadata'] ) ) { return serialize( self::parseMetadata( $this->mInfo['metadata'] ) ); } + return null; } /** - * @param $metadata array + * @return array|null Extended metadata (see imageinfo API for format) or + * null on error + */ + public function getExtendedMetadata() { + if ( isset( $this->mInfo['extmetadata'] ) ) { + return $this->mInfo['extmetadata']; + } + + return null; + } + + /** + * @param array $metadata * @return array */ public static function parseMetadata( $metadata ) { @@ -181,6 +200,7 @@ class ForeignAPIFile extends File { foreach ( $metadata as $meta ) { $ret[$meta['name']] = self::parseMetadata( $meta['value'] ); } + return $ret; } @@ -207,6 +227,8 @@ class ForeignAPIFile extends File { } /** + * @param int $audience + * @param User $user * @return null|string */ public function getDescription( $audience = self::FOR_PUBLIC, User $user = null ) { @@ -214,7 +236,7 @@ class ForeignAPIFile extends File { } /** - * @return null|String + * @return null|string */ function getSha1() { return isset( $this->mInfo['sha1'] ) @@ -223,7 +245,7 @@ class ForeignAPIFile extends File { } /** - * @return bool|Mixed|string + * @return bool|string */ function getTimestamp() { return wfTimestamp( TS_MW, @@ -241,6 +263,7 @@ class ForeignAPIFile extends File { $magic = MimeMagic::singleton(); $this->mInfo['mime'] = $magic->guessTypesForExtension( $this->getExtension() ); } + return $this->mInfo['mime']; } @@ -252,6 +275,7 @@ class ForeignAPIFile extends File { return $this->mInfo['mediatype']; } $magic = MimeMagic::singleton(); + return $magic->getMediaType( null, $this->getMimeType() ); } @@ -266,7 +290,7 @@ class ForeignAPIFile extends File { /** * Only useful if we're locally caching thumbs anyway... - * @param $suffix string + * @param string $suffix * @return null|string */ function getThumbPath( $suffix = '' ) { @@ -275,6 +299,7 @@ class ForeignAPIFile extends File { if ( $suffix ) { $path = $path . $suffix . '/'; } + return $path; } else { return null; @@ -314,7 +339,7 @@ class ForeignAPIFile extends File { } /** - * @param $options array + * @param array $options */ function purgeThumbnails( $options = array() ) { global $wgMemc; |