summaryrefslogtreecommitdiff
path: root/includes/installer/WebInstallerOutput.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2013-12-08 09:55:49 +0100
committerPierre Schmitz <pierre@archlinux.de>2013-12-08 09:55:49 +0100
commit4ac9fa081a7c045f6a9f1cfc529d82423f485b2e (patch)
treeaf68743f2f4a47d13f2b0eb05f5c4aaf86d8ea37 /includes/installer/WebInstallerOutput.php
parentaf4da56f1ad4d3ef7b06557bae365da2ea27a897 (diff)
Update to MediaWiki 1.22.0
Diffstat (limited to 'includes/installer/WebInstallerOutput.php')
-rw-r--r--includes/installer/WebInstallerOutput.php112
1 files changed, 75 insertions, 37 deletions
diff --git a/includes/installer/WebInstallerOutput.php b/includes/installer/WebInstallerOutput.php
index d61d843f..f2dc37fe 100644
--- a/includes/installer/WebInstallerOutput.php
+++ b/includes/installer/WebInstallerOutput.php
@@ -104,49 +104,85 @@ class WebInstallerOutput {
/**
* Get the raw vector CSS, flipping if needed
+ *
+ * @todo Possibly get rid of this function and use ResourceLoader in the manner it was
+ * designed to be used in, rather than just grabbing a list of filenames from it,
+ * and not properly handling such details as media types in module definitions.
+ *
* @param string $dir 'ltr' or 'rtl'
* @return String
*/
public function getCSS( $dir ) {
- $skinDir = dirname( dirname( __DIR__ ) ) . '/skins';
-
- // All these files will be concatenated in sequence and loaded
- // as one file.
- // The string 'images/' in the files' contents will be replaced
- // by '../skins/$skinName/images/', where $skinName is what appears
- // before the last '/' in each of the strings.
- $cssFileNames = array(
-
- // Basically the "skins.vector" ResourceLoader module styles
- 'common/shared.css',
- 'common/commonElements.css',
- 'common/commonContent.css',
- 'common/commonInterface.css',
- 'vector/screen.css',
-
- // mw-config specific
- 'common/config.css',
+ // All CSS files these modules reference will be concatenated in sequence
+ // and loaded as one file.
+ $moduleNames = array(
+ 'mediawiki.legacy.shared',
+ 'skins.vector',
+ 'mediawiki.legacy.config',
);
+ $prepend = '';
$css = '';
- wfSuppressWarnings();
- foreach ( $cssFileNames as $cssFileName ) {
- $fullCssFileName = "$skinDir/$cssFileName";
- $cssFileContents = file_get_contents( $fullCssFileName );
- if ( $cssFileContents ) {
- preg_match( "/^(\w+)\//", $cssFileName, $match );
- $skinName = $match[1];
- $css .= str_replace( 'images/', "../skins/$skinName/images/", $cssFileContents );
- } else {
- $css .= "/** Your webserver cannot read $fullCssFileName. Please check file permissions. */";
+ $cssFileNames = array();
+ $resourceLoader = new ResourceLoader();
+ foreach ( $moduleNames as $moduleName ) {
+ $module = $resourceLoader->getModule( $moduleName );
+ $cssFileNames = $module->getAllStyleFiles();
+
+ wfSuppressWarnings();
+ foreach ( $cssFileNames as $cssFileName ) {
+ if ( !file_exists( $cssFileName ) ) {
+ $prepend .= ResourceLoader::makeComment( "Unable to find $cssFileName." );
+ continue;
+ }
+
+ if ( !is_readable( $cssFileName ) ) {
+ $prepend .= ResourceLoader::makeComment( "Unable to read $cssFileName. Please check file permissions." );
+ continue;
+ }
+
+ try {
+
+ if ( preg_match( '/\.less$/', $cssFileName ) ) {
+ // Run the LESS compiler for *.less files (bug 55589)
+ $compiler = ResourceLoader::getLessCompiler();
+ $cssFileContents = $compiler->compileFile( $cssFileName );
+ } else {
+ // Regular CSS file
+ $cssFileContents = file_get_contents( $cssFileName );
+ }
+
+ if ( $cssFileContents ) {
+ // Rewrite URLs, though don't bother embedding images. While static image
+ // files may be cached, CSS returned by this function is definitely not.
+ $cssDirName = dirname( $cssFileName );
+ $css .= CSSMin::remap(
+ /* source */ $cssFileContents,
+ /* local */ $cssDirName,
+ /* remote */ '..' . str_replace(
+ array( $GLOBALS['IP'], DIRECTORY_SEPARATOR ),
+ array( '', '/' ),
+ $cssDirName
+ ),
+ /* embedData */ false
+ );
+ } else {
+ $prepend .= ResourceLoader::makeComment( "Unable to read $cssFileName." );
+ }
+
+ } catch ( Exception $e ) {
+ $prepend .= ResourceLoader::formatException( $e );
+ }
+
+ $css .= "\n";
}
-
- $css .= "\n";
+ wfRestoreWarnings();
}
- wfRestoreWarnings();
- if( $dir == 'rtl' ) {
+ $css = $prepend . $css;
+
+ if ( $dir == 'rtl' ) {
$css = CSSJanus::transform( $css, true );
}
@@ -185,6 +221,7 @@ class WebInstallerOutput {
*/
public function getDir() {
global $wgLang;
+
return is_object( $wgLang ) ? $wgLang->getDir() : 'ltr';
}
@@ -193,6 +230,7 @@ class WebInstallerOutput {
*/
public function getLanguageCode() {
global $wgLang;
+
return is_object( $wgLang ) ? $wgLang->getCode() : 'en';
}
@@ -216,22 +254,23 @@ class WebInstallerOutput {
public function outputHeader() {
$this->headerDone = true;
- $dbTypes = $this->parent->getDBTypes();
-
$this->parent->request->response()->header( 'Content-Type: text/html; charset=utf-8' );
+
if ( !$this->allowFrames ) {
$this->parent->request->response()->header( 'X-Frame-Options: DENY' );
}
+
if ( $this->redirectTarget ) {
- $this->parent->request->response()->header( 'Location: '.$this->redirectTarget );
+ $this->parent->request->response()->header( 'Location: ' . $this->redirectTarget );
+
return;
}
if ( $this->useShortHeader ) {
$this->outputShortHeader();
+
return;
}
-
?>
<?php echo Html::htmlHeader( $this->getHeadAttribs() ); ?>
<head>
@@ -239,7 +278,6 @@ class WebInstallerOutput {
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title><?php $this->outputTitle(); ?></title>
<?php echo $this->getCssUrl() . "\n"; ?>
- <?php echo Html::inlineScript( "var dbTypes = " . Xml::encodeJsVar( $dbTypes ) ) . "\n"; ?>
<?php echo $this->getJQuery() . "\n"; ?>
<?php echo Html::linkedScript( '../skins/common/config.js' ) . "\n"; ?>
</head>