Index: trunk/phase3/skins/chick/main.css |
— | — | @@ -419,7 +419,7 @@ |
420 | 420 | padding: 2px 4px; |
421 | 421 | } |
422 | 422 | |
423 | | -#jump-to-nav { |
| 423 | +#xjump-to-nav { |
424 | 424 | display: none; |
425 | 425 | } |
426 | 426 | |
— | — | @@ -430,3 +430,21 @@ |
431 | 431 | div#mw-recreate-deleted-warn ul li { |
432 | 432 | font-size: 95%; |
433 | 433 | } |
| 434 | + |
| 435 | + |
| 436 | +.printfooter { |
| 437 | + display: none; |
| 438 | +} |
| 439 | + |
| 440 | +#footer { |
| 441 | + background-color: white; |
| 442 | + border-top: 1px solid #fabd23; |
| 443 | + border-bottom: 1px solid #fabd23; |
| 444 | + margin: .6em 0 1em 0; |
| 445 | + padding: .4em 0 1.2em 0; |
| 446 | + text-align: center; |
| 447 | + font-size: 90%; |
| 448 | +} |
| 449 | +#f-poweredbyico, #f-copyrightico { |
| 450 | + display: inline; |
| 451 | +} |
\ No newline at end of file |
Index: trunk/phase3/skins/Chick.php |
— | — | @@ -23,7 +23,12 @@ |
24 | 24 | $this->skinname = 'chick'; |
25 | 25 | $this->stylename = 'chick'; |
26 | 26 | $this->template = 'MonoBookTemplate'; |
27 | | - $this->fixfiles = array( 'IE50', 'IE55', 'IE60' ); |
| 27 | + |
| 28 | + // Append to the default screen common & print styles... |
| 29 | + $this->addStyle( 'chick/main.css', 'screen,handheld' ); |
| 30 | + $this->addStyle( 'chick/IE50Fixes.css', 'screen,handheld', 'lt IE 5.5000' ); |
| 31 | + $this->addStyle( 'chick/IE55Fixes.css', 'screen,handheld', 'IE 5.5000' ); |
| 32 | + $this->addStyle( 'chick/IE60Fixes.css', 'screen,handheld', 'IE 6' ); |
28 | 33 | } |
29 | 34 | } |
30 | 35 | |
Index: trunk/phase3/skins/MonoBook.php |
— | — | @@ -21,13 +21,26 @@ |
22 | 22 | class SkinMonoBook extends SkinTemplate { |
23 | 23 | /** Using monobook. */ |
24 | 24 | function initPage( &$out ) { |
| 25 | + global $wgHandheldStyle; |
| 26 | + |
25 | 27 | SkinTemplate::initPage( $out ); |
26 | 28 | $this->skinname = 'monobook'; |
27 | 29 | $this->stylename = 'monobook'; |
28 | 30 | $this->template = 'MonoBookTemplate'; |
29 | | - # Bug 14520: skins that just include this file shouldn't load nonexis- |
30 | | - # tent CSS fix files. |
31 | | - $this->cssfiles = array( 'IE', 'IE50', 'IE55', 'IE60', 'IE70', 'rtl' ); |
| 31 | + |
| 32 | + // Append to the default screen common & print styles... |
| 33 | + $this->addStyle( 'monobook/main.css', 'screen' ); |
| 34 | + if( $wgHandheldStyle ) { |
| 35 | + // Currently in testing... try 'chick/main.css' |
| 36 | + $this->addStyle( $wgHandheldStyle, 'handheld' ); |
| 37 | + } |
| 38 | + |
| 39 | + $this->addStyle( 'monobook/IE50Fixes.css', 'screen', 'lt IE 5.5000' ); |
| 40 | + $this->addStyle( 'monobook/IE55Fixes.css', 'screen', 'IE 5.5000' ); |
| 41 | + $this->addStyle( 'monobook/IE60Fixes.css', 'screen', 'IE 6' ); |
| 42 | + $this->addStyle( 'monobook/IE70Fixes.css', 'screen', 'IE 7' ); |
| 43 | + |
| 44 | + $this->addStyle( 'monobook/rtl.css', 'screen', '', 'rtl' ); |
32 | 45 | } |
33 | 46 | } |
34 | 47 | |
— | — | @@ -62,17 +75,10 @@ |
63 | 76 | <meta http-equiv="Content-Type" content="<?php $this->text('mimetype') ?>; charset=<?php $this->text('charset') ?>" /> |
64 | 77 | <?php $this->html('headlinks') ?> |
65 | 78 | <title><?php $this->text('pagetitle') ?></title> |
66 | | - <style type="text/css" media="screen, projection">/*<![CDATA[*/ |
67 | | - @import "<?php $this->text('stylepath') ?>/common/shared.css?<?php echo $GLOBALS['wgStyleVersion'] ?>"; |
68 | | - @import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/main.css?<?php echo $GLOBALS['wgStyleVersion'] ?>"; |
69 | | - /*]]>*/</style> |
70 | | - <link rel="stylesheet" type="text/css" <?php if(empty($this->data['printable']) ) { ?>media="print"<?php } ?> href="<?php $this->text('printcss') ?>?<?php echo $GLOBALS['wgStyleVersion'] ?>" /> |
71 | | - <?php if( in_array( 'IE50', $skin->cssfiles ) ) { ?><!--[if lt IE 5.5000]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE50Fixes.css?<?php echo $GLOBALS['wgStyleVersion'] ?>";</style><![endif]--> |
72 | | - <?php } if( in_array( 'IE55', $skin->cssfiles ) ) { ?><!--[if IE 5.5000]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE55Fixes.css?<?php echo $GLOBALS['wgStyleVersion'] ?>";</style><![endif]--> |
73 | | - <?php } if( in_array( 'IE60', $skin->cssfiles ) ) { ?><!--[if IE 6]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE60Fixes.css?<?php echo $GLOBALS['wgStyleVersion'] ?>";</style><![endif]--> |
74 | | - <?php } if( in_array( 'IE70', $skin->cssfiles ) ) { ?><!--[if IE 7]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE70Fixes.css?<?php echo $GLOBALS['wgStyleVersion'] ?>";</style><![endif]--> |
75 | | - <?php } ?><!--[if lt IE 7]><?php if( in_array( 'IE', $skin->cssfiles ) ) { ?><script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath') ?>/common/IEFixes.js?<?php echo $GLOBALS['wgStyleVersion'] ?>"></script> |
76 | | - <?php } ?><meta http-equiv="imagetoolbar" content="no" /><![endif]--> |
| 79 | +<?php $this->html('csslinks') ?> |
| 80 | + |
| 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 | + <meta http-equiv="imagetoolbar" content="no" /><![endif]--> |
77 | 83 | |
78 | 84 | <?php print Skin::makeGlobalVariablesScript( $this->data ); ?> |
79 | 85 | |
Index: trunk/phase3/includes/SkinTemplate.php |
— | — | @@ -86,12 +86,13 @@ |
87 | 87 | * will actually fill the template. |
88 | 88 | */ |
89 | 89 | var $template; |
90 | | - |
| 90 | + |
91 | 91 | /** |
92 | | - * An array of strings representing extra CSS files to load. May include: |
93 | | - * 'IE', 'IE50', 'IE55', 'IE60', 'IE70', 'rtl'. |
| 92 | + * An array of stylesheet filenames (relative from skins path), with options |
| 93 | + * for CSS media, IE conditions, and RTL/LTR direction. |
| 94 | + * For internal use; add settings in the skin via $this->addStyle() |
94 | 95 | */ |
95 | | - var $cssfiles; |
| 96 | + var $styles = array(); |
96 | 97 | |
97 | 98 | /**#@-*/ |
98 | 99 | |
— | — | @@ -107,7 +108,9 @@ |
108 | 109 | $this->skinname = 'monobook'; |
109 | 110 | $this->stylename = 'monobook'; |
110 | 111 | $this->template = 'QuickTemplate'; |
111 | | - $this->cssfiles = array(); |
| 112 | + |
| 113 | + $this->addStyle( 'common/shared.css', 'screen' ); |
| 114 | + $this->addStyle( 'common/commonPrint.css', 'print' ); |
112 | 115 | } |
113 | 116 | |
114 | 117 | /** |
— | — | @@ -247,6 +250,8 @@ |
248 | 251 | $tpl->set( 'skinclass', get_class( $this ) ); |
249 | 252 | $tpl->setRef( 'stylename', $this->stylename ); |
250 | 253 | $tpl->set( 'printable', $wgRequest->getBool( 'printable' ) ); |
| 254 | + $tpl->set( 'handheld', $wgRequest->getBool( 'handheld' ) ); |
| 255 | + $tpl->set( 'csslinks', $this->buildCssLinks() ); |
251 | 256 | $tpl->setRef( 'loggedin', $this->loggedin ); |
252 | 257 | $tpl->set('nsclass', 'ns-'.$this->mTitle->getNamespace()); |
253 | 258 | $tpl->set('notspecialpage', $this->mTitle->getNamespace() != NS_SPECIAL); |
— | — | @@ -274,7 +279,6 @@ |
275 | 280 | $tpl->setRef( 'userpageurl', $this->userpageUrlDetails['href']); |
276 | 281 | $tpl->set( 'userlang', $wgLang->getCode() ); |
277 | 282 | $tpl->set( 'pagecss', $this->setupPageCss() ); |
278 | | - $tpl->set( 'printcss', $this->getPrintCss() ); |
279 | 283 | $tpl->setRef( 'usercss', $this->usercss); |
280 | 284 | $tpl->setRef( 'userjs', $this->userjs); |
281 | 285 | $tpl->setRef( 'userjsprev', $this->userjsprev); |
— | — | @@ -964,54 +968,49 @@ |
965 | 969 | |
966 | 970 | global $wgRequest, $wgAllowUserCss, $wgUseSiteCss, $wgContLang, $wgSquidMaxage, $wgStylePath, $wgUser; |
967 | 971 | |
968 | | - $sitecss = ''; |
969 | 972 | $usercss = ''; |
970 | 973 | $siteargs = '&maxage=' . $wgSquidMaxage; |
971 | 974 | if( $this->loggedin ) { |
972 | 975 | // Ensure that logged-in users' generated CSS isn't clobbered |
973 | 976 | // by anons' publicly cacheable generated CSS. |
974 | 977 | $siteargs .= '&smaxage=0'; |
975 | | - } |
976 | | - |
977 | | - # Add user-specific code if this is a user and we allow that kind of thing |
978 | | - |
979 | | - if ( $wgAllowUserCss && $this->loggedin ) { |
980 | | - $action = $wgRequest->getText('action'); |
981 | | - |
982 | | - # if we're previewing the CSS page, use it |
983 | | - if( $this->mTitle->isCssSubpage() and $this->userCanPreview( $action ) ) { |
984 | | - $siteargs = "&smaxage=0&maxage=0"; |
985 | | - $usercss = $wgRequest->getText('wpTextbox1'); |
986 | | - } else { |
987 | | - $usercss = '@import "' . |
988 | | - self::makeUrl($this->userpage . '/'.$this->skinname.'.css', |
989 | | - 'action=raw&ctype=text/css') . '";' ."\n"; |
990 | | - } |
991 | | - |
992 | 978 | $siteargs .= '&ts=' . $wgUser->mTouched; |
993 | 979 | } |
994 | 980 | |
995 | | - if( $wgContLang->isRTL() && in_array( 'rtl', $this->cssfiles ) ) { |
996 | | - global $wgStyleVersion; |
997 | | - $sitecss .= "@import \"$wgStylePath/$this->stylename/rtl.css?$wgStyleVersion\";\n"; |
998 | | - } |
999 | | - |
1000 | 981 | # If we use the site's dynamic CSS, throw that in, too |
| 982 | + // Per-site custom styles |
1001 | 983 | if ( $wgUseSiteCss ) { |
1002 | 984 | $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage"; |
1003 | 985 | $skinquery = ''; |
1004 | 986 | if (($us = $wgRequest->getVal('useskin', '')) !== '') |
1005 | 987 | $skinquery = "&useskin=$us"; |
1006 | | - $sitecss .= '@import "' . self::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI) . '";' . "\n"; |
1007 | | - $sitecss .= '@import "' . self::makeNSUrl( ucfirst( $this->skinname ) . '.css', $query, NS_MEDIAWIKI ) . '";' . "\n"; |
1008 | | - $sitecss .= '@import "' . self::makeUrl( '-', "action=raw&gen=css$siteargs$skinquery" ) . '";' . "\n"; |
| 988 | + |
| 989 | + $this->addStyle( self::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI) ); |
| 990 | + $this->addStyle( self::makeNSUrl( ucfirst( $this->skinname ) . '.css', $query, NS_MEDIAWIKI ), |
| 991 | + 'screen' ); |
1009 | 992 | } |
1010 | 993 | |
1011 | | - # If we use any dynamic CSS, make a little CDATA block out of it. |
| 994 | + // Per-user styles based on preferences |
| 995 | + $this->addStyle( self::makeUrl( '-', "action=raw&gen=css$siteargs$skinquery" ), 'screen' ); |
1012 | 996 | |
1013 | | - if ( !empty($sitecss) || !empty($usercss) ) { |
1014 | | - $this->usercss = "/*<![CDATA[*/\n" . $sitecss . $usercss . '/*]]>*/'; |
| 997 | + // Per-user custom style pages |
| 998 | + if ( $wgAllowUserCss && $this->loggedin ) { |
| 999 | + $action = $wgRequest->getVal('action'); |
| 1000 | + |
| 1001 | + # if we're previewing the CSS page, use it |
| 1002 | + if( $this->mTitle->isCssSubpage() and $this->userCanPreview( $action ) ) { |
| 1003 | + $previewCss = $wgRequest->getText('wpTextbox1'); |
| 1004 | + |
| 1005 | + /// @fixme properly escape the cdata! |
| 1006 | + $this->usercss = "/*<![CDATA[*/\n" . |
| 1007 | + $previewCss . |
| 1008 | + "/*]]>*/"; |
| 1009 | + } else { |
| 1010 | + $this->addStyle( self::makeUrl($this->userpage . '/'.$this->skinname.'.css', |
| 1011 | + 'action=raw&ctype=text/css'), 'screen' ); |
| 1012 | + } |
1015 | 1013 | } |
| 1014 | + |
1016 | 1015 | wfProfileOut( __METHOD__ ); |
1017 | 1016 | } |
1018 | 1017 | |
— | — | @@ -1063,17 +1062,6 @@ |
1064 | 1063 | } |
1065 | 1064 | |
1066 | 1065 | /** |
1067 | | - * Returns the print stylesheet for this skin. In all default skins this |
1068 | | - * is just commonPrint.css, but third-party skins may want to modify it. |
1069 | | - * |
1070 | | - * @return string |
1071 | | - */ |
1072 | | - protected function getPrintCss() { |
1073 | | - global $wgStylePath; |
1074 | | - return $wgStylePath . "/common/commonPrint.css"; |
1075 | | - } |
1076 | | - |
1077 | | - /** |
1078 | 1066 | * This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate- |
1079 | 1067 | * nated together. For some bizarre reason, it does *not* return any |
1080 | 1068 | * custom user JS from subpages. Huh? |
— | — | @@ -1102,6 +1090,118 @@ |
1103 | 1091 | wfProfileOut( __METHOD__ ); |
1104 | 1092 | return $s; |
1105 | 1093 | } |
| 1094 | + |
| 1095 | + /** |
| 1096 | + * Add a local or specified stylesheet, with the given media options. |
| 1097 | + * Meant primarily for internal use... |
| 1098 | + * |
| 1099 | + * @param $media -- to specify a media type, 'screen', 'printable', 'handheld' or any. |
| 1100 | + * @param $conditional -- for IE conditional comments, specifying an IE version |
| 1101 | + * @param $dir -- set to 'rtl' or 'ltr' for direction-specific sheets |
| 1102 | + */ |
| 1103 | + public function addStyle( $style, $media='', $condition='', $dir='' ) { |
| 1104 | + $options = array(); |
| 1105 | + if( $media ) |
| 1106 | + $options['media'] = $media; |
| 1107 | + if( $condition ) |
| 1108 | + $options['condition'] = $condition; |
| 1109 | + if( $dir ) |
| 1110 | + $options['dir'] = $dir; |
| 1111 | + $this->styles[$style] = $options; |
| 1112 | + } |
| 1113 | + |
| 1114 | + /** |
| 1115 | + * Build a set of <link>s for the stylesheets specified in the $this->styles array. |
| 1116 | + * These will be applied to various media & IE conditionals. |
| 1117 | + */ |
| 1118 | + protected function buildCssLinks() { |
| 1119 | + global $wgContLang; |
| 1120 | + |
| 1121 | + foreach( $this->styles as $file => $options ) { |
| 1122 | + $links[] = $this->styleLink( $file, $options ); |
| 1123 | + } |
| 1124 | + |
| 1125 | + return implode( "\n", $links ); |
| 1126 | + } |
| 1127 | + |
| 1128 | + protected function styleLink( $style, $options ) { |
| 1129 | + global $wgRequest; |
| 1130 | + |
| 1131 | + if( isset( $options['dir'] ) ) { |
| 1132 | + global $wgContLang; |
| 1133 | + $siteDir = $wgContLang->isRTL() ? 'rtl' : 'ltr'; |
| 1134 | + if( $siteDir != $options['dir'] ) |
| 1135 | + return ''; |
| 1136 | + } |
| 1137 | + |
| 1138 | + if( isset( $options['media'] ) ) { |
| 1139 | + $media = $this->transformCssMedia( $options['media'] ); |
| 1140 | + if( is_null( $media ) ) { |
| 1141 | + return ''; |
| 1142 | + } |
| 1143 | + } else { |
| 1144 | + $media = ''; |
| 1145 | + } |
| 1146 | + |
| 1147 | + if( substr( $style, 0, 1 ) == '/' || |
| 1148 | + substr( $style, 0, 5 ) == 'http:' || |
| 1149 | + substr( $style, 0, 6 ) == 'https:' ) { |
| 1150 | + $url = $style; |
| 1151 | + } else { |
| 1152 | + global $wgStylePath, $wgStyleVersion; |
| 1153 | + $url = $wgStylePath . '/' . $style . '?' . $wgStyleVersion; |
| 1154 | + } |
| 1155 | + |
| 1156 | + $attribs = array( |
| 1157 | + 'rel' => 'stylesheet', |
| 1158 | + 'href' => $url, |
| 1159 | + 'type' => 'text/css' ); |
| 1160 | + if( $media ) { |
| 1161 | + $attribs['media'] = $media; |
| 1162 | + } |
| 1163 | + |
| 1164 | + $link = Xml::element( 'link', $attribs ); |
| 1165 | + |
| 1166 | + if( isset( $options['condition'] ) ) { |
| 1167 | + $condition = htmlspecialchars( $options['condition'] ); |
| 1168 | + $link = "<!--[if $condition]>$link<![endif]-->"; |
| 1169 | + } |
| 1170 | + return $link; |
| 1171 | + } |
| 1172 | + |
| 1173 | + function transformCssMedia( $media ) { |
| 1174 | + global $wgRequest, $wgHandheldForIPhone; |
| 1175 | + |
| 1176 | + // Switch in on-screen display for media testing |
| 1177 | + $switches = array( |
| 1178 | + 'printable' => 'print', |
| 1179 | + 'handheld' => 'handheld', |
| 1180 | + ); |
| 1181 | + foreach( $switches as $switch => $targetMedia ) { |
| 1182 | + if( $wgRequest->getBool( $switch ) ) { |
| 1183 | + if( $media == $targetMedia ) { |
| 1184 | + $media = ''; |
| 1185 | + } elseif( $media == 'screen' ) { |
| 1186 | + return null; |
| 1187 | + } |
| 1188 | + } |
| 1189 | + } |
| 1190 | + |
| 1191 | + // Expand longer media queries as iPhone doesn't grok 'handheld' |
| 1192 | + if( $wgHandheldForIPhone ) { |
| 1193 | + $mediaAliases = array( |
| 1194 | + 'screen' => 'screen and (min-device-width: 481px)', |
| 1195 | + 'handheld' => 'handheld, only screen and (max-device-width: 480px)', |
| 1196 | + ); |
| 1197 | + |
| 1198 | + if( isset( $mediaAliases[$media] ) ) { |
| 1199 | + $media = $mediaAliases[$media]; |
| 1200 | + } |
| 1201 | + } |
| 1202 | + |
| 1203 | + return $media; |
| 1204 | + } |
| 1205 | + |
1106 | 1206 | } |
1107 | 1207 | |
1108 | 1208 | /** |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -2137,6 +2137,32 @@ |
2138 | 2138 | $wgDefaultSkin = 'monobook'; |
2139 | 2139 | |
2140 | 2140 | /** |
| 2141 | + * Optionally, we can specify a stylesheet to use for media="handheld". |
| 2142 | + * This is recognized by some, but not all, handheld/mobile/PDA browsers. |
| 2143 | + * If left empty, compliant handheld browsers won't pick up the skin |
| 2144 | + * stylesheet, which is specified for 'screen' media. |
| 2145 | + * |
| 2146 | + * Can be a complete URL, base-relative path, or $wgStylePath-relative path. |
| 2147 | + * Try 'chick/main.css' to apply the Chick styles to the MonoBook HTML. |
| 2148 | + * |
| 2149 | + * Will also be switched in when 'handheld=yes' is added to the URL, like |
| 2150 | + * the 'printable=yes' mode for print media. |
| 2151 | + */ |
| 2152 | +$wgHandheldStyle = false; |
| 2153 | + |
| 2154 | +/** |
| 2155 | + * If set, 'screen' and 'handheld' media specifiers for stylesheets are |
| 2156 | + * transformed such that they apply to the iPhone/iPod Touch Mobile Safari, |
| 2157 | + * which doesn't recognize 'handheld' but does support media queries on its |
| 2158 | + * screen size. |
| 2159 | + * |
| 2160 | + * Consider only using this if you have a *really good* handheld stylesheet, |
| 2161 | + * as iPhone users won't have any way to disable it and use the "grown-up" |
| 2162 | + * styles instead. |
| 2163 | + */ |
| 2164 | +$wgHandheldForIPhone = false; |
| 2165 | + |
| 2166 | +/** |
2141 | 2167 | * Settings added to this array will override the default globals for the user |
2142 | 2168 | * preferences used by anonymous visitors and newly created accounts. |
2143 | 2169 | * For instance, to disable section editing links: |