• Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • File List
  • File Members

includes/analyze.inc

Go to the documentation of this file.
00001 <?php
00002 
00022 function views_analyze_view(&$view) {
00023   $view->init_display();
00024   $messages = module_invoke_all('views_analyze', $view);
00025 
00026   return $messages;
00027 }
00028 
00035 function views_analyze_format_result($view, $messages) {
00036   if (empty($messages)) {
00037     $messages = array(views_ui_analysis(t('View analysis can find nothing to report.'), 'ok'));
00038   }
00039 
00040   $types = array('ok' => array(), 'warning' => array(), 'error' => array());
00041   foreach ($messages as $message) {
00042     if (empty($types[$message['type']])) {
00043       $types[$message['type']] = array();
00044     }
00045     $types[$message['type']][] = $message['message'];
00046   }
00047 
00048   $output = '';
00049   foreach ($types as $type => $messages) {
00050     $message = '';
00051     if (count($messages) > 1) {
00052       $message = theme('item_list', array('items' => $messages));
00053     }
00054     elseif ($messages) {
00055       $message = array_shift($messages);
00056     }
00057 
00058     if ($message) {
00059       $output .= "<div class=\"$type\">$message</div>";
00060     }
00061   }
00062 
00063   return $output;
00064 }
00065 
00088 function views_ui_analysis($message, $type = 'error') {
00089   return array('message' => $message, 'type' => $type);
00090 }
00091 
00099 function views_ui_views_analyze($view) {
00100   $ret = array();
00101   // Check for something other than the default display:
00102   if (count($view->display) < 2) {
00103     $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');
00104   }
00105   // You can give a page display the same path as an alias existing in the
00106   // system, so the alias will not work anymore. Report this to the user,
00107   // because he probably wanted something else.
00108   foreach ($view->display as $id => $display) {
00109     if (empty($display->handler)) {
00110       continue;
00111     }
00112     if ($display->handler->has_path() && $path = $display->handler->get_option('path')) {
00113       $normal_path = drupal_get_normal_path($path);
00114       if ($path != $normal_path) {
00115         $ret[] = views_ui_analysis(t('You have configured display %display with a path which is an path alias as well. This might lead to unwanted effects so better use an internal path.', array('%display' => $display->display_title)), 'warning');
00116       }
00117     }
00118   }
00119 
00120   return $ret;
00121 }

Generated on Sun Feb 26 2012 12:52:51 for Views by  doxygen 1.7.1