You are here

function views_analyze_format_result in Views (for Drupal 7) 6.3

Same name and namespace in other branches
  1. 6.2 includes/analyze.inc \views_analyze_format_result()
  2. 7.3 includes/analyze.inc \views_analyze_format_result()

Format the analyze result into a message string.

This is based upon the format of drupal_set_message which uses separate boxes for "ok", "warning" and "error".

1 call to views_analyze_format_result()
views_ui_analyze_view_form in includes/admin.inc
Form constructor callback to display analysis information on a view

File

includes/analyze.inc, line 35
Contains the view analyze tool code.

Code

function views_analyze_format_result($view, $messages) {
  if (empty($messages)) {
    $messages = array(
      views_ui_analysis(t('View analysis can find nothing to report.'), 'ok'),
    );
  }
  $types = array(
    'ok' => array(),
    'warning' => array(),
    'error' => array(),
  );
  foreach ($messages as $message) {
    if (empty($types[$message['type']])) {
      $types[$message['type']] = array();
    }
    $types[$message['type']][] = $message['message'];
  }
  $output = '';
  foreach ($types as $type => $messages) {
    $message = '';
    if (count($messages) > 1) {
      $message = theme('item_list', $messages);
    }
    else {
      if ($messages) {
        $message = array_shift($messages);
      }
    }
    if ($message) {
      $output .= "<div class=\"{$type}\">{$message}</div>";
    }
  }
  return $output;
}