function _regions_top_nav_status_messages in Regions 7
Helper function to retrieves system messages.
1 string reference to '_regions_top_nav_status_messages'
- regions_top_nav_theme_registry_alter in modules/
regions_top_nav/ regions_top_nav.module - Implements hook_theme_registry_alter().
File
- modules/
regions_top_nav/ regions_top_nav.module, line 78 - Add a top nav bar for dropping blocks into.
Code
function _regions_top_nav_status_messages($variables) {
global $user;
$output = '';
// get all messages and unset them for the session
$messages = drupal_get_messages();
// need a separater container for title mapping
$title_messages = $messages;
if (!empty($messages)) {
$content = '';
// get a map of all known values
$map = _regions_top_nav_get_map();
// account for parent items which reduces redundancy in the UI
foreach ($title_messages as $key => $message_group) {
// if this item actually has a parent, move it's status messages in there
if (isset($map[$key]['parent'])) {
// test to see if this item came across itself to merge under, otherwise
if (isset($title_messages[$map[$key]['parent']])) {
$title_messages[$map[$key]['parent']] = array_merge($title_messages[$map[$key]['parent']], $message_group);
}
else {
// this is basically just a push of the value into its parent
$title_messages[$map[$key]['parent']] = $message_group;
}
unset($title_messages[$key]);
}
}
// build out the title bar
$title = '';
foreach ($title_messages as $key => $message_group) {
// see if we have a map, if not use default
if (isset($map[$key])) {
$type = $key;
}
else {
$type = 'default';
}
// if there are multiple messages then place a count indicator
$msg_count = '';
if (count($message_group) > 1) {
$msg_count = '<div class="regions_top_nav_msg_bar_icon_count">' . count($message_group) . '</div>';
}
// block title as icons
$title .= '<div class="regions_top_nav_msg_bar_icon"><a href="#" title="' . $map[$type]['title'] . ', click for more details"><img src="' . $map[$type]['bar_icon'] . '" title="' . $map[$type]['title'] . ', click for more details" alt="' . $map[$type]['title'] . ', click for more details" /></a>' . $msg_count . '</div>';
}
// build out the message array
foreach ($messages as $key => $message_group) {
// see if we have a map, if not use default
if (isset($map[$key])) {
$type = $key;
}
else {
$type = 'default';
}
// loop through as messages are grouped by type
foreach ($message_group as $message) {
// block content area
$content .= '<div class="regions_top_nav_row"><img src="' . $map[$type]['icon'] . '" title="' . $map[$type]['title'] . ', click for more details" alt="' . $map[$type]['title'] . ', click for more details" class="regions_top_nav_icon"/><div class="regions_top_nav_msg"><div class="regions_top_nav_msg_title">' . $map[$type]['title'] . '</div><div class="regions_top_nav_msg_text">' . $message . '</div></div></div>';
}
}
// add arrow to right side to indicate this can be opened
$title .= '<a href="#" title="Click to see notifications"><img src="' . base_path() . drupal_get_path('module', 'regions_top_nav') . '/images/notifications/arrow_down.png" alt="Click to see notifications" class="regions_top_nav_arrow"/></a>';
// construct the block for display
$output = '<div class="regions_block_title">' . $title . '</div><div class="regions_block_content">' . $content . '</div>';
}
return $output;
}