diff --git a/includes/theme.inc b/includes/theme.inc
index 569c5d256ba..7bc2d309d24 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -100,33 +100,18 @@ function _init_theme($theme, $base_theme = array()) {
$theme_path = dirname($theme->filename);
- // Add the default stylesheet
- if (!empty($theme->stylesheet)) {
- drupal_add_css($theme->stylesheet, 'theme');
- }
- else {
- // If we don't have a stylesheet of our own, look for the first
- // base to have one and use its.
- foreach ($base_theme as $base) {
- if (!empty($base->stylesheet)) {
- drupal_add_css($base->stylesheet, 'theme');
- break;
+ // Add stylesheets used by this theme.
+ if (!empty($theme->stylesheets)) {
+ foreach ($theme->stylesheets as $media => $stylesheets) {
+ foreach ($stylesheets as $stylesheet) {
+ drupal_add_css($stylesheet, 'theme', $media);
}
}
}
-
- // Add the default script
- if (!empty($theme->script)) {
- drupal_add_js($theme->script, 'theme');
- }
- else {
- // If we don't have a script of our own, look for the first
- // base to have one and use its.
- foreach ($base_theme as $base) {
- if (!empty($base->script)) {
- drupal_add_js($base->script, 'theme');
- break;
- }
+ // Add scripts used by this theme.
+ if (!empty($theme->scripts)) {
+ foreach ($theme->scripts as $script) {
+ drupal_add_js($script, 'theme');
}
}
@@ -356,11 +341,17 @@ function list_themes($refresh = FALSE) {
while ($theme = db_fetch_object($result)) {
if (file_exists($theme->filename)) {
$theme->info = unserialize($theme->info);
- if (!empty($theme->info['stylesheet']) && file_exists($theme->info['stylesheet'])) {
- $theme->stylesheet = $theme->info['stylesheet'];
+ foreach ($theme->info['stylesheets'] as $media => $stylesheets) {
+ foreach ($stylesheets as $stylesheet => $path) {
+ if (file_exists($path)) {
+ $theme->stylesheets[$media][$stylesheet] = $path;
+ }
+ }
}
- if (!empty($theme->info['script']) && file_exists($theme->info['script'])) {
- $theme->script = $theme->info['script'];
+ foreach ($theme->info['scripts'] as $script => $path) {
+ if (file_exists($path)) {
+ $theme->scripts[$script] = $path;
+ }
}
if (isset($theme->info['engine'])) {
$theme->engine = $theme->info['engine'];
diff --git a/modules/system/system.module b/modules/system/system.module
index cb14f61f0cf..b58c79fb0fd 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -1047,8 +1047,10 @@ function system_theme_default() {
'search',
'slogan'
),
- 'stylesheet' => 'style.css',
- 'script' => 'script.js',
+ 'stylesheets' => array(
+ 'all' => array('style.css')
+ ),
+ 'scripts' => array('script.js'),
'screenshot' => 'screenshot.png',
'php' => DRUPAL_MINIMUM_PHP,
);
@@ -1104,14 +1106,21 @@ function system_theme_data() {
}
}
- // Give the stylesheet proper path information.
- if (!empty($themes[$key]->info['stylesheet'])) {
- $themes[$key]->info['stylesheet'] = dirname($themes[$key]->filename) .'/'. $themes[$key]->info['stylesheet'];
+ // Give the stylesheets proper path information.
+ $pathed_stylesheets = array();
+ foreach ($themes[$key]->info['stylesheets'] as $media => $stylesheets) {
+ foreach ($stylesheets as $stylesheet) {
+ $pathed_stylesheets[$media][$stylesheet] = dirname($themes[$key]->filename) .'/'. $stylesheet;
+ }
}
- // Give the script proper path information.
- if (!empty($themes[$key]->info['script'])) {
- $themes[$key]->info['script'] = dirname($themes[$key]->filename) .'/'. $themes[$key]->info['script'];
+ $themes[$key]->info['stylesheets'] = $pathed_stylesheets;
+
+ // Give the scripts proper path information.
+ $scripts = array();
+ foreach ($themes[$key]->info['scripts'] as $script) {
+ $scripts[$script] = dirname($themes[$key]->filename) .'/'. $script;
}
+ $themes[$key]->info['scripts'] = $scripts;
// Give the screenshot proper path information.
if (!empty($themes[$key]->info['screenshot'])) {
$themes[$key]->info['screenshot'] = dirname($themes[$key]->filename) .'/'. $themes[$key]->info['screenshot'];
@@ -1137,6 +1146,28 @@ function system_theme_data() {
$themes[$key]->prefix = $key;
}
}
+ // Add any stylesheets from the base theme, unless the names match in which case
+ // the sub-theme wins. Note that we slip the base theme's stylesheets in at the
+ // beginning of the array so that they get added to the page in the correct order.
+ foreach ($themes[$base_key]->info['stylesheets'] as $media => $stylesheets) {
+ foreach ($stylesheets as $stylesheet => $path) {
+ if (!isset($themes[$key]->info['stylesheets'][$media][$stylesheet])) {
+ // We need to ensure the media array exists, or the array addition below doesn't work.
+ if (!isset($themes[$key]->info['stylesheets'][$media])) {
+ $themes[$key]->info['stylesheets'][$media] = array();
+ }
+ $themes[$key]->info['stylesheets'][$media] = array($stylesheet => $path) + $themes[$key]->info['stylesheets'][$media];
+ }
+ }
+ }
+ // Add any scripts from the base theme, unless the names match in which case
+ // the sub-theme wins. Note that we slip the base theme's scripts in at the
+ // beginning of the array so that they get added to the page in the correct order.
+ foreach ($themes[$base_key]->info['scripts'] as $script => $path) {
+ if (!isset($themes[$key]->info['scripts'][$script])) {
+ $themes[$key]->info['scripts'] = array($script => $path) + $themes[$key]->info['scripts'];
+ }
+ }
}
// Extract current files from database.
diff --git a/themes/chameleon/chameleon.info b/themes/chameleon/chameleon.info
index 2103648ddb0..4a6850e4dfd 100644
--- a/themes/chameleon/chameleon.info
+++ b/themes/chameleon/chameleon.info
@@ -7,5 +7,7 @@ features[] = logo
features[] = favicon
features[] = name
features[] = slogan
+stylesheets[all][] = style.css
+stylesheets[all][] = common.css
version = VERSION
core = 6.x
diff --git a/themes/chameleon/chameleon.theme b/themes/chameleon/chameleon.theme
index aa74055409e..7433ed8ef7b 100644
--- a/themes/chameleon/chameleon.theme
+++ b/themes/chameleon/chameleon.theme
@@ -29,8 +29,6 @@ function chameleon_page($content, $show_blocks = TRUE, $show_messages = TRUE) {
drupal_set_html_head('');
}
- drupal_add_css(path_to_theme() .'/common.css', 'theme');
-
$title = drupal_get_title();
// Get blocks before so that they can alter the header (JavaScript, Stylesheets etc.)
diff --git a/themes/garland/garland.info b/themes/garland/garland.info
index 32c000d9283..3a5d3bb7c60 100644
--- a/themes/garland/garland.info
+++ b/themes/garland/garland.info
@@ -4,3 +4,5 @@ description = Tableless, recolorable, multi-column, fluid width theme (default).
version = VERSION
core = 6.x
engine = phptemplate
+stylesheets[all][] = style.css
+stylesheets[print][] = print.css
diff --git a/themes/garland/page.tpl.php b/themes/garland/page.tpl.php
index 5f607822866..bba6c898ce0 100644
--- a/themes/garland/page.tpl.php
+++ b/themes/garland/page.tpl.php
@@ -6,7 +6,6 @@
-