From: Aaron Schulz Date: Sun, 10 Aug 2008 07:14:08 +0000 (+0000) Subject: Another go at extension CSS order X-Git-Tag: 1.31.0-rc.0~45977 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=b80edb5f27cb8327689bcae159d28c89f4b562a5;p=lhc%2Fweb%2Fwiklou.git Another go at extension CSS order --- diff --git a/includes/OutputPage.php b/includes/OutputPage.php index e985cb795a..9fcac1b3c1 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -7,6 +7,7 @@ if ( ! defined( 'MEDIAWIKI' ) ) */ class OutputPage { var $mMetatags = array(), $mKeywords = array(), $mLinktags = array(); + var $mExtStyles = array(); var $mPagetitle = '', $mBodytext = '', $mDebugtext = ''; var $mHTMLtitle = '', $mIsarticle = true, $mPrintable = false; var $mSubtitle = '', $mRedirect = '', $mStatusCode; @@ -76,6 +77,11 @@ class OutputPage { 'href' => $wgStylePath . '/' . $style . '?' . $wgStyleVersion, 'type' => 'text/css' ) ); } + + function addExtensionStyle( $url ) { + $linkarr = array( 'rel' => 'stylesheet', 'href' => $url, 'type' => 'text/css' ); + array_push( $this->mExtStyles, $linkarr ); + } /** * Add a JavaScript file out of skins/common, or a given relative path. @@ -88,7 +94,6 @@ class OutputPage { } else { $path = "{$wgStylePath}/common/{$file}"; } - $encPath = htmlspecialchars( $path ); $this->addScript( "\n" ); } @@ -129,6 +134,11 @@ class OutputPage { # $linkarr should be an associative array of attributes. We'll escape on output. array_push( $this->mLinktags, $linkarr ); } + + # Get all links added by extensions + function getExtStyle() { + return $this->mExtStyles; + } function addMetadataLink( $linkarr ) { # note: buggy CC software only reads first "meta" link @@ -1409,8 +1419,13 @@ class OutputPage { $ret .= "\n"; $sk = $wgUser->getSkin(); + // Load order here is key $ret .= $sk->getHeadScripts( $this->mAllowUserJs ); $ret .= $this->mScripts; + $ret .= $sk->getSiteStyles(); + foreach( $this->mExtStyles as $tag ) { + $ret .= Xml::element( 'link', $tag ) . "\n"; + } $ret .= $sk->getUserStyles(); $ret .= $this->getHeadItems(); diff --git a/includes/Skin.php b/includes/Skin.php index f13b75ad84..39d5c57842 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -434,21 +434,30 @@ class Skin extends Linker { $wgRequest->getVal( 'wpEditToken' ) ); } - # get the user/site-specific stylesheet, SkinTemplate loads via RawPage.php (settings are cached that way) - function getUserStylesheet() { - global $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage, $wgStyleVersion; + /** + * Get the site-specific stylesheet, SkinTemplate loads via RawPage.php (settings are cached that way) + */ + function getSiteStylesheet() { + global $wgStylePath, $wgContLang, $wgStyleVersion; $sheet = $this->getStylesheet(); $s = "@import \"$wgStylePath/common/shared.css?$wgStyleVersion\";\n"; $s .= "@import \"$wgStylePath/common/oldshared.css?$wgStyleVersion\";\n"; $s .= "@import \"$wgStylePath/$sheet?$wgStyleVersion\";\n"; - if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css?$wgStyleVersion\";\n"; + if( $wgContLang->isRTL() ) + $s .= "@import \"$wgStylePath/common/common_rtl.css?$wgStyleVersion\";\n"; + return "$s\n"; + } + /** + * Get the user-specific stylesheet, SkinTemplate loads via RawPage.php (settings are cached that way) + */ + function getUserStylesheet() { + global $wgContLang, $wgSquidMaxage, $wgStyleVersion; $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage"; - $s .= '@import "' . self::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI ) . "\";\n" . - '@import "' . self::makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI ) . "\";\n"; - + $s = '@import "' . self::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI ) . "\";\n"; + $s .= '@import "' . self::makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI ) . "\";\n"; $s .= $this->doGetUserStyles(); - return $s."\n"; + return "$s\n"; } /** @@ -478,6 +487,18 @@ class Skin extends Linker { return $s; } + /** + * Return html code that include site stylesheets + */ + function getSiteStyles() { + $s = "\n"; + return $s; + } + /** * Return html code that include User stylesheets */ diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 89b0f690d8..d1b2af670e 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -182,7 +182,7 @@ class SkinTemplate extends Skin { } $this->usercss = $this->userjs = $this->userjsprev = false; - $this->setupUserCss(); + $this->setupUserCss( $out->getExtStyle() ); $this->setupUserJs( $out->isUserJsAllowed() ); $this->titletxt = $this->mTitle->getPrefixedText(); wfProfileOut( __METHOD__."-stuff" ); @@ -966,7 +966,7 @@ class SkinTemplate extends Skin { /** * @private */ - function setupUserCss() { + function setupUserCss( $extCSS = array() ) { global $wgRequest, $wgAllowUserCss, $wgUseSiteCss, $wgContLang, $wgSquidMaxage, $wgStylePath, $wgUser; wfProfileIn( __METHOD__ ); @@ -981,6 +981,11 @@ class SkinTemplate extends Skin { $siteargs['smaxage'] = '0'; $siteargs['ts'] = $wgUser->mTouched; } + + // Add any extension CSS + foreach( $extCSS as $tag ) { + $this->addStyle( $tag['href'] ); + } // If we use the site's dynamic CSS, throw that in, too // Per-site custom styles