00001 <?php
00007 class views_handler_field_comment_node_link extends views_handler_field_entity {
00008 function construct() {
00009 parent::construct();
00010
00011
00012 $this->additional_fields['nid'] = array(
00013 'field' => 'nid',
00014 );
00015 $this->additional_fields['type'] = array(
00016 'field' => 'type',
00017 );
00018 $this->additional_fields['comment'] = array(
00019 'field' => 'comment',
00020 );
00021 }
00022
00023 function option_definition() {
00024 $options = parent::option_definition();
00025 $options['teaser'] = array('default' => 0);
00026 return $options;
00027 }
00028
00029 function options_form(&$form, &$form_state) {
00030 $form['teaser'] = array(
00031 '#type' => 'checkbox',
00032 '#title' => t('Show teaser-style link'),
00033 '#default_value' => $this->options['teaser'],
00034 '#description' => t('Show the comment link in the form used on standard node teasers, rather than the full node form.'),
00035 '#fieldset' => 'more',
00036 );
00037
00038 parent::options_form($form, $form_state);
00039 }
00040
00041 function query() {
00042 $this->ensure_my_table();
00043 $this->add_additional_fields();
00044 }
00045
00046 function render($values) {
00047
00048 $node = $this->get_value($values);
00049
00050
00051
00052 comment_node_view($node, $this->options['teaser'] ? 'teaser' : 'full');
00053
00054
00055
00056
00057 return !empty($node->content['links']['comment']) ? drupal_render($node->content['links']['comment']) : '';
00058 }
00059 }