function site_banner_build_banner in Site Banner 7
Builds the site banner and implementing the context hooks.
Parameters
array $page: the page object being formatted.
Return value
array the page object formatted with the site banner.
2 calls to site_banner_build_banner()
- SiteBannerRenderingUnitTestCase::testBannerHeaderTagExists in ./
site_banner.test - Tests if header banner is in right CSS tag.
- site_banner_page_build in ./
site_banner.module - Implements hook_page_build().
File
- ./
site_banner.module, line 62 - Main module file implementing callbacks for the site banner module.
Code
function site_banner_build_banner($page) {
$banner_active = variable_get('site_banner_status', FALSE);
$debug_mode = site_banner_check_if_debug_mode_active();
if (module_exists('context')) {
$plugin = context_get_plugin('reaction', 'change_banner_status');
if ($plugin) {
$plugin
->execute($banner_active, $debug_mode);
}
}
if ($banner_active) {
// ******************************************************
// Add link to banner CSS files and define banner colors.
// ******************************************************
$background_color_as_text = variable_get('site_banner_background_color', site_banner_get_default_background_color());
$text_color_as_text = variable_get('site_banner_text_color', site_banner_get_default_text_color());
// Execute context hooks to see if we need to alter the text or background
// colors. Will overwrite $background_color_as_text and $text_color_as_text
// variables.
if (module_exists('context')) {
$plugin = context_get_plugin('reaction', 'change_banner_text_color');
if ($plugin) {
$plugin
->execute($text_color_as_text);
}
$plugin = context_get_plugin('reaction', 'change_banner_background_color');
if ($plugin) {
$plugin
->execute($background_color_as_text);
}
}
$banner_css_colors_value = "#siteBannerFooterBanner, #siteBannerHeaderBanner {background-color:{$background_color_as_text}; color:{$text_color_as_text};}";
drupal_add_css(filter_xss_admin($banner_css_colors_value), array(
'group' => CSS_DEFAULT,
'type' => 'inline',
'media' => 'all',
));
// ************************
// Add banner text to page.
// ************************
$banner_text = variable_get('site_banner_text', site_banner_get_default_text());
if ($debug_mode) {
$banner_text = site_banner_generate_link_to_admin_page($banner_text);
}
// Execute context hooks to see if we need to alter the text or background
// colors. Will overwrite $background_color_as_text and $text_color_as_text
// variables.
if (module_exists('context')) {
$plugin = context_get_plugin('reaction', 'change_banner_text');
if ($plugin) {
$plugin
->execute($banner_text);
}
}
$top_banner_active = variable_get('site_banner_top_banner_active', TRUE);
$page_array = array();
if ($top_banner_active) {
$page_element = array(
'#type' => 'html_tag',
'#tag' => 'div',
'#attributes' => array(
'id' => 'siteBannerHeaderBanner',
'class' => array(
'toolbar',
'clearfix',
'toolbar-processed',
'overlay-displace-top',
),
),
'#value' => filter_xss_admin($banner_text),
'#weight' => -100,
);
array_push($page_array, $page_element);
}
$bottom_banner_active = variable_get('site_banner_bottom_banner_active', TRUE);
if ($bottom_banner_active) {
$page_element = array(
'#type' => 'html_tag',
'#tag' => 'div',
'#attributes' => array(
'id' => 'siteBannerFooterBanner',
'class' => array(
'toolbar',
'clearfix',
'toolbar-processed',
'overlay-displace-top',
),
),
'#value' => filter_xss_admin($banner_text),
'#weight' => -100,
);
array_push($page_array, $page_element);
}
// Define the site banner text in html body.
$page['page_top'] = $page_array;
}
return $page;
}