4 * A foreign repository with a remote MediaWiki with an API thingy
5 * Very hacky and inefficient
10 class ForeignAPIRepo
extends FileRepo
{
11 function __construct( $info ) {
12 parent
::__construct( $info );
13 $this->mApiBase
= $info['apibase']; // http://commons.wikimedia.org/w/api.php
16 function storeBatch( $triplets, $flags = 0 ) {
20 function storeTemp( $originalName, $srcPath ) {
23 function publishBatch( $triplets, $flags = 0 ) {
26 function deleteBatch( $sourceDestPairs ) {
29 function getFileProps( $virtualUrl ) {
32 function newFile( $title, $time = false ) {
35 function findFile( $title, $time = false ) {
36 $url = $this->mApiBase
.
41 'titles' => $title, // fixme -- canonical namespacea
42 'prop' => 'imageinfo',
43 'iiprop' => 'timestamp|user|comment|url|size|sha1|metadata' ) );
44 $json = Http
::get( $url );
45 $data = json_decode( $json, true );
47 if( isset( $data['query']['pages'] ) ) {
48 foreach( $data['query']['pages'] as $pageid => $info ) {
49 if( isset( $info['imageinfo'][0] ) ) {
50 return new ForeignAPIFile( $title, $this, $info['imageinfo'][0] );