Révision 5d12d676
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/views/modules/comment/views_handler_field_node_new_comments.inc | ||
---|---|---|
11 | 11 |
* @ingroup views_field_handlers |
12 | 12 |
*/ |
13 | 13 |
class views_handler_field_node_new_comments extends views_handler_field_numeric { |
14 |
function init(&$view, &$options) { |
|
14 |
|
|
15 |
/** |
|
16 |
* {@inheritdoc} |
|
17 |
*/ |
|
18 |
public function init(&$view, &$options) { |
|
15 | 19 |
parent::init($view, $options); |
16 | 20 |
|
17 |
// translate an older setting:
|
|
21 |
// Translate an older setting.
|
|
18 | 22 |
if (!empty($options['no_empty'])) { |
19 | 23 |
$this->options['hide_empty'] = TRUE; |
20 | 24 |
unset($this->options['no_empty']); |
21 | 25 |
} |
22 | 26 |
} |
23 | 27 |
|
24 |
function construct() { |
|
28 |
/** |
|
29 |
* {@inheritdoc} |
|
30 |
*/ |
|
31 |
public function construct() { |
|
25 | 32 |
parent::construct(); |
26 | 33 |
$this->additional_fields['nid'] = 'nid'; |
27 | 34 |
$this->additional_fields['type'] = 'type'; |
28 | 35 |
$this->additional_fields['comment_count'] = array('table' => 'node_comment_statistics', 'field' => 'comment_count'); |
29 | 36 |
} |
30 | 37 |
|
31 |
function option_definition() { |
|
38 |
/** |
|
39 |
* {@inheritdoc} |
|
40 |
*/ |
|
41 |
public function option_definition() { |
|
32 | 42 |
$options = parent::option_definition(); |
33 | 43 |
|
34 | 44 |
$options['link_to_comment'] = array('default' => TRUE, 'bool' => TRUE); |
... | ... | |
36 | 46 |
return $options; |
37 | 47 |
} |
38 | 48 |
|
39 |
function options_form(&$form, &$form_state) { |
|
49 |
/** |
|
50 |
* {@inheritdoc} |
|
51 |
*/ |
|
52 |
public function options_form(&$form, &$form_state) { |
|
40 | 53 |
$form['link_to_comment'] = array( |
41 | 54 |
'#title' => t('Link this field to new comments'), |
42 | 55 |
'#description' => t("Enable to override this field's links."), |
... | ... | |
47 | 60 |
parent::options_form($form, $form_state); |
48 | 61 |
} |
49 | 62 |
|
50 |
function query() { |
|
63 |
/** |
|
64 |
* {@inheritdoc} |
|
65 |
*/ |
|
66 |
public function query() { |
|
51 | 67 |
$this->ensure_my_table(); |
52 | 68 |
$this->add_additional_fields(); |
53 | 69 |
$this->field_alias = $this->table . '_' . $this->field; |
54 | 70 |
} |
55 | 71 |
|
56 |
function pre_render(&$values) { |
|
72 |
/** |
|
73 |
* {@inheritdoc} |
|
74 |
*/ |
|
75 |
public function pre_render(&$values) { |
|
57 | 76 |
global $user; |
58 | 77 |
if (!$user->uid || empty($values)) { |
59 | 78 |
return; |
... | ... | |
89 | 108 |
} |
90 | 109 |
} |
91 | 110 |
|
92 |
function render_link($data, $values) { |
|
111 |
/** |
|
112 |
* {@inheritdoc} |
|
113 |
*/ |
|
114 |
public function render_link($data, $values) { |
|
93 | 115 |
if (!empty($this->options['link_to_comment']) && $data !== NULL && $data !== '') { |
94 | 116 |
$node = new stdClass(); |
95 | 117 |
$node->nid = $this->get_value($values, 'nid'); |
... | ... | |
103 | 125 |
return $data; |
104 | 126 |
} |
105 | 127 |
|
106 |
function render($values) { |
|
128 |
/** |
|
129 |
* {@inheritdoc} |
|
130 |
*/ |
|
131 |
public function render($values) { |
|
107 | 132 |
$value = $this->get_value($values); |
108 | 133 |
if (!empty($value)) { |
109 | 134 |
return $this->render_link(parent::render($values), $values); |
... | ... | |
112 | 137 |
$this->options['alter']['make_link'] = FALSE; |
113 | 138 |
} |
114 | 139 |
} |
140 |
|
|
115 | 141 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules