views_handler_field_comment_link.inc

  1. 3.x modules/comment/views_handler_field_comment_link.inc
  2. 2.x modules/comment/views_handler_field_comment_link.inc

File

modules/comment/views_handler_field_comment_link.inc
View source
  1. <?php
  2. /**
  3. * Base field handler to present a link.
  4. */
  5. class views_handler_field_comment_link extends views_handler_field {
  6. function construct() {
  7. parent::construct();
  8. $this->additional_fields['cid'] = 'cid';
  9. $this->additional_fields['nid'] = 'nid';
  10. }
  11. function option_definition() {
  12. $options = parent::option_definition();
  13. $options['text'] = array('default' => '', 'translatable' => TRUE);
  14. return $options;
  15. }
  16. function options_form(&$form, &$form_state) {
  17. parent::options_form($form, $form_state);
  18. $form['text'] = array(
  19. '#type' => 'textfield',
  20. '#title' => t('Text to display'),
  21. '#default_value' => $this->options['text'],
  22. );
  23. }
  24. function query() {
  25. $this->ensure_my_table();
  26. $this->add_additional_fields();
  27. }
  28. function render($values) {
  29. $text = !empty($this->options['text']) ? $this->options['text'] : t('view');
  30. return l($text, "node/" . $values->{$this->aliases['nid']}, array('html' => TRUE, 'fragment' => "comment-" . $values->{$this->aliases['cid']}));
  31. }
  32. }