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