Issue #850728 by tim.plunkett, bleen18, toco, kscheirer: Bartik: template.php cleanups.

8.0.x
Nathaniel Catchpole 2014-02-11 11:18:12 +00:00
parent d6555f2636
commit 44a153acf7
1 changed files with 24 additions and 28 deletions

View File

@ -63,19 +63,9 @@ function bartik_preprocess_page(&$variables) {
$variables['secondary_menu']['#attributes']['class'] = array('links', 'inline', 'clearfix'); $variables['secondary_menu']['#attributes']['class'] = array('links', 'inline', 'clearfix');
} }
$site_config = \Drupal::config('system.site'); // Set the options that apply to both page and maintenance page.
// Always print the site name and slogan, but if they are toggled off, we'll _bartik_process_page($variables);
// just hide them visually.
$variables['hide_site_name'] = theme_get_setting('features.name') ? FALSE : TRUE;
$variables['hide_site_slogan'] = theme_get_setting('features.slogan') ? FALSE : TRUE;
if ($variables['hide_site_name']) {
// If toggle_name is FALSE, the site_name will be empty, so we rebuild it.
$variables['site_name'] = check_plain($site_config->get('name'));
}
if ($variables['hide_site_slogan']) {
// If toggle_site_slogan is FALSE, the site_slogan will be empty, so we rebuild it.
$variables['site_slogan'] = filter_xss_admin($site_config->get('slogan'));
}
// Since the title and the shortcut link are both block level elements, // Since the title and the shortcut link are both block level elements,
// positioning them next to each other is much simpler with a wrapper div. // positioning them next to each other is much simpler with a wrapper div.
if (!empty($variables['title_suffix']['add_or_remove_shortcut']) && $variables['title']) { if (!empty($variables['title_suffix']['add_or_remove_shortcut']) && $variables['title']) {
@ -115,21 +105,8 @@ function bartik_preprocess_maintenance_page(&$variables) {
), ),
); );
drupal_render($libraries); // Set the options that apply to both page and maintenance page.
_bartik_process_page($variables);
$site_config = \Drupal::config('system.site');
// Always print the site name and slogan, but if they are toggled off, we'll
// just hide them visually.
$variables['hide_site_name'] = theme_get_setting('features.name') ? FALSE : TRUE;
$variables['hide_site_slogan'] = theme_get_setting('features.slogan') ? FALSE : TRUE;
if ($variables['hide_site_name']) {
// If toggle_name is FALSE, the site_name will be empty, so we rebuild it.
$variables['site_name'] = check_plain($site_config->get('name'));
}
if ($variables['hide_site_slogan']) {
// If toggle_site_slogan is FALSE, the site_slogan will be empty, so we rebuild it.
$variables['site_slogan'] = filter_xss_admin($site_config->get('slogan'));
}
} }
/** /**
@ -197,3 +174,22 @@ function bartik_field__taxonomy_term_reference($variables) {
return $output; return $output;
} }
/**
+ * Helper function for handling the site name and slogan.
+ */
function _bartik_process_page(&$variables) {
$site_config = \Drupal::config('system.site');
// Always print the site name and slogan, but if they are toggled off, we'll
// just hide them visually.
$variables['hide_site_name'] = theme_get_setting('features.name') ? FALSE : TRUE;
$variables['hide_site_slogan'] = theme_get_setting('features.slogan') ? FALSE : TRUE;
if ($variables['hide_site_name']) {
// If toggle_name is FALSE, the site_name will be empty, so we rebuild it.
$variables['site_name'] = check_plain($site_config->get('name'));
}
if ($variables['hide_site_slogan']) {
// If toggle_site_slogan is FALSE, the site_slogan will be empty, so we rebuild it.
$variables['site_slogan'] = filter_xss_admin($site_config->get('slogan'));
}
}