You are here

function purr_messages_status_messages in Purr Messages 6.2

Same name and namespace in other branches
  1. 8.2 purr_messages.module \purr_messages_status_messages()
  2. 6 purr_messages.module \purr_messages_status_messages()
  3. 7.2 purr_messages.module \purr_messages_status_messages()
  4. 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

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 95
Purr Messages A jQuery based override of Drupal's core message system

Code

function purr_messages_status_messages($variables = NULL) {
  $display = $variables['display'];
  $output = '';
  $purr = NULL;
  foreach (drupal_get_messages($display) as $type => $messages) {
    if (purr_messages_type($type, $messages) !== FALSE) {
      $purr[] = _purr_messages_purr($type, $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($themelayer = 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
    drupal_add_js(array(
      'purr_messages' => 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),
      ),
    ), 'setting');
    $output .= "<script type=\"text/javascript\">";
    $output .= "Drupal.behaviors.purr_messages = function(context) {\n \n      if (\$('#purr-container').length == 0) {\n var notice = ";
    foreach ($purr as $purr_message) {
      $script[] = $purr_message['script'];
    }
    $output .= implode(' + ', $script);
    $output .= '$(notice).purr();';

    // Finish off the script.
    $output .= ";\n}\n};</script>\n";
    $output .= "<noscript>\n";
    foreach ($purr as $purr_message) {
      $output .= $purr_message['noscript'];
    }
    $output .= "</noscript>\n";
  }
  return $output;
}