* (bug 2064) Configurable JavaScript mimetype with $wgJsMimeType
authorÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Thu, 5 May 2005 21:00:49 +0000 (21:00 +0000)
committerÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Thu, 5 May 2005 21:00:49 +0000 (21:00 +0000)
14 files changed:
RELEASE-NOTES
includes/DefaultSettings.php
includes/EditPage.php
includes/Linker.php
includes/RawPage.php
includes/Skin.php
includes/SkinTemplate.php
skins/MonoBook.php
skins/Standard.php
skins/disabled/Amethyst.pt
skins/disabled/Chick.pt
skins/disabled/HTMLDump.php
skins/disabled/MonoBook.pt
skins/disabled/WikimediaWiki.pt

index 32b0e67..06ce3e6 100644 (file)
@@ -147,6 +147,7 @@ Various bugfixes, small features, and a few experimental things:
 * (bug 1739) A new magicword, {{REVISIONID}} give you the article or diff database
   revision id, useful for proper citation.
 * (bug 1998) Updated the Russian translation.
+* (bug 2064) Configurable JavaScript mimetype with $wgJsMimeType
 * It's now possible to invert the namespace selection at Special:Allpages and Special:Contributions
 * No longer using sorbs.net to check for open proxies by default.
 * What was $wgDisableUploads is now $wgEnableUploads, and should be set to true if one wishes to enable uploads.
index c34a8c5..587870c 100644 (file)
@@ -374,6 +374,7 @@ $wgEditEncoding             = '';
 $wgLegacyEncoding   = false;
 
 $wgMimeType                    = 'text/html';
+$wgJsMimeType                  = 'text/javascript';
 $wgDocType                     = '-//W3C//DTD XHTML 1.0 Transitional//EN';
 $wgDTD                         = 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd';
 
index 0696872..093a9c4 100644 (file)
@@ -628,7 +628,8 @@ class EditPage {
                 * it will fall through to the normal form submission method.
                 */
                if( $wgLivePreview ) {
-                       $wgOut->addHTML( '<script type="text/javascript" src="' .
+                       global $wgJsMimeType;
+                       $wgOut->addHTML( '<script type="'.$wgJsMimeType.'" src="' .
                                htmlspecialchars( $wgStylePath . '/common/preview.js' ) .
                                '"></script>' . "\n" );
                        $liveAction = $wgTitle->getLocalUrl( 'action=submit&wpPreview=true&live=true' );
@@ -923,7 +924,7 @@ END
         * The necessary JavaScript code can be found in style/wikibits.js.
         */
        function getEditToolbar() {
-               global $wgStylePath, $wgLang, $wgMimeType;
+               global $wgStylePath, $wgLang, $wgMimeType, $wgJsMimeType;
 
                /**
                 * toolarray an array of arrays which each include the filename of
@@ -1015,7 +1016,7 @@ END
                                        'key'   =>      'R'
                                )
                );
-               $toolbar ="<script type='text/javascript'>\n/*<![CDATA[*/\n";
+               $toolbar ="<script type='$wgJsMimeType'>\n/*<![CDATA[*/\n";
 
                $toolbar.="document.writeln(\"<div id='toolbar'>\");\n";
                foreach($toolarray as $tool) {
index c0bff50..a63288a 100644 (file)
@@ -718,11 +718,12 @@ class Linker {
 
        /** @todo document */
        function tocList($toc) {
+               global $wgJsMimeType;
                return "<table id='toc' class='toc'><tr><td>" 
                           . "<div id='toctitle'><h2>" . wfMsgForContent('toc') . "</h2></div>\n"
                     . $toc
                                 . "</ul>\n</td></tr></table>\n"
-                                . '<script type="text/javascript">'
+                                . '<script type="'.$wgJsMimeType.'">'
                                 . ' if (window.showTocToggle) {'
                                 . ' var tocShowText = "' . wfEscapeJsString( wfMsgForContent('showtoc') ) . '";'
                                 . ' var tocHideText = "' . wfEscapeJsString( wfMsgForContent('hidetoc') ) . '";'
index fdbd0a8..e3ea7f7 100644 (file)
@@ -20,8 +20,8 @@ require_once( 'Revision.php' );
 class RawPage {
 
        function RawPage( $article ) {
-               global $wgRequest, $wgInputEncoding, $wgSquidMaxage;
-               $allowedCTypes = array('text/x-wiki', 'text/javascript', 'text/css', 'application/x-zope-edit');
+               global $wgRequest, $wgInputEncoding, $wgSquidMaxage, $wgJsMimeType;
+               $allowedCTypes = array('text/x-wiki', $wgJsMimeType, 'text/css', 'application/x-zope-edit');
                $this->mArticle =& $article;
                $this->mTitle =& $article->mTitle;
                        
@@ -38,7 +38,7 @@ class RawPage {
                } else if ($gen == 'js') {
                        $this->mGen = $gen;
                        if($smaxage == '') $smaxage = $wgSquidMaxage;
-                       if($ctype == '') $ctype = 'text/javascript';
+                       if($ctype == '') $ctype = $wgJsMimeType;
                } else {
                        $this->mGen = false;
                }
index 2f79d90..d717a68 100644 (file)
@@ -172,14 +172,14 @@ class Skin extends Linker {
        }
 
        function getHeadScripts() {
-               global $wgStylePath, $wgUser, $wgContLang, $wgAllowUserJs;
-               $r = "<script type=\"text/javascript\" src=\"{$wgStylePath}/common/wikibits.js\"></script>\n";
+               global $wgStylePath, $wgUser, $wgContLang, $wgAllowUserJs, $wgJsMimeType;
+               $r = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js\"></script>\n";
                if( $wgAllowUserJs && $wgUser->isLoggedIn() ) {
                        $userpage = $wgUser->getUserPage();
                        $userjs = htmlspecialchars( $this->makeUrl(
                                $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
-                               'action=raw&ctype=text/javascript'));
-                       $r .= '<script type="text/javascript" src="'.$userjs."\"></script>\n";
+                               'action=raw&ctype='.$wgJsMimeType));
+                       $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
                }
                return $r;
        }
index 9e34601..6f71eaa 100644 (file)
@@ -145,7 +145,7 @@ class SkinTemplate extends Skin {
        function outputPage( &$out ) {
                global $wgTitle, $wgArticle, $wgUser, $wgLang, $wgContLang, $wgOut;
                global $wgScript, $wgStylePath, $wgLanguageCode, $wgContLanguageCode, $wgUseNewInterlanguage;
-               global $wgMimeType, $wgOutputEncoding, $wgUseDatabaseMessages, $wgRequest;
+               global $wgMimeType, $wgJsMimeType, $wgOutputEncoding, $wgUseDatabaseMessages, $wgRequest;
                global $wgDisableCounters, $wgLogo, $action, $wgFeedClasses;
                global $wgMaxCredits, $wgShowCreditsIfMax;
                global $wgPageShowWatchingUsers;
@@ -218,6 +218,7 @@ class SkinTemplate extends Skin {
                        $tpl->set( 'feeds', false );
                }
                $tpl->setRef( 'mimetype', $wgMimeType );
+               $tpl->setRef( 'jsmimetype', $wgJsMimeType );
                $tpl->setRef( 'charset', $wgOutputEncoding );
                $tpl->set( 'headlinks', $out->getHeadLinks() );
                $tpl->setRef( 'wgScript', $wgScript );
@@ -898,7 +899,7 @@ class SkinTemplate extends Skin {
                $fname = 'SkinTemplate::setupUserJs';
                wfProfileIn( $fname );
                
-               global $wgRequest, $wgAllowUserJs;
+               global $wgRequest, $wgAllowUserJs, $wgJsMimeType;
                $action = $wgRequest->getText('action');
 
                if( $wgAllowUserJs && $this->loggedin ) {
@@ -906,7 +907,7 @@ class SkinTemplate extends Skin {
                                # XXX: additional security check/prompt?
                                $this->userjsprev = '/*<![CDATA[*/ ' . $wgRequest->getText('wpTextbox1') . ' /*]]>*/';
                        } else {
-                               $this->userjs = $this->makeUrl($this->userpage.'/'.$this->skinname.'.js', 'action=raw&ctype=text/javascript&dontcountme=s');
+                               $this->userjs = $this->makeUrl($this->userpage.'/'.$this->skinname.'.js', 'action=raw&ctype='.$wgJsMimeType.'&dontcountme=s');
                        }
                }
                wfProfileOut( $fname );
index f0c4f30..952b86d 100644 (file)
@@ -61,13 +61,13 @@ class MonoBookTemplate extends QuickTemplate {
     <!--[if lt IE 5.5000]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE50Fixes.css";</style><![endif]-->
     <!--[if IE 5.5000]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE55Fixes.css";</style><![endif]-->
     <!--[if IE 6]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE60Fixes.css";</style><![endif]-->
-    <!--[if IE]><script type="text/javascript" src="<?php $this->text('stylepath') ?>/common/IEFixes.js"></script>
+    <!--[if IE]><script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath') ?>/common/IEFixes.js"></script>
     <meta http-equiv="imagetoolbar" content="no" /><![endif]-->
-    <?php if($this->data['jsvarurl'  ]) { ?><script type="text/javascript" src="<?php $this->text('jsvarurl'  ) ?>"></script><?php } ?>
-    <script type="text/javascript" src="<?php                                   $this->text('stylepath' ) ?>/common/wikibits.js"></script>
+    <?php if($this->data['jsvarurl'  ]) { ?><script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('jsvarurl'  ) ?>"></script><?php } ?>
+    <script type="<?php $this->text('jsmimetype') ?>" src="<?php                                   $this->text('stylepath' ) ?>/common/wikibits.js"></script>
     <?php if($this->data['usercss'   ]) { ?><style type="text/css"><?php              $this->html('usercss'   ) ?></style><?php    } ?>
-    <?php if($this->data['userjs'    ]) { ?><script type="text/javascript" src="<?php $this->text('userjs'    ) ?>"></script><?php } ?>
-    <?php if($this->data['userjsprev']) { ?><script type="text/javascript"><?php      $this->html('userjsprev') ?></script><?php   } ?>
+    <?php if($this->data['userjs'    ]) { ?><script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('userjs'    ) ?>"></script><?php } ?>
+    <?php if($this->data['userjsprev']) { ?><script type="<?php $this->text('jsmimetype') ?>"><?php      $this->html('userjsprev') ?></script><?php   } ?>
   </head>
   <body <?php if($this->data['body_ondblclick']) { ?>ondblclick="<?php $this->text('body_ondblclick') ?>"<?php } ?>
         <?php if($this->data['body_onload'    ]) { ?>onload="<?php     $this->text('body_onload')     ?>"<?php } ?>
@@ -122,7 +122,7 @@ class MonoBookTemplate extends QuickTemplate {
            href="<?php echo htmlspecialchars($this->data['nav_urls']['mainpage']['href'])?>"
            title="<?php $this->msg('mainpage') ?>"></a>
        </div>
-       <script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script>
+       <script type="<?php $this->text('jsmimetype') ?>"> if (window.isMSIE55) fixalpha(); </script>
        <div class="portlet" id="p-nav">
          <h5><?php $this->msg('navigation') ?></h5>
          <div class="pBody">
index 1c72f0d..44c1a4f 100644 (file)
@@ -21,11 +21,11 @@ class SkinStandard extends Skin {
         *
         */
        function getHeadScripts() {
-               global $wgStylePath;
+               global $wgStylePath, $wgJsMimeType;
 
                $s = parent::getHeadScripts();
                if ( 3 == $this->qbSetting() ) { # Floating left
-                       $s .= "<script language='javascript' type='text/javascript' " .
+                       $s .= "<script language='javascript' type='$wgJsMimeType' " .
                          "src='{$wgStylePath}/common/sticky.js'></script>\n";
                }
                return $s;
index 48a698b..aa2c10d 100644 (file)
@@ -7,13 +7,13 @@
     <style type="text/css" media="screen,projection">/*<![CDATA[*/ @import "${stylepath}/${stylename}/main.css"; /*]]>*/</style>
     <link rel="stylesheet" type="text/css" media="print" href="${stylepath}/common/commonPrint.css" />
     <!--[if IE]><style type="text/css" media="all">@import "${stylepath}/${stylename}/IEFixes.css";</style>
-    <script type="text/javascript" src="${stylepath}/common/IEFixes.js"></script>
+    <script type="${jsmimetype}" src="${stylepath}/common/IEFixes.js"></script>
     <meta http-equiv="imagetoolbar" content="no" /><![endif]-->
-    <script tal:condition="jsvarurl" type="text/javascript" tal:attributes="src jsvarurl"></script>
-    <script type="text/javascript" src="${stylepath}/common/wikibits.js"></script>
+    <script tal:condition="jsvarurl" type="${jsmimetype}" tal:attributes="src jsvarurl"></script>
+    <script type="${jsmimetype}" src="${stylepath}/common/wikibits.js"></script>
     <style tal:condition="usercss" type="text/css">/*<![CDATA[*/ ${usercss} /*]]>*/</style>
-    <script tal:condition="userjs" type="text/javascript" tal:attributes="src userjs"></script><script 
-      tal:condition="userjsprev" type="text/javascript">/*<![CDATA[*/${userjsprev}/*]]>*/</script>
+    <script tal:condition="userjs" type="${jsmimetype}" tal:attributes="src userjs"></script><script 
+      tal:condition="userjsprev" type="${jsmimetype}">/*<![CDATA[*/${userjsprev}/*]]>*/</script>
   </head>
   <body tal:attributes="ondblclick body-ondblclick|default; class nsclass|default">
     <div id="globalWrapper">
@@ -59,7 +59,7 @@
        <div class="portlet" id="p-logo">
          <a style="background-image: url(${logopath});" href="${nav_urls/mainpage/href}" i18n:attributes="title string:mainpage"></a>
        </div>
-       <script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script>
+       <script type="${jsmimetype}"> if (window.isMSIE55) fixalpha(); </script>
        <div class="portlet" id="p-nav">
          <h5 i18n:translate="string:navigation">Navigation</h5>
          <div class="pBody">
index f6d7092..9ea755c 100644 (file)
@@ -5,11 +5,11 @@
     <div tal:replace="structure headlinks"></div>
     <title tal:content="pagetitle">Exciting xhtml slimfast</title>
     <style type="text/css" media="screen,projection">/*<![CDATA[*/ @import "${stylepath}/${stylename}/main.css"; /*]]>*/</style>
-    <script tal:condition="jsvarurl" type="text/javascript" tal:attributes="src jsvarurl"></script>
-    <script type="text/javascript" src="${stylepath}/common/wikibits.js"></script>
+    <script tal:condition="jsvarurl" type="${jsmimetype}" tal:attributes="src jsvarurl"></script>
+    <script type="${jsmimetype}" src="${stylepath}/common/wikibits.js"></script>
     <style tal:condition="usercss" tal:content="structure usercss" type="text/css"></style>
-    <script tal:condition="userjs" type="text/javascript" tal:attributes="src userjs"></script><script 
-      tal:condition="userjsprev" tal:content="structure userjsprev" type="text/javascript"></script>
+    <script tal:condition="userjs" type="${jsmimetype}" tal:attributes="src userjs"></script><script 
+      tal:condition="userjsprev" tal:content="structure userjsprev" type="${jsmimetype}"></script>
   </head>
   <body>
     <a name="top"></a>
index 5d94389..d933591 100644 (file)
@@ -105,10 +105,10 @@ class HTMLDumpTemplate extends QuickTemplate {
     <!--[if lt IE 5.5000]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE50Fixes.css";</style><![endif]-->
     <!--[if IE 5.5000]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE55Fixes.css";</style><![endif]-->
     <!--[if IE 6]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE60Fixes.css";</style><![endif]-->
-    <!--[if IE]><script type="text/javascript" src="<?php $this->text('stylepath') ?>/common/IEFixes.js"></script>
+    <!--[if IE]><script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath') ?>/common/IEFixes.js"></script>
     <meta http-equiv="imagetoolbar" content="no" /><![endif]-->
-    <?php if($this->data['jsvarurl'  ]) { ?><script type="text/javascript" src="<?php $this->text('jsvarurl'  ) ?>"></script><?php } ?>
-    <script type="text/javascript" src="<?php $this->text('stylepath' ) ?>/common/wikibits.js"></script>
+    <?php if($this->data['jsvarurl'  ]) { ?><script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('jsvarurl'  ) ?>"></script><?php } ?>
+    <script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath' ) ?>/common/wikibits.js"></script>
   </head>
   <body 
     <?php if($this->data['nsclass'        ]) { ?>class="<?php      $this->text('nsclass')         ?>"<?php } ?>>
@@ -148,7 +148,7 @@ class HTMLDumpTemplate extends QuickTemplate {
            href="<?php echo htmlspecialchars($this->data['nav_urls']['mainpage']['href'])?>"
            title="<?php $this->msg('mainpage') ?>"></a>
        </div>
-       <script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script>
+       <script type="<?php $this->text('jsmimetype') ?>"> if (window.isMSIE55) fixalpha(); </script>
        <div class="portlet" id="p-nav">
          <h5><?php $this->msg('navigation') ?></h5>
          <div class="pBody">
index 2bb67eb..56179f1 100644 (file)
@@ -9,13 +9,13 @@
     <!--[if lt IE 5.5000]><style type="text/css"> @import "${stylepath}/${stylename}/IE50Fixes.css"; </style><![endif]-->
     <!--[if IE 5.5000]><style type="text/css"> @import "${stylepath}/${stylename}/IE55Fixes.css"; </style><![endif]-->
     <!--[if IE 6]><style type="text/css"> @import "${stylepath}/${stylename}/IE60Fixes.css"; </style><![endif]-->
-    <!--[if IE]><script type="text/javascript" src="${stylepath}/common/IEFixes.js"></script>
+    <!--[if IE]><script type="${jsmimetype}" src="${stylepath}/common/IEFixes.js"></script>
     <meta http-equiv="imagetoolbar" content="no" /><![endif]-->
-    <script tal:condition="jsvarurl" type="text/javascript" tal:attributes="src jsvarurl"></script>
-    <script type="text/javascript" src="${stylepath}/common/wikibits.js"></script>
+    <script tal:condition="jsvarurl" type="${jsmimetype}" tal:attributes="src jsvarurl"></script>
+    <script type="${jsmimetype}" src="${stylepath}/common/wikibits.js"></script>
     <style tal:condition="usercss" tal:content="structure usercss" type="text/css"></style>
-    <script tal:condition="userjs" type="text/javascript" tal:attributes="src userjs"></script><script 
-      tal:condition="userjsprev" tal:content="structure userjsprev" type="text/javascript"></script>
+    <script tal:condition="userjs" type="${jsmimetype}" tal:attributes="src userjs"></script><script 
+      tal:condition="userjsprev" tal:content="structure userjsprev" type="${jsmimetype}"></script>
   </head>
   <body tal:attributes="ondblclick body_ondblclick|default; class nsclass|default">
     <div id="globalWrapper">
@@ -61,7 +61,7 @@
        <div class="portlet" id="p-logo">
          <a style="background-image: url(${logopath});" href="${nav_urls/mainpage/href}" i18n:attributes="title string:mainpage"></a>
        </div>
-       <script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script>
+       <script type="${jsmimetype}"> if (window.isMSIE55) fixalpha(); </script>
        <div class="portlet" id="p-nav">
          <h5 i18n:translate="string:navigation">Navigation</h5>
          <div class="pBody">
index 06f8761..27e434e 100644 (file)
@@ -7,13 +7,13 @@
     <style type="text/css" media="screen,projection">/*<![CDATA[*/ @import "${stylepath}/${stylename}/main.css"; /*]]>*/</style>
     <link rel="stylesheet" type="text/css" media="print" href="${stylepath}/common/commonPrint.css" />
     <!--[if IE]><style type="text/css" media="all">@import "${stylepath}/${stylename}/common/IEFixes.css";</style>
-    <script type="text/javascript" src="${stylepath}/IEFixes.js"></script>
+    <script type="${jsmimetype}" src="${stylepath}/IEFixes.js"></script>
     <meta http-equiv="imagetoolbar" content="no" /><![endif]-->
-    <script tal:condition="jsvarurl" type="text/javascript" tal:attributes="src jsvarurl"></script>
-    <script type="text/javascript" src="${stylepath}/common/wikibits.js"></script>
+    <script tal:condition="jsvarurl" type="${jsmimetype}" tal:attributes="src jsvarurl"></script>
+    <script type="${jsmimetype}" src="${stylepath}/common/wikibits.js"></script>
     <style tal:condition="usercss" type="text/css">/*<![CDATA[*/ ${usercss} /*]]>*/</style>
-    <script tal:condition="userjs" type="text/javascript" tal:attributes="src userjs"></script><script 
-      tal:condition="userjsprev" type="text/javascript">/*<![CDATA[*/${userjsprev}/*]]>*/</script>
+    <script tal:condition="userjs" type="${jsmimetype}" tal:attributes="src userjs"></script><script 
+      tal:condition="userjsprev" type="${jsmimetype}">/*<![CDATA[*/${userjsprev}/*]]>*/</script>
   </head>
   <body tal:attributes="ondblclick body-ondblclick|default; class nsclass|default">
     <div id="globalWrapper">
@@ -59,7 +59,7 @@
        <div class="portlet" id="p-logo">
          <a style="background-image: url(${logopath});" href="${nav_urls/mainpage/href}" i18n:attributes="title string:mainpage"></a>
        </div>
-       <script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script>
+       <script type="${jsmimetype}"> if (window.isMSIE55) fixalpha(); </script>
        <div class="portlet" id="p-nav">
          <h5 i18n:translate="string:navigation">Navigation</h5>
          <div class="pBody">