#325630: Broken link in "Theme registry rebuilt" warning when Clean URLs is off
[project/zen.git] / zen / template.theme-registry.inc
1 <?php
2 // $Id$
3
4 /**
5 * @file
6 * Contains infrequently used theme registry build functions.
7 */
8
9 /**
10 * Implements HOOK_theme().
11 *
12 * We are simply using this hook as a convenient time to do some related work.
13 */
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);
21 }
22 }
23
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);
27
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');
31 }
32
33 // Return nothing.
34 return array();
35 }
36
37 /**
38 * Return the theme settings' default values from the .info and save them into the database.
39 *
40 * @param $theme
41 * The name of theme.
42 */
43 function zen_theme_get_default_settings($theme) {
44 $themes = list_themes();
45
46 // Get the default values from the .info file.
47 $defaults = !empty($themes[$theme]->info['settings']) ? $themes[$theme]->info['settings'] : array();
48
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]);
56 }
57 }
58 // Save default theme settings.
59 variable_set(
60 str_replace('/', '_', 'theme_' . $theme . '_settings'),
61 array_merge($defaults, $settings)
62 );
63 // If the active theme has been loaded, force refresh of Drupal internals.
64 if (!empty($GLOBALS['theme_key'])) {
65 theme_get_setting('', TRUE);
66 }
67 }
68
69 // Return the default settings.
70 return $defaults;
71 }