4 * Very hacky and inefficient
9 class ForeignAPIFile
extends File
{
10 function __construct( $title, $repo, $info ) {
11 parent
::__construct( $title, $repo );
15 static function newFromTitle( $title, $repo ) {
16 $info = $repo->getImageInfo( $title );
18 return new ForeignAPIFile( $title, $repo, $info );
25 public function exists() {
29 public function getPath() {
33 function transform( $params, $flags = 0 ) {
34 $thumbUrl = $this->repo
->getThumbUrl(
36 isset( $params['width'] ) ?
$params['width'] : -1,
37 isset( $params['height'] ) ?
$params['height'] : -1 );
39 wfDebug( __METHOD__
. " got remote thumb $thumbUrl\n" );
40 return $this->handler
->getTransform( $this, 'bogus', $thumbUrl, $params );;
45 // Info we can get from API...
46 public function getWidth( $page = 1 ) {
47 return intval( @$this->mInfo
['width'] );
50 public function getHeight( $page = 1 ) {
51 return intval( @$this->mInfo
['height'] );
54 public function getMetadata() {
55 return serialize( (array)@$this->mInfo
['metadata'] );
58 public function getSize() {
59 return intval( @$this->mInfo
['size'] );
62 public function getUrl() {
63 return strval( @$this->mInfo
['url'] );
66 public function getUser( $method='text' ) {
67 return strval( @$this->mInfo
['user'] );
70 public function getDescription() {
71 return strval( @$this->mInfo
['comment'] );
75 return wfBaseConvert( strval( @$this->mInfo
['sha1'] ), 16, 36, 31 );
78 function getTimestamp() {
79 return wfTimestamp( TS_MW
, strval( @$this->mInfo
['timestamp'] ) );
82 function getMimeType() {
83 if( empty( $info['mime'] ) ) {
84 $magic = MimeMagic
::singleton();
85 $info['mime'] = $magic->guessTypesForExtension( $this->getExtension() );
90 /// @fixme May guess wrong on file types that can be eg audio or video
91 function getMediaType() {
92 $magic = MimeMagic
::singleton();
93 return $magic->getMediaType( null, $this->getMimeType() );
96 function getDescriptionUrl() {
97 return isset( $this->mInfo
['descriptionurl'] )
98 ?
$this->mInfo
['descriptionurl']