6 * Contains infrequently used theme registry build functions.
10 * Implements HOOK_theme().
12 * We are simply using this hook as a convenient time to do some related work.
14 function _zen_theme(&$existing, $type, $theme, $path) {
15 // Compute the conditional stylesheets.
16 if (!module_exists('conditional_styles')) {
17 include_once
'./' .
drupal_get_path('theme', 'zen') .
'/template.conditional-styles.inc';
18 // _conditional_styles_theme() only needs to be run once.
19 if ($theme == 'zen') {
20 _conditional_styles_theme($existing, $type, $theme, $path);
24 // Since we are rebuilding the theme registry and the theme settings' default
25 // values may have changed, make sure they are saved in the database properly.
26 zen_theme_get_default_settings($theme);
28 // If we are auto-rebuilding the theme registry, warn about feature.
29 if (theme_get_setting('zen_rebuild_registry') && $theme == $GLOBALS['theme']) {
30 drupal_set_message(t('The theme registry has been rebuilt. <a href="!link">Turn off</a> this feature on production websites.', array('!link' => url('admin/build/themes/settings/' .
$GLOBALS['theme']))), 'warning');
38 * Return the theme settings' default values from the .info and save them into the database.
43 function zen_theme_get_default_settings($theme) {
44 $themes = list_themes();
46 // Get the default values from the .info file.
47 $defaults = !empty($themes[$theme]->info
['settings']) ?
$themes[$theme]->info
['settings'] : array();
49 if (!empty($defaults)) {
50 // Get the theme settings saved in the database.
51 $settings = theme_get_settings($theme);
52 // Don't save the toggle_node_info_ variables.
53 if (module_exists('node')) {
54 foreach (node_get_types() as
$type => $name) {
55 unset($settings['toggle_node_info_' .
$type]);
58 // Save default theme settings.
60 str_replace('/', '_', 'theme_' .
$theme .
'_settings'),
61 array_merge($defaults, $settings)
63 // If the active theme has been loaded, force refresh of Drupal internals.
64 if (!empty($GLOBALS['theme_key'])) {
65 theme_get_setting('', TRUE
);
69 // Return the default settings.