(bug 4178) MediaWiki:Common.js will now be included for all users if $wgUseSiteJs...
authorAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 17 Nov 2006 02:05:34 +0000 (02:05 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 17 Nov 2006 02:05:34 +0000 (02:05 +0000)
No extra page loads, brion!

RELEASE-NOTES
includes/Skin.php
includes/SkinTemplate.php
languages/messages/MessagesEn.php

index f7bc31e..e841e8f 100644 (file)
@@ -192,6 +192,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   right on Apache too!
 * Replace 'old-revision-navigation' message with 'revision-info' and
   'revision-nav' messages, wrapped in divs with appropriate id's.
+* (bug 4178) MediaWiki:Common.js will now be included for all users if
+  $wgUseSiteJs is enabled, in addition to (if applicable) MediaWiki:Monobook.js
+  and user JS subpages.
 
 
 == Languages updated ==
index 0f9ca2c..8d52867 100644 (file)
@@ -324,6 +324,14 @@ class Skin extends Linker {
                $r = self::makeGlobalVariablesScript( $vars );
 
                $r .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>\n";
+               global $wgUseSiteJs;
+               if ($wgUseSiteJs) {
+                       if ($wgUser->isLoggedIn()) {
+                               $r .= "<script type=\"$wgJsMimeType\" src=\"".urlencode(self::makeUrl('-','action=raw&smaxage=0&gen=js'))."\"><!-- site js --></script>\n";
+                       } else {
+                               $r .= "<script type=\"$wgJsMimeType\" src=\"".urlencode(self::makeUrl('-','action=raw&gen=js'))."\"><!-- site js --></script>\n";
+                       }
+               }
                if( $wgAllowUserJs && $wgUser->isLoggedIn() ) {
                        $userpage = $wgUser->getUserPage();
                        $userjs = htmlspecialchars( self::makeUrl(
@@ -376,9 +384,27 @@ class Skin extends Linker {
        }
 
        /**
-        * placeholder, returns generated js in monobook
+        * This returns MediaWiki:Common.js.  For some bizarre reason, it does
+        * *not* return any custom user JS from user subpages.  Huh?
+        *
+        * @return string
         */
-       function getUserJs() { return; }
+       function getUserJs() {
+               $fname = 'Skin::getUserJs';
+               wfProfileIn( $fname );
+
+               global $wgStylePath;
+               $s = "/* generated javascript */\n";
+               $s .= "var skin = '{$this->skinname}';\nvar stylepath = '{$wgStylePath}';";
+               $s .= "\n\n/* MediaWiki:Common.js */\n";
+               $commonJs = wfMsgForContent('Common.js');
+               if ( !wfEmptyMsg ( 'Common.js', $commonJs ) ) {
+                       $s .= $commonJs;
+               }
+
+               wfProfileOut( $fname );
+               return $s;
+    }
 
        /**
         * Return html code that include User stylesheets
index a4238cc..95bd876 100644 (file)
@@ -1013,16 +1013,23 @@ class SkinTemplate extends Skin {
        }
 
        /**
-        * @public
+        * This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate-
+        * nated together.  For some bizarre reason, it does *not* return any
+        * custom user JS from subpages.  Huh?
+        *
+        * There's absolutely no reason to have separate Monobook/Common JSes.
+        * Any JS that cares can just check the skin variable generated at the
+        * top.  For now Monobook.js will be maintained, but it should be consi-
+        * dered deprecated.
+        *
+        * @return string
         */
-       function getUserJs() {
+       public function getUserJs() {
                $fname = 'SkinTemplate::getUserJs';
                wfProfileIn( $fname );
 
-               global $wgStylePath;
-               $s = '/* generated javascript */';
-               $s .= "var skin = '{$this->skinname}';\nvar stylepath = '{$wgStylePath}';";
-               $s .= '/* MediaWiki:'.ucfirst($this->skinname)." */\n";
+               $s = parent::getUserJs();
+               $s .= "\n\n/* MediaWiki:".ucfirst($this->skinname).".js (deprecated; migrate to Common.js!) */\n";
 
                // avoid inclusion of non defined user JavaScript (with custom skins only)
                // by checking for default message content
index c16609c..5814df1 100644 (file)
@@ -2127,6 +2127,9 @@ ta[\'ca-nstab-template\'] = new Array(\'c\',\'View the template\');
 ta[\'ca-nstab-help\'] = new Array(\'c\',\'View the help page\');
 ta[\'ca-nstab-category\'] = new Array(\'c\',\'View the category page\');',
 
+# Common.js: contains nothing but a placeholder comment
+'Common.js' => '/* Any JavaScript here will be loaded for all users on every page load. */',
+
 # image deletion
 'deletedrevision' => 'Deleted old revision $1.',