Révision 5d12d676
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/views/modules/user/views_handler_field_user.inc | ||
---|---|---|
11 | 11 |
* @ingroup views_field_handlers |
12 | 12 |
*/ |
13 | 13 |
class views_handler_field_user extends views_handler_field { |
14 |
|
|
14 | 15 |
/** |
15 | 16 |
* Override init function to provide generic option to link to user. |
16 | 17 |
*/ |
17 |
function init(&$view, &$data) { |
|
18 |
public function init(&$view, &$data) {
|
|
18 | 19 |
parent::init($view, $data); |
19 | 20 |
if (!empty($this->options['link_to_user'])) { |
20 | 21 |
$this->additional_fields['uid'] = 'uid'; |
21 | 22 |
} |
22 | 23 |
} |
23 | 24 |
|
24 |
function option_definition() { |
|
25 |
/** |
|
26 |
* {@inheritdoc} |
|
27 |
*/ |
|
28 |
public function option_definition() { |
|
25 | 29 |
$options = parent::option_definition(); |
26 | 30 |
$options['link_to_user'] = array('default' => TRUE, 'bool' => TRUE); |
27 | 31 |
return $options; |
28 | 32 |
} |
29 | 33 |
|
30 | 34 |
/** |
31 |
* Provide link to node option |
|
35 |
* Provide link to node option.
|
|
32 | 36 |
*/ |
33 |
function options_form(&$form, &$form_state) { |
|
37 |
public function options_form(&$form, &$form_state) {
|
|
34 | 38 |
$form['link_to_user'] = array( |
35 | 39 |
'#title' => t('Link this field to its user'), |
36 | 40 |
'#description' => t("Enable to override this field's links."), |
... | ... | |
40 | 44 |
parent::options_form($form, $form_state); |
41 | 45 |
} |
42 | 46 |
|
43 |
function render_link($data, $values) { |
|
47 |
/** |
|
48 |
* {@inheritdoc} |
|
49 |
*/ |
|
50 |
public function render_link($data, $values) { |
|
44 | 51 |
if (!empty($this->options['link_to_user']) && user_access('access user profiles') && ($uid = $this->get_value($values, 'uid')) && $data !== NULL && $data !== '') { |
45 | 52 |
$this->options['alter']['make_link'] = TRUE; |
46 | 53 |
$this->options['alter']['path'] = "user/" . $uid; |
... | ... | |
48 | 55 |
return $data; |
49 | 56 |
} |
50 | 57 |
|
51 |
function render($values) { |
|
58 |
/** |
|
59 |
* {@inheritdoc} |
|
60 |
*/ |
|
61 |
public function render($values) { |
|
52 | 62 |
$value = $this->get_value($values); |
53 | 63 |
return $this->render_link($this->sanitize_value($value), $values); |
54 | 64 |
} |
65 |
|
|
55 | 66 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules