webmaster@1: base_theme)) { webmaster@1: $base_theme[] = $new_base_theme = $themes[$themes[$ancestor]->base_theme]; webmaster@1: $ancestor = $themes[$ancestor]->base_theme; webmaster@1: } webmaster@1: _init_theme($themes[$theme], array_reverse($base_theme), '_theme_load_offline_registry'); webmaster@1: webmaster@1: // These are usually added from system_init() -except maintenance.css. webmaster@1: // When the database is inactive it's not called so we add it here. webmaster@1: drupal_add_css(drupal_get_path('module', 'system') .'/defaults.css', 'module'); webmaster@1: drupal_add_css(drupal_get_path('module', 'system') .'/system.css', 'module'); webmaster@1: drupal_add_css(drupal_get_path('module', 'system') .'/system-menus.css', 'module'); webmaster@1: drupal_add_css(drupal_get_path('module', 'system') .'/maintenance.css', 'module'); webmaster@1: } webmaster@1: webmaster@1: /** webmaster@1: * This builds the registry when the site needs to bypass any database calls. webmaster@1: */ webmaster@1: function _theme_load_offline_registry($theme, $base_theme = NULL, $theme_engine = NULL) { webmaster@1: $registry = _theme_build_registry($theme, $base_theme, $theme_engine); webmaster@1: _theme_set_registry($registry); webmaster@1: } webmaster@1: webmaster@1: /** webmaster@1: * Return a themed list of maintenance tasks to perform. webmaster@1: * webmaster@1: * @ingroup themeable webmaster@1: */ webmaster@1: function theme_task_list($items, $active = NULL) { webmaster@1: $done = isset($items[$active]) || $active == NULL; webmaster@1: $output = '
    '; webmaster@1: foreach ($items as $k => $item) { webmaster@1: if ($active == $k) { webmaster@1: $class = 'active'; webmaster@1: $done = false; webmaster@1: } webmaster@1: else { webmaster@1: $class = $done ? 'done' : ''; webmaster@1: } webmaster@1: $output .= '
  1. '. $item .'
  2. '; webmaster@1: } webmaster@1: $output .= '
'; webmaster@1: return $output; webmaster@1: } webmaster@1: webmaster@1: /** webmaster@1: * Generate a themed installation page. webmaster@1: * webmaster@1: * Note: this function is not themeable. webmaster@1: * webmaster@1: * @param $content webmaster@1: * The page content to show. webmaster@1: */ webmaster@1: function theme_install_page($content) { webmaster@1: drupal_set_header('Content-Type: text/html; charset=utf-8'); webmaster@1: webmaster@1: // Assign content. webmaster@1: $variables['content'] = $content; webmaster@1: // Delay setting the message variable so it can be processed below. webmaster@1: $variables['show_messages'] = FALSE; webmaster@1: // The maintenance preprocess function is recycled here. webmaster@1: template_preprocess_maintenance_page($variables); webmaster@1: webmaster@1: // Special handling of error messages webmaster@1: $messages = drupal_set_message(); webmaster@1: if (isset($messages['error'])) { webmaster@1: $title = count($messages['error']) > 1 ? st('The following errors must be resolved before you can continue the installation process') : st('The following error must be resolved before you can continue the installation process'); webmaster@1: $variables['messages'] .= '

'. $title .':

'; webmaster@1: $variables['messages'] .= theme('status_messages', 'error'); webmaster@1: $variables['content'] .= '

'. st('Please check the error messages and try again.', array('!url' => request_uri())) .'

'; webmaster@1: } webmaster@1: webmaster@1: // Special handling of warning messages webmaster@1: if (isset($messages['warning'])) { webmaster@1: $title = count($messages['warning']) > 1 ? st('The following installation warnings should be carefully reviewed') : st('The following installation warning should be carefully reviewed'); webmaster@1: $variables['messages'] .= '

'. $title .':

'; webmaster@1: $variables['messages'] .= theme('status_messages', 'warning'); webmaster@1: } webmaster@1: webmaster@1: // Special handling of status messages webmaster@1: if (isset($messages['status'])) { webmaster@1: $title = count($messages['status']) > 1 ? st('The following installation warnings should be carefully reviewed, but in most cases may be safely ignored') : st('The following installation warning should be carefully reviewed, but in most cases may be safely ignored'); webmaster@1: $variables['messages'] .= '

'. $title .':

'; webmaster@1: $variables['messages'] .= theme('status_messages', 'status'); webmaster@1: } webmaster@1: webmaster@1: // This was called as a theme hook (not template), so we need to webmaster@1: // fix path_to_theme() for the template, to point at the actual webmaster@1: // theme rather than system module as owner of the hook. webmaster@1: global $theme_path; webmaster@1: $theme_path = 'themes/garland'; webmaster@1: webmaster@1: return theme_render_template('themes/garland/maintenance-page.tpl.php', $variables); webmaster@1: } webmaster@1: webmaster@1: /** webmaster@1: * Generate a themed update page. webmaster@1: * webmaster@1: * Note: this function is not themeable. webmaster@1: * webmaster@1: * @param $content webmaster@1: * The page content to show. webmaster@1: * @param $show_messages webmaster@1: * Whether to output status and error messages. webmaster@1: * FALSE can be useful to postpone the messages to a subsequent page. webmaster@1: */ webmaster@1: function theme_update_page($content, $show_messages = TRUE) { webmaster@1: // Set required headers. webmaster@1: drupal_set_header('Content-Type: text/html; charset=utf-8'); webmaster@1: webmaster@1: // Assign content and show message flag. webmaster@1: $variables['content'] = $content; webmaster@1: $variables['show_messages'] = $show_messages; webmaster@1: // The maintenance preprocess function is recycled here. webmaster@1: template_preprocess_maintenance_page($variables); webmaster@1: webmaster@1: // Special handling of warning messages. webmaster@1: $messages = drupal_set_message(); webmaster@1: if (isset($messages['warning'])) { webmaster@1: $title = count($messages['warning']) > 1 ? 'The following update warnings should be carefully reviewed before continuing' : 'The following update warning should be carefully reviewed before continuing'; webmaster@1: $variables['messages'] .= '

'. $title .':

'; webmaster@1: $variables['messages'] .= theme('status_messages', 'warning'); webmaster@1: } webmaster@1: webmaster@1: // This was called as a theme hook (not template), so we need to webmaster@1: // fix path_to_theme() for the template, to point at the actual webmaster@1: // theme rather than system module as owner of the hook. webmaster@1: global $theme_path; webmaster@1: $theme_path = 'themes/garland'; webmaster@1: webmaster@1: return theme_render_template('themes/garland/maintenance-page.tpl.php', $variables); webmaster@1: } webmaster@1: webmaster@1: /** webmaster@1: * The variables generated here is a mirror of template_preprocess_page(). webmaster@1: * This preprocessor will run it's course when theme_maintenance_page() is webmaster@1: * invoked. It is also used in theme_install_page() and theme_update_page() to webmaster@1: * keep all the variables consistent. webmaster@1: * webmaster@1: * An alternate template file of "maintenance-page-offline.tpl.php" can be webmaster@1: * used when the database is offline to hide errors and completely replace the webmaster@1: * content. webmaster@1: * webmaster@1: * The $variables array contains the following arguments: webmaster@1: * - $content webmaster@1: * - $show_blocks webmaster@1: * webmaster@1: * @see maintenance-page.tpl.php webmaster@1: */ webmaster@1: function template_preprocess_maintenance_page(&$variables) { webmaster@1: // Add favicon webmaster@1: if (theme_get_setting('toggle_favicon')) { webmaster@1: drupal_set_html_head(''); webmaster@1: } webmaster@1: webmaster@1: global $theme; webmaster@1: // Retrieve the theme data to list all available regions. webmaster@1: $theme_data = _system_theme_data(); webmaster@1: $regions = $theme_data[$theme]->info['regions']; webmaster@1: webmaster@1: // Get all region content set with drupal_set_content(). webmaster@1: foreach (array_keys($regions) as $region) { webmaster@1: // Assign region to a region variable. webmaster@1: $region_content = drupal_get_content($region); webmaster@1: isset($variables[$region]) ? $variables[$region] .= $region_content : $variables[$region] = $region_content; webmaster@1: } webmaster@1: webmaster@1: // Setup layout variable. webmaster@1: $variables['layout'] = 'none'; webmaster@1: if (!empty($variables['left'])) { webmaster@1: $variables['layout'] = 'left'; webmaster@1: } webmaster@1: if (!empty($variables['right'])) { webmaster@1: $variables['layout'] = ($variables['layout'] == 'left') ? 'both' : 'right'; webmaster@1: } webmaster@1: webmaster@1: // Construct page title webmaster@1: if (drupal_get_title()) { webmaster@1: $head_title = array(strip_tags(drupal_get_title()), variable_get('site_name', 'Drupal')); webmaster@1: } webmaster@1: else { webmaster@1: $head_title = array(variable_get('site_name', 'Drupal')); webmaster@1: if (variable_get('site_slogan', '')) { webmaster@1: $head_title[] = variable_get('site_slogan', ''); webmaster@1: } webmaster@1: } webmaster@1: $variables['head_title'] = implode(' | ', $head_title); webmaster@1: $variables['base_path'] = base_path(); webmaster@1: $variables['breadcrumb'] = ''; webmaster@1: $variables['feed_icons'] = ''; webmaster@1: $variables['footer_message'] = filter_xss_admin(variable_get('site_footer', FALSE)); webmaster@1: $variables['head'] = drupal_get_html_head(); webmaster@1: $variables['help'] = ''; webmaster@1: $variables['language'] = $GLOBALS['language']; webmaster@1: $variables['language']->dir = $GLOBALS['language']->direction ? 'rtl' : 'ltr'; webmaster@1: $variables['logo'] = theme_get_setting('logo'); webmaster@1: $variables['messages'] = $variables['show_messages'] ? theme('status_messages') : ''; webmaster@1: $variables['mission'] = ''; webmaster@1: $variables['primary_links'] = array(); webmaster@1: $variables['secondary_links'] = array(); webmaster@1: $variables['search_box'] = ''; webmaster@1: $variables['site_name'] = (theme_get_setting('toggle_name') ? variable_get('site_name', 'Drupal') : ''); webmaster@1: $variables['site_slogan'] = (theme_get_setting('toggle_slogan') ? variable_get('site_slogan', '') : ''); webmaster@1: $variables['css'] = drupal_add_css(); webmaster@1: $variables['styles'] = drupal_get_css(); webmaster@1: $variables['scripts'] = drupal_get_js(); webmaster@1: $variables['tabs'] = ''; webmaster@1: $variables['title'] = drupal_get_title(); webmaster@1: $variables['closure'] = ''; webmaster@1: webmaster@1: // Compile a list of classes that are going to be applied to the body element. webmaster@1: $body_classes = array(); webmaster@1: $body_classes[] = 'in-maintenance'; webmaster@1: if (isset($variables['db_is_active']) && !$variables['db_is_active']) { webmaster@1: $body_classes[] = 'db-offline'; webmaster@1: } webmaster@1: if ($variables['layout'] == 'both') { webmaster@1: $body_classes[] = 'two-sidebars'; webmaster@1: } webmaster@1: elseif ($variables['layout'] == 'none') { webmaster@1: $body_classes[] = 'no-sidebars'; webmaster@1: } webmaster@1: else { webmaster@1: $body_classes[] = 'one-sidebar sidebar-'. $variables['layout']; webmaster@1: } webmaster@1: $variables['body_classes'] = implode(' ', $body_classes); webmaster@1: webmaster@1: // Dead databases will show error messages so supplying this template will webmaster@1: // allow themers to override the page and the content completely. webmaster@1: if (isset($variables['db_is_active']) && !$variables['db_is_active']) { webmaster@1: $variables['template_file'] = 'maintenance-page-offline'; webmaster@1: } webmaster@1: }