Set site logo url in ResourceLoaderSiteModule instead of inline styles
authortholam <t.lam@lamsinfosystem.com>
Sun, 1 Dec 2013 00:49:21 +0000 (18:49 -0600)
committerKrinkle <krinklemail@gmail.com>
Mon, 22 Sep 2014 18:12:02 +0000 (18:12 +0000)
Requires skins to use the 'mw-wiki-logo' class on the logo element
for the styles to apply. This is backwards compatible with skins
not using that class and using inline styles instead.

Bug: 56257
Change-Id: I89e32fcd27c9f07e889aa5b67d7d97d06b412aea

RELEASE-NOTES-1.25
includes/resourceloader/ResourceLoaderSiteModule.php

index c935ffe..c8bea32 100644 (file)
@@ -27,6 +27,8 @@ changes to languages because of Bugzilla reports.
   removed. See https://www.mediawiki.org/wiki/Manual:Skin_autodiscovery for
   migration guide for creators and users of custom skins that relied on it. 
 * Javascript variable 'wgFileCanRotate' now only available on Special:Upload.
+* (bug 56257) Set site logo url in ResourceLoaderSiteModule instead of inline
+  styles in the HTML output.
 
 == Compatibility ==
 
index 1d9721a..6de3d73 100644 (file)
@@ -53,6 +53,49 @@ class ResourceLoaderSiteModule extends ResourceLoaderWikiModule {
 
        /* Methods */
 
+       /**
+        * @param $context ResourceLoaderContext
+        * @return array
+        */
+       public function getStyles( ResourceLoaderContext $context ) {
+               global $wgLogo;
+
+               $styles = parent::getStyles( $context );
+               $styles['all'][] = '.mw-wiki-logo { background-image: ' .
+                       CSSMin::buildUrlValue( $wgLogo ) .
+                       '; }';
+
+               return $styles;
+       }
+
+       /**
+        * @param $context ResourceLoaderContext
+        * @return boolean
+        */
+       public function isKnownEmpty( ResourceLoaderContext $context ) {
+               // Regardless of whether the wiki page(s) exist, we always
+               // provide mw-wiki-logo styles.
+               return false;
+       }
+
+       /**
+        * @param $context ResourceLoaderContext
+        * @return int|mixed
+        */
+       public function getModifiedTime( ResourceLoaderContext $context ) {
+               $parentMTime = parent::getModifiedTime( $context );
+               return max( $parentMTime, $this->getHashMtime( $context ) );
+       }
+
+       /**
+        * @param $context ResourceLoaderContext
+        * @return string: Hash
+        */
+       public function getModifiedHash( ResourceLoaderContext $context ) {
+               global $wgLogo;
+               return md5( parent::getModifiedHash( $context ) . $wgLogo );
+       }
+
        /**
         * Gets group name
         *