WARNING: HUGE COMMIT
[lhc/web/wiklou.git] / includes / filerepo / ForeignDBRepo.php
1 <?php
2
3 /**
4 * A foreign repository with a remote MediaWiki with an API thingy
5 * Very hacky and inefficient
6 * do not use :D
7 * @ingroup FileRepo
8 */
9 class ForeignDBRepo extends LocalRepo {
10 # Settings
11 var $dbType, $dbServer, $dbUser, $dbPassword, $dbName, $dbFlags,
12 $tablePrefix, $hasSharedCache;
13
14 # Other stuff
15 var $dbConn;
16 var $fileFactory = array( 'ForeignDBFile', 'newFromTitle' );
17
18 function newFileFromRow( $row ) {
19 if ( isset( $row->img_name ) )
20 return ForeignDBFile::newFromRow( $row, $this );
21 return parent::newFileFromRow( $row );
22 }
23
24 function __construct( $info ) {
25 parent::__construct( $info );
26 $this->dbType = $info['dbType'];
27 $this->dbServer = $info['dbServer'];
28 $this->dbUser = $info['dbUser'];
29 $this->dbPassword = $info['dbPassword'];
30 $this->dbName = $info['dbName'];
31 $this->dbFlags = $info['dbFlags'];
32 $this->tablePrefix = $info['tablePrefix'];
33 $this->hasSharedCache = $info['hasSharedCache'];
34 }
35
36 function getMasterDB() {
37 if ( !isset( $this->dbConn ) ) {
38 $class = 'Database' . ucfirst( $this->dbType );
39 $this->dbConn = new $class( $this->dbServer, $this->dbUser,
40 $this->dbPassword, $this->dbName, false, $this->dbFlags,
41 $this->tablePrefix );
42 }
43 return $this->dbConn;
44 }
45
46 function getSlaveDB() {
47 return $this->getMasterDB();
48 }
49
50 function hasSharedCache() {
51 return $this->hasSharedCache;
52 }
53
54 function store( $srcPath, $dstZone, $dstRel, $flags = 0 ) {
55 throw new MWException( get_class($this) . ': write operations are not supported' );
56 }
57 function publish( $srcPath, $dstRel, $archiveRel, $flags = 0 ) {
58 throw new MWException( get_class($this) . ': write operations are not supported' );
59 }
60 function deleteBatch( $fileMap ) {
61 throw new MWException( get_class($this) . ': write operations are not supported' );
62 }
63 }