diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2011-12-03 13:29:22 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2011-12-03 13:29:22 +0100 |
commit | ca32f08966f1b51fcb19460f0996bb0c4048e6fe (patch) | |
tree | ec04cc15b867bc21eedca904cea9af0254531a11 /includes/filerepo/RepoGroup.php | |
parent | a22fbfc60f36f5f7ee10d5ae6fe347340c2ee67c (diff) |
Update to MediaWiki 1.18.0
* also update ArchLinux skin to chagnes in MonoBook
* Use only css to hide our menu bar when printing
Diffstat (limited to 'includes/filerepo/RepoGroup.php')
-rw-r--r-- | includes/filerepo/RepoGroup.php | 56 |
1 files changed, 50 insertions, 6 deletions
diff --git a/includes/filerepo/RepoGroup.php b/includes/filerepo/RepoGroup.php index b9996941..d4875908 100644 --- a/includes/filerepo/RepoGroup.php +++ b/includes/filerepo/RepoGroup.php @@ -16,16 +16,26 @@ * @ingroup FileRepo */ class RepoGroup { - var $localRepo, $foreignRepos, $reposInitialised = false; + + /** + * @var LocalRepo + */ + var $localRepo; + + var $foreignRepos, $reposInitialised = false; var $localInfo, $foreignInfo; var $cache; + /** + * @var RepoGroup + */ protected static $instance; const MAX_CACHE_SIZE = 1000; /** * Get a RepoGroup instance. At present only one instance of RepoGroup is * needed in a MediaWiki invocation, this may change in the future. + * @return RepoGroup */ static function singleton() { if ( self::$instance ) { @@ -46,6 +56,8 @@ class RepoGroup { /** * Set the singleton instance to a given object + * + * @param $instance RepoGroup */ static function setSingleton( $instance ) { self::$instance = $instance; @@ -70,8 +82,8 @@ class RepoGroup { * Search repositories for an image. * You can also use wfFindFile() to do this. * - * @param $title Mixed: Title object or string - * @param $options Associative array of options: + * @param $title Title|string Title object or string + * @param $options array Associative array of options: * time: requested time for an archived image, or false for the * current version. An image object will be returned which was * created at the specified time. @@ -101,7 +113,7 @@ class RepoGroup { } if ( $title->getNamespace() != NS_MEDIA && $title->getNamespace() != NS_FILE ) { - throw new MWException( __METHOD__ . ' recieved an Title object with incorrect namespace' ); + throw new MWException( __METHOD__ . ' received an Title object with incorrect namespace' ); } # Check the cache @@ -204,14 +216,44 @@ class RepoGroup { return false; } + /** + * Find an instance of the file with this key, created at the specified time + * Returns false if the file does not exist. + * + * @param $hash String base 36 SHA-1 hash + * @param $options Option array, same as findFile() + * @return File object or false if it is not found + */ + function findFileFromKey( $hash, $options = array() ) { + if ( !$this->reposInitialised ) { + $this->initialiseRepos(); + } + + $file = $this->localRepo->findFileFromKey( $hash, $options ); + if ( !$file ) { + foreach ( $this->foreignRepos as $repo ) { + $file = $repo->findFileFromKey( $hash, $options ); + if ( $file ) break; + } + } + return $file; + } + + /** + * Find all instances of files with this key + * + * @param $hash String base 36 SHA-1 hash + * @return Array of File objects + */ function findBySha1( $hash ) { if ( !$this->reposInitialised ) { $this->initialiseRepos(); } $result = $this->localRepo->findBySha1( $hash ); - foreach ( $this->foreignRepos as $repo ) + foreach ( $this->foreignRepos as $repo ) { $result = array_merge( $result, $repo->findBySha1( $hash ) ); + } return $result; } @@ -247,6 +289,8 @@ class RepoGroup { /** * Get the local repository, i.e. the one corresponding to the local image * table. Files are typically uploaded to the local repository. + * + * @return LocalRepo */ function getLocalRepo() { return $this->getRepo( 'local' ); @@ -307,7 +351,7 @@ class RepoGroup { */ function splitVirtualUrl( $url ) { if ( substr( $url, 0, 9 ) != 'mwrepo://' ) { - throw new MWException( __METHOD__.': unknown protoocl' ); + throw new MWException( __METHOD__.': unknown protocol' ); } $bits = explode( '/', substr( $url, 9 ), 3 ); |