From ba49b0e68a18b80110e6e5ad45953e7073c8291c Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Fri, 5 Nov 2010 13:14:24 +0000 Subject: [PATCH] Dynamically generate CSS (using vector now). Handles RTL/LTR flip properly \o/ UI's busted though ;-) --- includes/installer/WebInstaller.php | 13 +++++++-- includes/installer/WebInstallerOutput.php | 35 ++++++++++++++++++++--- includes/installer/WebInstallerPage.php | 2 +- 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/includes/installer/WebInstaller.php b/includes/installer/WebInstaller.php index f016775d08..fa233ec5fe 100644 --- a/includes/installer/WebInstaller.php +++ b/includes/installer/WebInstaller.php @@ -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 { diff --git a/includes/installer/WebInstallerOutput.php b/includes/installer/WebInstallerOutput.php index fb887e0012..204ea9c370 100644 --- a/includes/installer/WebInstallerOutput.php +++ b/includes/installer/WebInstallerOutput.php @@ -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 { <?php $this->outputTitle(); ?> - + getCssUrl() ) . "\n"; ?> getJQuery() . "\n"; ?> @@ -162,8 +189,8 @@ class WebInstallerOutput { .config-show-help { display: none; } -
-
+
+
@@ -211,7 +238,7 @@ class WebInstallerOutput { <?php $this->outputTitle(); ?> - + getCssUrl() ) . "\n"; ?> getJQuery(); ?> getJQueryTipsy() . "\n"; ?> diff --git a/includes/installer/WebInstallerPage.php b/includes/installer/WebInstallerPage.php index 7a90171f2f..187e81af84 100644 --- a/includes/installer/WebInstallerPage.php +++ b/includes/installer/WebInstallerPage.php @@ -13,7 +13,7 @@ * @since 1.17 */ abstract class WebInstallerPage { - + /** * The WebInstaller object this WebInstallerPage belongs to. * -- 2.20.1