summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/system.module44
-rw-r--r--modules/system/system.module44
2 files changed, 48 insertions, 40 deletions
diff --git a/modules/system.module b/modules/system.module
index f62459f69..e414d77b0 100644
--- a/modules/system.module
+++ b/modules/system.module
@@ -373,39 +373,41 @@ function system_theme_data() {
/**
* Get a list of available regions from a specified theme.
*
- * @param $theme
+ * @param $theme_key
* The name of a theme.
* @return
* An array of regions in the form $region['name'] = 'description'.
*/
-function system_region_list($theme) {
+function system_region_list($theme_key) {
static $list = array();
- if(!array_key_exists($theme, $list)) {
+ if(!array_key_exists($theme_key, $list)) {
- $themes = list_themes();
+ $result = db_query("SELECT * FROM {system} WHERE type = 'theme' AND name = '%s'", $theme_key);
+ $theme = db_fetch_object($result);
- if (strpos($themes[$theme]->filename, '.css')) {
+ if (strpos($theme->filename, '.css')) {
// File is a style, which can't have its own regions; use its theme instead.
- $theme = basename(dirname($themes[$theme]->description));
+ $list[$theme_key] = system_region_list(basename(dirname($theme->description)));
+ return $list[$theme_key];
}
- if (file_exists($file = dirname($themes[$theme]->filename) .'/' . $themes[$theme]->name . '.theme')) {
+ if (file_exists($file = dirname($theme->filename) .'/' . $theme_key . '.theme')) {
include_once($file);
}
- $regions = function_exists($theme . '_regions') ? call_user_func($theme . '_regions') : array();
- if (strpos($themes[$theme]->description, '.engine')) {
+ $regions = function_exists($theme_key . '_regions') ? call_user_func($theme_key . '_regions') : array();
+ if (strpos($theme->description, '.engine')) {
// File is a template; include its engine's regions.
- include_once($themes[$theme]->description);
- $theme_engine = basename($themes[$theme]->description, '.engine');
+ include_once($theme->description);
+ $theme_engine = basename($theme->description, '.engine');
$engine_regions = function_exists($theme_engine . '_regions') ? call_user_func($theme_engine . '_regions') : array();
$regions = array_merge($engine_regions, $regions);
}
- $list[$theme] = $regions;
+ $list[$theme_key] = $regions;
}
- return $list[$theme];
+ return $list[$theme_key];
}
/**
@@ -560,7 +562,7 @@ function system_listing_save($edit = array()) {
$status = 1;
}
// If status is being set to 1 from 0, initialize block data for this theme if necessary.
- if (($status == 1) && db_num_rows(db_query("SELECT status FROM {system} WHERE type = '%s' AND name = '%s' AND status = 0", $edit['type'], $name))) {
+ if (($edit['type'] == 'theme') && ($status == 1) && db_num_rows(db_query("SELECT status FROM {system} WHERE type = '%s' AND name = '%s' AND status = 0", $edit['type'], $name))) {
system_initialize_theme_blocks($name);
}
@@ -578,19 +580,21 @@ function system_listing_save($edit = array()) {
}
}
/**
- * Assign an initial, default set of blocks for a theme. This function is called the first
- * time a new theme is enabled. The new theme gets a copy of the default theme's blocks,
- * with the difference that if a particular region isn't available in the new theme, the block
- * is assigned instead to the new theme's default region.
+ * Assign an initial, default set of blocks for a theme.
+ *
+ * This function is called the first time a new theme is enabled. The new theme
+ * gets a copy of the default theme's blocks, with the difference that if a
+ * particular region isn't available in the new theme, the block is assigned
+ * to the new theme's default region.
*
* @param $theme
* The name of a theme.
*/
function system_initialize_theme_blocks($theme) {
- $default_theme = variable_get('theme_default', 'bluemarine');
- $regions = system_region_list($theme);
// Initialize theme's blocks if none already registered.
if (!(db_num_rows(db_query("SELECT module FROM {blocks} WHERE theme = '%s'", $theme)))) {
+ $default_theme = variable_get('theme_default', 'bluemarine');
+ $regions = system_region_list($theme);
$result = db_query("SELECT * FROM {blocks} WHERE theme = '%s'", $default_theme);
while($block = db_fetch_array($result)) {
// If the region isn't supported by the theme, assign the block to the theme's default region.
diff --git a/modules/system/system.module b/modules/system/system.module
index f62459f69..e414d77b0 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -373,39 +373,41 @@ function system_theme_data() {
/**
* Get a list of available regions from a specified theme.
*
- * @param $theme
+ * @param $theme_key
* The name of a theme.
* @return
* An array of regions in the form $region['name'] = 'description'.
*/
-function system_region_list($theme) {
+function system_region_list($theme_key) {
static $list = array();
- if(!array_key_exists($theme, $list)) {
+ if(!array_key_exists($theme_key, $list)) {
- $themes = list_themes();
+ $result = db_query("SELECT * FROM {system} WHERE type = 'theme' AND name = '%s'", $theme_key);
+ $theme = db_fetch_object($result);
- if (strpos($themes[$theme]->filename, '.css')) {
+ if (strpos($theme->filename, '.css')) {
// File is a style, which can't have its own regions; use its theme instead.
- $theme = basename(dirname($themes[$theme]->description));
+ $list[$theme_key] = system_region_list(basename(dirname($theme->description)));
+ return $list[$theme_key];
}
- if (file_exists($file = dirname($themes[$theme]->filename) .'/' . $themes[$theme]->name . '.theme')) {
+ if (file_exists($file = dirname($theme->filename) .'/' . $theme_key . '.theme')) {
include_once($file);
}
- $regions = function_exists($theme . '_regions') ? call_user_func($theme . '_regions') : array();
- if (strpos($themes[$theme]->description, '.engine')) {
+ $regions = function_exists($theme_key . '_regions') ? call_user_func($theme_key . '_regions') : array();
+ if (strpos($theme->description, '.engine')) {
// File is a template; include its engine's regions.
- include_once($themes[$theme]->description);
- $theme_engine = basename($themes[$theme]->description, '.engine');
+ include_once($theme->description);
+ $theme_engine = basename($theme->description, '.engine');
$engine_regions = function_exists($theme_engine . '_regions') ? call_user_func($theme_engine . '_regions') : array();
$regions = array_merge($engine_regions, $regions);
}
- $list[$theme] = $regions;
+ $list[$theme_key] = $regions;
}
- return $list[$theme];
+ return $list[$theme_key];
}
/**
@@ -560,7 +562,7 @@ function system_listing_save($edit = array()) {
$status = 1;
}
// If status is being set to 1 from 0, initialize block data for this theme if necessary.
- if (($status == 1) && db_num_rows(db_query("SELECT status FROM {system} WHERE type = '%s' AND name = '%s' AND status = 0", $edit['type'], $name))) {
+ if (($edit['type'] == 'theme') && ($status == 1) && db_num_rows(db_query("SELECT status FROM {system} WHERE type = '%s' AND name = '%s' AND status = 0", $edit['type'], $name))) {
system_initialize_theme_blocks($name);
}
@@ -578,19 +580,21 @@ function system_listing_save($edit = array()) {
}
}
/**
- * Assign an initial, default set of blocks for a theme. This function is called the first
- * time a new theme is enabled. The new theme gets a copy of the default theme's blocks,
- * with the difference that if a particular region isn't available in the new theme, the block
- * is assigned instead to the new theme's default region.
+ * Assign an initial, default set of blocks for a theme.
+ *
+ * This function is called the first time a new theme is enabled. The new theme
+ * gets a copy of the default theme's blocks, with the difference that if a
+ * particular region isn't available in the new theme, the block is assigned
+ * to the new theme's default region.
*
* @param $theme
* The name of a theme.
*/
function system_initialize_theme_blocks($theme) {
- $default_theme = variable_get('theme_default', 'bluemarine');
- $regions = system_region_list($theme);
// Initialize theme's blocks if none already registered.
if (!(db_num_rows(db_query("SELECT module FROM {blocks} WHERE theme = '%s'", $theme)))) {
+ $default_theme = variable_get('theme_default', 'bluemarine');
+ $regions = system_region_list($theme);
$result = db_query("SELECT * FROM {blocks} WHERE theme = '%s'", $default_theme);
while($block = db_fetch_array($result)) {
// If the region isn't supported by the theme, assign the block to the theme's default region.