You are here

function views_ui_views_analyze in Views (for Drupal 7) 6.3

Same name and namespace in other branches
  1. 8.3 views_ui/views_ui.module \views_ui_views_analyze()
  2. 6.2 includes/analyze.inc \views_ui_views_analyze()
  3. 7.3 includes/analyze.inc \views_ui_views_analyze()

Implementation of hook_views_analyze().

This is the basic views analysis that checks for very minimal problems. There are other analysis tools in core specific sections, such as node.views.inc as well.

File

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

Code

function views_ui_views_analyze($view) {
  $ret = array();

  // Check for something other than the default display:
  if (count($view->display) < 2) {
    $ret[] = views_ui_analysis(t('This view has only a default display and therefore will not be placed anywhere on your site; perhaps you want to add a page or a block display.'), 'warning');
  }
  foreach ($view->display as $display_id => $display) {
    if (empty($display->handler) || !empty($display->handler->broken)) {
      $ret[] = views_ui_analysis(t('Display plugin @plugin is not available.', array(
        '@plugin' => $display->display_plugin,
      )), 'error');
    }
    $plugin = $display->handler
      ->get_plugin('style');
    if ($plugin) {
      $plugin
        ->init($view, $display);
      if ($validate_messages = $plugin
        ->validate()) {
        foreach ($validate_messages as $validate_message) {
          $ret[] = views_ui_analysis(t('Style plugin @plugin: @message', array(
            '@plugin' => $plugin_name,
            '@message' => $validate_message,
          )));
        }
      }
    }
    else {
      $ret[] = views_ui_analysis(t('Style plugin @plugin is not available.', array(
        '@plugin' => $plugin_name,
      )), 'error');
    }
    foreach (views_object_types() as $type => $info) {
      $handlers = $display->handler
        ->get_handlers($type);
      if ($handlers) {
        foreach ($handlers as $id => $handler) {
          if ($validate_messages = $handler
            ->validate()) {
            foreach ($validate_messages as $message) {
              $ret[] = views_ui_analysis("{$display_id}: {$id}: {$message}", 'error');
            }
          }
          if ($handler
            ->broken()) {
            $ret[] = views_ui_analysis(t('@type handler @table.@field is not available.', array(
              '@type' => $info['stitle'],
              '@table' => $handler->table,
              '@field' => $handler->field,
            )), 'error');
          }
        }
      }
    }
  }
  return $ret;
}