1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Provide views data and handlers for comment.module.
|
6 |
|
|
*
|
7 |
|
|
* @ingroup views_module_handlers
|
8 |
|
|
*/
|
9 |
|
|
|
10 |
|
|
/**
|
11 |
|
|
* Implements hook_views_data().
|
12 |
|
|
*/
|
13 |
|
|
function comment_views_data() {
|
14 |
|
|
$data['comments']['moved to'] = 'comment';
|
15 |
|
|
$data['comment']['comment']['moved to'] = array('field_data_comment_body', 'comment_body');
|
16 |
|
|
$data['comment']['comment']['field']['moved to'] = array('field_data_comment_body', 'comment_body');
|
17 |
5d12d676
|
Assos Assos
|
// Define the base group of this table. Fields that don't have a group
|
18 |
|
|
// defined will go into this field by default.
|
19 |
85ad3d82
|
Assos Assos
|
$data['comment']['table']['group'] = t('Comment');
|
20 |
|
|
|
21 |
|
|
$data['comment']['table']['base'] = array(
|
22 |
|
|
'field' => 'cid',
|
23 |
|
|
'title' => t('Comment'),
|
24 |
|
|
'help' => t("Comments are responses to node content."),
|
25 |
|
|
'access query tag' => 'comment_access',
|
26 |
|
|
);
|
27 |
|
|
$data['comment']['table']['entity type'] = 'comment';
|
28 |
|
|
|
29 |
|
|
// Provide a "default relationship" to keep older views from choking.
|
30 |
|
|
$data['comment']['table']['default_relationship'] = array(
|
31 |
|
|
'node' => array(
|
32 |
|
|
'table' => 'node',
|
33 |
|
|
'field' => 'cid',
|
34 |
|
|
),
|
35 |
|
|
);
|
36 |
|
|
|
37 |
|
|
// ----------------------------------------------------------------
|
38 |
5d12d676
|
Assos Assos
|
// Fields.
|
39 |
|
|
// Subject.
|
40 |
85ad3d82
|
Assos Assos
|
$data['comment']['subject'] = array(
|
41 |
|
|
'title' => t('Title'),
|
42 |
|
|
'help' => t('The title of the comment.'),
|
43 |
|
|
'field' => array(
|
44 |
|
|
'handler' => 'views_handler_field_comment',
|
45 |
|
|
'click sortable' => TRUE,
|
46 |
|
|
),
|
47 |
|
|
'filter' => array(
|
48 |
|
|
'handler' => 'views_handler_filter_string',
|
49 |
|
|
),
|
50 |
|
|
'sort' => array(
|
51 |
|
|
'handler' => 'views_handler_sort',
|
52 |
|
|
),
|
53 |
|
|
'argument' => array(
|
54 |
|
|
'handler' => 'views_handler_argument_string',
|
55 |
|
|
),
|
56 |
|
|
);
|
57 |
|
|
|
58 |
5d12d676
|
Assos Assos
|
// Comment ID / 'cid'.
|
59 |
85ad3d82
|
Assos Assos
|
$data['comment']['cid'] = array(
|
60 |
|
|
'title' => t('ID'),
|
61 |
|
|
'help' => t('The comment ID of the field'),
|
62 |
|
|
'field' => array(
|
63 |
|
|
'handler' => 'views_handler_field_comment',
|
64 |
|
|
'click sortable' => TRUE,
|
65 |
|
|
),
|
66 |
|
|
'filter' => array(
|
67 |
|
|
'handler' => 'views_handler_filter_numeric',
|
68 |
|
|
),
|
69 |
|
|
'sort' => array(
|
70 |
|
|
'handler' => 'views_handler_sort',
|
71 |
|
|
),
|
72 |
|
|
'argument' => array(
|
73 |
|
|
'handler' => 'views_handler_argument_numeric',
|
74 |
|
|
),
|
75 |
|
|
);
|
76 |
|
|
|
77 |
5d12d676
|
Assos Assos
|
// Username of the comment author.
|
78 |
85ad3d82
|
Assos Assos
|
$data['comment']['name'] = array(
|
79 |
|
|
'title' => t('Author'),
|
80 |
|
|
'help' => t("The name of the comment's author. Can be rendered as a link to the author's homepage."),
|
81 |
|
|
'field' => array(
|
82 |
|
|
'handler' => 'views_handler_field_comment_username',
|
83 |
|
|
'click sortable' => TRUE,
|
84 |
|
|
),
|
85 |
|
|
'filter' => array(
|
86 |
|
|
'handler' => 'views_handler_filter_string',
|
87 |
|
|
),
|
88 |
|
|
'sort' => array(
|
89 |
|
|
'handler' => 'views_handler_sort',
|
90 |
|
|
),
|
91 |
|
|
'argument' => array(
|
92 |
|
|
'handler' => 'views_handler_argument_string',
|
93 |
|
|
),
|
94 |
|
|
);
|
95 |
|
|
|
96 |
5d12d676
|
Assos Assos
|
// Homepage.
|
97 |
85ad3d82
|
Assos Assos
|
$data['comment']['homepage'] = array(
|
98 |
|
|
'title' => t("Author's website"),
|
99 |
|
|
'help' => t("The website address of the comment's author. Can be rendered as a link. Will be empty if the author is a registered user."),
|
100 |
|
|
'field' => array(
|
101 |
|
|
'handler' => 'views_handler_field_url',
|
102 |
|
|
'click sortable' => TRUE,
|
103 |
|
|
),
|
104 |
|
|
'filter' => array(
|
105 |
|
|
'handler' => 'views_handler_filter_string',
|
106 |
|
|
),
|
107 |
|
|
'sort' => array(
|
108 |
|
|
'handler' => 'views_handler_sort',
|
109 |
|
|
),
|
110 |
|
|
'argument' => array(
|
111 |
|
|
'handler' => 'views_handler_argument_string',
|
112 |
|
|
),
|
113 |
|
|
);
|
114 |
|
|
|
115 |
5d12d676
|
Assos Assos
|
// hostname.
|
116 |
85ad3d82
|
Assos Assos
|
$data['comment']['hostname'] = array(
|
117 |
|
|
'title' => t('Hostname'),
|
118 |
|
|
'help' => t('Hostname of user that posted the comment.'),
|
119 |
|
|
'field' => array(
|
120 |
|
|
'handler' => 'views_handler_field',
|
121 |
|
|
'click sortable' => TRUE,
|
122 |
5d12d676
|
Assos Assos
|
),
|
123 |
85ad3d82
|
Assos Assos
|
'filter' => array(
|
124 |
|
|
'handler' => 'views_handler_filter_string',
|
125 |
|
|
),
|
126 |
|
|
'sort' => array(
|
127 |
|
|
'handler' => 'views_handler_sort',
|
128 |
|
|
),
|
129 |
|
|
'argument' => array(
|
130 |
|
|
'handler' => 'views_handler_argument_string',
|
131 |
|
|
),
|
132 |
|
|
);
|
133 |
|
|
|
134 |
5d12d676
|
Assos Assos
|
// Email address.
|
135 |
85ad3d82
|
Assos Assos
|
$data['comment']['mail'] = array(
|
136 |
8be7bf84
|
Assos Assos
|
'title' => t('E-mail'),
|
137 |
|
|
'help' => t('E-mail of user that posted the comment. Will be empty if the author is a registered user.'),
|
138 |
85ad3d82
|
Assos Assos
|
'field' => array(
|
139 |
|
|
'handler' => 'views_handler_field',
|
140 |
|
|
'click sortable' => TRUE,
|
141 |
5d12d676
|
Assos Assos
|
),
|
142 |
85ad3d82
|
Assos Assos
|
'filter' => array(
|
143 |
|
|
'handler' => 'views_handler_filter_string',
|
144 |
|
|
),
|
145 |
|
|
'sort' => array(
|
146 |
|
|
'handler' => 'views_handler_sort',
|
147 |
|
|
),
|
148 |
|
|
'argument' => array(
|
149 |
|
|
'handler' => 'views_handler_argument_string',
|
150 |
|
|
),
|
151 |
|
|
);
|
152 |
|
|
|
153 |
5d12d676
|
Assos Assos
|
// Created - when comment was posted.
|
154 |
85ad3d82
|
Assos Assos
|
$data['comment']['created'] = array(
|
155 |
|
|
'title' => t('Post date'),
|
156 |
|
|
'help' => t('Date and time of when the comment was created.'),
|
157 |
|
|
'field' => array(
|
158 |
|
|
'handler' => 'views_handler_field_date',
|
159 |
|
|
'click sortable' => TRUE,
|
160 |
|
|
),
|
161 |
|
|
'sort' => array(
|
162 |
|
|
'handler' => 'views_handler_sort_date',
|
163 |
|
|
),
|
164 |
|
|
'filter' => array(
|
165 |
|
|
'handler' => 'views_handler_filter_date',
|
166 |
|
|
),
|
167 |
|
|
);
|
168 |
|
|
|
169 |
b08fce64
|
Assos Assos
|
$data['comment']['created_fulldata'] = array(
|
170 |
|
|
'title' => t('Created date'),
|
171 |
|
|
'help' => t('Date in the form of CCYYMMDD.'),
|
172 |
|
|
'argument' => array(
|
173 |
|
|
'field' => 'created',
|
174 |
|
|
'handler' => 'views_handler_argument_node_created_fulldate',
|
175 |
|
|
),
|
176 |
|
|
);
|
177 |
|
|
|
178 |
|
|
$data['comment']['created_year_month'] = array(
|
179 |
|
|
'title' => t('Created year + month'),
|
180 |
|
|
'help' => t('Date in the form of YYYYMM.'),
|
181 |
|
|
'argument' => array(
|
182 |
|
|
'field' => 'created',
|
183 |
|
|
'handler' => 'views_handler_argument_node_created_year_month',
|
184 |
|
|
),
|
185 |
|
|
);
|
186 |
|
|
|
187 |
|
|
$data['comment']['created_year'] = array(
|
188 |
|
|
'title' => t('Created year'),
|
189 |
|
|
'help' => t('Date in the form of YYYY.'),
|
190 |
|
|
'argument' => array(
|
191 |
|
|
'field' => 'created',
|
192 |
|
|
'handler' => 'views_handler_argument_node_created_year',
|
193 |
|
|
),
|
194 |
|
|
);
|
195 |
|
|
|
196 |
|
|
$data['comment']['created_month'] = array(
|
197 |
|
|
'title' => t('Created month'),
|
198 |
|
|
'help' => t('Date in the form of MM (01 - 12).'),
|
199 |
|
|
'argument' => array(
|
200 |
|
|
'field' => 'created',
|
201 |
|
|
'handler' => 'views_handler_argument_node_created_month',
|
202 |
|
|
),
|
203 |
|
|
);
|
204 |
|
|
|
205 |
|
|
$data['comment']['created_day'] = array(
|
206 |
|
|
'title' => t('Created day'),
|
207 |
|
|
'help' => t('Date in the form of DD (01 - 31).'),
|
208 |
|
|
'argument' => array(
|
209 |
|
|
'field' => 'created',
|
210 |
|
|
'handler' => 'views_handler_argument_node_created_day',
|
211 |
|
|
),
|
212 |
|
|
);
|
213 |
|
|
|
214 |
|
|
$data['comment']['created_week'] = array(
|
215 |
|
|
'title' => t('Created week'),
|
216 |
|
|
'help' => t('Date in the form of WW (01 - 53).'),
|
217 |
|
|
'argument' => array(
|
218 |
|
|
'field' => 'created',
|
219 |
|
|
'handler' => 'views_handler_argument_node_created_week',
|
220 |
|
|
),
|
221 |
|
|
);
|
222 |
85ad3d82
|
Assos Assos
|
|
223 |
5d12d676
|
Assos Assos
|
// Language field.
|
224 |
85ad3d82
|
Assos Assos
|
if (module_exists('locale')) {
|
225 |
|
|
$data['comment']['language'] = array(
|
226 |
|
|
'title' => t('Language'),
|
227 |
|
|
'help' => t('The language the comment is in.'),
|
228 |
|
|
'field' => array(
|
229 |
|
|
'handler' => 'views_handler_field_locale_language',
|
230 |
|
|
'click sortable' => TRUE,
|
231 |
|
|
),
|
232 |
|
|
'filter' => array(
|
233 |
|
|
'handler' => 'views_handler_filter_locale_language',
|
234 |
|
|
),
|
235 |
|
|
'argument' => array(
|
236 |
|
|
'handler' => 'views_handler_argument_locale_language',
|
237 |
|
|
),
|
238 |
|
|
'sort' => array(
|
239 |
|
|
'handler' => 'views_handler_sort',
|
240 |
|
|
),
|
241 |
|
|
);
|
242 |
|
|
}
|
243 |
|
|
|
244 |
|
|
$data['comments']['timestamp']['moved to'] = array('comment', 'changed');
|
245 |
5d12d676
|
Assos Assos
|
// Changed (when comment was last updated).
|
246 |
85ad3d82
|
Assos Assos
|
$data['comment']['changed'] = array(
|
247 |
|
|
'title' => t('Updated date'),
|
248 |
|
|
'help' => t('Date and time of when the comment was last updated.'),
|
249 |
|
|
'field' => array(
|
250 |
|
|
'handler' => 'views_handler_field_date',
|
251 |
|
|
'click sortable' => TRUE,
|
252 |
|
|
),
|
253 |
|
|
'sort' => array(
|
254 |
|
|
'handler' => 'views_handler_sort_date',
|
255 |
|
|
),
|
256 |
|
|
'filter' => array(
|
257 |
|
|
'handler' => 'views_handler_filter_date',
|
258 |
|
|
),
|
259 |
|
|
);
|
260 |
|
|
|
261 |
|
|
$data['comments']['timestamp_fulldate']['moved to'] = array('comment', 'changed_fulldata');
|
262 |
|
|
$data['comment']['changed_fulldata'] = array(
|
263 |
b08fce64
|
Assos Assos
|
'title' => t('Changed date'),
|
264 |
85ad3d82
|
Assos Assos
|
'help' => t('Date in the form of CCYYMMDD.'),
|
265 |
|
|
'argument' => array(
|
266 |
|
|
'field' => 'changed',
|
267 |
|
|
'handler' => 'views_handler_argument_node_created_fulldate',
|
268 |
|
|
),
|
269 |
|
|
);
|
270 |
|
|
|
271 |
|
|
$data['comments']['timestamp_year_month']['moved to'] = array('comment', 'changed_year_month');
|
272 |
|
|
$data['comment']['changed_year_month'] = array(
|
273 |
b08fce64
|
Assos Assos
|
'title' => t('Changed year + month'),
|
274 |
85ad3d82
|
Assos Assos
|
'help' => t('Date in the form of YYYYMM.'),
|
275 |
|
|
'argument' => array(
|
276 |
|
|
'field' => 'changed',
|
277 |
|
|
'handler' => 'views_handler_argument_node_created_year_month',
|
278 |
|
|
),
|
279 |
|
|
);
|
280 |
|
|
|
281 |
|
|
$data['comments']['timestamp_year']['moved to'] = array('comment', 'changed_year');
|
282 |
|
|
$data['comment']['changed_year'] = array(
|
283 |
b08fce64
|
Assos Assos
|
'title' => t('Changed year'),
|
284 |
85ad3d82
|
Assos Assos
|
'help' => t('Date in the form of YYYY.'),
|
285 |
|
|
'argument' => array(
|
286 |
|
|
'field' => 'changed',
|
287 |
|
|
'handler' => 'views_handler_argument_node_created_year',
|
288 |
|
|
),
|
289 |
|
|
);
|
290 |
|
|
|
291 |
|
|
$data['comments']['timestamp_month']['moved to'] = array('comment', 'changed_month');
|
292 |
|
|
$data['comment']['changed_month'] = array(
|
293 |
b08fce64
|
Assos Assos
|
'title' => t('Changed month'),
|
294 |
85ad3d82
|
Assos Assos
|
'help' => t('Date in the form of MM (01 - 12).'),
|
295 |
|
|
'argument' => array(
|
296 |
|
|
'field' => 'changed',
|
297 |
|
|
'handler' => 'views_handler_argument_node_created_month',
|
298 |
|
|
),
|
299 |
|
|
);
|
300 |
|
|
|
301 |
|
|
$data['comments']['timestamp_day']['moved to'] = array('comment', 'changed_day');
|
302 |
|
|
$data['comment']['changed_day'] = array(
|
303 |
b08fce64
|
Assos Assos
|
'title' => t('Changed day'),
|
304 |
85ad3d82
|
Assos Assos
|
'help' => t('Date in the form of DD (01 - 31).'),
|
305 |
|
|
'argument' => array(
|
306 |
|
|
'field' => 'changed',
|
307 |
|
|
'handler' => 'views_handler_argument_node_created_day',
|
308 |
|
|
),
|
309 |
|
|
);
|
310 |
|
|
|
311 |
|
|
$data['comments']['timestamp_week']['moved to'] = array('comment', 'changed_week');
|
312 |
|
|
$data['comment']['changed_week'] = array(
|
313 |
b08fce64
|
Assos Assos
|
'title' => t('Changed week'),
|
314 |
85ad3d82
|
Assos Assos
|
'help' => t('Date in the form of WW (01 - 53).'),
|
315 |
|
|
'argument' => array(
|
316 |
|
|
'field' => 'changed',
|
317 |
|
|
'handler' => 'views_handler_argument_node_created_week',
|
318 |
|
|
),
|
319 |
|
|
);
|
320 |
|
|
|
321 |
5d12d676
|
Assos Assos
|
// Status (approved or not).
|
322 |
85ad3d82
|
Assos Assos
|
$data['comment']['status'] = array(
|
323 |
8be7bf84
|
Assos Assos
|
'title' => t('Approved status'),
|
324 |
85ad3d82
|
Assos Assos
|
'help' => t('Whether the comment is approved (or still in the moderation queue).'),
|
325 |
|
|
'field' => array(
|
326 |
|
|
'handler' => 'views_handler_field_boolean',
|
327 |
|
|
'click sortable' => TRUE,
|
328 |
|
|
'output formats' => array(
|
329 |
|
|
'approved-not-approved' => array(t('Approved'), t('Not Approved')),
|
330 |
|
|
),
|
331 |
|
|
),
|
332 |
|
|
'filter' => array(
|
333 |
|
|
'handler' => 'views_handler_filter_boolean_operator',
|
334 |
8be7bf84
|
Assos Assos
|
'label' => t('Approved comment status'),
|
335 |
85ad3d82
|
Assos Assos
|
'type' => 'yes-no',
|
336 |
|
|
),
|
337 |
|
|
'sort' => array(
|
338 |
|
|
'handler' => 'views_handler_sort',
|
339 |
|
|
),
|
340 |
|
|
);
|
341 |
|
|
|
342 |
5d12d676
|
Assos Assos
|
// Link to view comment.
|
343 |
85ad3d82
|
Assos Assos
|
$data['comment']['view_comment'] = array(
|
344 |
|
|
'field' => array(
|
345 |
8be7bf84
|
Assos Assos
|
'title' => t('Link to comment'),
|
346 |
85ad3d82
|
Assos Assos
|
'help' => t('Provide a simple link to view the comment.'),
|
347 |
|
|
'handler' => 'views_handler_field_comment_link',
|
348 |
|
|
),
|
349 |
|
|
);
|
350 |
|
|
|
351 |
5d12d676
|
Assos Assos
|
// Link to edit comment.
|
352 |
85ad3d82
|
Assos Assos
|
$data['comment']['edit_comment'] = array(
|
353 |
|
|
'field' => array(
|
354 |
8be7bf84
|
Assos Assos
|
'title' => t('Link to edit comment'),
|
355 |
85ad3d82
|
Assos Assos
|
'help' => t('Provide a simple link to edit the comment.'),
|
356 |
|
|
'handler' => 'views_handler_field_comment_link_edit',
|
357 |
|
|
),
|
358 |
|
|
);
|
359 |
|
|
|
360 |
5d12d676
|
Assos Assos
|
// Link to delete comment.
|
361 |
85ad3d82
|
Assos Assos
|
$data['comment']['delete_comment'] = array(
|
362 |
|
|
'field' => array(
|
363 |
8be7bf84
|
Assos Assos
|
'title' => t('Link to delete comment'),
|
364 |
85ad3d82
|
Assos Assos
|
'help' => t('Provide a simple link to delete the comment.'),
|
365 |
|
|
'handler' => 'views_handler_field_comment_link_delete',
|
366 |
|
|
),
|
367 |
|
|
);
|
368 |
|
|
|
369 |
5d12d676
|
Assos Assos
|
// Link to approve comment.
|
370 |
85ad3d82
|
Assos Assos
|
$data['comment']['approve_comment'] = array(
|
371 |
|
|
'field' => array(
|
372 |
8be7bf84
|
Assos Assos
|
'title' => t('Link to approve comment'),
|
373 |
85ad3d82
|
Assos Assos
|
'help' => t('Provide a simple link to approve the comment.'),
|
374 |
|
|
'handler' => 'views_handler_field_comment_link_approve',
|
375 |
|
|
),
|
376 |
|
|
);
|
377 |
|
|
|
378 |
5d12d676
|
Assos Assos
|
// Link to reply to comment.
|
379 |
85ad3d82
|
Assos Assos
|
$data['comment']['replyto_comment'] = array(
|
380 |
|
|
'field' => array(
|
381 |
8be7bf84
|
Assos Assos
|
'title' => t('Link to reply-to comment'),
|
382 |
85ad3d82
|
Assos Assos
|
'help' => t('Provide a simple link to reply to the comment.'),
|
383 |
|
|
'handler' => 'views_handler_field_comment_link_reply',
|
384 |
|
|
),
|
385 |
|
|
);
|
386 |
|
|
|
387 |
|
|
$data['comment']['thread'] = array(
|
388 |
|
|
'field' => array(
|
389 |
|
|
'title' => t('Depth'),
|
390 |
|
|
'help' => t('Display the depth of the comment if it is threaded.'),
|
391 |
|
|
'handler' => 'views_handler_field_comment_depth',
|
392 |
|
|
),
|
393 |
|
|
'sort' => array(
|
394 |
|
|
'title' => t('Thread'),
|
395 |
|
|
'help' => t('Sort by the threaded order. This will keep child comments together with their parents.'),
|
396 |
|
|
'handler' => 'views_handler_sort_comment_thread',
|
397 |
|
|
),
|
398 |
|
|
);
|
399 |
|
|
|
400 |
|
|
$data['comment']['nid'] = array(
|
401 |
|
|
'title' => t('Nid'),
|
402 |
|
|
'help' => t('The node ID to which the comment is a reply to.'),
|
403 |
|
|
'relationship' => array(
|
404 |
|
|
'title' => t('Content'),
|
405 |
|
|
'help' => t('The content to which the comment is a reply to.'),
|
406 |
|
|
'base' => 'node',
|
407 |
|
|
'base field' => 'nid',
|
408 |
|
|
'handler' => 'views_handler_relationship',
|
409 |
|
|
'label' => t('Content'),
|
410 |
|
|
),
|
411 |
|
|
'filter' => array(
|
412 |
|
|
'handler' => 'views_handler_filter_numeric',
|
413 |
|
|
),
|
414 |
|
|
'argument' => array(
|
415 |
|
|
'handler' => 'views_handler_argument_numeric',
|
416 |
|
|
),
|
417 |
|
|
'field' => array(
|
418 |
|
|
'handler' => 'views_handler_field_numeric',
|
419 |
|
|
),
|
420 |
|
|
);
|
421 |
|
|
|
422 |
|
|
$data['comment']['uid'] = array(
|
423 |
|
|
'title' => t('Author uid'),
|
424 |
|
|
'help' => t('If you need more fields than the uid add the comment: author relationship'),
|
425 |
|
|
'relationship' => array(
|
426 |
|
|
'title' => t('Author'),
|
427 |
|
|
'help' => t("The User ID of the comment's author."),
|
428 |
|
|
'base' => 'users',
|
429 |
|
|
'base field' => 'uid',
|
430 |
|
|
'handler' => 'views_handler_relationship',
|
431 |
|
|
'label' => t('author'),
|
432 |
|
|
),
|
433 |
|
|
'filter' => array(
|
434 |
|
|
'handler' => 'views_handler_filter_numeric',
|
435 |
|
|
),
|
436 |
|
|
'argument' => array(
|
437 |
|
|
'handler' => 'views_handler_argument_numeric',
|
438 |
|
|
),
|
439 |
|
|
'field' => array(
|
440 |
|
|
'handler' => 'views_handler_field_user',
|
441 |
|
|
),
|
442 |
|
|
);
|
443 |
|
|
|
444 |
|
|
$data['comment']['pid'] = array(
|
445 |
|
|
'title' => t('Parent CID'),
|
446 |
|
|
'help' => t('The Comment ID of the parent comment.'),
|
447 |
|
|
'field' => array(
|
448 |
|
|
'handler' => 'views_handler_field',
|
449 |
|
|
),
|
450 |
|
|
'relationship' => array(
|
451 |
|
|
'title' => t('Parent comment'),
|
452 |
|
|
'help' => t('The parent comment.'),
|
453 |
|
|
'base' => 'comment',
|
454 |
|
|
'base field' => 'cid',
|
455 |
|
|
'handler' => 'views_handler_relationship',
|
456 |
|
|
'label' => t('Parent comment'),
|
457 |
|
|
),
|
458 |
|
|
);
|
459 |
|
|
|
460 |
|
|
// ----------------------------------------------------------------------
|
461 |
5d12d676
|
Assos Assos
|
// 'node_comment_statistics' table.
|
462 |
|
|
// Define the group.
|
463 |
85ad3d82
|
Assos Assos
|
$data['node_comment_statistics']['table']['group'] = t('Content');
|
464 |
|
|
|
465 |
5d12d676
|
Assos Assos
|
// Joins.
|
466 |
85ad3d82
|
Assos Assos
|
$data['node_comment_statistics']['table']['join'] = array(
|
467 |
5d12d676
|
Assos Assos
|
// ...to the node table.
|
468 |
85ad3d82
|
Assos Assos
|
'node' => array(
|
469 |
|
|
'type' => 'INNER',
|
470 |
|
|
'left_field' => 'nid',
|
471 |
|
|
'field' => 'nid',
|
472 |
5d12d676
|
Assos Assos
|
),
|
473 |
85ad3d82
|
Assos Assos
|
);
|
474 |
|
|
|
475 |
5d12d676
|
Assos Assos
|
// Timestamp of the last comment.
|
476 |
85ad3d82
|
Assos Assos
|
$data['node_comment_statistics']['last_comment_timestamp'] = array(
|
477 |
|
|
'title' => t('Last comment time'),
|
478 |
|
|
'help' => t('Date and time of when the last comment was posted.'),
|
479 |
|
|
'field' => array(
|
480 |
|
|
'handler' => 'views_handler_field_last_comment_timestamp',
|
481 |
|
|
'click sortable' => TRUE,
|
482 |
|
|
),
|
483 |
|
|
'sort' => array(
|
484 |
|
|
'handler' => 'views_handler_sort_date',
|
485 |
|
|
),
|
486 |
|
|
'filter' => array(
|
487 |
|
|
'handler' => 'views_handler_filter_date',
|
488 |
|
|
),
|
489 |
|
|
);
|
490 |
|
|
|
491 |
5d12d676
|
Assos Assos
|
// Last comment author's username.
|
492 |
85ad3d82
|
Assos Assos
|
$data['node_comment_statistics']['last_comment_name'] = array(
|
493 |
|
|
'title' => t("Last comment author"),
|
494 |
|
|
'help' => t('The name of the author of the last posted comment.'),
|
495 |
|
|
'field' => array(
|
496 |
|
|
'handler' => 'views_handler_field_ncs_last_comment_name',
|
497 |
|
|
'click sortable' => TRUE,
|
498 |
|
|
'no group by' => TRUE,
|
499 |
|
|
),
|
500 |
|
|
'sort' => array(
|
501 |
|
|
'handler' => 'views_handler_sort_ncs_last_comment_name',
|
502 |
|
|
'no group by' => TRUE,
|
503 |
|
|
),
|
504 |
|
|
);
|
505 |
|
|
|
506 |
5d12d676
|
Assos Assos
|
// Comment count.
|
507 |
85ad3d82
|
Assos Assos
|
$data['node_comment_statistics']['comment_count'] = array(
|
508 |
|
|
'title' => t('Comment count'),
|
509 |
|
|
'help' => t('The number of comments a node has.'),
|
510 |
|
|
'field' => array(
|
511 |
|
|
'handler' => 'views_handler_field_numeric',
|
512 |
|
|
'click sortable' => TRUE,
|
513 |
|
|
),
|
514 |
|
|
'filter' => array(
|
515 |
|
|
'handler' => 'views_handler_filter_numeric',
|
516 |
|
|
),
|
517 |
|
|
'sort' => array(
|
518 |
|
|
'handler' => 'views_handler_sort',
|
519 |
|
|
),
|
520 |
|
|
'argument' => array(
|
521 |
|
|
'handler' => 'views_handler_argument',
|
522 |
|
|
),
|
523 |
|
|
);
|
524 |
|
|
|
525 |
5d12d676
|
Assos Assos
|
// Timestamp of when the last comment update happened.
|
526 |
85ad3d82
|
Assos Assos
|
$data['node_comment_statistics']['last_updated'] = array(
|
527 |
|
|
'title' => t('Updated/commented date'),
|
528 |
|
|
'help' => t('The most recent of last comment posted or node updated time.'),
|
529 |
|
|
'field' => array(
|
530 |
|
|
'handler' => 'views_handler_field_ncs_last_updated',
|
531 |
|
|
'click sortable' => TRUE,
|
532 |
|
|
'no group by' => TRUE,
|
533 |
|
|
),
|
534 |
|
|
'sort' => array(
|
535 |
|
|
'handler' => 'views_handler_sort_ncs_last_updated',
|
536 |
|
|
'no group by' => TRUE,
|
537 |
|
|
),
|
538 |
|
|
'filter' => array(
|
539 |
|
|
'handler' => 'views_handler_filter_ncs_last_updated',
|
540 |
|
|
),
|
541 |
|
|
);
|
542 |
|
|
|
543 |
|
|
$data['node_comment_statistics']['cid'] = array(
|
544 |
|
|
'title' => t('Last comment CID'),
|
545 |
|
|
'help' => t('Display the last comment of a node'),
|
546 |
|
|
'relationship' => array(
|
547 |
8be7bf84
|
Assos Assos
|
'title' => t('Last comment'),
|
548 |
85ad3d82
|
Assos Assos
|
'help' => t('The last comment of a node.'),
|
549 |
|
|
'group' => t('Comment'),
|
550 |
|
|
'base' => 'comment',
|
551 |
|
|
'base field' => 'cid',
|
552 |
|
|
'handler' => 'views_handler_relationship',
|
553 |
|
|
'label' => t('Last Comment'),
|
554 |
|
|
),
|
555 |
|
|
);
|
556 |
|
|
|
557 |
5d12d676
|
Assos Assos
|
// The user ID / 'uid' of the user who last posted a comment.
|
558 |
85ad3d82
|
Assos Assos
|
$data['node_comment_statistics']['last_comment_uid'] = array(
|
559 |
|
|
'title' => t('Last comment uid'),
|
560 |
|
|
'help' => t('The User ID of the author of the last comment of a node.'),
|
561 |
|
|
'relationship' => array(
|
562 |
|
|
'title' => t('Last comment author'),
|
563 |
|
|
'base' => 'users',
|
564 |
|
|
'base field' => 'uid',
|
565 |
|
|
'handler' => 'views_handler_relationship',
|
566 |
|
|
'label' => t('Last comment author'),
|
567 |
|
|
),
|
568 |
|
|
'filter' => array(
|
569 |
|
|
'handler' => 'views_handler_filter_numeric',
|
570 |
|
|
),
|
571 |
|
|
'argument' => array(
|
572 |
|
|
'handler' => 'views_handler_argument_numeric',
|
573 |
|
|
),
|
574 |
|
|
'field' => array(
|
575 |
|
|
'handler' => 'views_handler_field_numeric',
|
576 |
|
|
),
|
577 |
|
|
);
|
578 |
|
|
|
579 |
|
|
return $data;
|
580 |
|
|
}
|
581 |
|
|
|
582 |
|
|
/**
|
583 |
5d12d676
|
Assos Assos
|
* Implements hook_views_data_alter() on behalf of comment.module.
|
584 |
|
|
*
|
585 |
|
|
* Add items to the node table that are relevant to comments.
|
586 |
85ad3d82
|
Assos Assos
|
*/
|
587 |
|
|
function comment_views_data_alter(&$data) {
|
588 |
5d12d676
|
Assos Assos
|
// New comments.
|
589 |
85ad3d82
|
Assos Assos
|
$data['node']['new_comments'] = array(
|
590 |
|
|
'title' => t('New comments'),
|
591 |
|
|
'help' => t('The number of new comments on the node.'),
|
592 |
|
|
'field' => array(
|
593 |
|
|
'handler' => 'views_handler_field_node_new_comments',
|
594 |
|
|
'no group by' => TRUE,
|
595 |
|
|
),
|
596 |
|
|
);
|
597 |
|
|
|
598 |
|
|
$data['node']['comments_link'] = array(
|
599 |
|
|
'field' => array(
|
600 |
|
|
'title' => t('Add comment link'),
|
601 |
|
|
'help' => t('Display the standard add comment link used on regular nodes, which will only display if the viewing user has access to add a comment.'),
|
602 |
|
|
'handler' => 'views_handler_field_comment_node_link',
|
603 |
|
|
),
|
604 |
|
|
);
|
605 |
|
|
|
606 |
5d12d676
|
Assos Assos
|
// Comment status of the node.
|
607 |
85ad3d82
|
Assos Assos
|
$data['node']['comment'] = array(
|
608 |
|
|
'title' => t('Comment status'),
|
609 |
|
|
'help' => t('Whether comments are enabled or disabled on the node.'),
|
610 |
|
|
'field' => array(
|
611 |
|
|
'handler' => 'views_handler_field_node_comment',
|
612 |
|
|
'click sortable' => TRUE,
|
613 |
|
|
),
|
614 |
|
|
'sort' => array(
|
615 |
|
|
'handler' => 'views_handler_sort',
|
616 |
|
|
),
|
617 |
|
|
'filter' => array(
|
618 |
|
|
'handler' => 'views_handler_filter_node_comment',
|
619 |
|
|
),
|
620 |
|
|
);
|
621 |
|
|
|
622 |
|
|
$data['node']['uid_touch'] = array(
|
623 |
|
|
'title' => t('User posted or commented'),
|
624 |
|
|
'help' => t('Display nodes only if a user posted the node or commented on the node.'),
|
625 |
|
|
'argument' => array(
|
626 |
|
|
'field' => 'uid',
|
627 |
|
|
'name table' => 'users',
|
628 |
|
|
'name field' => 'name',
|
629 |
|
|
'handler' => 'views_handler_argument_comment_user_uid',
|
630 |
|
|
'no group by' => TRUE,
|
631 |
|
|
),
|
632 |
|
|
'filter' => array(
|
633 |
|
|
'field' => 'uid',
|
634 |
|
|
'name table' => 'users',
|
635 |
|
|
'name field' => 'name',
|
636 |
5d12d676
|
Assos Assos
|
'handler' => 'views_handler_filter_comment_user_uid',
|
637 |
85ad3d82
|
Assos Assos
|
),
|
638 |
|
|
);
|
639 |
|
|
|
640 |
|
|
$data['node']['cid'] = array(
|
641 |
|
|
'title' => t('Comments of the node'),
|
642 |
|
|
'help' => t('Relate all comments on the node. This will create 1 duplicate record for every comment. Usually if you need this it is better to create a comment view.'),
|
643 |
|
|
'relationship' => array(
|
644 |
|
|
'group' => t('Comment'),
|
645 |
|
|
'label' => t('Comments'),
|
646 |
|
|
'base' => 'comment',
|
647 |
|
|
'base field' => 'nid',
|
648 |
|
|
'relationship field' => 'nid',
|
649 |
|
|
'handler' => 'views_handler_relationship',
|
650 |
|
|
),
|
651 |
|
|
);
|
652 |
|
|
}
|
653 |
|
|
|
654 |
|
|
/**
|
655 |
|
|
* Implements hook_views_plugins().
|
656 |
|
|
*/
|
657 |
|
|
function comment_views_plugins() {
|
658 |
|
|
return array(
|
659 |
|
|
'module' => 'views',
|
660 |
|
|
'row' => array(
|
661 |
|
|
'comment' => array(
|
662 |
|
|
'title' => t('Comment'),
|
663 |
|
|
'help' => t('Display the comment with standard comment view.'),
|
664 |
|
|
'handler' => 'views_plugin_row_comment_view',
|
665 |
|
|
'theme' => 'views_view_row_comment',
|
666 |
5d12d676
|
Assos Assos
|
'path' => drupal_get_path('module', 'views') . '/modules/comment',
|
667 |
|
|
// Not necessary for most modules.
|
668 |
|
|
'base' => array('comment'),
|
669 |
|
|
// Only works with 'comment' as base.
|
670 |
85ad3d82
|
Assos Assos
|
'uses options' => TRUE,
|
671 |
|
|
'type' => 'normal',
|
672 |
|
|
'help topic' => 'style-comment',
|
673 |
|
|
),
|
674 |
|
|
'comment_rss' => array(
|
675 |
|
|
'title' => t('Comment'),
|
676 |
|
|
'help' => t('Display the comment as RSS.'),
|
677 |
|
|
'handler' => 'views_plugin_row_comment_rss',
|
678 |
|
|
'theme' => 'views_view_row_rss',
|
679 |
5d12d676
|
Assos Assos
|
'path' => drupal_get_path('module', 'views') . '/modules/comment',
|
680 |
|
|
// Not necessary for most modules.
|
681 |
|
|
'base' => array('comment'),
|
682 |
|
|
// Only works with 'comment' as base.
|
683 |
85ad3d82
|
Assos Assos
|
'uses options' => TRUE,
|
684 |
|
|
'type' => 'feed',
|
685 |
|
|
'help topic' => 'style-comment-rss',
|
686 |
|
|
),
|
687 |
|
|
),
|
688 |
|
|
);
|
689 |
|
|
}
|
690 |
|
|
|
691 |
|
|
/**
|
692 |
5d12d676
|
Assos Assos
|
* Template helper for theme_views_view_row_comment.
|
693 |
85ad3d82
|
Assos Assos
|
*/
|
694 |
|
|
function template_preprocess_views_view_row_comment(&$vars) {
|
695 |
|
|
$options = $vars['options'];
|
696 |
|
|
$view = &$vars['view'];
|
697 |
|
|
$plugin = &$view->style_plugin->row_plugin;
|
698 |
|
|
$comment = $plugin->comments[$vars['row']->{$vars['field_alias']}];
|
699 |
|
|
$node = $plugin->nodes[$comment->nid];
|
700 |
|
|
// Put the view on the node so we can retrieve it in the preprocess.
|
701 |
|
|
$node->view = &$view;
|
702 |
|
|
|
703 |
|
|
$build = comment_view_multiple(array($comment->cid => $comment), $node, $plugin->options['view_mode']);
|
704 |
5d12d676
|
Assos Assos
|
// If displaying the comments without links, remove them from the renderable
|
705 |
|
|
// array; there is no way to avoid building them in the first place.
|
706 |
|
|
// @see comment_build_content()
|
707 |
85ad3d82
|
Assos Assos
|
if (empty($options['links'])) {
|
708 |
|
|
foreach ($build as $cid => &$comment_build) {
|
709 |
|
|
if (isset($comment_build['links'])) {
|
710 |
|
|
unset($comment_build['links']);
|
711 |
|
|
}
|
712 |
|
|
}
|
713 |
|
|
}
|
714 |
|
|
$vars['comment'] = drupal_render($build);
|
715 |
|
|
} |