Go to the documentation of this file.00001 <?php
00014 class views_plugin_row_node_view extends views_plugin_row {
00015
00016 var $base_table = 'node';
00017 var $base_field = 'nid';
00018
00019
00020 var $nodes = array();
00021
00022 function init(&$view, &$display, $options = NULL) {
00023 parent::init($view, $display, $options);
00024
00025 if (isset($this->options['teaser'])) {
00026 $this->options['build_mode'] = $this->options['teaser'] ? 'teaser' : 'full';
00027 }
00028
00029 if (isset($this->options['build_mode'])) {
00030 $this->options['view_mode'] = $this->options['build_mode'];
00031 }
00032 }
00033
00034 function option_definition() {
00035 $options = parent::option_definition();
00036
00037 $options['view_mode'] = array('default' => 'teaser');
00038 $options['links'] = array('default' => TRUE);
00039 $options['comments'] = array('default' => FALSE);
00040
00041 return $options;
00042 }
00043
00044 function options_form(&$form, &$form_state) {
00045 parent::options_form($form, $form_state);
00046
00047 $options = $this->options_form_summary_options();
00048 $form['view_mode'] = array(
00049 '#type' => 'select',
00050 '#options' => $options,
00051 '#title' => t('View mode'),
00052 '#default_value' => $this->options['view_mode'],
00053 );
00054 $form['links'] = array(
00055 '#type' => 'checkbox',
00056 '#title' => t('Display links'),
00057 '#default_value' => $this->options['links'],
00058 );
00059 $form['comments'] = array(
00060 '#type' => 'checkbox',
00061 '#title' => t('Display comments'),
00062 '#default_value' => $this->options['comments'],
00063 );
00064 }
00065
00069 function options_form_summary_options() {
00070 $entity_info = entity_get_info('node');
00071 $options = array();
00072 if (!empty($entity_info['view modes'])) {
00073 foreach ($entity_info['view modes'] as $mode => $settings) {
00074 $options[$mode] = $settings['label'];
00075 }
00076 }
00077 if (empty($options)) {
00078 $options = array(
00079 'teaser' => t('Teaser'),
00080 'full' => t('Full content')
00081 );
00082 }
00083
00084 return $options;
00085 }
00086
00087 function summary_title() {
00088 $options = $this->options_form_summary_options();
00089 return check_plain($options[$this->options['view_mode']]);
00090 }
00091
00092 function pre_render($values) {
00093 $nids = array();
00094 foreach ($values as $row) {
00095 $nids[] = $row->{$this->field_alias};
00096 }
00097 $this->nodes = node_load_multiple($nids);
00098 }
00099
00100 function render($row) {
00101 $node = $this->nodes[$row->{$this->field_alias}];
00102 $node->view = $this->view;
00103 $build = node_view($node, $this->options['view_mode']);
00104
00105 return drupal_render($build);
00106 }
00107 }