From 8073d4f2267d99f241d1c35dbb02ddd0bf8d12ed Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gerg=C5=91=20Tisza?= Date: Wed, 15 Jan 2014 20:38:11 +0000 Subject: [PATCH] Propagate the favicon information to getInfo() for local repos This is needed by MultimediaViewer to show a relevant icon next to the local and foreign db repo link in the description area The setting ends up in configuration for foreign DB, because the favicon value is stored in the configuration of a wiki, not in its database. Change-Id: I3d0599c1afa13e1d8540ff3c8bc34129a55792c5 --- includes/filerepo/FileRepo.php | 7 +++++-- includes/filerepo/ForeignDBRepo.php | 10 ++++++++++ includes/filerepo/LocalRepo.php | 13 +++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index cab5690f9b..12eff0ec4b 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -111,6 +111,9 @@ class FileRepo { */ protected $abbrvThreshold; + /** @var string The URL of the repo's favicon, if any */ + protected $favicon; + /** * Factory functions for creating new files * Override these in the base class @@ -147,7 +150,7 @@ class FileRepo { $optionalSettings = array( 'descBaseUrl', 'scriptDirUrl', 'articleUrl', 'fetchDescription', 'thumbScriptUrl', 'pathDisclosureProtection', 'descriptionCacheExpiry', - 'scriptExtension' + 'scriptExtension', 'favicon' ); foreach ( $optionalSettings as $var ) { if ( isset( $info[$var] ) ) { @@ -1845,7 +1848,7 @@ class FileRepo { $optionalSettings = array( 'url', 'thumbUrl', 'initialCapital', 'descBaseUrl', 'scriptDirUrl', 'articleUrl', - 'fetchDescription', 'descriptionCacheExpiry', 'scriptExtension' + 'fetchDescription', 'descriptionCacheExpiry', 'scriptExtension', 'favicon' ); foreach ( $optionalSettings as $k ) { if ( isset( $this->$k ) ) { diff --git a/includes/filerepo/ForeignDBRepo.php b/includes/filerepo/ForeignDBRepo.php index 92f017f6c6..6e9e6add48 100644 --- a/includes/filerepo/ForeignDBRepo.php +++ b/includes/filerepo/ForeignDBRepo.php @@ -126,4 +126,14 @@ class ForeignDBRepo extends LocalRepo { protected function assertWritableRepo() { throw new MWException( get_class( $this ) . ': write operations are not supported.' ); } + + /** + * Return information about the repository. + * + * @return array + * @since 1.22 + */ + function getInfo() { + return FileRepo::getInfo(); + } } diff --git a/includes/filerepo/LocalRepo.php b/includes/filerepo/LocalRepo.php index c5346aa1c4..5a99fd3174 100644 --- a/includes/filerepo/LocalRepo.php +++ b/includes/filerepo/LocalRepo.php @@ -491,4 +491,17 @@ class LocalRepo extends FileRepo { $wgMemc->set( $memcKey, ' PURGED', 12 ); } } + + /** + * Return information about the repository. + * + * @return array + * @since 1.22 + */ + function getInfo() { + global $wgFavicon; + return array_merge( parent::getInfo(), array( + 'favicon' => wfExpandUrl( $wgFavicon ), + ) ); + } } -- 2.20.1