r64463 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64462‎ | r64463 | r64464 >
Date:23:56, 31 March 2010
Author:neilk
Status:deferred
Tags:
Comment:
use more portable environment variables to calculate current URL of scriptloader
Modified paths:
  • /branches/js2-work/phase3/js/mwEmbed/jsScriptLoader.php (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js/mwEmbed/jsScriptLoader.php
@@ -345,8 +345,8 @@
346346 if( ! $this->debug ) {
347347 $cssOptions[ 'preserveComments' ] = false;
348348 }
349 - $serverUri = $_SERVER['SCRIPT_URI'];
350 -
 349+ $serverUri = $this->getScriptLoaderUri();
 350+
351351 // Check for the two jsScriptLoader entry points:
352352 if( strpos( $serverUri, 'mwScriptLoader.php') !== false ){
353353 $cssOptions[ 'prependRelativePath' ] =
@@ -364,6 +364,28 @@
365365 }
366366
367367 /**
 368+ * Get the URI of the scriptLoader
 369+ */
 370+ private function getScriptLoaderUri() {
 371+
 372+ // protocol is http or https
 373+ $protocol = 'http';
 374+ if ($_SERVER['SERVER_PORT'] == 443 || (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')) {
 375+ $protocol .= 's';
 376+ $protocol_port = $_SERVER['SERVER_PORT'];
 377+ } else {
 378+ $protocol_port = 80;
 379+ }
 380+
 381+ // $port will be "" or something like ":8100"
 382+ $port = ( $_SERVER['SERVER_PORT'] == $protocol_port ) ? '' : ':' . $_SERVER['SERVER_PORT'];
 383+
 384+ // php_self is the URL that invoked this script, without CGI parameters or fragment.
 385+ return $protocol . '://' . $_SERVER['HTTP_HOST'] . $port . $_SERVER['PHP_SELF'];
 386+ }
 387+
 388+
 389+ /**
368390 * Outputs the script headers
369391 */
370392 function outputJsHeaders() {

Status & tagging log