Projet

Général

Profil

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

root / drupal7 / sites / all / modules / views / modules / user / views_handler_field_user_link.inc @ 4003efde

1
<?php
2

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

    
8
/**
9
 * Field handler to present a link to the user.
10
 *
11
 * @ingroup views_field_handlers
12
 */
13
class views_handler_field_user_link extends views_handler_field {
14

    
15
  /**
16
   * {@inheritdoc}
17
   */
18
  public function construct() {
19
    parent::construct();
20
    $this->additional_fields['uid'] = 'uid';
21
  }
22

    
23
  /**
24
   * {@inheritdoc}
25
   */
26
  public function option_definition() {
27
    $options = parent::option_definition();
28
    $options['text'] = array('default' => '', 'translatable' => TRUE);
29
    return $options;
30
  }
31

    
32
  /**
33
   * {@inheritdoc}
34
   */
35
  public function options_form(&$form, &$form_state) {
36
    $form['text'] = array(
37
      '#type' => 'textfield',
38
      '#title' => t('Text to display'),
39
      '#default_value' => $this->options['text'],
40
    );
41
    parent::options_form($form, $form_state);
42
  }
43

    
44
  /**
45
   * An example of field level access control.
46
   */
47
  public function access() {
48
    return user_access('access user profiles');
49
  }
50

    
51
  /**
52
   * {@inheritdoc}
53
   */
54
  public function query() {
55
    $this->ensure_my_table();
56
    $this->add_additional_fields();
57
  }
58

    
59
  /**
60
   * {@inheritdoc}
61
   */
62
  public function render($values) {
63
    $value = $this->get_value($values, 'uid');
64
    return $this->render_link($this->sanitize_value($value), $values);
65
  }
66

    
67
  /**
68
   * {@inheritdoc}
69
   */
70
  public function render_link($data, $values) {
71
    $text = !empty($this->options['text']) ? $this->options['text'] : t('view');
72

    
73
    $this->options['alter']['make_link'] = TRUE;
74
    $this->options['alter']['path'] = "user/" . $data;
75

    
76
    return $text;
77
  }
78

    
79
}