summaryrefslogtreecommitdiff
path: root/modules/system/system.module
diff options
context:
space:
mode:
authorGábor Hojtsy <gabor@hojtsy.hu>2007-11-30 12:19:10 +0000
committerGábor Hojtsy <gabor@hojtsy.hu>2007-11-30 12:19:10 +0000
commite9f52b4248a5268630b51ee0746dcf8b6449d445 (patch)
tree2a75a607895da5e9ec5271971426a5344e8911a4 /modules/system/system.module
parent6d4b0a24fad35cfbbf48d3b3f82ff5dbc243e5cb (diff)
downloadbrdo-e9f52b4248a5268630b51ee0746dcf8b6449d445.tar.gz
brdo-e9f52b4248a5268630b51ee0746dcf8b6449d445.tar.bz2
#141727 by merlinofchaos, dvessel, sun: restore themeability support for maintenance pages (regression)
Diffstat (limited to 'modules/system/system.module')
-rw-r--r--modules/system/system.module180
1 files changed, 94 insertions, 86 deletions
diff --git a/modules/system/system.module b/modules/system/system.module
index d6997c2f1..ca8e54703 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -77,7 +77,7 @@ function system_help($path, $arg) {
}
function system_theme() {
- return array_merge(drupal_common_themes(), array(
+ return array_merge(drupal_common_theme(), array(
'system_theme_select_form' => array(
'arguments' => array('form' => NULL),
'file' => 'system.admin.inc',
@@ -711,111 +711,119 @@ function system_theme_default() {
}
/**
- * Collect data about all currently available themes
+ * Collect data about all currently available themes.
+ *
+ * @return
+ * Array of all available themes and their data.
*/
function system_theme_data() {
- // Find themes
- $themes = drupal_system_listing('\.info$', 'themes');
+ // Scan the installation theme .info files and their engines.
+ $themes = _system_theme_data();
- // Find theme engines
- $engines = drupal_system_listing('\.engine$', 'themes/engines');
-
- // Remove all theme engines from the system table
- db_query("DELETE FROM {system} WHERE type = '%s'", 'theme_engine');
+ // Extract current files from database.
+ system_get_files_database($themes, 'theme');
- foreach ($engines as $engine) {
- // Insert theme engine into system table
- drupal_get_filename('theme_engine', $engine->name, $engine->filename);
- drupal_load('theme_engine', $engine->name);
- db_query("INSERT INTO {system} (name, type, filename, status, throttle, bootstrap) VALUES ('%s', '%s', '%s', %d, %d, %d)", $engine->name, 'theme_engine', $engine->filename, 1, 0, 0);
- }
+ db_query("DELETE FROM {system} WHERE type = 'theme'");
- $defaults = system_theme_default();
+ foreach ($themes as $theme) {
+ if (!isset($theme->owner)) {
+ $theme->owner = '';
+ }
- $sub_themes = array();
- // Read info files for each theme
- foreach ($themes as $key => $theme) {
- $themes[$key]->info = drupal_parse_info_file($theme->filename) + $defaults;
+ db_query("INSERT INTO {system} (name, owner, info, type, filename, status, throttle, bootstrap) VALUES ('%s', '%s', '%s', '%s', '%s', %d, %d, %d)", $theme->name, $theme->owner, serialize($theme->info), 'theme', $theme->filename, isset($theme->status) ? $theme->status : 0, 0, 0);
+ }
- // Invoke hook_system_info_alter() to give installed modules a chance to
- // modify the data in the .info files if necessary.
- drupal_alter('system_info', $themes[$key]->info, $themes[$key]);
+ return $themes;
+}
- if (!empty($themes[$key]->info['base theme'])) {
- $sub_themes[] = $key;
- }
- if (empty($themes[$key]->info['engine'])) {
- $filename = dirname($themes[$key]->filename) .'/'. $themes[$key]->name .'.theme';
- if (file_exists($filename)) {
- $themes[$key]->owner = $filename;
- $themes[$key]->prefix = $key;
+/**
+ * Helper function to scan and collect theme .info data and their engines.
+ */
+function _system_theme_data() {
+ static $themes_info = array();
+
+ if (empty($theme_info)) {
+ // Find themes
+ $themes = drupal_system_listing('\.info$', 'themes');
+ // Find theme engines
+ $engines = drupal_system_listing('\.engine$', 'themes/engines');
+
+ $defaults = system_theme_default();
+
+ $sub_themes = array();
+ // Read info files for each theme
+ foreach ($themes as $key => $theme) {
+ $themes[$key]->info = drupal_parse_info_file($theme->filename) + $defaults;
+
+ // Invoke hook_system_info_alter() to give installed modules a chance to
+ // modify the data in the .info files if necessary.
+ drupal_alter('system_info', $themes[$key]->info, $themes[$key]);
+
+ if (!empty($themes[$key]->info['base theme'])) {
+ $sub_themes[] = $key;
}
- }
- else {
- $engine = $themes[$key]->info['engine'];
- if (isset($engines[$engine])) {
- $themes[$key]->owner = $engines[$engine]->filename;
- $themes[$key]->prefix = $engines[$engine]->name;
- $themes[$key]->template = TRUE;
+ if (empty($themes[$key]->info['engine'])) {
+ $filename = dirname($themes[$key]->filename) .'/'. $themes[$key]->name .'.theme';
+ if (file_exists($filename)) {
+ $themes[$key]->owner = $filename;
+ $themes[$key]->prefix = $key;
+ }
}
- }
-
- // 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;
+ else {
+ $engine = $themes[$key]->info['engine'];
+ if (isset($engines[$engine])) {
+ $themes[$key]->owner = $engines[$engine]->filename;
+ $themes[$key]->prefix = $engines[$engine]->name;
+ $themes[$key]->template = TRUE;
+ }
}
- }
- $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'];
- }
- }
+ // 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;
+ }
+ }
+ $themes[$key]->info['stylesheets'] = $pathed_stylesheets;
- // Now that we've established all our master themes, go back and fill in
- // data for subthemes.
- foreach ($sub_themes as $key) {
- $base_key = system_find_base_theme($themes, $key);
- if (!$base_key) {
- continue;
- }
- // Copy the 'owner' and 'engine' over if the top level theme uses a
- // theme engine.
- if (isset($themes[$base_key]->owner)) {
- if (isset($themes[$base_key]->info['engine'])) {
- $themes[$key]->info['engine'] = $themes[$base_key]->info['engine'];
- $themes[$key]->owner = $themes[$base_key]->owner;
- $themes[$key]->prefix = $themes[$base_key]->prefix;
+ // Give the scripts proper path information.
+ $scripts = array();
+ foreach ($themes[$key]->info['scripts'] as $script) {
+ $scripts[$script] = dirname($themes[$key]->filename) .'/'. $script;
}
- else {
- $themes[$key]->prefix = $key;
+ $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'];
}
}
- }
-
- // Extract current files from database.
- system_get_files_database($themes, 'theme');
- db_query("DELETE FROM {system} WHERE type = 'theme'");
-
- foreach ($themes as $theme) {
- if (!isset($theme->owner)) {
- $theme->owner = '';
+ // Now that we've established all our master themes, go back and fill in
+ // data for subthemes.
+ foreach ($sub_themes as $key) {
+ $base_key = system_find_base_theme($themes, $key);
+ if (!$base_key) {
+ continue;
+ }
+ // Copy the 'owner' and 'engine' over if the top level theme uses a
+ // theme engine.
+ if (isset($themes[$base_key]->owner)) {
+ if (isset($themes[$base_key]->info['engine'])) {
+ $themes[$key]->info['engine'] = $themes[$base_key]->info['engine'];
+ $themes[$key]->owner = $themes[$base_key]->owner;
+ $themes[$key]->prefix = $themes[$base_key]->prefix;
+ }
+ else {
+ $themes[$key]->prefix = $key;
+ }
+ }
}
-
- db_query("INSERT INTO {system} (name, owner, info, type, filename, status, throttle, bootstrap) VALUES ('%s', '%s', '%s', '%s', '%s', %d, %d, %d)", $theme->name, $theme->owner, serialize($theme->info), 'theme', $theme->filename, isset($theme->status) ? $theme->status : 0, 0, 0);
+
+ $themes_info = $themes;
}
- return $themes;
+ return $themes_info;
}
/**