diff options
-rw-r--r-- | includes/theme.inc | 38 | ||||
-rw-r--r-- | modules/system.module | 8 | ||||
-rw-r--r-- | modules/system/system.module | 8 | ||||
-rw-r--r-- | themes/bluemarine/xtemplate.xtmpl | 2 | ||||
-rw-r--r-- | themes/chameleon/chameleon.theme | 13 | ||||
-rw-r--r-- | themes/engines/xtemplate/xtemplate.engine | 21 | ||||
-rw-r--r-- | themes/pushbutton/xtemplate.xtmpl | 2 |
7 files changed, 61 insertions, 31 deletions
diff --git a/includes/theme.inc b/includes/theme.inc index af647fb91..7c87fcee9 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -53,16 +53,16 @@ function init_theme() { // Also load the stylesheet using drupal_set_html_head(). // Otherwise, load the theme. if (strpos($themes[$theme]->filename, '.css')) { - // File is a style; put it in the html_head buffer + // File is a style; loads its CSS. // Set theme to its template/theme - drupal_set_html_head(theme('stylesheet_import', $themes[$theme]->filename)); + theme_add_style($themes[$theme]->filename); $theme = $themes[$theme]->description; } else { // File is a template/theme - // Put the css with the same name in html_head, if it exists + // Load its CSS, if it exists if (file_exists($stylesheet = dirname($themes[$theme]->filename) .'/style.css')) { - drupal_set_html_head(theme('stylesheet_import', $stylesheet)); + theme_add_style($stylesheet); } } @@ -206,7 +206,7 @@ function path_to_theme() { * @return * An associative array containing theme settings. */ -function drupal_get_theme_settings($key = NULL) { +function theme_get_settings($key = NULL) { $defaults = array( 'primary_links' => '', 'secondary_links' => l('edit secondary links', 'admin/themes/settings'), @@ -252,12 +252,12 @@ function drupal_get_theme_settings($key = NULL) { * @return * The value of the requested setting, NULL if the setting does not exist. */ -function drupal_get_theme_setting($setting_name, $refresh = FALSE) { +function theme_get_setting($setting_name, $refresh = FALSE) { global $theme_key; static $settings; if (empty($settings) || $refresh) { - $settings = drupal_get_theme_settings($theme_key); + $settings = theme_get_settings($theme_key); $themes = list_themes(); $theme_object = $themes[$theme_key]; @@ -297,6 +297,29 @@ function drupal_get_theme_setting($setting_name, $refresh = FALSE) { } /** + * Add a theme stylesheet to be included later. This is handled separately from + * drupal_set_html_head() to enforce the correct CSS cascading order. + */ +function theme_add_style($style = '') { + static $styles = array(); + if ($style) { + $styles[] = $style; + } + return $styles; +} + +/** + * Return the HTML for a theme's stylesheets. + */ +function theme_get_styles() { + $output = ''; + foreach (theme_add_style() as $style) { + $output .= theme('stylesheet_import', $style); + } + return $output; +} + +/** * @defgroup themeable Themeable functions * @{ * @@ -335,6 +358,7 @@ function theme_page($content, $title = NULL, $breadcrumb = NULL) { $output .= '<head>'; $output .= ' <title>'. (drupal_get_title() ? drupal_get_title() : variable_get('site_name', 'drupal')) .'</title>'; $output .= drupal_get_html_head(); + $output .= theme_get_styles(); $output .= ' </head>'; $output .= ' <body style="background-color: #fff; color: #000;"'. theme('onload_attribute'). '">'; diff --git a/modules/system.module b/modules/system.module index e7f049be9..52b922e08 100644 --- a/modules/system.module +++ b/modules/system.module @@ -115,7 +115,7 @@ function system_user($type, $edit, &$user, $category = NULL) { // Screenshot column. $screenshot = dirname($value->filename) .'/screenshot.png'; - $row[] = file_exists($screenshot) ? theme('image', $screenshot, t('Screenshot for %theme theme', array('%theme' => $value->name)), '', 'class="screenshot"') : t('no screenshot'); + $row[] = file_exists($screenshot) ? theme('image', $screenshot, t('Screenshot for %theme theme', array('%theme' => $value->name)), '', 'class="screenshot"', false) : t('no screenshot'); // Information field. $field = '<strong>'. basename($value->name) .'</strong>'; @@ -391,7 +391,7 @@ function system_theme_listing() { $row = array(); // Screenshot column. - $row[] = file_exists($info->screenshot) ? theme('image', $info->screenshot, t('Screenshot for %theme theme', array('%theme' => $info->shortname)), '', 'class="screenshot"') : t('no screenshot'); + $row[] = file_exists($info->screenshot) ? theme('image', $info->screenshot, t('Screenshot for %theme theme', array('%theme' => $info->shortname)), '', 'class="screenshot"', false) : t('no screenshot'); // Information field. $field = '<strong>'. $info->shortname .'</strong>'; @@ -568,13 +568,13 @@ function system_theme_settings() { // Default settings are defined in _theme_settings() in includes/theme.inc $key = str_replace('.', '/', arg(3)); if ($key) { - $settings = drupal_get_theme_settings($key); + $settings = theme_get_settings($key); $var = str_replace('/', '_', 'theme_'. $key .'_settings'); $themes = system_theme_data('themes'); $features = function_exists($themes[$key]->prefix .'_features') ? call_user_func($themes[$key]->prefix .'_features') : array(); } else { - $settings = drupal_get_theme_settings(''); + $settings = theme_get_settings(''); $var = 'theme_settings'; } diff --git a/modules/system/system.module b/modules/system/system.module index e7f049be9..52b922e08 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -115,7 +115,7 @@ function system_user($type, $edit, &$user, $category = NULL) { // Screenshot column. $screenshot = dirname($value->filename) .'/screenshot.png'; - $row[] = file_exists($screenshot) ? theme('image', $screenshot, t('Screenshot for %theme theme', array('%theme' => $value->name)), '', 'class="screenshot"') : t('no screenshot'); + $row[] = file_exists($screenshot) ? theme('image', $screenshot, t('Screenshot for %theme theme', array('%theme' => $value->name)), '', 'class="screenshot"', false) : t('no screenshot'); // Information field. $field = '<strong>'. basename($value->name) .'</strong>'; @@ -391,7 +391,7 @@ function system_theme_listing() { $row = array(); // Screenshot column. - $row[] = file_exists($info->screenshot) ? theme('image', $info->screenshot, t('Screenshot for %theme theme', array('%theme' => $info->shortname)), '', 'class="screenshot"') : t('no screenshot'); + $row[] = file_exists($info->screenshot) ? theme('image', $info->screenshot, t('Screenshot for %theme theme', array('%theme' => $info->shortname)), '', 'class="screenshot"', false) : t('no screenshot'); // Information field. $field = '<strong>'. $info->shortname .'</strong>'; @@ -568,13 +568,13 @@ function system_theme_settings() { // Default settings are defined in _theme_settings() in includes/theme.inc $key = str_replace('.', '/', arg(3)); if ($key) { - $settings = drupal_get_theme_settings($key); + $settings = theme_get_settings($key); $var = str_replace('/', '_', 'theme_'. $key .'_settings'); $themes = system_theme_data('themes'); $features = function_exists($themes[$key]->prefix .'_features') ? call_user_func($themes[$key]->prefix .'_features') : array(); } else { - $settings = drupal_get_theme_settings(''); + $settings = theme_get_settings(''); $var = 'theme_settings'; } diff --git a/themes/bluemarine/xtemplate.xtmpl b/themes/bluemarine/xtemplate.xtmpl index a622be24f..fbeef1e58 100644 --- a/themes/bluemarine/xtemplate.xtmpl +++ b/themes/bluemarine/xtemplate.xtmpl @@ -4,6 +4,8 @@ <head> <title>{head_title}</title> {head} + {styles} + <script type="text/javascript"> </script> </head> <body{onload_attributes}> diff --git a/themes/chameleon/chameleon.theme b/themes/chameleon/chameleon.theme index 470abc2c3..c449d8f46 100644 --- a/themes/chameleon/chameleon.theme +++ b/themes/chameleon/chameleon.theme @@ -25,24 +25,25 @@ function chameleon_page($content, $title = NULL, $breadcrumb = NULL) { $output .= " <title>". ($title ? $title ." | ". variable_get("site_name", "drupal") : variable_get("site_name", "drupal") ." | ". variable_get("site_slogan", "")) ."</title>\n"; $output .= drupal_get_html_head(); $output .= " <link rel=\"stylesheet\" type=\"text/css\" href=\"themes/chameleon/common.css\" />\n"; + $output .= theme_get_styles(); $output .= "</head>"; $output .= "<body". theme_onload_attribute() .">\n"; $output .= " <div id=\"header\">"; - if ($logo = drupal_get_theme_setting('logo')) { + if ($logo = theme_get_setting('logo')) { $output .= " <a href=\"./\" title=\"Home\"><img src=\"$logo\" alt=\"Home\" /></a>"; } - if (drupal_get_theme_setting('toggle_name')) { + if (theme_get_setting('toggle_name')) { $output .= " <h1 class=\"site-name title\">". l(variable_get('site_name', 'drupal'), ""). "</h1>"; } - if (drupal_get_theme_setting('toggle_slogan')) { + if (theme_get_setting('toggle_slogan')) { $output .= " <div class=\"site-slogan\">". variable_get('site_slogan', '') ."</div>"; } $output .= "</div>\n"; - $primary_links = drupal_get_theme_setting('primary_links'); - $secondary_links = drupal_get_theme_setting('secondary_links'); + $primary_links = theme_get_setting('primary_links'); + $secondary_links = theme_get_setting('secondary_links'); if ($primary_links || $secondary_links) { $output .= ' <div class="navlinks">'; if ($primary_links) { @@ -121,7 +122,7 @@ function chameleon_node($node, $main = 0, $page = 0) { $output .= " </div>\n"; - $submitted = drupal_get_theme_setting("toggle_node_info_$node->type") ? array(t("By %author at %date", array('%author' => format_name($node), '%date' => format_date($node->created, 'small')))) : array(); + $submitted = theme_get_setting("toggle_node_info_$node->type") ? array(t("By %author at %date", array('%author' => format_name($node), '%date' => format_date($node->created, 'small')))) : array(); if (module_exist('taxonomy')) { $terms = taxonomy_link("taxonomy terms", $node); diff --git a/themes/engines/xtemplate/xtemplate.engine b/themes/engines/xtemplate/xtemplate.engine index 02f5cfba2..0a795f32c 100644 --- a/themes/engines/xtemplate/xtemplate.engine +++ b/themes/engines/xtemplate/xtemplate.engine @@ -32,7 +32,7 @@ function xtemplate_node($node, $main = 0, $page = 0) { global $xtemplate; $xtemplate->template->assign(array( - "submitted" => drupal_get_theme_setting("toggle_node_info_$node->type") ? + "submitted" => theme_get_setting("toggle_node_info_$node->type") ? t("Submitted by %a on %b.", array("%a" => format_name($node), "%b" => format_date($node->created))) : '', @@ -47,7 +47,7 @@ function xtemplate_node($node, $main = 0, $page = 0) { $xtemplate->template->parse("node.title"); } - if (drupal_get_theme_setting('toggle_node_user_picture') && $picture = theme('user_picture', $node)) { + if (theme_get_setting('toggle_node_user_picture') && $picture = theme('user_picture', $node)) { $xtemplate->template->assign("picture", $picture); $xtemplate->template->parse("node.picture"); } @@ -86,7 +86,7 @@ function xtemplate_comment($comment, $links = 0) { $xtemplate->template->parse("comment.new"); } - if (drupal_get_theme_setting('toggle_comment_user_picture') && $picture = theme('user_picture', $comment)) { + if (theme_get_setting('toggle_comment_user_picture') && $picture = theme('user_picture', $comment)) { $xtemplate->template->assign("picture", $picture); $xtemplate->template->parse("comment.picture"); } @@ -116,22 +116,23 @@ function xtemplate_page($content, $title = NULL, $breadcrumb = NULL) { $xtemplate->template->assign(array( "head_title" => (drupal_get_title() ? drupal_get_title() ." | ". variable_get("site_name", "drupal") : variable_get("site_name", "drupal") ." | ". variable_get("site_slogan", "")), "head" => drupal_get_html_head(), + "styles" => theme_get_styles(), "onload_attributes" => theme_onload_attribute(), - "primary_links" => drupal_get_theme_setting('primary_links'), - "secondary_links" => drupal_get_theme_setting('secondary_links') + "primary_links" => theme_get_setting('primary_links'), + "secondary_links" => theme_get_setting('secondary_links') )); - if ($logo = drupal_get_theme_setting('logo')) { + if ($logo = theme_get_setting('logo')) { $xtemplate->template->assign('logo', $logo); $xtemplate->template->parse('header.logo'); } - if (drupal_get_theme_setting('toggle_name')) { + if (theme_get_setting('toggle_name')) { $xtemplate->template->assign('site_name', variable_get('site_name', '')); $xtemplate->template->parse('header.site_name'); } - if (drupal_get_theme_setting('toggle_slogan')) { + if (theme_get_setting('toggle_slogan')) { $xtemplate->template->assign('site_slogan', variable_get('site_slogan', '')); $xtemplate->template->parse('header.site_slogan'); } @@ -157,7 +158,7 @@ function xtemplate_page($content, $title = NULL, $breadcrumb = NULL) { $xtemplate->template->parse("header.message"); } - if (drupal_get_theme_setting('toggle_search')) { + if (theme_get_setting('toggle_search')) { $xtemplate->template->assign(array( //"search" => search_form(), "search_url" => url("search"), @@ -168,7 +169,7 @@ function xtemplate_page($content, $title = NULL, $breadcrumb = NULL) { } // only parse the mission block if we are on the frontpage ... - if ($_GET["q"] == variable_get("site_frontpage", "node") && drupal_get_theme_setting('toggle_mission') && ($mission = drupal_get_theme_setting('mission'))) { + if ($_GET["q"] == variable_get("site_frontpage", "node") && theme_get_setting('toggle_mission') && ($mission = theme_get_setting('mission'))) { $xtemplate->template->assign("mission", $mission); $xtemplate->template->parse("header.mission"); } diff --git a/themes/pushbutton/xtemplate.xtmpl b/themes/pushbutton/xtemplate.xtmpl index 8239d4634..dbd6bdb9b 100644 --- a/themes/pushbutton/xtemplate.xtmpl +++ b/themes/pushbutton/xtemplate.xtmpl @@ -3,6 +3,8 @@ <head> <title>{head_title}</title> {head} + {styles} + <script type="text/javascript"> </script> </head> <body bgcolor="#ffffff" {onload_attributes}> |