r37719 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37718‎ | r37719 | r37720 >
Date:21:35, 15 July 2008
Author:brion
Status:old
Tags:
Comment:
Revert r37686, 37687 for now:

"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.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/docs/hooks.txt (modified) (history)
  • /trunk/phase3/includes/Skin.php (modified) (history)
  • /trunk/phase3/includes/SkinTemplate.php (modified) (history)
  • /trunk/phase3/skins/Modern.php (modified) (history)
  • /trunk/phase3/skins/MonoBook.php (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/MonoBook.php
@@ -158,7 +158,6 @@
159159 if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
160160 if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
161161 if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;
162 -
163162 foreach ($sidebar as $boxName => $cont) {
164163 if ( $boxName == 'SEARCH' ) {
165164 $this->searchBox();
@@ -167,10 +166,7 @@
168167 } elseif ( $boxName == 'LANGUAGES' ) {
169168 $this->languageBox();
170169 } else {
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 - }
 170+ $this->customBox( $boxName, $cont );
175171 }
176172 }
177173 ?>
Index: trunk/phase3/skins/Modern.php
@@ -156,7 +156,7 @@
157157 if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
158158 if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
159159 if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;
160 -
 160+
161161 foreach ($sidebar as $boxName => $cont) {
162162 if ( $boxName == 'SEARCH' ) {
163163 $this->searchBox();
@@ -165,10 +165,7 @@
166166 } elseif ( $boxName == 'LANGUAGES' ) {
167167 $this->languageBox();
168168 } else {
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 - }
 169+ $this->customBox( $boxName, $cont );
173170 }
174171 }
175172 ?>
@@ -352,5 +349,4 @@
353350 }
354351
355352 } // end of class
356 -
357 -
 353+?>
Index: trunk/phase3/docs/hooks.txt
@@ -1056,27 +1056,6 @@
10571057 &$text: bottomScripts Text
10581058 Append to $text to add additional text/scripts after the stock bottom scripts.
10591059
1060 -'SkinGlobalVariables': Allows modification of the JS global variables exported to the browser
1061 -&$vars: The list of variables
1062 -
1063 -'SkinSetupSiteCss': Allows modification of the stylesheets and css imported into the skin
1064 -&$stylesheets: The list of stylesheet urls for importing, keys allow for internal things to be
1065 -unset or have query arguments appended
1066 -&$rawcss: Raw css to be exported
1067 -$msgQuery: Query containing caching and other params to use when adding a stylesheet url
1068 -that comes from a MediaWiki: message page
1069 -
1070 -'SkinSidebarOutputSpecialBox': Allows for custom outputting of special sidebar boxes
1071 -&$skin: Skin object
1072 -$boxName: Name of the skin box to output
1073 -$cont: Content array which may be used for options
1074 -
1075 -'SkinSidebarSpecialBox': Allows for extension definition of custom special sidebar boxes
1076 -Set $cont to an array of initial data and return false to define a new sidebar box
1077 -&$skin: Skin object
1078 -$boxName: Name of the custom box to match
1079 -&$cont: Content array
1080 -
10811060 'SkinSubPageSubtitle': At the beginning of Skin::subPageSubtitle()
10821061 $skin: Skin object
10831062 &$subpages: Subpage links HTML
Index: trunk/phase3/includes/SkinTemplate.php
@@ -964,62 +964,54 @@
965965
966966 global $wgRequest, $wgAllowUserCss, $wgUseSiteCss, $wgContLang, $wgSquidMaxage, $wgStylePath, $wgUser;
967967
968 - $stylesheets = array();
969 - $rawcss = '';
 968+ $sitecss = '';
 969+ $usercss = '';
970970 $siteargs = '&maxage=' . $wgSquidMaxage;
971 - $userPreview = false;
972971 if( $this->loggedin ) {
973972 // Ensure that logged-in users' generated CSS isn't clobbered
974973 // by anons' publicly cacheable generated CSS.
975974 $siteargs .= '&smaxage=0';
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";
 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";
983990 }
 991+
 992+ $siteargs .= '&ts=' . $wgUser->mTouched;
984993 }
985 -
 994+
986995 if( $wgContLang->isRTL() && in_array( 'rtl', $this->cssfiles ) ) {
987996 global $wgStyleVersion;
988 - $stylesheets['skinrtl'] = "$wgStylePath/$this->stylename/rtl.css?$wgStyleVersion";
 997+ $sitecss .= "@import \"$wgStylePath/$this->stylename/rtl.css?$wgStyleVersion\";\n";
989998 }
990 -
 999+
9911000 # If we use the site's dynamic CSS, throw that in, too
992 - if( $wgUseSiteCss ) {
 1001+ if ( $wgUseSiteCss ) {
9931002 $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
9941003 $skinquery = '';
9951004 if (($us = $wgRequest->getVal('useskin', '')) !== '')
9961005 $skinquery = "&useskin=$us";
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" );
 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";
10001009 }
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 -
 1010+
10161011 # If we use any dynamic CSS, make a little CDATA block out of it.
1017 - $s = '';
1018 - foreach( $stylesheets as $link ) {
1019 - $s .= "@import \"$link\";\n";
 1012+
 1013+ if ( !empty($sitecss) || !empty($usercss) ) {
 1014+ $this->usercss = "/*<![CDATA[*/\n" . $sitecss . $usercss . '/*]]>*/';
10201015 }
1021 - $s .= $rawcss;
1022 - if( $s != '' ) $this->usercss = "/*<![CDATA[*/\n{$s}/*]]>*/";
1023 -
10241016 wfProfileOut( __METHOD__ );
10251017 }
10261018
Index: trunk/phase3/includes/Skin.php
@@ -361,8 +361,6 @@
362362 }
363363 $vars['wgAjaxWatch'] = $msgs;
364364 }
365 -
366 - wfRunHooks('SkinGlobalVariables', array(&$vars));
367365
368366 return self::makeVariablesScript( $vars );
369367 }
@@ -420,25 +418,17 @@
421419 function getUserStylesheet() {
422420 global $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage, $wgStyleVersion;
423421 $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+
424427 $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
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";
 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";
443433 }
444434
445435 /**
@@ -1682,35 +1672,19 @@
16831673 $bar = array();
16841674 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
16851675 $heading = '';
1686 - $specialBox = false;
16871676 foreach ($lines as $line) {
16881677 if (strpos($line, '*') !== 0)
16891678 continue;
16901679 if (strpos($line, '**') !== 0) {
16911680 $line = trim($line, '* ');
1692 -
16931681 if ( $line == 'SEARCH' || $line == 'TOOLBOX' || $line == 'LANGUAGES' ) {
1694 - # Internal special box type
 1682+ # Special box type
16951683 $bar[$line] = array();
1696 - $specialBox = true;
16971684 } else {
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 - }
 1685+ $heading = $line;
17081686 }
1709 - $heading = $line;
17101687 } else {
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
 1688+ if (strpos($line, '|') !== false) { // sanity check
17151689 $line = array_map('trim', explode( '|' , trim($line, '* '), 2 ) );
17161690 $link = wfMsgForContent( $line[0] );
17171691 if ($link == '-')
Index: trunk/phase3/RELEASE-NOTES
@@ -181,19 +181,12 @@
182182 * (bug 11732) Allow localisation of edit button images
183183 * Allow the search box, toolbox and languages box in the Monobook sidebar to be
184184 moved around arbitrarily using special sections in [[MediaWiki:Sidebar]]:
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.
 185+ SEARCH, TOOLBOX and LANGUAGES
188186 * Add a new hook NormalizeMessageKey to allow extensions to replace messages before
189187 the database is potentially queried
190188 * (bug 9736) Redirects on Special:Fewestrevisions are now marked as such.
191189 * New date/time formats in Cs localization according to ČSN and PČP.
192 -* Add a new hook SkinSetupSiteCss to allow extensions to define new stylesheets
193 - to load site wide, or modify the list of stylesheets to load. This can be useful
194 - for wiki farms who need a specific placement of the stylesheets to cascade right.
195 -* Add a new hook SkinGlobalVariables to allow extensions to add new global variables
196 - to be exported for JavaScript code to make use of.
197 -
 190+
198191 === Bug fixes in 1.13 ===
199192
200193 * (bug 10677) Add link to the file description page on the shared repository

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r37686Improving extendibility of the sidebar improvements, css adding, and also JS ...dantman11:03, 15 July 2008

Status & tagging log