123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <?php
- function views_analyze_view(&$view) {
- $view->init_display();
- $messages = module_invoke_all('views_analyze', $view);
- return $messages;
- }
- 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) {
- $type .= ' messages';
- $message = '';
- if (count($messages) > 1) {
- $message = theme('item_list', array('items' => $messages));
- }
- elseif ($messages) {
- $message = array_shift($messages);
- }
- if ($message) {
- $output .= "<div class=\"$type\">$message</div>";
- }
- }
- return $output;
- }
- function views_ui_analysis($message, $type = 'error') {
- return array('message' => $message, 'type' => $type);
- }
- function views_ui_views_analyze($view) {
- $ret = array();
-
- 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 $id => $display) {
- if (empty($display->handler)) {
- continue;
- }
- if ($display->handler->has_path() && $path = $display->handler->get_option('path')) {
- $normal_path = drupal_get_normal_path($path);
- if ($path != $normal_path) {
- $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');
- }
- }
- }
- return $ret;
- }
|