views_plugin_row_node_view.inc

  1. 3.x modules/node/views_plugin_row_node_view.inc
  2. 2.x modules/node/views_plugin_row_node_view.inc

Contains the node view row style plugin.

File

modules/node/views_plugin_row_node_view.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Contains the node view row style plugin.
  5. */
  6. /**
  7. * Plugin which performs a node_view on the resulting object.
  8. *
  9. * Most of the code on this object is in the theme function.
  10. */
  11. class views_plugin_row_node_view extends views_plugin_row {
  12. // Basic properties that let the row style follow relationships.
  13. var $base_table = 'node';
  14. var $base_field = 'nid';
  15. function init(&$view, &$display, $options = NULL) {
  16. parent::init($view, $display, $options);
  17. // Handle existing views with the deprecated 'teaser' option.
  18. if (isset($this->options['teaser'])) {
  19. $this->options['build_mode'] = $this->options['teaser'] ? 'teaser' : 'full';
  20. }
  21. }
  22. function option_definition() {
  23. $options = parent::option_definition();
  24. $options['build_mode'] = array('default' => 'teaser');
  25. $options['links'] = array('default' => TRUE);
  26. $options['comments'] = array('default' => FALSE);
  27. return $options;
  28. }
  29. function options_form(&$form, &$form_state) {
  30. parent::options_form($form, $form_state);
  31. // CCK holds the registry of available build modes, but can hardly
  32. // push them as options for the node row style, so we break the normal
  33. // rule of not directly relying on non-core modules.
  34. if ($modes = module_invoke('content', 'build_modes')) {
  35. $options = array();
  36. foreach ($modes as $key => $value) {
  37. if (isset($value['views style']) && $value['views style']) {
  38. $options[$key] = $value['title'];
  39. }
  40. }
  41. }
  42. else {
  43. $options = array(
  44. 'teaser' => t('Teaser'),
  45. 'full' => t('Full node')
  46. );
  47. }
  48. $form['build_mode'] = array(
  49. '#type' => 'select',
  50. '#options' => $options,
  51. '#title' => t('Build mode'),
  52. '#default_value' => $this->options['build_mode'],
  53. );
  54. $form['links'] = array(
  55. '#type' => 'checkbox',
  56. '#title' => t('Display links'),
  57. '#default_value' => $this->options['links'],
  58. );
  59. $form['comments'] = array(
  60. '#type' => 'checkbox',
  61. '#title' => t('Display node comments'),
  62. '#default_value' => $this->options['comments'],
  63. );
  64. }
  65. }