$this->mInfo = $info;
}
+ static function newFromTitle( $title, $repo ) {
+ $info = $repo->getImageInfo( $title );
+ if( $info ) {
+ return new ForeignAPIFile( $title, $repo, $info );
+ } else {
+ return null;
+ }
+ }
+
// Dummy functions...
public function exists() {
return true;
return $this->mInfo['comment'];
}
+ function getSha1() {
+ return wfBaseConvert( $this->mInfo['sha1'], 16, 36, 31 );
+ }
+
+ function getTimestamp() {
+ return wfTimestamp( TS_MW, $this->mInfo['timestamp'] );
+ }
+
// Info we had to guess...
function getMimeType() {
return $this->mInfo['mime'];
* @ingroup FileRepo
*/
class ForeignAPIRepo extends FileRepo {
+ var $fileFactory = array( 'ForeignAPIFile', 'newFromTitle' );
protected $mQueryCache = array();
function __construct( $info ) {
function getFileProps( $virtualUrl ) {
return false;
}
- function newFile( $title, $time = false ) {
- return false;
- }
protected function queryImage( $query ) {
$data = $this->fetchImageQuery( $query );
return json_decode( $this->mQueryCache[$url], true );
}
- function findFile( $title, $time = false ) {
- $info = $this->queryImage( array(
+ function getImageInfo( $title, $time = false ) {
+ return $this->queryImage( array(
'titles' => 'Image:' . $title->getText(),
'iiprop' => 'timestamp|user|comment|url|size|sha1|metadata|mimetype' ) );
- if( $info ) {
- return new ForeignAPIFile( $title, $this, $info );
- } else {
- return false;
- }
}
function getThumbUrl( $name, $width=-1, $height=-1 ) {