Propagate the favicon information to getInfo() for local repos
authorGergő Tisza <tgr.huwiki@gmail.com>
Wed, 15 Jan 2014 20:38:11 +0000 (20:38 +0000)
committergilles <gdubuc@wikimedia.org>
Fri, 17 Jan 2014 10:31:16 +0000 (11:31 +0100)
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
includes/filerepo/ForeignDBRepo.php
includes/filerepo/LocalRepo.php

index cab5690..12eff0e 100644 (file)
@@ -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 ) ) {
index 92f017f..6e9e6ad 100644 (file)
@@ -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();
+       }
 }
index c5346aa..5a99fd3 100644 (file)
@@ -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 ),
+               ) );
+       }
 }