http://www.mediawiki.org/wiki/Special:Code/MediaWiki/73571
Revision: 73571
Author: kaldari
Date: 2010-09-22 21:03:27 +0000 (Wed, 22 Sep 2010)
Log Message:
-----------
use $wgJsMimeType, ensure cachability of JSONP requests, escape
$wgCentralPagePath before putting into javascript (fixes for r73554)
Modified Paths:
--------------
trunk/extensions/CentralNotice/SpecialBannerController.php
trunk/extensions/CentralNotice/SpecialBannerListLoader.php
trunk/extensions/CentralNotice/SpecialBannerLoader.php
Modified: trunk/extensions/CentralNotice/SpecialBannerController.php
===================================================================
--- trunk/extensions/CentralNotice/SpecialBannerController.php 2010-09-22
20:55:52 UTC (rev 73570)
+++ trunk/extensions/CentralNotice/SpecialBannerController.php 2010-09-22
21:03:27 UTC (rev 73571)
@@ -6,7 +6,6 @@
class SpecialBannerController extends UnlistedSpecialPage {
protected $sharedMaxAge = 7200; // Cache for 2 hours on the server side
protected $maxAge = 7200; // Cache for 2 hours on the client side
- protected $contentType = 'text/javascript';
function __construct() {
// Register special page
@@ -34,7 +33,8 @@
* Generate the HTTP response headers for the banner controller
*/
function sendHeaders() {
- header( "Content-type: $this->contentType; charset=utf-8" );
+ global $wgJsMimeType;
+ header( "Content-type: $wgJsMimeType; charset=utf-8" );
header( "Cache-Control: public, s-maxage=$this->sharedMaxAge,
max-age=$this->maxAge" );
}
@@ -47,6 +47,7 @@
$js = $this->getScriptFunctions() . $this->getToggleScripts();
$js .= <<<EOT
( function( $ ) {
+ $.ajaxSetup({ cache: true });
$.centralNotice = {
'data': {
'getVars': {}
@@ -56,7 +57,7 @@
// Get the requested banner
var bannerPage =
'Special:BannerLoader?banner='+bannerName+'&userlang='+wgContentLanguage+'&sitename='+wgNoticeProject;
EOT;
- $js .= "\n\t\t\t\tvar bannerScript = '<script
type=\"text/javascript\" src=\"$wgCentralPagePath' + bannerPage +
'\"></script>';\n";
+ $js .= "\n\t\t\t\tvar bannerScript = '<script
type=\"text/javascript\" src=\"".Xml::escapeJsString( $wgCentralPagePath )."' +
bannerPage + '\"></script>';\n";
$js .= <<<EOT
$( '#siteNotice' ).prepend( '<div
id="centralNotice" class="' + ( wgNoticeToggleState ? 'expanded' : 'collapsed'
) + '">'+bannerScript+'</div>' );
},
Modified: trunk/extensions/CentralNotice/SpecialBannerListLoader.php
===================================================================
--- trunk/extensions/CentralNotice/SpecialBannerListLoader.php 2010-09-22
20:55:52 UTC (rev 73570)
+++ trunk/extensions/CentralNotice/SpecialBannerListLoader.php 2010-09-22
21:03:27 UTC (rev 73571)
@@ -10,7 +10,6 @@
public $centralNoticeDB;
protected $sharedMaxAge = 900; // Cache for 15 minutes on the server
side
protected $maxAge = 900; // Cache for 15 minutes on the client side
- protected $contentType = 'text/javascript';
function __construct() {
// Register special page
@@ -49,7 +48,8 @@
* Generate the HTTP response headers for the banner file
*/
function sendHeaders() {
- header( "Content-type: $this->contentType; charset=utf-8" );
+ global $wgJsMimeType;
+ header( "Content-type: $wgJsMimeType; charset=utf-8" );
header( "Cache-Control: public, s-maxage=$this->sharedMaxAge,
max-age=$this->maxAge" );
}
Modified: trunk/extensions/CentralNotice/SpecialBannerLoader.php
===================================================================
--- trunk/extensions/CentralNotice/SpecialBannerLoader.php 2010-09-22
20:55:52 UTC (rev 73570)
+++ trunk/extensions/CentralNotice/SpecialBannerLoader.php 2010-09-22
21:03:27 UTC (rev 73571)
@@ -8,7 +8,6 @@
public $language = 'en'; // User language
protected $sharedMaxAge = 900; // Cache for 15 minutes on the server
side
protected $maxAge = 0; // No client-side banner caching so we get all
impressions
- protected $contentType = 'text/js';
function __construct() {
// Register special page
@@ -47,7 +46,8 @@
* Generate the HTTP response headers for the banner file
*/
function sendHeaders() {
- header( "Content-type: $this->contentType; charset=utf-8" );
+ global $wgJsMimeType;
+ header( "Content-type: $wgJsMimeType; charset=utf-8" );
header( "Cache-Control: public, s-maxage=$this->sharedMaxAge,
max-age=$this->maxAge" );
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs