summaryrefslogtreecommitdiff
path: root/includes/theme.inc
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2006-01-06 07:25:44 +0000
committerDries Buytaert <dries@buytaert.net>2006-01-06 07:25:44 +0000
commit6c20d333d2737f2875292e69f6e4bdfcfd57a684 (patch)
tree8a687efe73b0fd2c90ea4acaa70c7129e3fcc206 /includes/theme.inc
parentcade6b2bdacd39923f2ed1bf581c035b9be92c62 (diff)
downloadbrdo-6c20d333d2737f2875292e69f6e4bdfcfd57a684.tar.gz
brdo-6c20d333d2737f2875292e69f6e4bdfcfd57a684.tar.bz2
- Patch #35667 by Crell: bug fix: on ?q=admin/block style.css was imported twice.
Diffstat (limited to 'includes/theme.inc')
-rw-r--r--includes/theme.inc22
1 files changed, 12 insertions, 10 deletions
diff --git a/includes/theme.inc b/includes/theme.inc
index cf520c95c..f12c04665 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -28,11 +28,14 @@ define('MARK_UPDATED', 2);
/**
* Initialize the theme system by loading the theme.
*
- * @return
- * The name of the currently selected theme.
*/
function init_theme() {
- global $user, $custom_theme, $theme_engine, $theme_key;
+ global $theme, $user, $custom_theme, $theme_engine, $theme_key;
+
+ // If $theme is already set, assume the others are set, too, and do nothing
+ if (isset($theme)) {
+ return;
+ }
drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
$themes = list_themes();
@@ -78,8 +81,6 @@ function init_theme() {
call_user_func($theme_engine .'_init', $themes[$theme]);
}
}
-
- return $theme;
}
/**
@@ -160,9 +161,10 @@ function list_theme_engines($refresh = FALSE) {
function theme() {
global $theme, $theme_engine;
- if ($theme === NULL) {
- // Initialize the enabled theme.
- $theme = init_theme();
+ // Because theme() is called a lot, calling init_theme() only to have it
+ // smartly return is a noticeable performance hit. Don't do it.
+ if (!isset($theme)) {
+ init_theme();
}
$args = func_get_args();
@@ -314,11 +316,11 @@ function theme_get_setting($setting_name, $refresh = FALSE) {
*/
function theme_add_style($path = '', $media = 'all') {
static $styles = array();
- if ($path) {
+ if ($path && !isset($styles["$media:$path"])) {
$style = new stdClass();
$style->path = $path;
$style->media = $media;
- $styles[] = $style;
+ $styles["$media:$path"] = $style;
}
return $styles;
}