~spreadubuntu/spreadubuntu/devel-drupal6

« back to all changes in this revision

Viewing changes to modules/views/modules/node/views_plugin_row_node_view.inc

  • Committer: ruben
  • Date: 2009-06-08 09:38:49 UTC
  • Revision ID: ruben@captive-20090608093849-s1qtsyctv2vwp1x1
SpreadUbuntu moving to Drupal6. Based on ubuntu-drupal theme and adding our modules

Show diffs side-by-side

added added

removed removed

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