r76088 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76087‎ | r76088 | r76089 >
Date:13:14, 5 November 2010
Author:demon
Status:resolved (Comments)
Tags:
Comment:
Dynamically generate CSS (using vector now). Handles RTL/LTR flip properly \o/ UI's busted though ;-)
Modified paths:
  • /trunk/phase3/includes/installer/WebInstaller.php (modified) (history)
  • /trunk/phase3/includes/installer/WebInstallerOutput.php (modified) (history)
  • /trunk/phase3/includes/installer/WebInstallerPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/installer/WebInstaller.php
@@ -120,17 +120,24 @@
121121
122122 if( $this->getVar( '_InstallDone' ) && $this->request->getVal( 'localsettings' ) )
123123 {
124 - $ls = new LocalSettingsGenerator( $this );
125 - $this->request->response()->header('Content-type: text/plain');
126 -
 124+ $this->request->response()->header( 'Content-type: text/plain' );
127125 $this->request->response()->header(
128126 'Content-Disposition: attachment; filename="LocalSettings.php"'
129127 );
130128
 129+ $ls = new LocalSettingsGenerator( $this );
131130 echo $ls->getText();
132131 return $this->session;
133132 }
134133
 134+ $cssDir = $this->request->getVal( 'css' );
 135+ if( $cssDir ) {
 136+ $cssDir = ( $cssDir == 'rtl' ? 'rtl' : 'ltr' );
 137+ $this->request->response()->header( 'Content-type: text/css' );
 138+ echo $this->output->getCSS( $cssDir );
 139+ return $this->session;
 140+ }
 141+
135142 if ( isset( $session['happyPages'] ) ) {
136143 $this->happyPages = $session['happyPages'];
137144 } else {
Index: trunk/phase3/includes/installer/WebInstallerOutput.php
@@ -79,6 +79,33 @@
8080 $this->outputFooter();
8181 }
8282
 83+ /**
 84+ * Get the raw vector CSS, flipping if needed
 85+ * @param $dir String 'ltr' or 'rtl'
 86+ * @return String
 87+ */
 88+ public function getCSS( $dir ) {
 89+ $vectorCssFile = dirname( __FILE__ ) . '/../../skins/vector/screen.css';
 90+ wfSuppressWarnings();
 91+ $css = file_get_contents( $vectorCssFile );
 92+ wfRestoreWarnings();
 93+ if( !$css ) {
 94+ return '';
 95+ } elseif( $dir == 'rtl' ) {
 96+ return CSSJanus::transform( $css, true );
 97+ } else {
 98+ return $css;
 99+ }
 100+ }
 101+
 102+ /**
 103+ * URL for index.php?css=foobar
 104+ * @return String
 105+ */
 106+ private function getCssUrl( ) {
 107+ return $_SERVER['PHP_SELF'] . '?css=' . $this->getDir();
 108+ }
 109+
83110 public function useShortHeader( $use = true ) {
84111 $this->useShortHeader = $use;
85112 }
@@ -147,7 +174,7 @@
148175 <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
149176 <title><?php $this->outputTitle(); ?></title>
150177 <?php echo Html::linkedStyle( '../skins/common/shared.css' ) . "\n"; ?>
151 - <?php echo Html::linkedStyle( '../skins/monobook/main.css' ) . "\n"; ?>
 178+ <?php echo Html::linkedStyle( $this->getCssUrl() ) . "\n"; ?>
152179 <?php echo Html::linkedStyle( '../skins/common/config.css' ) . "\n"; ?>
153180 <?php echo Html::inlineScript( "var dbTypes = " . Xml::encodeJsVar( $dbTypes ) ) . "\n"; ?>
154181 <?php echo $this->getJQuery() . "\n"; ?>
@@ -162,8 +189,8 @@
163190 .config-show-help { display: none; }
164191 </style>
165192 </noscript>
166 -<div id="globalWrapper">
167 -<div id="column-content">
 193+<div id="mw-page-base">
 194+<div id="mw-head-base">
168195 <div id="content">
169196 <div id="bodyContent">
170197
@@ -211,7 +238,7 @@
212239 <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
213240 <meta name="robots" content="noindex, nofollow" />
214241 <title><?php $this->outputTitle(); ?></title>
215 - <?php echo Html::linkedStyle( '../skins/monobook/main.css' ) . "\n"; ?>
 242+ <?php echo Html::linkedStyle( $this->getCssUrl() ) . "\n"; ?>
216243 <?php echo Html::linkedStyle( '../skins/common/config.css' ) . "\n"; ?>
217244 <?php echo $this->getJQuery(); ?>
218245 <?php echo $this->getJQueryTipsy() . "\n"; ?>
Index: trunk/phase3/includes/installer/WebInstallerPage.php
@@ -13,7 +13,7 @@
1414 * @since 1.17
1515 */
1616 abstract class WebInstallerPage {
17 -
 17+
1818 /**
1919 * The WebInstaller object this WebInstallerPage belongs to.
2020 *

Follow-up revisions

RevisionCommit summaryAuthorDate
r76091Followup r76088: in the case where we can't read screen.css, output a comment...demon13:37, 5 November 2010
r76313Followup r76088: rewrite relative CSS urlsdemon16:19, 8 November 2010
r76880Fix for r76088: if you want the Vector stylesheets you have to use the Vector...tstarling11:43, 17 November 2010

Comments

#Comment by 😂 (talk | contribs)   13:31, 5 November 2010

Going ahead and marking this broken because it is. Needs TLC from a CSS ninja :)

#Comment by Tim Starling (talk | contribs)   11:37, 17 November 2010

You're right, that's broken in a lot of ways.

#Comment by Catrope (talk | contribs)   10:56, 3 December 2010

Is this still broken (i.e. deserving of fixme status)?

#Comment by Tim Starling (talk | contribs)   12:48, 3 December 2010

It should be OK after r76880.

Status & tagging log