]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blob - includes/filerepo/ForeignDBRepo.php
MediaWiki 1.11.0
[autoinstalls/mediawiki.git] / includes / filerepo / ForeignDBRepo.php
1 <?php
2
3 /**
4  * A foreign repository with an accessible MediaWiki database
5  */
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 __construct( $info ) {
17                 parent::__construct( $info );
18                 $this->dbType = $info['dbType'];
19                 $this->dbServer = $info['dbServer'];
20                 $this->dbUser = $info['dbUser'];
21                 $this->dbPassword = $info['dbPassword'];
22                 $this->dbName = $info['dbName'];
23                 $this->dbFlags = $info['dbFlags'];
24                 $this->tablePrefix = $info['tablePrefix'];
25                 $this->hasSharedCache = $info['hasSharedCache'];
26         }
27
28         function getMasterDB() {
29                 if ( !isset( $this->dbConn ) ) {
30                         $class = 'Database' . ucfirst( $this->dbType );
31                         $this->dbConn = new $class( $this->dbServer, $this->dbUser, 
32                                 $this->dbPassword, $this->dbName, false, $this->dbFlags, 
33                                 $this->tablePrefix );
34                 }
35                 return $this->dbConn;
36         }
37
38         function getSlaveDB() {
39                 return $this->getMasterDB();
40         }
41
42         function hasSharedCache() {
43                 return $this->hasSharedCache;
44         }
45
46         function store( $srcPath, $dstZone, $dstRel, $flags = 0 ) {
47                 throw new MWException( get_class($this) . ': write operations are not supported' );
48         }
49         function publish( $srcPath, $dstRel, $archiveRel, $flags = 0 ) {
50                 throw new MWException( get_class($this) . ': write operations are not supported' );
51         }
52         function deleteBatch( $fileMap ) {
53                 throw new MWException( get_class($this) . ': write operations are not supported' );
54         }
55 }
56
57