function views_plugin_display::validate

Make sure the display and all associated handlers are valid.

Return value

Empty array if the display is valid; an array of error strings if it is not.

Overrides views_plugin::validate

1 call to views_plugin_display::validate()
views_plugin_display_page::validate in plugins/views_plugin_display_page.inc
Make sure the display and all associated handlers are valid.
1 method overrides views_plugin_display::validate()
views_plugin_display_page::validate in plugins/views_plugin_display_page.inc
Make sure the display and all associated handlers are valid.

File

plugins/views_plugin_display.inc, line 2906

Class

views_plugin_display
The default display plugin handler. Display plugins handle options and basic mechanisms for different output methods.

Code

public function validate() {
    $errors = array();
    // Make sure displays that use fields HAVE fields.
    if ($this->uses_fields()) {
        $fields = FALSE;
        foreach ($this->get_handlers('field') as $field) {
            if (empty($field->options['exclude'])) {
                $fields = TRUE;
            }
        }
        if (!$fields) {
            $errors[] = t('Display "@display" uses fields but there are none defined for it or all are excluded.', array(
                '@display' => $this->display->display_title,
            ));
        }
    }
    if ($this->has_path() && !$this->get_option('path')) {
        $errors[] = t('Display "@display" uses a path but the path is undefined.', array(
            '@display' => $this->display->display_title,
        ));
    }
    // Validate style plugin.
    $style = $this->get_plugin();
    if (empty($style)) {
        $errors[] = t('Display "@display" has an invalid style plugin.', array(
            '@display' => $this->display->display_title,
        ));
    }
    else {
        $result = $style->validate();
        if (!empty($result) && is_array($result)) {
            $errors = array_merge($errors, $result);
        }
    }
    // Validate query plugin.
    $query = $this->get_plugin('query');
    $result = $query->validate();
    if (!empty($result) && is_array($result)) {
        $errors = array_merge($errors, $result);
    }
    // Validate handlers.
    foreach (views_object_types() as $type => $info) {
        foreach ($this->get_handlers($type) as $handler) {
            $result = $handler->validate();
            if (!empty($result) && is_array($result)) {
                $errors = array_merge($errors, $result);
            }
        }
    }
    return $errors;
}