Projet

Général

Profil

Paste
Télécharger (1,47 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / views / modules / comment / views_handler_field_comment_link_edit.inc @ 5d12d676

1
<?php
2

    
3
/**
4
 * @file
5
 * Definition of views_handler_field_comment_link_edit.
6
 */
7

    
8
/**
9
 * Field handler to present a link node edit.
10
 *
11
 * @ingroup views_field_handlers
12
 */
13
class views_handler_field_comment_link_edit extends views_handler_field_comment_link {
14

    
15
  /**
16
   * {@inheritdoc}
17
   */
18
  public function option_definition() {
19
    $options = parent::option_definition();
20
    $options['destination'] = array('default' => FALSE, 'bool' => TRUE);
21

    
22
    return $options;
23
  }
24

    
25
  /**
26
   * {@inheritdoc}
27
   */
28
  public function options_form(&$form, &$form_state) {
29
    parent::options_form($form, $form_state);
30

    
31
    $form['destination'] = array(
32
      '#type' => 'checkbox',
33
      '#title' => t('Use destination'),
34
      '#description' => t('Add destination to the link'),
35
      '#default_value' => $this->options['destination'],
36
      '#fieldset' => 'more',
37
    );
38
  }
39

    
40
  /**
41
   * {@inheritdoc}
42
   */
43
  public function render_link($data, $values) {
44
    parent::render_link($data, $values);
45
    // Ensure user has access to edit this comment.
46
    $comment = $this->get_value($values);
47
    if (!comment_access('edit', $comment)) {
48
      return;
49
    }
50

    
51
    $text = !empty($this->options['text']) ? $this->options['text'] : t('edit');
52
    unset($this->options['alter']['fragment']);
53

    
54
    if (!empty($this->options['destination'])) {
55
      $this->options['alter']['query'] = drupal_get_destination();
56
    }
57

    
58
    $this->options['alter']['path'] = "comment/" . $comment->cid . "/edit";
59

    
60
    return $text;
61
  }
62

    
63
}