Issue #1198904 by das-peter, jox: Drupal_load_stylesheet() fails to load @import files in different directories.
parent
97ba84ca65
commit
16fe2e9d8c
|
@ -3673,17 +3673,23 @@ function drupal_load_stylesheet($file, $optimize = NULL, $reset_basepath = TRUE)
|
|||
if ($basepath && !file_uri_scheme($file)) {
|
||||
$file = $basepath . '/' . $file;
|
||||
}
|
||||
// Store the parent base path to restore it later.
|
||||
$parent_base_path = $basepath;
|
||||
// Set the current base path to process possible child imports.
|
||||
$basepath = dirname($file);
|
||||
|
||||
// Load the CSS stylesheet. We suppress errors because themes may specify
|
||||
// stylesheets in their .info file that don't exist in the theme's path,
|
||||
// but are merely there to disable certain module CSS files.
|
||||
$content = '';
|
||||
if ($contents = @file_get_contents($file)) {
|
||||
// Return the processed stylesheet.
|
||||
return drupal_load_stylesheet_content($contents, $_optimize);
|
||||
$content = drupal_load_stylesheet_content($contents, $_optimize);
|
||||
}
|
||||
|
||||
return '';
|
||||
// Restore the parent base path as the file and its childen are processed.
|
||||
$basepath = $parent_base_path;
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,16 @@
|
|||
|
||||
|
||||
|
||||
ul, select {
|
||||
font: 1em/160% Verdana, sans-serif;
|
||||
color: #494949;
|
||||
}
|
||||
.ui-icon{background-image: url(images/icon.png);}
|
||||
|
||||
p, select {
|
||||
font: 1em/160% Verdana, sans-serif;
|
||||
color: #494949;
|
||||
}
|
||||
|
||||
|
||||
body {
|
||||
|
|
29
modules/simpletest/files/css_test_files/css_subfolder/css_input_with_import.css
vendored
Normal file
29
modules/simpletest/files/css_test_files/css_subfolder/css_input_with_import.css
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
|
||||
|
||||
@import "../import1.css";
|
||||
@import "../import2.css";
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background: #edf5fa;
|
||||
font: 76%/170% Verdana, sans-serif;
|
||||
color: #494949;
|
||||
}
|
||||
|
||||
.this .is .a .test {
|
||||
font: 1em/100% Verdana, sans-serif;
|
||||
color: #494949;
|
||||
}
|
||||
.this
|
||||
.is
|
||||
.a
|
||||
.test {
|
||||
font: 1em/100% Verdana, sans-serif;
|
||||
color: #494949;
|
||||
}
|
||||
|
||||
textarea, select {
|
||||
font: 1em/160% Verdana, sans-serif;
|
||||
color: #494949;
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
ul,select{font:1em/160% Verdana,sans-serif;color:#494949;}.ui-icon{background-image:url(../images/icon.png);}
|
||||
p,select{font:1em/160% Verdana,sans-serif;color:#494949;}
|
||||
body{margin:0;padding:0;background:#edf5fa;font:76%/170% Verdana,sans-serif;color:#494949;}.this .is .a .test{font:1em/100% Verdana,sans-serif;color:#494949;}.this
|
||||
.is
|
||||
.a
|
||||
.test{font:1em/100% Verdana,sans-serif;color:#494949;}textarea,select{font:1em/160% Verdana,sans-serif;color:#494949;}
|
|
@ -0,0 +1,39 @@
|
|||
|
||||
|
||||
|
||||
ul, select {
|
||||
font: 1em/160% Verdana, sans-serif;
|
||||
color: #494949;
|
||||
}
|
||||
.ui-icon{background-image: url(../images/icon.png);}
|
||||
|
||||
p, select {
|
||||
font: 1em/160% Verdana, sans-serif;
|
||||
color: #494949;
|
||||
}
|
||||
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background: #edf5fa;
|
||||
font: 76%/170% Verdana, sans-serif;
|
||||
color: #494949;
|
||||
}
|
||||
|
||||
.this .is .a .test {
|
||||
font: 1em/100% Verdana, sans-serif;
|
||||
color: #494949;
|
||||
}
|
||||
.this
|
||||
.is
|
||||
.a
|
||||
.test {
|
||||
font: 1em/100% Verdana, sans-serif;
|
||||
color: #494949;
|
||||
}
|
||||
|
||||
textarea, select {
|
||||
font: 1em/160% Verdana, sans-serif;
|
||||
color: #494949;
|
||||
}
|
|
@ -926,26 +926,30 @@ class CascadingStylesheetsUnitTest extends DrupalUnitTestCase {
|
|||
$testfiles = array(
|
||||
'css_input_without_import.css',
|
||||
'css_input_with_import.css',
|
||||
'css_subfolder/css_input_with_import.css',
|
||||
'comment_hacks.css'
|
||||
);
|
||||
$path = drupal_get_path('module', 'simpletest') . '/files/css_test_files';
|
||||
foreach ($testfiles as $file) {
|
||||
$expected = file_get_contents("$path/$file.unoptimized.css");
|
||||
$unoptimized_output = drupal_load_stylesheet("$path/$file.unoptimized.css", FALSE);
|
||||
$file_path = $path . '/' . $file;
|
||||
$file_url = $GLOBALS['base_url'] . '/' . $file_path;
|
||||
|
||||
$expected = file_get_contents($file_path . '.unoptimized.css');
|
||||
$unoptimized_output = drupal_load_stylesheet($file_path, FALSE);
|
||||
$this->assertEqual($unoptimized_output, $expected, format_string('Unoptimized CSS file has expected contents (@file)', array('@file' => $file)));
|
||||
|
||||
$expected = file_get_contents("$path/$file.optimized.css");
|
||||
$optimized_output = drupal_load_stylesheet("$path/$file", TRUE);
|
||||
$expected = file_get_contents($file_path . '.optimized.css');
|
||||
$optimized_output = drupal_load_stylesheet($file_path, TRUE);
|
||||
$this->assertEqual($optimized_output, $expected, format_string('Optimized CSS file has expected contents (@file)', array('@file' => $file)));
|
||||
|
||||
// Repeat the tests by accessing the stylesheets by URL.
|
||||
$expected = file_get_contents("$path/$file.unoptimized.css");
|
||||
$unoptimized_output_url = drupal_load_stylesheet($GLOBALS['base_url'] . "/$path/$file.unoptimized.css", FALSE);
|
||||
$this->assertEqual($unoptimized_output, $expected, format_string('Unoptimized CSS file (loaded from an URL) has expected contents (@file)', array('@file' => $file)));
|
||||
$expected = file_get_contents($file_path . '.unoptimized.css');
|
||||
$unoptimized_output_url = drupal_load_stylesheet($file_url, FALSE);
|
||||
$this->assertEqual($unoptimized_output_url, $expected, format_string('Unoptimized CSS file (loaded from an URL) has expected contents (@file)', array('@file' => $file)));
|
||||
|
||||
$expected = file_get_contents("$path/$file.optimized.css");
|
||||
$optimized_output = drupal_load_stylesheet($GLOBALS['base_url'] . "/$path/$file", TRUE);
|
||||
$this->assertEqual($optimized_output, $expected, format_string('Optimized CSS file (loaded from an URL) has expected contents (@file)', array('@file' => $file)));
|
||||
$expected = file_get_contents($file_path . '.optimized.css');
|
||||
$optimized_output_url = drupal_load_stylesheet($file_url, TRUE);
|
||||
$this->assertEqual($optimized_output_url, $expected, format_string('Optimized CSS file (loaded from an URL) has expected contents (@file)', array('@file' => $file)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue