• Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • File List
  • File Members

modules/comment/views_plugin_row_comment_view.inc

Go to the documentation of this file.
00001 <?php
00010 class views_plugin_row_comment_view extends views_plugin_row {
00011   var $base_field = 'cid';
00012   var $base_table = 'comment';
00013 
00017   var $comments = array();
00018 
00022   var $nodes = array();
00023 
00024   function summary_title() {
00025     return t('Settings');
00026   }
00027 
00028   function option_definition() {
00029     $options = parent::option_definition();
00030     $options['links'] = array('default' => TRUE);
00031     $options['view_mode'] = array('default' => 'full');
00032     return $options;
00033   }
00034 
00035   function options_form(&$form, &$form_state) {
00036     parent::options_form($form, $form_state);
00037 
00038     $options = $this->options_form_summary_options();
00039     $form['view_mode'] = array(
00040       '#type' => 'select',
00041       '#options' => $options,
00042       '#title' => t('View mode'),
00043       '#default_value' => $this->options['view_mode'],
00044      );
00045 
00046     $form['links'] = array(
00047       '#type' => 'checkbox',
00048       '#title' => t('Display links'),
00049       '#default_value' => $this->options['links'],
00050     );
00051   }
00052 
00053 
00057   function options_form_summary_options() {
00058     $entity_info = entity_get_info('comment');
00059     $options = array();
00060     if (!empty($entity_info['view modes'])) {
00061       foreach ($entity_info['view modes'] as $mode => $settings) {
00062         $options[$mode] = $settings['label'];
00063       }
00064     }
00065     if (empty($options)) {
00066       $options = array(
00067         'full' => t('Full content')
00068       );
00069     }
00070 
00071     return $options;
00072   }
00073 
00074   function pre_render($result) {
00075     $cids = array();
00076 
00077     foreach ($result as $row) {
00078       $cids[] = $row->cid;
00079     }
00080 
00081     // Load all comments.
00082     $cresult = comment_load_multiple($cids);
00083     $nids = array();
00084     foreach ($cresult as $comment) {
00085       $comment->depth = count(explode('.', $comment->thread)) - 1;
00086       $this->comments[$comment->cid] = $comment;
00087       $nids[] = $comment->nid;
00088     }
00089 
00090     // Load all nodes of the comments.
00091     $nodes = node_load_multiple(array_unique($nids));
00092     foreach ($nodes as $node) {
00093       $this->nodes[$node->nid] = $node;
00094     }
00095   }
00096 }

Generated on Sun Feb 26 2012 12:52:51 for Views by  doxygen 1.7.1