Révision 5d12d676
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/views/modules/comment/views_handler_field_comment_node_link.inc | ||
---|---|---|
11 | 11 |
* @ingroup views_field_handlers |
12 | 12 |
*/ |
13 | 13 |
class views_handler_field_comment_node_link extends views_handler_field_entity { |
14 |
function construct() { |
|
14 |
|
|
15 |
/** |
|
16 |
* {@inheritdoc} |
|
17 |
*/ |
|
18 |
public function construct() { |
|
15 | 19 |
parent::construct(); |
16 | 20 |
|
17 |
// Add the node fields that comment_link will need..
|
|
21 |
// Add the node fields that comment_link will need. |
|
18 | 22 |
$this->additional_fields['nid'] = array( |
19 | 23 |
'field' => 'nid', |
20 | 24 |
); |
... | ... | |
26 | 30 |
); |
27 | 31 |
} |
28 | 32 |
|
29 |
function option_definition() { |
|
33 |
/** |
|
34 |
* {@inheritdoc} |
|
35 |
*/ |
|
36 |
public function option_definition() { |
|
30 | 37 |
$options = parent::option_definition(); |
31 | 38 |
$options['teaser'] = array('default' => FALSE, 'bool' => TRUE); |
32 | 39 |
return $options; |
33 | 40 |
} |
34 | 41 |
|
35 |
function options_form(&$form, &$form_state) { |
|
42 |
/** |
|
43 |
* {@inheritdoc} |
|
44 |
*/ |
|
45 |
public function options_form(&$form, &$form_state) { |
|
36 | 46 |
$form['teaser'] = array( |
37 | 47 |
'#type' => 'checkbox', |
38 | 48 |
'#title' => t('Show teaser-style link'), |
... | ... | |
43 | 53 |
parent::options_form($form, $form_state); |
44 | 54 |
} |
45 | 55 |
|
46 |
function query() { |
|
56 |
/** |
|
57 |
* {@inheritdoc} |
|
58 |
*/ |
|
59 |
public function query() { |
|
47 | 60 |
$this->ensure_my_table(); |
48 | 61 |
$this->add_additional_fields(); |
49 | 62 |
} |
50 | 63 |
|
51 |
function render($values) { |
|
64 |
/** |
|
65 |
* {@inheritdoc} |
|
66 |
*/ |
|
67 |
public function render($values) { |
|
52 | 68 |
// Build fake $node. |
53 | 69 |
$node = $this->get_value($values); |
54 | 70 |
|
55 |
// Call comment.module's hook_link: comment_link($type, $node = NULL, $teaser = FALSE) |
|
56 |
// Call node by reference so that something is changed here |
|
71 |
// Call comment.module's hook_link: |
|
72 |
// comment_link($type, $node = NULL, $teaser = FALSE) |
|
73 |
// Call node by reference so that something is changed here. |
|
57 | 74 |
comment_node_view($node, $this->options['teaser'] ? 'teaser' : 'full'); |
58 |
// question: should we run these through: drupal_alter('link', $links, $node); |
|
59 |
// might this have unexpected consequences if these hooks expect items in $node that we don't have? |
|
75 |
// Question: should we run these through: |
|
76 |
// drupal_alter('link', $links, $node); |
|
77 |
// Might this have unexpected consequences if these hooks expect items in |
|
78 |
// $node that we don't have? |
|
60 | 79 |
|
61 | 80 |
// Only render the links, if they are defined. |
62 | 81 |
return !empty($node->content['links']['comment']) ? drupal_render($node->content['links']['comment']) : ''; |
63 | 82 |
} |
83 |
|
|
64 | 84 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules