views_ui_comment_views_wizard.class.php

Definition of ViewsUiCommentViewsWizard.

File

plugins/views_wizard/views_ui_comment_views_wizard.class.php
View source
  1. <?php
  2. /**
  3. * @file
  4. * Definition of ViewsUiCommentViewsWizard.
  5. */
  6. /**
  7. * Tests creating comment views with the wizard.
  8. */
  9. class ViewsUiCommentViewsWizard extends ViewsUiBaseViewsWizard {
  10. protected function row_style_options($type) {
  11. $options = array();
  12. $options['comment'] = t('comments');
  13. $options['fields'] = t('fields');
  14. return $options;
  15. }
  16. protected function build_form_style(&$form, &$form_state, $type) {
  17. parent::build_form_style($form, $form_state, $type);
  18. $style_form =& $form['displays'][$type]['options']['style'];
  19. // Some style plugins don't support row plugins so stop here if that's the
  20. // case.
  21. if (!isset($style_form['row_plugin']['#default_value'])) {
  22. return;
  23. }
  24. $row_plugin = $style_form['row_plugin']['#default_value'];
  25. switch ($row_plugin) {
  26. case 'comment':
  27. $style_form['row_options']['links'] = array(
  28. '#type' => 'select',
  29. '#title_display' => 'invisible',
  30. '#title' => t('Should links be displayed below each comment'),
  31. '#options' => array(
  32. 1 => t('with links (allow users to reply to the comment, etc.)'),
  33. 0 => t('without links'),
  34. ),
  35. '#default_value' => 1,
  36. );
  37. break;
  38. }
  39. }
  40. protected function page_display_options($form, $form_state) {
  41. $display_options = parent::page_display_options($form, $form_state);
  42. $row_plugin = isset($form_state['values']['page']['style']['row_plugin']) ? $form_state['values']['page']['style']['row_plugin'] : NULL;
  43. $row_options = isset($form_state['values']['page']['style']['row_options']) ? $form_state['values']['page']['style']['row_options'] : array();
  44. $this->display_options_row($display_options, $row_plugin, $row_options);
  45. return $display_options;
  46. }
  47. protected function block_display_options($form, $form_state) {
  48. $display_options = parent::block_display_options($form, $form_state);
  49. $row_plugin = isset($form_state['values']['block']['style']['row_plugin']) ? $form_state['values']['block']['style']['row_plugin'] : NULL;
  50. $row_options = isset($form_state['values']['block']['style']['row_options']) ? $form_state['values']['block']['style']['row_options'] : array();
  51. $this->display_options_row($display_options, $row_plugin, $row_options);
  52. return $display_options;
  53. }
  54. /**
  55. * Set the row style and row style plugins to the display_options.
  56. */
  57. protected function display_options_row(&$display_options, $row_plugin, $row_options) {
  58. switch ($row_plugin) {
  59. case 'comment':
  60. $display_options['row_plugin'] = 'comment';
  61. $display_options['row_options']['links'] = !empty($row_options['links']);
  62. break;
  63. }
  64. }
  65. protected function default_display_options($form, $form_state) {
  66. $display_options = parent::default_display_options($form, $form_state);
  67. // Add permission-based access control.
  68. $display_options['access']['type'] = 'perm';
  69. // Add a relationship to nodes.
  70. $display_options['relationships']['nid']['id'] = 'nid';
  71. $display_options['relationships']['nid']['table'] = 'comment';
  72. $display_options['relationships']['nid']['field'] = 'nid';
  73. $display_options['relationships']['nid']['required'] = 1;
  74. // Remove the default fields, since we are customizing them here.
  75. unset($display_options['fields']);
  76. /* Field: Comment: Title */
  77. $display_options['fields']['subject']['id'] = 'subject';
  78. $display_options['fields']['subject']['table'] = 'comment';
  79. $display_options['fields']['subject']['field'] = 'subject';
  80. $display_options['fields']['subject']['label'] = '';
  81. $display_options['fields']['subject']['alter']['alter_text'] = 0;
  82. $display_options['fields']['subject']['alter']['make_link'] = 0;
  83. $display_options['fields']['subject']['alter']['absolute'] = 0;
  84. $display_options['fields']['subject']['alter']['trim'] = 0;
  85. $display_options['fields']['subject']['alter']['word_boundary'] = 0;
  86. $display_options['fields']['subject']['alter']['ellipsis'] = 0;
  87. $display_options['fields']['subject']['alter']['strip_tags'] = 0;
  88. $display_options['fields']['subject']['alter']['html'] = 0;
  89. $display_options['fields']['subject']['hide_empty'] = 0;
  90. $display_options['fields']['subject']['empty_zero'] = 0;
  91. $display_options['fields']['subject']['link_to_comment'] = 1;
  92. return $display_options;
  93. }
  94. }