function theme_absolute_messages in Absolute Messages 7
Same name and namespace in other branches
- 6 absolute_messages.module \theme_absolute_messages()
Theme function, overriding Drupal's theme_status_messages().
1 string reference to 'theme_absolute_messages'
- absolute_messages_theme_registry_alter in ./
absolute_messages.module - Implements hook_theme_registry_alter(). Replace original messages theming function with our own.
File
- ./
absolute_messages.module, line 111 - Module displaying system messages in colored horizontal bars on top of the page, similar to Stack Overflow / Stack Exchange network notifications.
Code
function theme_absolute_messages($variables) {
global $user;
// Check whether Absolute Messages should be enabled
// on current page and for current user role.
if (!_absolute_messages_visibility_pages() || !_absolute_messages_visibility_roles($user)) {
return theme_status_messages($variables);
}
// Fall back to standard Drupal's way of displaying messages if JS is not
// available or user does not have 'access absolute messages' permission.
// Still though use AM theme function if not checking "has_js" cookie.
$skip_cookie_check = variable_get('absolute_messages_no_js_check', FALSE);
if (!user_access('access absolute messages') || !$skip_cookie_check && !isset($_COOKIE['has_js'])) {
return theme_status_messages($variables);
}
// Get all messages, and skip further processing if no messages found.
$all_messages = drupal_get_messages($variables['display']);
if (empty($all_messages)) {
return;
}
// Provide hook_messages_alter($messages) to other modules.
// Allows modules to update messages before they are displayed.
drupal_alter('messages', $all_messages);
// Theme all messages for output.
$output = '';
$total_messages = 0;
foreach ($all_messages as $type => $messages) {
// Group duplicate messages if enabled.
if (variable_get('absolute_messages_group', FALSE)) {
$messages = _absolute_messages_group_duplicates($messages);
}
$vars = array(
'type' => $type,
'messages' => $messages,
);
$output .= theme('absolute_messages_messages', $vars);
$total_messages += count($messages);
}
// Add 'Dismiss all messages'.
$vars = array(
'dismiss_all' => t('Dismiss all messages'),
);
$output .= theme('absolute_messages_dismiss_all', array(
'vars' => $vars,
));
// Return formatted messages.
$vars = array(
'messages' => $output,
'show_dismissed' => t('Show dismissed messages'),
);
// Return all AM-themes messages together with devel messages
// themed in standard Drupal way.
return theme('absolute_messages_wrapper', array(
'vars' => $vars,
)) . theme_status_messages($variables);
}