You are here

class ViewsUiCommentViewsWizard in Views (for Drupal 7) 7.3

Tests creating comment views with the wizard.

Hierarchy

Expanded class hierarchy of ViewsUiCommentViewsWizard

1 string reference to 'ViewsUiCommentViewsWizard'
comment.inc in plugins/views_wizard/comment.inc
Views wizard for comment views.

File

plugins/views_wizard/views_ui_comment_views_wizard.class.php, line 11
Definition of ViewsUiCommentViewsWizard.

View source
class ViewsUiCommentViewsWizard extends ViewsUiBaseViewsWizard {
  protected function row_style_options($type) {
    $options = array();
    $options['comment'] = t('comments');
    $options['fields'] = t('fields');
    return $options;
  }
  protected function build_form_style(&$form, &$form_state, $type) {
    parent::build_form_style($form, $form_state, $type);
    $style_form =& $form['displays'][$type]['options']['style'];

    // Some style plugins don't support row plugins so stop here if that's the
    // case.
    if (!isset($style_form['row_plugin']['#default_value'])) {
      return;
    }
    $row_plugin = $style_form['row_plugin']['#default_value'];
    switch ($row_plugin) {
      case 'comment':
        $style_form['row_options']['links'] = array(
          '#type' => 'select',
          '#title_display' => 'invisible',
          '#title' => t('Should links be displayed below each comment'),
          '#options' => array(
            1 => t('with links (allow users to reply to the comment, etc.)'),
            0 => t('without links'),
          ),
          '#default_value' => 1,
        );
        break;
    }
  }
  protected function page_display_options($form, $form_state) {
    $display_options = parent::page_display_options($form, $form_state);
    $row_plugin = isset($form_state['values']['page']['style']['row_plugin']) ? $form_state['values']['page']['style']['row_plugin'] : NULL;
    $row_options = isset($form_state['values']['page']['style']['row_options']) ? $form_state['values']['page']['style']['row_options'] : array();
    $this
      ->display_options_row($display_options, $row_plugin, $row_options);
    return $display_options;
  }
  protected function block_display_options($form, $form_state) {
    $display_options = parent::block_display_options($form, $form_state);
    $row_plugin = isset($form_state['values']['block']['style']['row_plugin']) ? $form_state['values']['block']['style']['row_plugin'] : NULL;
    $row_options = isset($form_state['values']['block']['style']['row_options']) ? $form_state['values']['block']['style']['row_options'] : array();
    $this
      ->display_options_row($display_options, $row_plugin, $row_options);
    return $display_options;
  }

  /**
   * Set the row style and row style plugins to the display_options.
   */
  protected function display_options_row(&$display_options, $row_plugin, $row_options) {
    switch ($row_plugin) {
      case 'comment':
        $display_options['row_plugin'] = 'comment';
        $display_options['row_options']['links'] = !empty($row_options['links']);
        break;
    }
  }
  protected function default_display_options($form, $form_state) {
    $display_options = parent::default_display_options($form, $form_state);

    // Add permission-based access control.
    $display_options['access']['type'] = 'perm';
    $display_options['access']['perm'] = 'access comments';

    // Add a relationship to nodes.
    $display_options['relationships']['nid']['id'] = 'nid';
    $display_options['relationships']['nid']['table'] = 'comment';
    $display_options['relationships']['nid']['field'] = 'nid';
    $display_options['relationships']['nid']['required'] = 1;

    // Remove the default fields, since we are customizing them here.
    unset($display_options['fields']);

    /* Field: Comment: Title */
    $display_options['fields']['subject']['id'] = 'subject';
    $display_options['fields']['subject']['table'] = 'comment';
    $display_options['fields']['subject']['field'] = 'subject';
    $display_options['fields']['subject']['label'] = '';
    $display_options['fields']['subject']['alter']['alter_text'] = 0;
    $display_options['fields']['subject']['alter']['make_link'] = 0;
    $display_options['fields']['subject']['alter']['absolute'] = 0;
    $display_options['fields']['subject']['alter']['trim'] = 0;
    $display_options['fields']['subject']['alter']['word_boundary'] = 0;
    $display_options['fields']['subject']['alter']['ellipsis'] = 0;
    $display_options['fields']['subject']['alter']['strip_tags'] = 0;
    $display_options['fields']['subject']['alter']['html'] = 0;
    $display_options['fields']['subject']['hide_empty'] = 0;
    $display_options['fields']['subject']['empty_zero'] = 0;
    $display_options['fields']['subject']['link_to_comment'] = 1;
    return $display_options;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ViewsUiBaseViewsWizard::$base_table protected property
ViewsUiBaseViewsWizard::$entity_info protected property
ViewsUiBaseViewsWizard::$entity_type protected property
ViewsUiBaseViewsWizard::$filter_defaults protected property
ViewsUiBaseViewsWizard::$plugin protected property
ViewsUiBaseViewsWizard::$validated_views protected property
ViewsUiBaseViewsWizard::add_displays protected function Add the array of display options to the view, with appropriate overrides.
ViewsUiBaseViewsWizard::alter_display_options protected function Alter the full array of display options before they are added to the view.
ViewsUiBaseViewsWizard::build_display_options protected function Build an array of display options for the view.
ViewsUiBaseViewsWizard::build_filters protected function Build the part of the form that allows the user to select the filters.
ViewsUiBaseViewsWizard::build_form function For AJAX callbacks to build other elements in the "show" form. Overrides ViewsWizardInterface::build_form
ViewsUiBaseViewsWizard::build_sorts protected function Build the part of the form that allows the user to select the sort order.
ViewsUiBaseViewsWizard::create_view function Create a View from values that have been already submitted to validate(). Overrides ViewsWizardInterface::create_view
ViewsUiBaseViewsWizard::default_display_filters protected function
ViewsUiBaseViewsWizard::default_display_filters_user protected function
ViewsUiBaseViewsWizard::default_display_sorts protected function
ViewsUiBaseViewsWizard::default_display_sorts_user protected function
ViewsUiBaseViewsWizard::instantiate_view protected function
ViewsUiBaseViewsWizard::page_feed_display_options protected function
ViewsUiBaseViewsWizard::retrieve_validated_view protected function
ViewsUiBaseViewsWizard::set_default_options protected function Sets options for a display and makes them the default options if possible.
ViewsUiBaseViewsWizard::set_override_options protected function Sets options for a display, inheriting from the defaults when possible.
ViewsUiBaseViewsWizard::set_validated_view protected function
ViewsUiBaseViewsWizard::validate function Instantiates a view and validates values. Overrides ViewsWizardInterface::validate
ViewsUiBaseViewsWizard::__construct function Constructor. Overrides ViewsWizardInterface::__construct
ViewsUiCommentViewsWizard::block_display_options protected function Overrides ViewsUiBaseViewsWizard::block_display_options
ViewsUiCommentViewsWizard::build_form_style protected function Build the part of the form that builds the display format options. Overrides ViewsUiBaseViewsWizard::build_form_style
ViewsUiCommentViewsWizard::default_display_options protected function Most subclasses will need to override this method to provide some fields or a different row plugin. Overrides ViewsUiBaseViewsWizard::default_display_options
ViewsUiCommentViewsWizard::display_options_row protected function Set the row style and row style plugins to the display_options.
ViewsUiCommentViewsWizard::page_display_options protected function Overrides ViewsUiBaseViewsWizard::page_display_options
ViewsUiCommentViewsWizard::row_style_options protected function Add possible row style options. Overrides ViewsUiBaseViewsWizard::row_style_options