Tholam has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/98460


Change subject: Create ResourceLoaderLogoModule to load logo
......................................................................

Create ResourceLoaderLogoModule to load logo

logo is now loaded using a module instead of inline.

Bug: 56257
Change-Id: I47c52bb4aa266a309bf5affb4e9dbed3f3688669
---
M includes/AutoLoader.php
M includes/OutputPage.php
A includes/resourceloader/ResourceLoaderLogoModule.php
M resources/Resources.php
M skins/MonoBook.php
M skins/Vector.php
6 files changed, 52 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/60/98460/1

diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php
index 60ee2a8..d119369 100644
--- a/includes/AutoLoader.php
+++ b/includes/AutoLoader.php
@@ -840,6 +840,7 @@
        'ResourceLoaderFileModule' => 
'includes/resourceloader/ResourceLoaderFileModule.php',
        'ResourceLoaderFilePageModule' => 
'includes/resourceloader/ResourceLoaderFilePageModule.php',
        'ResourceLoaderLESSFunctions' => 
'includes/resourceloader/ResourceLoaderLESSFunctions.php',
+       'ResourceLoaderLogoModule' => 
'includes/resourceloader/ResourceLoaderLogoModule.php',
        'ResourceLoaderModule' => 
'includes/resourceloader/ResourceLoaderModule.php',
        'ResourceLoaderNoscriptModule' => 
'includes/resourceloader/ResourceLoaderNoscriptModule.php',
        'ResourceLoaderSiteModule' => 
'includes/resourceloader/ResourceLoaderSiteModule.php',
diff --git a/includes/OutputPage.php b/includes/OutputPage.php
index f1c7d5b..0eb53cb 100644
--- a/includes/OutputPage.php
+++ b/includes/OutputPage.php
@@ -3432,6 +3432,9 @@
                        $moduleStyles[] = 'user.cssprefs';
                }
 
+               // Add style for logo
+               $moduleStyles[] = 'logo';
+
                foreach ( $moduleStyles as $name ) {
                        $module = $resourceLoader->getModule( $name );
                        if ( !$module ) {
diff --git a/includes/resourceloader/ResourceLoaderLogoModule.php 
b/includes/resourceloader/ResourceLoaderLogoModule.php
new file mode 100644
index 0000000..c9e03cf
--- /dev/null
+++ b/includes/resourceloader/ResourceLoaderLogoModule.php
@@ -0,0 +1,45 @@
+<?php
+/**
+ * Resource loader module for logo.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @author Thomas Lam
+ */
+
+/**
+ * Module for user preference customizations
+ */
+class ResourceLoaderLogoModule extends ResourceLoaderModule {
+
+       /* Methods */
+
+       /**
+        * @param $context ResourceLoaderContext
+        * @return array
+        */
+       public function getStyles( ResourceLoaderContext $context ) {
+               global $wgLogo;
+
+               $styles = parent::getStyles( $context );
+               $styles['all'][] =
+                       "#p-logo a { background-image: url('" .
+                       addslashes($wgLogo) .
+                       "'); }";
+               return $styles;
+       }
+}
diff --git a/resources/Resources.php b/resources/Resources.php
index a022c6d..6804888 100644
--- a/resources/Resources.php
+++ b/resources/Resources.php
@@ -36,6 +36,7 @@
        'startup' => array( 'class' => 'ResourceLoaderStartUpModule' ),
        'filepage' => array( 'class' => 'ResourceLoaderFilePageModule' ),
        'user.groups' => array( 'class' => 'ResourceLoaderUserGroupsModule' ),
+       'logo' => array( 'class' => 'ResourceLoaderLogoModule' ),
 
        // Scripts managed by the current user (stored in their user space)
        'user' => array( 'class' => 'ResourceLoaderUserModule' ),
diff --git a/skins/MonoBook.php b/skins/MonoBook.php
index f7fb0d8..334a9ec 100644
--- a/skins/MonoBook.php
+++ b/skins/MonoBook.php
@@ -117,8 +117,7 @@
        <div class="portlet" id="p-logo" role="banner">
 <?php
                        echo Html::element( 'a', array(
-                               'href' => 
$this->data['nav_urls']['mainpage']['href'],
-                               'style' => "background-image: 
url({$this->data['logopath']});" )
+                               'href' => 
$this->data['nav_urls']['mainpage']['href'] )
                                + Linker::tooltipAndAccesskeyAttribs( 'p-logo' 
) ); ?>
 
        </div>
diff --git a/skins/Vector.php b/skins/Vector.php
index 288b5fd..f16fe0b 100644
--- a/skins/Vector.php
+++ b/skins/Vector.php
@@ -211,7 +211,7 @@
                                </div>
                        </div>
                        <div id="mw-panel">
-                                       <div id="p-logo" role="banner"><a 
style="background-image: url(<?php $this->text( 'logopath' ) ?>);" href="<?php 
echo htmlspecialchars( $this->data['nav_urls']['mainpage']['href'] ) ?>" <?php 
echo Xml::expandAttributes( Linker::tooltipAndAccesskeyAttribs( 'p-logo' ) ) 
?>></a></div>
+                                       <div id="p-logo" role="banner"><a 
href="<?php echo htmlspecialchars( $this->data['nav_urls']['mainpage']['href'] 
) ?>" <?php echo Xml::expandAttributes( Linker::tooltipAndAccesskeyAttribs( 
'p-logo' ) ) ?>></a></div>
                                <?php $this->renderPortals( 
$this->data['sidebar'] ); ?>
                        </div>
                </div>

-- 
To view, visit https://gerrit.wikimedia.org/r/98460
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I47c52bb4aa266a309bf5affb4e9dbed3f3688669
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Tholam <t....@lamsinfosystem.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to