Merge "Fix the (un)watch token to include the namespace name."
[lhc/web/wiklou.git] / includes / installer / WebInstallerOutput.php
index fd6ed00..174120f 100644 (file)
@@ -119,87 +119,50 @@ 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.
+        * Get the stylesheet of the MediaWiki skin.
         *
         * @return string
         */
        public function getCSS() {
-               // All CSS files these modules reference will be concatenated in sequence
-               // and loaded as one file.
+               // Horrible, horrible hack: the installer is currently hardcoded to use the Vector skin, so load
+               // it here. Include instead of require, as this will work without it, it will just look bad.
+               global $wgStyleDirectory;
+               include_once "$wgStyleDirectory/Vector/Vector.php";
+
                $moduleNames = array(
+                       // See SkinTemplate::setupSkinUserCss
                        'mediawiki.legacy.shared',
+                       // See Vector::setupSkinUserCss
                        'mediawiki.skinning.interface',
                        'skins.vector.styles',
+
                        'mediawiki.legacy.config',
                );
 
-               $prepend = '';
                $css = '';
 
                $resourceLoader = new ResourceLoader();
+               $rlContext = new ResourceLoaderContext( $resourceLoader, new FauxRequest( array(
+                               'debug' => 'true',
+                               'lang' => $this->getLanguageCode(),
+                               'only' => 'styles',
+                               'skin' => 'vector',
+               ) ) );
                foreach ( $moduleNames as $moduleName ) {
                        /** @var ResourceLoaderFileModule $module */
                        $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";
+                       // One of the modules will be missing if Vector is unavailable
+                       if ( !$module ) {
+                               continue;
                        }
-                       wfRestoreWarnings();
-               }
 
-               $css = $prepend . $css;
+                       // Based on: ResourceLoaderFileModule::getStyles (without the DB query)
+                       $styles = ResourceLoader::makeCombinedStyles( $module->readStyleFiles(
+                               $module->getStyleFiles( $rlContext ),
+                               $module->getFlip( $rlContext )
+                       ) );
 
-               if ( $this->getDir() == 'rtl' ) {
-                       $css = CSSJanus::transform( $css, true );
+                       $css .= implode( "\n", $styles );
                }
 
                return $css;