Index: trunk/phase3/skins/MonoBook.php |
— | — | @@ -158,6 +158,7 @@ |
159 | 159 | if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true; |
160 | 160 | if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true; |
161 | 161 | if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true; |
| 162 | + |
162 | 163 | foreach ($sidebar as $boxName => $cont) { |
163 | 164 | if ( $boxName == 'SEARCH' ) { |
164 | 165 | $this->searchBox(); |
— | — | @@ -166,7 +167,10 @@ |
167 | 168 | } elseif ( $boxName == 'LANGUAGES' ) { |
168 | 169 | $this->languageBox(); |
169 | 170 | } else { |
170 | | - $this->customBox( $boxName, $cont ); |
| 171 | + if( wfRunHooks( 'SkinSidebarOutputSpecialBox', array( &$this, $boxName, $cont ) ) ) { |
| 172 | + # If no hook returned false, then output a normal box |
| 173 | + $this->customBox( $boxName, $cont ); |
| 174 | + } |
171 | 175 | } |
172 | 176 | } |
173 | 177 | ?> |
Index: trunk/phase3/skins/Modern.php |
— | — | @@ -156,7 +156,7 @@ |
157 | 157 | if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true; |
158 | 158 | if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true; |
159 | 159 | if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true; |
160 | | - |
| 160 | + |
161 | 161 | foreach ($sidebar as $boxName => $cont) { |
162 | 162 | if ( $boxName == 'SEARCH' ) { |
163 | 163 | $this->searchBox(); |
— | — | @@ -165,7 +165,10 @@ |
166 | 166 | } elseif ( $boxName == 'LANGUAGES' ) { |
167 | 167 | $this->languageBox(); |
168 | 168 | } else { |
169 | | - $this->customBox( $boxName, $cont ); |
| 169 | + if( wfRunHooks( 'SkinSidebarOutputSpecialBox', array( &$this, $boxName, $cont ) ) ) { |
| 170 | + # If no hook returned false, then output a normal box |
| 171 | + $this->customBox( $boxName, $cont ); |
| 172 | + } |
170 | 173 | } |
171 | 174 | } |
172 | 175 | ?> |
— | — | @@ -349,4 +352,5 @@ |
350 | 353 | } |
351 | 354 | |
352 | 355 | } // end of class |
353 | | -?> |
| 356 | + |
| 357 | + |
Index: trunk/phase3/docs/hooks.txt |
— | — | @@ -1062,6 +1062,27 @@ |
1063 | 1063 | &$text: bottomScripts Text |
1064 | 1064 | Append to $text to add additional text/scripts after the stock bottom scripts. |
1065 | 1065 | |
| 1066 | +'SkinGlobalVariables': Allows modification of the JS global variables exported to the browser |
| 1067 | +&$vars: The list of variables |
| 1068 | + |
| 1069 | +'SkinSetupSiteCss': Allows modification of the stylesheets and css imported into the skin |
| 1070 | +&$stylesheets: The list of stylesheet urls for importing, keys allow for internal things to be |
| 1071 | +unset or have query arguments appended |
| 1072 | +&$rawcss: Raw css to be exported |
| 1073 | +$msgQuery: Query containing caching and other params to use when adding a stylesheet url |
| 1074 | +that comes from a MediaWiki: message page |
| 1075 | + |
| 1076 | +'SkinSidebarOutputSpecialBox': Allows for custom outputting of special sidebar boxes |
| 1077 | +&$skin: Skin object |
| 1078 | +$boxName: Name of the skin box to output |
| 1079 | +$cont: Content array which may be used for options |
| 1080 | + |
| 1081 | +'SkinSidebarSpecialBox': Allows for extension definition of custom special sidebar boxes |
| 1082 | +Set $cont to an array of initial data and return false to define a new sidebar box |
| 1083 | +&$skin: Skin object |
| 1084 | +$boxName: Name of the custom box to match |
| 1085 | +&$cont: Content array |
| 1086 | + |
1066 | 1087 | 'SkinSubPageSubtitle': At the beginning of Skin::subPageSubtitle() |
1067 | 1088 | $skin: Skin object |
1068 | 1089 | &$subpages: Subpage links HTML |
Index: trunk/phase3/includes/SkinTemplate.php |
— | — | @@ -964,54 +964,62 @@ |
965 | 965 | |
966 | 966 | global $wgRequest, $wgAllowUserCss, $wgUseSiteCss, $wgContLang, $wgSquidMaxage, $wgStylePath, $wgUser; |
967 | 967 | |
968 | | - $sitecss = ''; |
969 | | - $usercss = ''; |
| 968 | + $stylesheets = array(); |
| 969 | + $rawcss = ''; |
970 | 970 | $siteargs = '&maxage=' . $wgSquidMaxage; |
| 971 | + $userPreview = false; |
971 | 972 | if( $this->loggedin ) { |
972 | 973 | // Ensure that logged-in users' generated CSS isn't clobbered |
973 | 974 | // by anons' publicly cacheable generated CSS. |
974 | 975 | $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"; |
| 976 | + |
| 977 | + // If we allow user-specific code append some arguments for it |
| 978 | + if( $wgAllowUserCss ) { |
| 979 | + $action = $wgRequest->getText('action'); |
| 980 | + $userPreview = $this->mTitle->isCssSubpage() && $this->userCanPreview( $action ); |
| 981 | + $siteargs .= '&ts=' . $wgUser->mTouched; |
| 982 | + if( $userPreview ) $siteargs = "&smaxage=0&maxage=0"; |
990 | 983 | } |
991 | | - |
992 | | - $siteargs .= '&ts=' . $wgUser->mTouched; |
993 | 984 | } |
994 | | - |
| 985 | + |
995 | 986 | if( $wgContLang->isRTL() && in_array( 'rtl', $this->cssfiles ) ) { |
996 | 987 | global $wgStyleVersion; |
997 | | - $sitecss .= "@import \"$wgStylePath/$this->stylename/rtl.css?$wgStyleVersion\";\n"; |
| 988 | + $stylesheets['skinrtl'] = "$wgStylePath/$this->stylename/rtl.css?$wgStyleVersion"; |
998 | 989 | } |
999 | | - |
| 990 | + |
1000 | 991 | # If we use the site's dynamic CSS, throw that in, too |
1001 | | - if ( $wgUseSiteCss ) { |
| 992 | + if( $wgUseSiteCss ) { |
1002 | 993 | $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage"; |
1003 | 994 | $skinquery = ''; |
1004 | 995 | if (($us = $wgRequest->getVal('useskin', '')) !== '') |
1005 | 996 | $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"; |
| 997 | + $stylesheets['sitecommon'] = self::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI); |
| 998 | + $stylesheets['siteskin'] = self::makeNSUrl( ucfirst( $this->skinname ) . '.css', $query, NS_MEDIAWIKI ); |
| 999 | + $stylesheets['gen'] = self::makeUrl( '-', "action=raw&gen=css$siteargs$skinquery" ); |
1009 | 1000 | } |
1010 | | - |
| 1001 | + |
| 1002 | + # Add user-specific code if this is a user and we allow that kind of thing |
| 1003 | + if( $wgAllowUserCss && $this->loggedin ) { |
| 1004 | + # if we're previewing the CSS page, use it |
| 1005 | + if( $userPreview ) { |
| 1006 | + $rawcss .= $wgRequest->getText('wpTextbox1'); |
| 1007 | + } else { |
| 1008 | + $stylesheets['userskin'] = self::makeUrl( |
| 1009 | + $this->userpage . '/'.$this->skinname.'.css', |
| 1010 | + 'action=raw&ctype=text/css'); |
| 1011 | + } |
| 1012 | + } |
| 1013 | + |
| 1014 | + wfRunHooks( 'SkinSetupSiteCss', array( &$stylesheets, &$rawcss, $query ) ); |
| 1015 | + |
1011 | 1016 | # If we use any dynamic CSS, make a little CDATA block out of it. |
1012 | | - |
1013 | | - if ( !empty($sitecss) || !empty($usercss) ) { |
1014 | | - $this->usercss = "/*<![CDATA[*/\n" . $sitecss . $usercss . '/*]]>*/'; |
| 1017 | + $s = ''; |
| 1018 | + foreach( $stylesheets as $link ) { |
| 1019 | + $s .= "@import \"$link\";\n"; |
1015 | 1020 | } |
| 1021 | + $s .= $rawcss; |
| 1022 | + if( $s != '' ) $this->usercss = "/*<![CDATA[*/\n{$s}/*]]>*/"; |
| 1023 | + |
1016 | 1024 | wfProfileOut( __METHOD__ ); |
1017 | 1025 | } |
1018 | 1026 | |
Index: trunk/phase3/includes/Skin.php |
— | — | @@ -361,6 +361,8 @@ |
362 | 362 | } |
363 | 363 | $vars['wgAjaxWatch'] = $msgs; |
364 | 364 | } |
| 365 | + |
| 366 | + wfRunHooks('SkinGlobalVariables', array(&$vars)); |
365 | 367 | |
366 | 368 | return self::makeVariablesScript( $vars ); |
367 | 369 | } |
— | — | @@ -418,17 +420,25 @@ |
419 | 421 | function getUserStylesheet() { |
420 | 422 | global $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage, $wgStyleVersion; |
421 | 423 | $sheet = $this->getStylesheet(); |
422 | | - $s = "@import \"$wgStylePath/common/shared.css?$wgStyleVersion\";\n"; |
423 | | - $s .= "@import \"$wgStylePath/common/oldshared.css?$wgStyleVersion\";\n"; |
424 | | - $s .= "@import \"$wgStylePath/$sheet?$wgStyleVersion\";\n"; |
425 | | - if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css?$wgStyleVersion\";\n"; |
426 | | - |
427 | 424 | $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage"; |
428 | | - $s .= '@import "' . self::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI ) . "\";\n" . |
429 | | - '@import "' . self::makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI ) . "\";\n"; |
430 | | - |
431 | | - $s .= $this->doGetUserStyles(); |
432 | | - return $s."\n"; |
| 425 | + |
| 426 | + $stylesheets = array(); |
| 427 | + $stylesheets['shared'] = "$wgStylePath/common/shared.css?$wgStyleVersion"; |
| 428 | + $stylesheets['oldshared'] = "$wgStylePath/common/oldshared.css?$wgStyleVersion"; |
| 429 | + $stylesheets['skin'] = "$wgStylePath/$sheet?$wgStyleVersion"; |
| 430 | + if($wgContLang->isRTL()) $stylesheets['rtl'] = "$wgStylePath/common/common_rtl.css?$wgStyleVersion"; |
| 431 | + $stylesheets['sitecommon'] = self::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI ); |
| 432 | + $stylesheets['siteskin'] = self::makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI ); |
| 433 | + |
| 434 | + $rawcss = $this->doGetUserStyles(); |
| 435 | + |
| 436 | + wfRunHooks( 'SkinSetupSiteCss', array( &$stylesheets, &$rawcss, $query ) ); |
| 437 | + |
| 438 | + $s = ''; |
| 439 | + foreach( $stylesheets as $link ) { |
| 440 | + $s .= "@import \"$link\";\n"; |
| 441 | + } |
| 442 | + return "{$s}{$rawcss}\n"; |
433 | 443 | } |
434 | 444 | |
435 | 445 | /** |
— | — | @@ -1672,19 +1682,35 @@ |
1673 | 1683 | $bar = array(); |
1674 | 1684 | $lines = explode( "\n", wfMsgForContent( 'sidebar' ) ); |
1675 | 1685 | $heading = ''; |
| 1686 | + $specialBox = false; |
1676 | 1687 | foreach ($lines as $line) { |
1677 | 1688 | if (strpos($line, '*') !== 0) |
1678 | 1689 | continue; |
1679 | 1690 | if (strpos($line, '**') !== 0) { |
1680 | 1691 | $line = trim($line, '* '); |
| 1692 | + |
1681 | 1693 | if ( $line == 'SEARCH' || $line == 'TOOLBOX' || $line == 'LANGUAGES' ) { |
1682 | | - # Special box type |
| 1694 | + # Internal special box type |
1683 | 1695 | $bar[$line] = array(); |
| 1696 | + $specialBox = true; |
1684 | 1697 | } else { |
1685 | | - $heading = $line; |
| 1698 | + $cont = null; |
| 1699 | + # Allow extensions to start a special box |
| 1700 | + if( !wfRunHooks( 'SkinSidebarSpecialBox', array( &$this, $line, &$cont ) ); ) { |
| 1701 | + # Extension special box type |
| 1702 | + $bar[$line] = $cont; |
| 1703 | + $specialBox = true; |
| 1704 | + } else { |
| 1705 | + # Normal box |
| 1706 | + $specialBox = false; |
| 1707 | + } |
1686 | 1708 | } |
| 1709 | + $heading = $line; |
1687 | 1710 | } else { |
1688 | | - if (strpos($line, '|') !== false) { // sanity check |
| 1711 | + if( $specialBox ) { |
| 1712 | + # Inside a special box, we just append the lines into the $cont |
| 1713 | + $bar[$heading][] = $line; |
| 1714 | + } elseif (strpos($line, '|') !== false) { // sanity check |
1689 | 1715 | $line = array_map('trim', explode( '|' , trim($line, '* '), 2 ) ); |
1690 | 1716 | $link = wfMsgForContent( $line[0] ); |
1691 | 1717 | if ($link == '-') |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -181,7 +181,9 @@ |
182 | 182 | * (bug 11732) Allow localisation of edit button images |
183 | 183 | * Allow the search box, toolbox and languages box in the Monobook sidebar to be |
184 | 184 | moved around arbitrarily using special sections in [[MediaWiki:Sidebar]]: |
185 | | - SEARCH, TOOLBOX and LANGUAGES |
| 185 | + SEARCH, TOOLBOX and LANGUAGES extensions may also add new custom boxes to the |
| 186 | + sidebar by hooking into SkinSidebarSpecialBox to define the box and into |
| 187 | + SkinSidebarOutputSpecialBox to output data for the box. |
186 | 188 | * Add a new hook NormalizeMessageKey to allow extensions to replace messages before |
187 | 189 | the database is potentially queried |
188 | 190 | * (bug 9736) Redirects on Special:Fewestrevisions are now marked as such. |
— | — | @@ -190,7 +192,12 @@ |
191 | 193 | * HTML entities like now work (are not escaped) in edit summaries. |
192 | 194 | * (bug 13815) In the comment for page moves, use the colon-separator message |
193 | 195 | instead of a hardcoded colon. |
194 | | - |
| 196 | +* Add a new hook SkinSetupSiteCss to allow extensions to define new stylesheets |
| 197 | + to load site wide, or modify the list of stylesheets to load. This can be useful |
| 198 | + for wiki farms who need a specific placement of the stylesheets to cascade right. |
| 199 | +* Add a new hook SkinGlobalVariables to allow extensions to add new global variables |
| 200 | + to be exported for JavaScript code to make use of. |
| 201 | + |
195 | 202 | === Bug fixes in 1.13 === |
196 | 203 | |
197 | 204 | * (bug 10677) Add link to the file description page on the shared repository |