}
/**
- * 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'
+ * Get the stylesheet of the MediaWiki skin.
*
* @return string
*/
- public function getCSS( $dir ) {
- // All CSS files these modules reference will be concatenated in sequence
- // and loaded as one file.
+ public function getCSS() {
+ // 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 $wgResourceModules;
+ global $wgStyleDirectory;
+ include_once "$wgStyleDirectory/Vector/Vector.php";
+
$moduleNames = array(
+ // See SkinTemplate::setupSkinUserCss
'mediawiki.legacy.shared',
- 'skins.common.interface',
+ // 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 ( $dir == 'rtl' ) {
- $css = CSSJanus::transform( $css, true );
+ $css .= implode( "\n", $styles );
}
return $css;
}
/**
- * "<link>" to index.php?css=foobar for the "<head>"
+ * "<link>" to index.php?css=1 for the "<head>"
*
* @return string
*/
private function getCssUrl() {
- return Html::linkedStyle( $_SERVER['PHP_SELF'] . '?css=' . $this->getDir() );
+ return Html::linkedStyle( $_SERVER['PHP_SELF'] . '?css=1' );
}
public function useShortHeader( $use = true ) {