moving SpecialUploadMogile.php from phase3/includes/specials to extensions/MogileClie...
[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 var $fileFromRowFactory = array( 'ForeignDBFile', 'newFromRow' );
16
17 function __construct( $info ) {
18 parent::__construct( $info );
19 $this->dbType = $info['dbType'];
20 $this->dbServer = $info['dbServer'];
21 $this->dbUser = $info['dbUser'];
22 $this->dbPassword = $info['dbPassword'];
23 $this->dbName = $info['dbName'];
24 $this->dbFlags = $info['dbFlags'];
25 $this->tablePrefix = $info['tablePrefix'];
26 $this->hasSharedCache = $info['hasSharedCache'];
27 }
28
29 function getMasterDB() {
30 if ( !isset( $this->dbConn ) ) {
31 $class = 'Database' . ucfirst( $this->dbType );
32 $this->dbConn = new $class( $this->dbServer, $this->dbUser,
33 $this->dbPassword, $this->dbName, false, $this->dbFlags,
34 $this->tablePrefix );
35 }
36 return $this->dbConn;
37 }
38
39 function getSlaveDB() {
40 return $this->getMasterDB();
41 }
42
43 function hasSharedCache() {
44 return $this->hasSharedCache;
45 }
46
47 /**
48 * Get a key on the primary cache for this repository.
49 * Returns false if the repository's cache is not accessible at this site.
50 * The parameters are the parts of the key, as for wfMemcKey().
51 */
52 function getSharedCacheKey( /*...*/ ) {
53 if ( $this->hasSharedCache() ) {
54 $args = func_get_args();
55 array_unshift( $args, $this->dbName, $this->tablePrefix );
56 return call_user_func_array( 'wfForeignMemcKey', $args );
57 } else {
58 return false;
59 }
60 }
61
62 function store( $srcPath, $dstZone, $dstRel, $flags = 0 ) {
63 throw new MWException( get_class($this) . ': write operations are not supported' );
64 }
65 function publish( $srcPath, $dstRel, $archiveRel, $flags = 0 ) {
66 throw new MWException( get_class($this) . ': write operations are not supported' );
67 }
68 function deleteBatch( $fileMap ) {
69 throw new MWException( get_class($this) . ': write operations are not supported' );
70 }
71 }