Revert r37686, 37687 for now:
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 15 Jul 2008 21:35:32 +0000 (21:35 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 15 Jul 2008 21:35:32 +0000 (21:35 +0000)
"Improving extendibility of the sidebar improvements, css adding, and also JS variables."

"* New hooks:"
"** SkinSidebarSpecialBox and SkinSidebarOutputSpecialBox to allow extensions to add new custom boxes to Tim's new Sidebar system"
"** SkinSetupSiteCss to allow extensions to modify and add new stylesheets to load into the page. This one allows for fine positioning and can be very useful for things like an extension providing global css for a wiki farm."
"** SkinGlobalVariables to allow extensions to add new global variables to export to the JS variables in the page."

At least some of these appear to duplicate existing functionality -- extensions already can add new stylesheets and JS variables, and I'm pretty sure can add portals as well.

RELEASE-NOTES
docs/hooks.txt
includes/Skin.php
includes/SkinTemplate.php
skins/Modern.php
skins/MonoBook.php

index bb618e9..6db1ed5 100644 (file)
@@ -181,19 +181,12 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 11732) Allow localisation of edit button images
 * Allow the search box, toolbox and languages box in the Monobook sidebar to be
   moved around arbitrarily using special sections in [[MediaWiki:Sidebar]]: 
-  SEARCH, TOOLBOX and LANGUAGES extensions may also add new custom boxes to the
-  sidebar by hooking into SkinSidebarSpecialBox to define the box and into
-  SkinSidebarOutputSpecialBox to output data for the box.
+  SEARCH, TOOLBOX and LANGUAGES
 * Add a new hook NormalizeMessageKey to allow extensions to replace messages before
   the database is potentially queried
 * (bug 9736) Redirects on Special:Fewestrevisions are now marked as such.
 * New date/time formats in Cs localization according to ČSN and PČP.
-* Add a new hook SkinSetupSiteCss to allow extensions to define new stylesheets
-  to load site wide, or modify the list of stylesheets to load. This can be useful
-  for wiki farms who need a specific placement of the stylesheets to cascade right.
-* Add a new hook SkinGlobalVariables to allow extensions to add new global variables
-  to be exported for JavaScript code to make use of.
-
 === Bug fixes in 1.13 ===
 
 * (bug 10677) Add link to the file description page on the shared repository
index a8930cc..2217a5e 100644 (file)
@@ -1056,27 +1056,6 @@ $skin: Skin object
 &$text: bottomScripts Text
 Append to $text to add additional text/scripts after the stock bottom scripts.
 
-'SkinGlobalVariables': Allows modification of the JS global variables exported to the browser
-&$vars: The list of variables
-
-'SkinSetupSiteCss': Allows modification of the stylesheets and css imported into the skin
-&$stylesheets: The list of stylesheet urls for importing, keys allow for internal things to be
-unset or have query arguments appended
-&$rawcss: Raw css to be exported
-$msgQuery: Query containing caching and other params to use when adding a stylesheet url
-that comes from a MediaWiki: message page
-
-'SkinSidebarOutputSpecialBox': Allows for custom outputting of special sidebar boxes
-&$skin: Skin object
-$boxName: Name of the skin box to output
-$cont: Content array which may be used for options
-
-'SkinSidebarSpecialBox': Allows for extension definition of custom special sidebar boxes
-Set $cont to an array of initial data and return false to define a new sidebar box
-&$skin: Skin object
-$boxName: Name of the custom box to match
-&$cont: Content array
-
 'SkinSubPageSubtitle': At the beginning of Skin::subPageSubtitle()
 $skin: Skin object
 &$subpages: Subpage links HTML
index 248a9e3..a9e44ab 100644 (file)
@@ -361,8 +361,6 @@ class Skin extends Linker {
                        }
                        $vars['wgAjaxWatch'] = $msgs;
                }
-               
-               wfRunHooks('SkinGlobalVariables', array(&$vars));
 
                return self::makeVariablesScript( $vars );
        }
@@ -420,25 +418,17 @@ class Skin extends Linker {
        function getUserStylesheet() {
                global $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage, $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";
+
                $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
-               
-               $stylesheets = array();
-               $stylesheets['shared']    = "$wgStylePath/common/shared.css?$wgStyleVersion";
-               $stylesheets['oldshared'] = "$wgStylePath/common/oldshared.css?$wgStyleVersion";
-               $stylesheets['skin']      = "$wgStylePath/$sheet?$wgStyleVersion";
-               if($wgContLang->isRTL()) $stylesheets['rtl'] = "$wgStylePath/common/common_rtl.css?$wgStyleVersion";
-               $stylesheets['sitecommon'] = self::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI );
-               $stylesheets['siteskin']  = self::makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI );
-               
-               $rawcss = $this->doGetUserStyles();
-               
-               wfRunHooks( 'SkinSetupSiteCss', array( &$stylesheets, &$rawcss, $query ) );
-               
-               $s = '';
-               foreach( $stylesheets as $link ) {
-                       $s .= "@import \"$link\";\n";
-               }
-               return "{$s}{$rawcss}\n";
+               $s .= '@import "' . self::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI ) . "\";\n" .
+                       '@import "' . self::makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI ) . "\";\n";
+
+               $s .= $this->doGetUserStyles();
+               return $s."\n";
        }
 
        /**
@@ -1682,35 +1672,19 @@ END;
                $bar = array();
                $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
                $heading = '';
-               $specialBox = false;
                foreach ($lines as $line) {
                        if (strpos($line, '*') !== 0)
                                continue;
                        if (strpos($line, '**') !== 0) {
                                $line = trim($line, '* ');
-                               
                                if ( $line == 'SEARCH' || $line == 'TOOLBOX' || $line == 'LANGUAGES' ) {
-                                       # Internal special box type
+                                       # Special box type
                                        $bar[$line] = array();
-                                       $specialBox = true;
                                } else {
-                                       $cont = null;
-                                       # Allow extensions to start a special box
-                                       if( !wfRunHooks( 'SkinSidebarSpecialBox', array( &$this, $line, &$cont ) ) ) {
-                                               # Extension special box type
-                                               $bar[$line] = $cont;
-                                               $specialBox = true;
-                                       } else {
-                                               # Normal box
-                                               $specialBox = false;
-                                       }
+                                       $heading = $line;
                                }
-                               $heading = $line;
                        } else {
-                               if( $specialBox ) {
-                                       # Inside a special box, we just append the lines into the $cont
-                                       $bar[$heading][] = $line;
-                               } elseif (strpos($line, '|') !== false) { // sanity check
+                               if (strpos($line, '|') !== false) { // sanity check
                                        $line = array_map('trim', explode( '|' , trim($line, '* '), 2 ) );
                                        $link = wfMsgForContent( $line[0] );
                                        if ($link == '-')
index ae894cc..c60cfb4 100644 (file)
@@ -964,62 +964,54 @@ class SkinTemplate extends Skin {
 
                global $wgRequest, $wgAllowUserCss, $wgUseSiteCss, $wgContLang, $wgSquidMaxage, $wgStylePath, $wgUser;
 
-               $stylesheets = array();
-               $rawcss = '';
+               $sitecss = '';
+               $usercss = '';
                $siteargs = '&maxage=' . $wgSquidMaxage;
-               $userPreview = false;
                if( $this->loggedin ) {
                        // Ensure that logged-in users' generated CSS isn't clobbered
                        // by anons' publicly cacheable generated CSS.
                        $siteargs .= '&smaxage=0';
-                       
-                       // If we allow user-specific code append some arguments for it
-                       if( $wgAllowUserCss ) {
-                               $action = $wgRequest->getText('action');
-                               $userPreview = $this->mTitle->isCssSubpage() && $this->userCanPreview( $action );
-                               $siteargs .= '&ts=' . $wgUser->mTouched;
-                               if( $userPreview ) $siteargs = "&smaxage=0&maxage=0";
+               }
+
+               # Add user-specific code if this is a user and we allow that kind of thing
+
+               if ( $wgAllowUserCss && $this->loggedin ) {
+                       $action = $wgRequest->getText('action');
+
+                       # if we're previewing the CSS page, use it
+                       if( $this->mTitle->isCssSubpage() and $this->userCanPreview( $action ) ) {
+                               $siteargs = "&smaxage=0&maxage=0";
+                               $usercss = $wgRequest->getText('wpTextbox1');
+                       } else {
+                               $usercss = '@import "' .
+                                 self::makeUrl($this->userpage . '/'.$this->skinname.'.css',
+                                                                'action=raw&ctype=text/css') . '";' ."\n";
                        }
+
+                       $siteargs .= '&ts=' . $wgUser->mTouched;
                }
-               
+
                if( $wgContLang->isRTL() && in_array( 'rtl', $this->cssfiles ) ) {
                        global $wgStyleVersion;
-                       $stylesheets['skinrtl'] = "$wgStylePath/$this->stylename/rtl.css?$wgStyleVersion";
+                       $sitecss .= "@import \"$wgStylePath/$this->stylename/rtl.css?$wgStyleVersion\";\n";
                }
-               
+
                # If we use the site's dynamic CSS, throw that in, too
-               if( $wgUseSiteCss ) {
+               if ( $wgUseSiteCss ) {
                        $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
                        $skinquery = '';
                        if (($us = $wgRequest->getVal('useskin', '')) !== '')
                                $skinquery = "&useskin=$us";
-                       $stylesheets['sitecommon'] = self::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI);
-                       $stylesheets['siteskin']   = self::makeNSUrl( ucfirst( $this->skinname ) . '.css', $query, NS_MEDIAWIKI );
-                       $stylesheets['gen']        = self::makeUrl( '-', "action=raw&gen=css$siteargs$skinquery" );
-               }
-               
-               # Add user-specific code if this is a user and we allow that kind of thing
-               if( $wgAllowUserCss && $this->loggedin ) {
-                       # if we're previewing the CSS page, use it
-                       if( $userPreview ) {
-                               $rawcss .= $wgRequest->getText('wpTextbox1');
-                       } else {
-                               $stylesheets['userskin'] = self::makeUrl(
-                                       $this->userpage . '/'.$this->skinname.'.css',
-                                       'action=raw&ctype=text/css');
-                       }
+                       $sitecss .= '@import "' . self::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI) . '";' . "\n";
+                       $sitecss .= '@import "' . self::makeNSUrl( ucfirst( $this->skinname ) . '.css', $query, NS_MEDIAWIKI ) . '";' . "\n";
+                       $sitecss .= '@import "' . self::makeUrl( '-', "action=raw&gen=css$siteargs$skinquery" ) . '";' . "\n";
                }
-               
-               wfRunHooks( 'SkinSetupSiteCss', array( &$stylesheets, &$rawcss, $query ) );
-               
+
                # If we use any dynamic CSS, make a little CDATA block out of it.
-               $s = '';
-               foreach( $stylesheets as $link ) {
-                       $s .= "@import \"$link\";\n";
+
+               if ( !empty($sitecss) || !empty($usercss) ) {
+                       $this->usercss = "/*<![CDATA[*/\n" . $sitecss . $usercss . '/*]]>*/';
                }
-               $s .= $rawcss;
-               if( $s != '' ) $this->usercss = "/*<![CDATA[*/\n{$s}/*]]>*/";
-               
                wfProfileOut( __METHOD__ );
        }
 
index bfbc0a8..e75e4ae 100644 (file)
@@ -156,7 +156,7 @@ class ModernTemplate extends QuickTemplate {
                if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
                if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
                if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;
-               
+
                foreach ($sidebar as $boxName => $cont) {
                        if ( $boxName == 'SEARCH' ) {
                                $this->searchBox();
@@ -165,10 +165,7 @@ class ModernTemplate extends QuickTemplate {
                        } elseif ( $boxName == 'LANGUAGES' ) {
                                $this->languageBox();
                        } else {
-                               if( wfRunHooks( 'SkinSidebarOutputSpecialBox', array( &$this, $boxName, $cont ) ) ) {
-                                       # If no hook returned false, then output a normal box
-                                       $this->customBox( $boxName, $cont );
-                               }
+                               $this->customBox( $boxName, $cont );
                        }
                }
        ?>
@@ -352,5 +349,4 @@ class ModernTemplate extends QuickTemplate {
        }
 
 } // end of class
-
-
+?>
index 6d3baf6..bfd94d5 100644 (file)
@@ -158,7 +158,6 @@ class MonoBookTemplate extends QuickTemplate {
                if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
                if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
                if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;
-               
                foreach ($sidebar as $boxName => $cont) {
                        if ( $boxName == 'SEARCH' ) {
                                $this->searchBox();
@@ -167,10 +166,7 @@ class MonoBookTemplate extends QuickTemplate {
                        } elseif ( $boxName == 'LANGUAGES' ) {
                                $this->languageBox();
                        } else {
-                               if( wfRunHooks( 'SkinSidebarOutputSpecialBox', array( &$this, $boxName, $cont ) ) ) {
-                                       # If no hook returned false, then output a normal box
-                                       $this->customBox( $boxName, $cont );
-                               }
+                               $this->customBox( $boxName, $cont );
                        }
                }
 ?>