Dynamically generate CSS (using vector now). Handles RTL/LTR flip properly \o/ UI...
authorChad Horohoe <demon@users.mediawiki.org>
Fri, 5 Nov 2010 13:14:24 +0000 (13:14 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Fri, 5 Nov 2010 13:14:24 +0000 (13:14 +0000)
includes/installer/WebInstaller.php
includes/installer/WebInstallerOutput.php
includes/installer/WebInstallerPage.php

index f016775..fa233ec 100644 (file)
@@ -120,17 +120,24 @@ class WebInstaller extends CoreInstaller {
 
                if( $this->getVar( '_InstallDone' ) && $this->request->getVal( 'localsettings' ) )
                {
-                       $ls = new LocalSettingsGenerator( $this );
-                       $this->request->response()->header('Content-type: text/plain');
-
+                       $this->request->response()->header( 'Content-type: text/plain' );
                        $this->request->response()->header(
                                'Content-Disposition: attachment; filename="LocalSettings.php"'
                        );
 
+                       $ls = new LocalSettingsGenerator( $this );
                        echo $ls->getText();
                        return $this->session;
                }
 
+               $cssDir = $this->request->getVal( 'css' );
+               if( $cssDir ) {
+                       $cssDir = ( $cssDir == 'rtl' ? 'rtl' : 'ltr' );
+                       $this->request->response()->header( 'Content-type: text/css' );
+                       echo $this->output->getCSS( $cssDir );
+                       return $this->session;
+               }
+
                if ( isset( $session['happyPages'] ) ) {
                        $this->happyPages = $session['happyPages'];
                } else {
index fb887e0..204ea9c 100644 (file)
@@ -79,6 +79,33 @@ class WebInstallerOutput {
                $this->outputFooter();
        }
 
+       /**
+        * Get the raw vector CSS, flipping if needed
+        * @param $dir String 'ltr' or 'rtl'
+        * @return String
+        */
+       public function getCSS( $dir ) {
+               $vectorCssFile = dirname( __FILE__ ) . '/../../skins/vector/screen.css';
+               wfSuppressWarnings();
+               $css = file_get_contents( $vectorCssFile );
+               wfRestoreWarnings();
+               if( !$css ) {
+                       return '';
+               } elseif( $dir == 'rtl' ) {
+                       return CSSJanus::transform( $css, true );
+               } else {
+                       return $css;
+               }
+       }
+
+       /**
+        * URL for index.php?css=foobar
+        * @return String
+        */
+       private function getCssUrl( ) {
+               return $_SERVER['PHP_SELF'] . '?css=' . $this->getDir();
+       }
+
        public function useShortHeader( $use = true ) {
                $this->useShortHeader = $use;
        }
@@ -147,7 +174,7 @@ class WebInstallerOutput {
        <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
        <title><?php $this->outputTitle(); ?></title>
        <?php echo Html::linkedStyle( '../skins/common/shared.css' ) . "\n"; ?>
-       <?php echo Html::linkedStyle( '../skins/monobook/main.css' ) . "\n"; ?>
+       <?php echo Html::linkedStyle( $this->getCssUrl() ) . "\n"; ?>
        <?php echo Html::linkedStyle( '../skins/common/config.css' ) . "\n"; ?>
        <?php echo Html::inlineScript(  "var dbTypes = " . Xml::encodeJsVar( $dbTypes ) ) . "\n"; ?>
        <?php echo $this->getJQuery() . "\n"; ?>
@@ -162,8 +189,8 @@ class WebInstallerOutput {
 .config-show-help { display: none; }
 </style>
 </noscript>
-<div id="globalWrapper">
-<div id="column-content">
+<div id="mw-page-base">
+<div id="mw-head-base">
 <div id="content">
 <div id="bodyContent">
 
@@ -211,7 +238,7 @@ class WebInstallerOutput {
        <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
        <meta name="robots" content="noindex, nofollow" />
        <title><?php $this->outputTitle(); ?></title>
-       <?php echo Html::linkedStyle( '../skins/monobook/main.css' ) . "\n"; ?>
+       <?php echo Html::linkedStyle( $this->getCssUrl() ) . "\n"; ?>
        <?php echo Html::linkedStyle( '../skins/common/config.css' ) . "\n"; ?>
        <?php echo $this->getJQuery(); ?>
        <?php echo $this->getJQueryTipsy() . "\n"; ?>
index 7a90171..187e81a 100644 (file)
@@ -13,7 +13,7 @@
  * @since 1.17
  */
 abstract class WebInstallerPage {
-       
+
        /**
         * The WebInstaller object this WebInstallerPage belongs to.
         *