2008-05-20 06:30:36 +00:00
|
|
|
<?php
|
|
|
|
|
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
/**
|
|
|
|
|
* Very hacky and inefficient
|
|
|
|
|
* do not use :D
|
|
|
|
|
*
|
|
|
|
|
* @ingroup FileRepo
|
|
|
|
|
*/
|
2008-05-20 06:30:36 +00:00
|
|
|
class ForeignAPIFile extends File {
|
|
|
|
|
function __construct( $title, $repo, $info ) {
|
|
|
|
|
parent::__construct( $title, $repo );
|
|
|
|
|
$this->mInfo = $info;
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-22 16:17:42 +00:00
|
|
|
static function newFromTitle( $title, $repo ) {
|
|
|
|
|
$info = $repo->getImageInfo( $title );
|
|
|
|
|
if( $info ) {
|
|
|
|
|
return new ForeignAPIFile( $title, $repo, $info );
|
|
|
|
|
} else {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-20 06:30:36 +00:00
|
|
|
// Dummy functions...
|
|
|
|
|
public function exists() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getPath() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2008-05-21 22:39:08 +00:00
|
|
|
|
|
|
|
|
function transform( $params, $flags = 0 ) {
|
2008-07-31 22:06:54 +00:00
|
|
|
if ( $this->repo->apiThumbCacheExpiry > 0 && $this->repo->apiThumbCacheDir ) {
|
2008-07-24 17:14:43 +00:00
|
|
|
$thumbUrl = $this->repo->getThumbUrlFromCache(
|
|
|
|
|
$this->getName(),
|
|
|
|
|
isset( $params['width'] ) ? $params['width'] : -1,
|
|
|
|
|
isset( $params['height'] ) ? $params['height'] : -1 );
|
|
|
|
|
} else {
|
|
|
|
|
$thumbUrl = $this->repo->getThumbUrl(
|
|
|
|
|
$this->getName(),
|
|
|
|
|
isset( $params['width'] ) ? $params['width'] : -1,
|
|
|
|
|
isset( $params['height'] ) ? $params['height'] : -1 );
|
|
|
|
|
}
|
2008-05-21 22:39:08 +00:00
|
|
|
if( $thumbUrl ) {
|
2008-07-03 21:12:32 +00:00
|
|
|
return $this->handler->getTransform( $this, 'bogus', $thumbUrl, $params );;
|
2008-05-21 22:39:08 +00:00
|
|
|
}
|
|
|
|
|
return false;
|
2008-05-20 06:30:36 +00:00
|
|
|
}
|
2008-05-21 22:39:08 +00:00
|
|
|
|
2008-05-20 06:30:36 +00:00
|
|
|
// Info we can get from API...
|
|
|
|
|
public function getWidth( $page = 1 ) {
|
2008-05-22 16:25:45 +00:00
|
|
|
return intval( @$this->mInfo['width'] );
|
2008-05-20 06:30:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getHeight( $page = 1 ) {
|
2008-05-22 16:25:45 +00:00
|
|
|
return intval( @$this->mInfo['height'] );
|
2008-05-20 06:30:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getMetadata() {
|
2008-05-22 16:25:45 +00:00
|
|
|
return serialize( (array)@$this->mInfo['metadata'] );
|
2008-05-20 06:30:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getSize() {
|
2008-05-22 16:25:45 +00:00
|
|
|
return intval( @$this->mInfo['size'] );
|
2008-05-20 06:30:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getUrl() {
|
2008-05-22 16:25:45 +00:00
|
|
|
return strval( @$this->mInfo['url'] );
|
2008-05-20 06:30:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getUser( $method='text' ) {
|
2008-05-22 16:25:45 +00:00
|
|
|
return strval( @$this->mInfo['user'] );
|
2008-05-20 06:30:36 +00:00
|
|
|
}
|
|
|
|
|
|
2008-05-21 22:39:08 +00:00
|
|
|
public function getDescription() {
|
2008-05-22 16:25:45 +00:00
|
|
|
return strval( @$this->mInfo['comment'] );
|
2008-05-20 06:30:36 +00:00
|
|
|
}
|
|
|
|
|
|
2008-05-22 16:17:42 +00:00
|
|
|
function getSha1() {
|
2008-05-22 16:25:45 +00:00
|
|
|
return wfBaseConvert( strval( @$this->mInfo['sha1'] ), 16, 36, 31 );
|
2008-05-22 16:17:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getTimestamp() {
|
2008-05-22 16:25:45 +00:00
|
|
|
return wfTimestamp( TS_MW, strval( @$this->mInfo['timestamp'] ) );
|
2008-05-22 16:17:42 +00:00
|
|
|
}
|
|
|
|
|
|
2008-05-20 06:30:36 +00:00
|
|
|
function getMimeType() {
|
2008-05-22 16:25:45 +00:00
|
|
|
if( empty( $info['mime'] ) ) {
|
|
|
|
|
$magic = MimeMagic::singleton();
|
|
|
|
|
$info['mime'] = $magic->guessTypesForExtension( $this->getExtension() );
|
|
|
|
|
}
|
|
|
|
|
return $info['mime'];
|
2008-05-20 06:30:36 +00:00
|
|
|
}
|
|
|
|
|
|
2008-05-22 16:25:45 +00:00
|
|
|
/// @fixme May guess wrong on file types that can be eg audio or video
|
2008-05-20 06:30:36 +00:00
|
|
|
function getMediaType() {
|
2008-05-22 16:25:45 +00:00
|
|
|
$magic = MimeMagic::singleton();
|
|
|
|
|
return $magic->getMediaType( null, $this->getMimeType() );
|
2008-05-20 06:30:36 +00:00
|
|
|
}
|
2008-05-21 22:39:08 +00:00
|
|
|
|
|
|
|
|
function getDescriptionUrl() {
|
|
|
|
|
return isset( $this->mInfo['descriptionurl'] )
|
|
|
|
|
? $this->mInfo['descriptionurl']
|
|
|
|
|
: false;
|
|
|
|
|
}
|
2008-05-20 06:30:36 +00:00
|
|
|
}
|