1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Definition of views_plugin_row_comment_view.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Plugin which performs a comment_view on the resulting object.
|
10
|
*/
|
11
|
class views_plugin_row_comment_view extends views_plugin_row {
|
12
|
|
13
|
/**
|
14
|
* {@inheritdoc}
|
15
|
*/
|
16
|
public $base_field = 'cid';
|
17
|
|
18
|
/**
|
19
|
* {@inheritdoc}
|
20
|
*/
|
21
|
public $base_table = 'comment';
|
22
|
|
23
|
/**
|
24
|
* Stores all comments which are preloaded.
|
25
|
*/
|
26
|
public $comments = array();
|
27
|
|
28
|
/**
|
29
|
* Stores all nodes of all comments which are preloaded.
|
30
|
*/
|
31
|
public $nodes = array();
|
32
|
|
33
|
/**
|
34
|
* {@inheritdoc}
|
35
|
*/
|
36
|
public function summary_title() {
|
37
|
return t('Settings');
|
38
|
}
|
39
|
|
40
|
/**
|
41
|
* {@inheritdoc}
|
42
|
*/
|
43
|
public function option_definition() {
|
44
|
$options = parent::option_definition();
|
45
|
$options['links'] = array('default' => TRUE, 'bool' => TRUE);
|
46
|
$options['view_mode'] = array('default' => 'full');
|
47
|
return $options;
|
48
|
}
|
49
|
|
50
|
/**
|
51
|
* {@inheritdoc}
|
52
|
*/
|
53
|
public function options_form(&$form, &$form_state) {
|
54
|
parent::options_form($form, $form_state);
|
55
|
|
56
|
$options = $this->options_form_summary_options();
|
57
|
$form['view_mode'] = array(
|
58
|
'#type' => 'select',
|
59
|
'#options' => $options,
|
60
|
'#title' => t('View mode'),
|
61
|
'#default_value' => $this->options['view_mode'],
|
62
|
);
|
63
|
|
64
|
$form['links'] = array(
|
65
|
'#type' => 'checkbox',
|
66
|
'#title' => t('Display links'),
|
67
|
'#default_value' => $this->options['links'],
|
68
|
);
|
69
|
}
|
70
|
|
71
|
/**
|
72
|
* Return the main options, which are shown in the summary title.
|
73
|
*/
|
74
|
public function options_form_summary_options() {
|
75
|
$entity_info = entity_get_info('comment');
|
76
|
$options = array();
|
77
|
if (!empty($entity_info['view modes'])) {
|
78
|
foreach ($entity_info['view modes'] as $mode => $settings) {
|
79
|
$options[$mode] = $settings['label'];
|
80
|
}
|
81
|
}
|
82
|
if (empty($options)) {
|
83
|
$options = array(
|
84
|
'full' => t('Full content')
|
85
|
);
|
86
|
}
|
87
|
|
88
|
return $options;
|
89
|
}
|
90
|
|
91
|
/**
|
92
|
* {@inheritdoc}
|
93
|
*/
|
94
|
public function pre_render($result) {
|
95
|
$cids = array();
|
96
|
|
97
|
foreach ($result as $row) {
|
98
|
$cids[] = $row->cid;
|
99
|
}
|
100
|
|
101
|
// Load all comments.
|
102
|
$cresult = comment_load_multiple($cids);
|
103
|
$nids = array();
|
104
|
foreach ($cresult as $comment) {
|
105
|
$comment->depth = count(explode('.', $comment->thread)) - 1;
|
106
|
$this->comments[$comment->cid] = $comment;
|
107
|
$nids[] = $comment->nid;
|
108
|
}
|
109
|
|
110
|
// Load all nodes of the comments.
|
111
|
$nodes = node_load_multiple(array_unique($nids));
|
112
|
foreach ($nodes as $node) {
|
113
|
$this->nodes[$node->nid] = $node;
|
114
|
}
|
115
|
}
|
116
|
|
117
|
}
|