Révision 5d12d676
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/views/modules/node/views_handler_field_node.inc | ||
---|---|---|
2 | 2 |
|
3 | 3 |
/** |
4 | 4 |
* @file |
5 |
* Contains the basic 'node' field handler.
|
|
5 |
* Definition of views_handler_field_node.
|
|
6 | 6 |
*/ |
7 | 7 |
|
8 | 8 |
/** |
9 | 9 |
* Field handler to provide simple renderer that allows linking to a node. |
10 |
* |
|
10 | 11 |
* Definition terms: |
11 |
* - link_to_node default: Should this field have the checkbox "link to node" enabled by default. |
|
12 |
* - link_to_node default: Should this field have the checkbox "link to node" |
|
13 |
* enabled by default. |
|
12 | 14 |
* |
13 | 15 |
* @ingroup views_field_handlers |
14 | 16 |
*/ |
15 | 17 |
class views_handler_field_node extends views_handler_field { |
16 | 18 |
|
17 |
function init(&$view, &$options) { |
|
19 |
/** |
|
20 |
* {@inheritdoc} |
|
21 |
*/ |
|
22 |
public function init(&$view, &$options) { |
|
18 | 23 |
parent::init($view, $options); |
19 |
// Don't add the additional fields to groupby |
|
24 |
// Don't add the additional fields to groupby.
|
|
20 | 25 |
if (!empty($this->options['link_to_node'])) { |
21 | 26 |
$this->additional_fields['nid'] = array('table' => 'node', 'field' => 'nid'); |
22 | 27 |
if (module_exists('translation')) { |
... | ... | |
25 | 30 |
} |
26 | 31 |
} |
27 | 32 |
|
28 |
function option_definition() { |
|
33 |
/** |
|
34 |
* {@inheritdoc} |
|
35 |
*/ |
|
36 |
public function option_definition() { |
|
29 | 37 |
$options = parent::option_definition(); |
30 | 38 |
$options['link_to_node'] = array('default' => isset($this->definition['link_to_node default']) ? $this->definition['link_to_node default'] : FALSE, 'bool' => TRUE); |
31 | 39 |
return $options; |
32 | 40 |
} |
33 | 41 |
|
34 | 42 |
/** |
35 |
* Provide link to node option |
|
43 |
* Provide link to node option.
|
|
36 | 44 |
*/ |
37 |
function options_form(&$form, &$form_state) { |
|
45 |
public function options_form(&$form, &$form_state) {
|
|
38 | 46 |
$form['link_to_node'] = array( |
39 | 47 |
'#title' => t('Link this field to the original piece of content'), |
40 | 48 |
'#description' => t("Enable to override this field's links."), |
... | ... | |
50 | 58 |
* |
51 | 59 |
* Data should be made XSS safe prior to calling this function. |
52 | 60 |
*/ |
53 |
function render_link($data, $values) { |
|
61 |
public function render_link($data, $values) {
|
|
54 | 62 |
if (!empty($this->options['link_to_node']) && !empty($this->additional_fields['nid'])) { |
55 | 63 |
if ($data !== NULL && $data !== '') { |
56 | 64 |
$this->options['alter']['make_link'] = TRUE; |
... | ... | |
73 | 81 |
return $data; |
74 | 82 |
} |
75 | 83 |
|
76 |
function render($values) { |
|
84 |
/** |
|
85 |
* {@inheritdoc} |
|
86 |
*/ |
|
87 |
public function render($values) { |
|
77 | 88 |
$value = $this->get_value($values); |
78 | 89 |
return $this->render_link($this->sanitize_value($value), $values); |
79 | 90 |
} |
91 |
|
|
80 | 92 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules