Index: trunk/phase3/includes/SkinTemplate.php |
— | — | @@ -142,7 +142,7 @@ |
143 | 143 | global $wgDisableCounters, $wgLogo, $action, $wgFeedClasses, $wgHideInterlanguageLinks; |
144 | 144 | global $wgMaxCredits, $wgShowCreditsIfMax; |
145 | 145 | global $wgPageShowWatchingUsers; |
146 | | - global $wgUseTrackbacks; |
| 146 | + global $wgUseTrackbacks, $wgUseSiteJs; |
147 | 147 | global $wgArticlePath, $wgScriptPath, $wgServer, $wgLang, $wgCanonicalNamespaceNames; |
148 | 148 | |
149 | 149 | wfProfileIn( __METHOD__ ); |
— | — | @@ -282,8 +282,7 @@ |
283 | 283 | $tpl->setRef( 'usercss', $this->usercss); |
284 | 284 | $tpl->setRef( 'userjs', $this->userjs); |
285 | 285 | $tpl->setRef( 'userjsprev', $this->userjsprev); |
286 | | - global $wgUseSiteJs; |
287 | | - if ($wgUseSiteJs) { |
| 286 | + if( $wgUseSiteJs ) { |
288 | 287 | $jsCache = $this->loggedin ? '&smaxage=0' : ''; |
289 | 288 | $tpl->set( 'jsvarurl', |
290 | 289 | self::makeUrl('-', |
— | — | @@ -330,7 +329,7 @@ |
331 | 330 | |
332 | 331 | wfProfileIn( __METHOD__."-stuff3" ); |
333 | 332 | $tpl->setRef( 'newtalk', $ntl ); |
334 | | - $tpl->setRef( 'skin', $this); |
| 333 | + $tpl->setRef( 'skin', $this ); |
335 | 334 | $tpl->set( 'logo', $this->logoText() ); |
336 | 335 | if ( $wgOut->isArticle() and (!isset( $oldid ) or isset( $diff )) and |
337 | 336 | $wgArticle and 0 != $wgArticle->getID() ) |
— | — | @@ -961,44 +960,63 @@ |
962 | 961 | } |
963 | 962 | |
964 | 963 | /** |
| 964 | + * Callback to get args for CSS query string, a bit like wfArrayTpCGI, but |
| 965 | + * does not escape args |
| 966 | + * |
| 967 | + * @param $val |
| 968 | + * @param $key |
| 969 | + */ |
| 970 | + static function cssWalkCallback( &$val, $key ){ |
| 971 | + $val = "$key=$val"; |
| 972 | + } |
| 973 | + |
| 974 | + /** |
965 | 975 | * @private |
966 | 976 | */ |
967 | 977 | function setupUserCss() { |
| 978 | + global $wgRequest, $wgAllowUserCss, $wgUseSiteCss, $wgContLang, $wgSquidMaxage, $wgStylePath, $wgUser; |
| 979 | + |
968 | 980 | wfProfileIn( __METHOD__ ); |
969 | 981 | |
970 | | - global $wgRequest, $wgAllowUserCss, $wgUseSiteCss, $wgContLang, $wgSquidMaxage, $wgStylePath, $wgUser; |
971 | | - |
972 | | - $usercss = ''; |
973 | | - $siteargs = '&maxage=' . $wgSquidMaxage; |
| 982 | + $siteargs = array( |
| 983 | + 'action' => 'raw', |
| 984 | + 'maxage' => $wgSquidMaxage, |
| 985 | + ); |
974 | 986 | if( $this->loggedin ) { |
975 | 987 | // Ensure that logged-in users' generated CSS isn't clobbered |
976 | 988 | // by anons' publicly cacheable generated CSS. |
977 | | - $siteargs .= '&smaxage=0'; |
978 | | - $siteargs .= '&ts=' . $wgUser->mTouched; |
| 989 | + $siteargs['smaxage'] = '0'; |
| 990 | + $siteargs['ts'] = $wgUser->mTouched; |
979 | 991 | } |
980 | 992 | |
981 | | - # If we use the site's dynamic CSS, throw that in, too |
| 993 | + // If we use the site's dynamic CSS, throw that in, too |
982 | 994 | // Per-site custom styles |
983 | 995 | if ( $wgUseSiteCss ) { |
984 | | - $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage"; |
985 | | - $skinquery = ''; |
986 | | - if (($us = $wgRequest->getVal('useskin', '')) !== '') |
987 | | - $skinquery = "&useskin=$us"; |
988 | | - |
989 | | - $this->addStyle( self::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI) ); |
990 | | - $this->addStyle( self::makeNSUrl( ucfirst( $this->skinname ) . '.css', $query, NS_MEDIAWIKI ), |
| 996 | + $query = array( |
| 997 | + 'usemsgcache' => 'yes', |
| 998 | + 'ctype' => 'text/css', |
| 999 | + 'smaxage' => $wgSquidMaxage |
| 1000 | + ) + $siteargs; |
| 1001 | + array_walk( $query, array( __CLASS__, 'cssWalkCallback' ) ); |
| 1002 | + $queryString = implode( '&', $query ); |
| 1003 | + $this->addStyle( self::makeNSUrl( 'Common.css', $queryString, NS_MEDIAWIKI ) ); |
| 1004 | + $this->addStyle( self::makeNSUrl( ucfirst( $this->skinname ) . '.css', $queryString, NS_MEDIAWIKI ), |
991 | 1005 | 'screen' ); |
992 | 1006 | } |
993 | 1007 | |
994 | 1008 | // Per-user styles based on preferences |
995 | | - $this->addStyle( self::makeUrl( '-', "action=raw&gen=css$siteargs$skinquery" ), 'screen' ); |
| 1009 | + $siteargs['gen'] = 'css'; |
| 1010 | + if( ( $us = $wgRequest->getVal( 'useskin', '' ) ) !== '' ) |
| 1011 | + $siteargs['useskin'] = $us; |
| 1012 | + array_walk( $siteargs, array( __CLASS__, 'cssWalkCallback' ) ); |
| 1013 | + $this->addStyle( self::makeUrl( '-', implode( '&', $siteargs ) ), 'screen' ); |
996 | 1014 | |
997 | 1015 | // Per-user custom style pages |
998 | 1016 | if ( $wgAllowUserCss && $this->loggedin ) { |
999 | 1017 | $action = $wgRequest->getVal('action'); |
1000 | 1018 | |
1001 | 1019 | # if we're previewing the CSS page, use it |
1002 | | - if( $this->mTitle->isCssSubpage() and $this->userCanPreview( $action ) ) { |
| 1020 | + if( $this->mTitle->isCssSubpage() && $this->userCanPreview( $action ) ) { |
1003 | 1021 | $previewCss = $wgRequest->getText('wpTextbox1'); |
1004 | 1022 | |
1005 | 1023 | /// @fixme properly escape the cdata! |
— | — | @@ -1115,13 +1133,11 @@ |
1116 | 1134 | * These will be applied to various media & IE conditionals. |
1117 | 1135 | */ |
1118 | 1136 | protected function buildCssLinks() { |
1119 | | - global $wgContLang; |
1120 | | - |
1121 | 1137 | foreach( $this->styles as $file => $options ) { |
1122 | 1138 | $links[] = $this->styleLink( $file, $options ); |
1123 | 1139 | } |
1124 | 1140 | |
1125 | | - return implode( "\n", $links ); |
| 1141 | + return implode( "\n\t\t", $links ); |
1126 | 1142 | } |
1127 | 1143 | |
1128 | 1144 | protected function styleLink( $style, $options ) { |
Index: trunk/phase3/includes/Skin.php |
— | — | @@ -280,14 +280,14 @@ |
281 | 281 | static function makeVariablesScript( $data ) { |
282 | 282 | global $wgJsMimeType; |
283 | 283 | |
284 | | - $r = "<script type= \"$wgJsMimeType\">/*<![CDATA[*/\n"; |
| 284 | + $r = array( "<script type= \"$wgJsMimeType\">/*<![CDATA[*/" ); |
285 | 285 | foreach ( $data as $name => $value ) { |
286 | 286 | $encValue = Xml::encodeJsVar( $value ); |
287 | | - $r .= "var $name = $encValue;\n"; |
| 287 | + $r[] = "var $name = $encValue;"; |
288 | 288 | } |
289 | | - $r .= "/*]]>*/</script>\n"; |
| 289 | + $r[] = "/*]]>*/</script>\n"; |
290 | 290 | |
291 | | - return $r; |
| 291 | + return implode( "\n\t\t", $r ); |
292 | 292 | } |
293 | 293 | |
294 | 294 | /** |
Index: trunk/phase3/skins/MonoBook.php |
— | — | @@ -75,7 +75,7 @@ |
76 | 76 | <meta http-equiv="Content-Type" content="<?php $this->text('mimetype') ?>; charset=<?php $this->text('charset') ?>" /> |
77 | 77 | <?php $this->html('headlinks') ?> |
78 | 78 | <title><?php $this->text('pagetitle') ?></title> |
79 | | -<?php $this->html('csslinks') ?> |
| 79 | + <?php $this->html('csslinks') ?> |
80 | 80 | |
81 | 81 | <!--[if lt IE 7]><script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath') ?>/common/IEFixes.js?<?php echo $GLOBALS['wgStyleVersion'] ?>"></script> |
82 | 82 | <meta http-equiv="imagetoolbar" content="no" /><![endif]--> |
Index: trunk/phase3/skins/Modern.php |
— | — | @@ -21,15 +21,18 @@ |
22 | 22 | * skin L&F. |
23 | 23 | */ |
24 | 24 | function getPoweredBy() { |
25 | | - global $wgVersion; |
| 25 | + global $wgVersion; |
26 | 26 | return "<div class='mw_poweredby'>Powered by MediaWiki $wgVersion</div>"; |
27 | 27 | } |
28 | 28 | |
29 | 29 | function initPage( &$out ) { |
30 | | - SkinTemplate::initPage( $out ); |
| 30 | + Skin::initPage( $out ); |
31 | 31 | $this->skinname = 'modern'; |
32 | 32 | $this->stylename = 'modern'; |
33 | 33 | $this->template = 'ModernTemplate'; |
| 34 | + |
| 35 | + $this->addStyle( 'common/shared.css', 'screen' ); |
| 36 | + $this->addStyle( 'modern/print.css', 'print' ); |
34 | 37 | } |
35 | 38 | } |
36 | 39 | |
— | — | @@ -69,8 +72,8 @@ |
70 | 73 | @import "<?php $this->text('stylepath') ?>/common/shared.css?<?php echo $GLOBALS['wgStyleVersion'] ?>"; |
71 | 74 | @import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/main.css?<?php echo $GLOBALS['wgStyleVersion'] ?>"; |
72 | 75 | /*]]>*/</style> |
73 | | - <?php } ?> |
74 | | - <link rel="stylesheet" type="text/css" <?php if(empty($this->data['printable']) ) { ?>media="print"<?php } ?> href="<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/print.css?<?php echo $GLOBALS['wgStyleVersion'] ?>" /> |
| 76 | + <?php } |
| 77 | + $this->html('csslinks') ?> |
75 | 78 | <!--[if lt IE 7]><meta http-equiv="imagetoolbar" content="no" /><![endif]--> |
76 | 79 | |
77 | 80 | <?php print Skin::makeGlobalVariablesScript( $this->data ); ?> |