function purr_messages_status_messages in Purr Messages 8.2
Same name and namespace in other branches
- 6.2 purr_messages.module \purr_messages_status_messages()
- 6 purr_messages.module \purr_messages_status_messages()
- 7.2 purr_messages.module \purr_messages_status_messages()
- 7 purr_messages.module \purr_messages_status_messages()
Checks options and determines which type of message to return to the theme layer.
Parameters
$variables: Array containing theme variables.
Return value
string A string containing a formatted message, either purr or original style.
1 string reference to 'purr_messages_status_messages'
- purr_messages_theme_registry_alter in ./
purr_messages.module - Implements hook_theme_registry_alter().
File
- ./
purr_messages.module, line 119 - Purr Messages A jQuery based override of Drupal's core message system
Code
function purr_messages_status_messages($variables) {
$display = $variables['display'];
$output = '';
$purr = NULL;
// Get the messages.
$messages = drupal_get_messages($display);
// Filter messages if disable_message module is enabled and filtering is
// also enabled.
if (module_exists('disable_messages') && variable_get('disable_messages_enable', '1')) {
$messages = disable_messages_apply_filters($messages);
}
foreach ($messages as $type => $messages) {
if (purr_messages_type($type, $messages) !== FALSE) {
$purr[] = _purr_messages_purr($type, array_unique($messages));
}
else {
$output .= theme('original_status_messages', array(
'type' => $type,
'messages' => $messages,
));
}
}
$module_path = drupal_get_path('module', 'purr_messages');
$custom_css = purr_messages_status(TRUE);
$custom_css ? drupal_add_css($custom_css) : drupal_add_css($module_path . '/purrcss/purr.css');
if ($purr) {
// Add the purr js
drupal_add_js($module_path . '/js/jquery.timer.js');
drupal_add_js($module_path . '/js/jquery.purr.js');
// Add the settings
$settings = array(
'fadeInSpeed' => variable_get('purr_messages_fade_in', PURR_FADE_IN),
'fadeOutSpeed' => variable_get('purr_messages_fade_out', PURR_FADE_OUT),
'removeTimer' => variable_get('purr_messages_timer', PURR_TIMER),
'pauseOnHover' => variable_get('purr_messages_hover', TRUE) ? TRUE : FALSE,
'usingTransparentPNG' => variable_get('purr_messages_transparent', TRUE) ? TRUE : FALSE,
'attachTo' => variable_get('purr_messages_attachto', PURR_ATTACH_TO),
'sticky' => variable_get('purr_messages_sticky', PURR_STICKY),
);
drupal_add_js(array(
'purr_messages' => $settings,
), 'setting');
$output .= "<script type=\"text/javascript\">";
$output .= "(function(\$) {\nDrupal.behaviors.purr_messages = {\n\n attach: function(context) {\n if (\$('#purr-container').length == 0) { \nvar notice = ";
foreach ($purr as $purr_message) {
$script[] = $purr_message['script'];
}
$script = array_unique($script);
$output .= implode(' + ', $script);
$output .= "\$(notice).purr();";
// Finish off the script.
$output .= "\n}\n}\n}\n})(jQuery);</script>\n";
$output .= "<noscript>\n";
foreach ($purr as $purr_message) {
$output .= $purr_message['noscript'];
}
$output .= "</noscript>\n";
}
return $output;
}