* (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
+ 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.
* 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.
* HTML entities like now work (are not escaped) in edit summaries.
* (bug 13815) In the comment for page moves, use the colon-separator message
instead of a hardcoded colon.
-
+* 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
&$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
}
$vars['wgAjaxWatch'] = $msgs;
}
+
+ wfRunHooks('SkinGlobalVariables', array(&$vars));
return self::makeVariablesScript( $vars );
}
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";
- $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";
+
+ $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";
}
/**
$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' ) {
- # Special box type
+ # Internal special box type
$bar[$line] = array();
+ $specialBox = true;
} else {
- $heading = $line;
+ $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;
} else {
- if (strpos($line, '|') !== false) { // sanity check
+ if( $specialBox ) {
+ # Inside a special box, we just append the lines into the $cont
+ $bar[$heading][] = $line;
+ } elseif (strpos($line, '|') !== false) { // sanity check
$line = array_map('trim', explode( '|' , trim($line, '* '), 2 ) );
$link = wfMsgForContent( $line[0] );
if ($link == '-')
global $wgRequest, $wgAllowUserCss, $wgUseSiteCss, $wgContLang, $wgSquidMaxage, $wgStylePath, $wgUser;
- $sitecss = '';
- $usercss = '';
+ $stylesheets = array();
+ $rawcss = '';
$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';
- }
-
- # 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";
+
+ // 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";
}
-
- $siteargs .= '&ts=' . $wgUser->mTouched;
}
-
+
if( $wgContLang->isRTL() && in_array( 'rtl', $this->cssfiles ) ) {
global $wgStyleVersion;
- $sitecss .= "@import \"$wgStylePath/$this->stylename/rtl.css?$wgStyleVersion\";\n";
+ $stylesheets['skinrtl'] = "$wgStylePath/$this->stylename/rtl.css?$wgStyleVersion";
}
-
+
# 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";
- $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";
+ $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');
+ }
+ }
+
+ wfRunHooks( 'SkinSetupSiteCss', array( &$stylesheets, &$rawcss, $query ) );
+
# If we use any dynamic CSS, make a little CDATA block out of it.
-
- if ( !empty($sitecss) || !empty($usercss) ) {
- $this->usercss = "/*<![CDATA[*/\n" . $sitecss . $usercss . '/*]]>*/';
+ $s = '';
+ foreach( $stylesheets as $link ) {
+ $s .= "@import \"$link\";\n";
}
+ $s .= $rawcss;
+ if( $s != '' ) $this->usercss = "/*<![CDATA[*/\n{$s}/*]]>*/";
+
wfProfileOut( __METHOD__ );
}
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();
} elseif ( $boxName == 'LANGUAGES' ) {
$this->languageBox();
} else {
- $this->customBox( $boxName, $cont );
+ if( wfRunHooks( 'SkinSidebarOutputSpecialBox', array( &$this, $boxName, $cont ) ) ) {
+ # If no hook returned false, then output a normal box
+ $this->customBox( $boxName, $cont );
+ }
}
}
?>
}
} // end of class
-?>
+
+
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();
} elseif ( $boxName == 'LANGUAGES' ) {
$this->languageBox();
} else {
- $this->customBox( $boxName, $cont );
+ if( wfRunHooks( 'SkinSidebarOutputSpecialBox', array( &$this, $boxName, $cont ) ) ) {
+ # If no hook returned false, then output a normal box
+ $this->customBox( $boxName, $cont );
+ }
}
}
?>