1 theme.inc | template_preprocess_maintenance_page(&$variables) |
Prepares variables for maintenance-page templates.
The variables array generated here is a mirror of template_preprocess_page(). This preprocessor will run its course when theme_maintenance_page() is invoked. An alternate template file of maintenance-page--offline.tpl.php can be used when the database is offline to hide errors and completely replace the content.
The $variables array contains the following arguments:
- $content
See also
File
- core/
includes/ theme.inc, line 2907 - The theme system, which controls the output of Backdrop.
Code
function template_preprocess_maintenance_page(&$variables) {
// Load site config if available, fallback to the default.
try {
$site_config = config('system.core');
$site_name = filter_xss_admin($site_config->getTranslated('site_name'));
$site_slogan = filter_xss_admin($site_config->getTranslated('site_slogan'));
}
catch (ConfigException $e) {
$site_name = 'Backdrop CMS';
$site_slogan = '';
}
// Add favicon to the page.
$favicon = backdrop_get_favicon();
backdrop_add_html_head_link(array('rel' => 'shortcut icon', 'href' => $favicon['path'], 'type' => $favicon['type']));
// Construct head <title>.
$head_title = array();
if (backdrop_get_title()) {
$head_title['title'] = strip_tags(backdrop_get_title());
}
$head_title['name'] = $site_name ? $site_name : 'Backdrop CMS';
if ($site_slogan) {
$head_title['slogan'] = $site_slogan;
}
// Set the default language if necessary.
$language = isset($GLOBALS['language']) ? $GLOBALS['language'] : language_default();
// Initialize attributes which are specific to the html element.
$variables['html_attributes'] = array();
$variables['html_attributes']['lang'] = $language->langcode;
$variables['html_attributes']['dir'] = $language->direction ? 'rtl' : 'ltr';
$variables['head_title_array'] = $head_title;
$variables['head_title'] = implode(' | ', $head_title);
$variables['base_path'] = base_path();
$variables['front_page'] = url();
$variables['breadcrumb'] = '';
$variables['feed_icons'] = '';
$variables['messages'] = $variables['show_messages'] ? theme('status_messages') : '';
$variables['main_menu'] = array();
$variables['secondary_menu'] = array();
$variables['logo'] = backdrop_get_logo();
$variables['site_name'] = $site_name;
$variables['site_slogan'] = $site_slogan;
$variables['tabs'] = '';
$variables['title'] = backdrop_get_title();
// Compile a list of classes that are going to be applied to the body element.
$variables['classes'][] = 'in-maintenance';
if (isset($variables['db_is_active']) && !$variables['db_is_active']) {
$variables['classes'][] = 'db-offline';
}
// Dead databases will show error messages so supplying this template will
// allow themers to override the page and the content completely.
if (isset($variables['db_is_active']) && !$variables['db_is_active']) {
$variables['theme_hook_suggestion'] = 'maintenance_page__offline';
}
}