4 * Very hacky and inefficient
9 class ForeignAPIFile
extends File
{
10 function __construct( $title, $repo, $info ) {
11 parent
::__construct( $title, $repo );
13 // For some reason API doesn't currently provide type info
14 $magic = MimeMagic
::singleton();
15 $info['mime'] = $magic->guessTypesForExtension( $this->getExtension() );
16 list( $info['major_mime'], $info['minor_mime'] ) = self
::splitMime( $info['mime'] );
17 $info['media_type'] = $magic->getMediaType( null, $info['mime'] );
23 public function exists() {
27 public function getPath() {
31 function transform( $params, $flags = 0 ) {
32 $thumbUrl = $this->repo
->getThumbUrl(
34 isset( $params['width'] ) ?
$params['width'] : -1,
35 isset( $params['height'] ) ?
$params['height'] : -1 );
37 wfDebug( __METHOD__
. " got remote thumb $thumbUrl\n" );
38 return $this->handler
->getTransform( $this, 'bogus', $thumbUrl, $params );;
43 // Info we can get from API...
44 public function getWidth( $page = 1 ) {
45 return intval( $this->mInfo
['width'] );
48 public function getHeight( $page = 1 ) {
49 return intval( $this->mInfo
['height'] );
52 public function getMetadata() {
53 return serialize( (array)$this->mInfo
['metadata'] );
56 public function getSize() {
57 return intval( $this->mInfo
['size'] );
60 public function getUrl() {
61 return $this->mInfo
['url'];
64 public function getUser( $method='text' ) {
65 return $this->mInfo
['user'];
68 public function getDescription() {
69 return $this->mInfo
['comment'];
72 // Info we had to guess...
73 function getMimeType() {
74 return $this->mInfo
['mime'];
77 function getMediaType() {
78 return $this->mInfo
['media_type'];
81 function getDescriptionUrl() {
82 return isset( $this->mInfo
['descriptionurl'] )
83 ?
$this->mInfo
['descriptionurl']