Removing translation directories
[project/views.git] / modules / node.views.inc
CommitLineData
cffc1056 1<?php
b06399e3
EM
2/**
3 * @file
0225248a
EM
4 * Provide views data and handlers for node.module
5 */
6
7/**
8 * @defgroup views_node_module node.module handlers
9 *
10 * Includes the tables 'node', 'node_revisions' and 'history'.
11 * @{
12 */
13
14/**
15 * Implementation of hook_views_data()
b06399e3 16 */
cffc1056 17function node_views_data() {
d8aa7200
EM
18 // ----------------------------------------------------------------
19 // node table -- basic table information.
0225248a
EM
20
21 // Define the base group of this table. Fields that don't
22 // have a group defined will go into this field by default.
23 $data['node']['table']['group'] = t('Node');
24
25 // Advertise this table as a possible base table
26 $data['node']['table']['base'] = array(
27 'field' => 'nid',
28 'title' => t('Node'),
ad2ba848 29 'help' => t("Nodes are a Drupal site's primary content."),
d8aa7200 30 'weight' => -10,
0225248a
EM
31 );
32
33 // For other base tables, explain how we join
34 $data['node']['table']['join'] = array(
2d3898d7 35 // this explains how the 'node' table (named in the line above)
6c12f53f
EM
36 // links toward the node_revisions table.
37 'node_revisions' => array(
0225248a 38 'handler' => 'views_join', // this is actually optional
6c12f53f
EM
39 'left_table' => 'node_revisions', // Because this is a direct link it could be left out.
40 'left_field' => 'nid',
41 'field' => 'nid',
2d3898d7
EM
42 // also supported:
43 // 'type' => 'INNER',
06f6fd84 44 // 'extra' => array(array('field' => 'fieldname', 'value' => 'value', 'operator' => '='))
6c12f53f
EM
45 // Unfortunately, you can't specify other tables here, but you can construct
46 // alternative joins in the handlers that can do that.
2d3898d7 47 // 'table' => 'the actual name of this table in the database',
0225248a 48 ),
0225248a 49 );
cffc1056 50
0225248a 51 // ----------------------------------------------------------------
d8aa7200 52 // node table -- fields
cffc1056 53
86ed07d8 54 // nid
cffc1056
EM
55 $data['node']['nid'] = array(
56 'title' => t('Nid'),
4fd71778 57 'help' => t('The node ID of the node.'), // The help that appears on the UI,
0225248a 58 // Information for displaying the nid
cffc1056
EM
59 'field' => array(
60 'handler' => 'views_handler_field_node',
725bd2c9 61 'click sortable' => TRUE,
cffc1056 62 ),
0225248a 63 // Information for accepting a nid as an argument
cffc1056 64 'argument' => array(
d69aa078 65 'handler' => 'views_handler_argument_node_nid',
fe44beb7 66 'parent' => 'views_handler_argument_numeric', // make sure parent is included
8881fd4d 67 'name field' => 'title', // the field to display in the summary.
d5a58088
EM
68 'numeric' => TRUE,
69 'validate type' => 'nid',
cffc1056 70 ),
0225248a 71 // Information for accepting a nid as a filter
cffc1056 72 'filter' => array(
6c88512c 73 'handler' => 'views_handler_filter_numeric',
cffc1056 74 ),
0225248a
EM
75 // Information for sorting on a nid.
76 'sort' => array(
77 'handler' => 'views_handler_sort',
78 ),
cffc1056
EM
79 );
80
d8aa7200
EM
81 // title
82 // This definition has more items in it than it needs to as an example.
83 $data['node']['title'] = array(
84 'title' => t('Title'), // The item it appears as on the UI,
85 'help' => t('The title of the node.'), // The help that appears on the UI,
86 // Information for displaying a title as a field
87 'field' => array(
88 'field' => 'title', // the real field. This could be left out since it is the same.
89 'group' => t('Node'), // The group it appears in on the UI. Could be left out.
90 'handler' => 'views_handler_field_node',
91 'click sortable' => TRUE,
92 ),
93 'sort' => array(
94 'handler' => 'views_handler_sort',
95 ),
96 // Information for accepting a title as a filter
97 'filter' => array(
98 'handler' => 'views_handler_filter_string',
99 ),
100 'argument' => array(
101 'handler' => 'views_handler_argument_string',
102 ),
103 );
104
cffc1056 105 // created field
0225248a
EM
106 $data['node']['created'] = array(
107 'title' => t('Post date'), // The item it appears as on the UI,
108 'help' => t('The date the node was posted.'), // The help that appears on the UI,
109 'field' => array(
110 'handler' => 'views_handler_field_date',
725bd2c9 111 'click sortable' => TRUE,
0225248a
EM
112 ),
113 'sort' => array(
01c6ed1e 114 'handler' => 'views_handler_sort_date',
0225248a 115 ),
4c3f2152
EM
116 'filter' => array(
117 'handler' => 'views_handler_filter_date',
118 ),
0225248a 119 );
cffc1056
EM
120
121 // changed field
0225248a 122 $data['node']['changed'] = array(
cffc1056 123 'title' => t('Updated date'), // The item it appears as on the UI,
0225248a
EM
124 'help' => t('The date the node was last updated.'), // The help that appears on the UI,
125 'field' => array(
126 'handler' => 'views_handler_field_date',
725bd2c9 127 'click sortable' => TRUE,
0225248a 128 ),
52208794 129 'sort' => array(
01c6ed1e 130 'handler' => 'views_handler_sort_date',
52208794 131 ),
4c3f2152
EM
132 'filter' => array(
133 'handler' => 'views_handler_filter_date',
134 ),
cffc1056 135 );
0225248a
EM
136
137 // Node type
138 $data['node']['type'] = array(
cffc1056 139 'title' => t('Type'), // The item it appears as on the UI,
4fd71778 140 'help' => t('The type of a node (for example, "blog entry", "forum post", "story", etc).'), // The help that appears on the UI,
0225248a
EM
141 'field' => array(
142 'handler' => 'views_handler_field_node_type',
725bd2c9 143 'click sortable' => TRUE,
0225248a 144 ),
5a8d618a
EM
145 'sort' => array(
146 'handler' => 'views_handler_sort',
147 ),
725bd2c9
EM
148 'filter' => array(
149 'handler' => 'views_handler_filter_node_type',
c60d618c 150 ),
0225248a
EM
151 'argument' => array(
152 'handler' => 'views_handler_argument_node_type',
153 ),
154 );
155
156 // published status
157 $data['node']['status'] = array(
d6eb26c3 158 'title' => t('Published'),
fa00c800 159 'help' => t('Whether or not the node is published.'),
0225248a
EM
160 'field' => array(
161 'handler' => 'views_handler_field_boolean',
725bd2c9 162 'click sortable' => TRUE,
52208794
EM
163 ),
164 'filter' => array(
165 'handler' => 'views_handler_filter_boolean_operator',
166 'label' => t('Published'),
e598d0dd 167 'type' => 'yes-no',
52208794 168 ),
0225248a
EM
169 'sort' => array(
170 'handler' => 'views_handler_sort',
171 ),
cffc1056
EM
172 );
173
d6eb26c3
EM
174 // published status + extra
175 $data['node']['status_extra'] = array(
176 'title' => t('Published or admin'),
177 'help' => t('Filters out unpublished nodes if the current user cannot view them.'),
178 'filter' => array(
179 'field' => 'status',
180 'handler' => 'views_handler_filter_node_status',
fa00c800 181 'label' => t('Published or admin'),
d6eb26c3
EM
182 ),
183 );
184
0225248a
EM
185 // promote status
186 $data['node']['promote'] = array(
d6eb26c3 187 'title' => t('Promoted to front page'),
fa00c800 188 'help' => t('Whether or not the node is promoted to the front page.'),
0225248a
EM
189 'field' => array(
190 'handler' => 'views_handler_field_boolean',
725bd2c9 191 'click sortable' => TRUE,
52208794
EM
192 ),
193 'filter' => array(
194 'handler' => 'views_handler_filter_boolean_operator',
195 'label' => t('Promoted to front page'),
e598d0dd 196 'type' => 'yes-no',
52208794 197 ),
0225248a
EM
198 'sort' => array(
199 'handler' => 'views_handler_sort',
200 ),
201 );
202
f0031392
EM
203 // moderate
204 $data['node']['moderate'] = array(
205 'title' => t('Moderated'), // The item it appears as on the UI,
206 'help' => t('Whether or not the node is moderated.'), // The help that appears on the UI,
207 // Information for displaying a title as a field
208 'field' => array(
209 'handler' => 'views_handler_field_boolean',
210 'click sortable' => TRUE,
211 ),
212 'filter' => array(
213 'handler' => 'views_handler_filter_boolean_operator',
214 'label' => t('Moderated'),
e598d0dd 215 'type' => 'yes-no',
f0031392
EM
216 ),
217 'sort' => array(
218 'handler' => 'views_handler_sort',
219 ),
220 );
928e6b86 221
0225248a
EM
222 // sticky
223 $data['node']['sticky'] = array(
224 'title' => t('Sticky'), // The item it appears as on the UI,
225 'help' => t('Whether or not the node is sticky.'), // The help that appears on the UI,
226 // Information for displaying a title as a field
227 'field' => array(
228 'handler' => 'views_handler_field_boolean',
725bd2c9 229 'click sortable' => TRUE,
52208794
EM
230 ),
231 'filter' => array(
232 'handler' => 'views_handler_filter_boolean_operator',
233 'label' => t('Sticky'),
e598d0dd 234 'type' => 'yes-no',
52208794 235 ),
0225248a
EM
236 'sort' => array(
237 'handler' => 'views_handler_sort',
238 ),
239 );
240
d8aa7200
EM
241 // links to operate on the node
242
7a5b8a0a
EM
243 $data['node']['view_node'] = array(
244 'field' => array(
c7819f0c 245 'title' => t('Link'),
7a5b8a0a
EM
246 'help' => t('Provide a simple link to the node.'),
247 'handler' => 'views_handler_field_node_link',
248 ),
249 );
7c9d559e 250
7a5b8a0a
EM
251 $data['node']['edit_node'] = array(
252 'field' => array(
c7819f0c 253 'title' => t('Edit link'),
7a5b8a0a
EM
254 'help' => t('Provide a simple link to edit the node.'),
255 'handler' => 'views_handler_field_node_link_edit',
256 ),
257 );
7c9d559e 258
7a5b8a0a
EM
259 $data['node']['delete_node'] = array(
260 'field' => array(
c7819f0c 261 'title' => t('Delete link'),
7a5b8a0a
EM
262 'help' => t('Provide a simple link to delete the node.'),
263 'handler' => 'views_handler_field_node_link_delete',
264 ),
265 );
7a5b8a0a 266
3f66ae28
EM
267 // Bogus fields for aliasing purposes.
268
7a5b8a0a
EM
269 $data['node']['created_fulldate'] = array(
270 'title' => t('Created date'),
271 'help' => t('In the form of CCYYMMDD.'),
272 'argument' => array(
273 'field' => 'created',
274 'handler' => 'views_handler_argument_node_created_fulldate',
275 ),
276 );
277
189ddc27
EM
278 $data['node']['created_year_month'] = array(
279 'title' => t('Created year + month'),
4fd71778 280 'help' => t('In the form of YYYYMM.'),
3f66ae28 281 'argument' => array(
7c9d559e 282 'field' => 'created',
999b2e53 283 'handler' => 'views_handler_argument_node_created_year_month',
189ddc27
EM
284 ),
285 );
286
287 $data['node']['created_year'] = array(
288 'title' => t('Created year'),
4fd71778 289 'help' => t('In the form of YYYY.'),
189ddc27 290 'argument' => array(
7c9d559e 291 'field' => 'created',
999b2e53 292 'handler' => 'views_handler_argument_node_created_year',
189ddc27
EM
293 ),
294 );
295
296 $data['node']['created_month'] = array(
297 'title' => t('Created month'),
4fd71778 298 'help' => t('In the form of MM (01 - 12).'),
189ddc27 299 'argument' => array(
7c9d559e 300 'field' => 'created',
999b2e53 301 'handler' => 'views_handler_argument_node_created_month',
3f66ae28
EM
302 ),
303 );
304
26405423
EM
305 $data['node']['created_day'] = array(
306 'title' => t('Created day'),
307 'help' => t('In the form of DD (01 - 31).'),
308 'argument' => array(
309 'field' => 'created',
310 'handler' => 'views_handler_argument_node_created_day',
311 ),
312 );
313
7a5b8a0a
EM
314 $data['node']['created_week'] = array(
315 'title' => t('Created week'),
316 'help' => t('In the form of WW (01 - 53).'),
317 'argument' => array(
318 'field' => 'created',
319 'handler' => 'views_handler_argument_node_created_week',
320 ),
321 );
7c9d559e 322
4ab73d53
EM
323 $data['node']['changed_fulldate'] = array(
324 'title' => t('Updated date'),
325 'help' => t('In the form of CCYYMMDD.'),
326 'argument' => array(
327 'field' => 'changed',
328 'handler' => 'views_handler_argument_node_created_fulldate',
329 ),
330 );
331
332 $data['node']['changed_year_month'] = array(
333 'title' => t('Updated year + month'),
334 'help' => t('In the form of YYYYMM.'),
335 'argument' => array(
336 'field' => 'changed',
337 'handler' => 'views_handler_argument_node_created_year_month',
338 ),
339 );
340
341 $data['node']['changed_year'] = array(
342 'title' => t('Updated year'),
343 'help' => t('In the form of YYYY.'),
344 'argument' => array(
345 'field' => 'changed',
346 'handler' => 'views_handler_argument_node_created_year',
347 ),
348 );
349
350 $data['node']['changed_month'] = array(
351 'title' => t('Updated month'),
352 'help' => t('In the form of MM (01 - 12).'),
353 'argument' => array(
354 'field' => 'changed',
355 'handler' => 'views_handler_argument_node_created_month',
356 ),
357 );
358
359 $data['node']['changed_day'] = array(
360 'title' => t('Updated day'),
361 'help' => t('In the form of DD (01 - 31).'),
362 'argument' => array(
363 'field' => 'changed',
364 'handler' => 'views_handler_argument_node_created_day',
365 ),
366 );
367
368 $data['node']['changed_week'] = array(
369 'title' => t('Updated week'),
370 'help' => t('In the form of WW (01 - 53).'),
371 'argument' => array(
372 'field' => 'changed',
373 'handler' => 'views_handler_argument_node_created_week',
374 ),
375 );
376
0225248a
EM
377 // ----------------------------------------------------------------------
378 // Node revisions table
379
380 // Define the base group of this table. Fields that don't
381 // have a group defined will go into this field by default.
c7819f0c 382 $data['node_revisions']['table']['group'] = t('Node revision');
cffc1056 383
0225248a 384 // Advertise this table as a possible base table
2bd5f0a0 385 $data['node_revisions']['table']['base'] = array(
0225248a 386 'field' => 'vid',
d8aa7200 387 'title' => t('Node revision'),
8881fd4d 388 'help' => t('Node revisions are a history of changes to nodes.'),
0225248a
EM
389 );
390
391 // For other base tables, explain how we join
2bd5f0a0 392 $data['node_revisions']['table']['join'] = array(
2d3898d7 393 // Directly links to node table.
0225248a 394 'node' => array(
2d3898d7
EM
395 'left_field' => 'vid',
396 'field' => 'vid',
397 ),
6c12f53f
EM
398 );
399
400 // uid field
401 $data['node_revisions']['uid'] = array(
402 'title' => t('User'),
403 'help' => t('Relate a node revision to the user who created the revision.'),
404 'relationship' => array(
405 'handler' => 'views_handler_relationship',
406 'base' => 'users',
407 'field' => 'uid',
408 'label' => t('user'),
2d3898d7 409 ),
0225248a
EM
410 );
411
412 // Body field
413 $data['node_revisions']['body'] = array(
c7819f0c 414 'group' => t('Node'),
0225248a 415 'title' => t('Body'), // The item it appears as on the UI,
2bd5f0a0 416 'help' => t('The actual, full data in the body field; this may not be valid data on all node types.'), // The help that appears on the UI,
0225248a
EM
417 // Information for displaying a title as a field
418 'field' => array(
0225248a 419 'handler' => 'views_handler_field_markup',
725bd2c9 420 'format' => 'format', // The name of the format field
52208794
EM
421 ),
422 'filter' => array(
423 'handler' => 'views_handler_filter_string',
424 ),
0225248a 425 );
2bd5f0a0
EM
426
427 // Teaser field
428 $data['node_revisions']['teaser'] = array(
c7819f0c 429 'group' => t('Node'),
2bd5f0a0
EM
430 'title' => t('Teaser'), // The item it appears as on the UI,
431 'help' => t('The stored teaser field. This may not be valid or useful data on all node types.'), // The help that appears on the UI,
432 // Information for displaying a title as a field
433 'field' => array(
434 'handler' => 'views_handler_field_markup',
725bd2c9 435 'format' => 'format', // The name of the format field
2bd5f0a0 436 ),
52208794
EM
437 'filter' => array(
438 'handler' => 'views_handler_filter_string',
439 ),
2bd5f0a0
EM
440 );
441
06f6fd84
EM
442 // nid
443 $data['node_revisions']['vid'] = array(
444 'title' => t('Vid'),
445 'help' => t('The revision ID of the node revision.'), // The help that appears on the UI,
446 // Information for displaying the nid
447 'field' => array(
97a8eb35 448// 'handler' => 'views_handler_field',
06f6fd84
EM
449 'click sortable' => TRUE,
450 ),
451 // Information for accepting a nid as an argument
452 'argument' => array(
453 'handler' => 'views_handler_argument_node_vid',
fe44beb7 454 'parent' => 'views_handler_argument_numeric', // make sure parent is included
06f6fd84 455 'click sortable' => TRUE,
d5a58088 456 'numeric' => TRUE,
06f6fd84
EM
457 ),
458 // Information for accepting a nid as a filter
459 'filter' => array(
460 'handler' => 'views_handler_filter_numeric',
461 ),
462 // Information for sorting on a nid.
463 'sort' => array(
464 'handler' => 'views_handler_sort',
465 ),
466 );
467
c7819f0c
EM
468 // title
469 $data['node_revisions']['title'] = array(
470 'title' => t('Title'), // The item it appears as on the UI,
471 'help' => t('The title of the node.'), // The help that appears on the UI,
472 // Information for displaying a title as a field
473 'field' => array(
474 'field' => 'title', // the real field
475 'handler' => 'views_handler_field_node',
476 'click sortable' => TRUE,
477 ),
478 'sort' => array(
479 'handler' => 'views_handler_sort',
480 ),
481 'filter' => array(
482 'handler' => 'views_handler_filter_string',
483 ),
484 'argument' => array(
485 'handler' => 'views_handler_argument_string',
486 ),
487 );
488
489 // log field
490 $data['node_revisions']['log'] = array(
491 'title' => t('Log message'), // The item it appears as on the UI,
492 'help' => t('The log message entered when the revision was created.'), // The help that appears on the UI,
493 // Information for displaying a title as a field
494 'field' => array(
495 'handler' => 'views_handler_field_xss',
496 ),
497 'filter' => array(
498 'handler' => 'views_handler_filter_string',
499 ),
500 );
501
52208794 502 // revision timestamp
c7819f0c 503 // changed field
06f6fd84 504 $data['node_revisions']['timestamp'] = array(
c7819f0c
EM
505 'title' => t('Created date'), // The item it appears as on the UI,
506 'help' => t('The date the node revision was created.'), // The help that appears on the UI,
507 'field' => array(
508 'handler' => 'views_handler_field_date',
509 'click sortable' => TRUE,
510 ),
511 'sort' => array(
512 'handler' => 'views_handler_sort_date',
513 ),
514 'filter' => array(
515 'handler' => 'views_handler_filter_date',
516 ),
517 );
518
2ef7bd19
EM
519 // input format id
520 $data['node_revisions']['format'] = array(
521 'title' => t('Input format id'), // The item it appears as on the UI,
522 'help' => t('The numeric input format of the node revision. !default means the default input format.', array('!default' => FILTER_FORMAT_DEFAULT)), // The help that appears on the UI,
523 // Information for displaying an input format as a field
524 'field' => array(
525 'handler' => 'views_handler_field_numeric',
526 'click sortable' => TRUE,
527 ),
528 // Information for sorting on input format
529 'sort' => array(
530 'handler' => 'views_handler_sort',
531 ),
532 // Information for accepting input format as a filter
533 'filter' => array(
534 'handler' => 'views_handler_filter_numeric',
535 ),
536 );
537
538 // input format name
539 // A (numeric) format of 0 means the default; Drupal also applies the default
540 // if the format specifed for a node revision has been deleted.
541 // This complexity makes sorting and filtering by format name tricky,
542 // hence these are not yet supported.
543 $data['node_revisions']['format_name'] = array(
544 'title' => t('Input format'), // The item it appears as on the UI,
545 'help' => t('The name of the input format of the node revision.'), // The help that appears on the UI,
546 // Information for displaying an input format as a field
547 'field' => array(
548 'handler' => 'views_handler_field_filter_format_name',
549 ),
550 );
551
c7819f0c
EM
552 $data['node_revisions']['revert_revision'] = array(
553 'field' => array(
554 'title' => t('Revert link'),
555 'help' => t('Provide a simple link to revert to the revision.'),
556 'handler' => 'views_handler_field_node_revision_link_revert',
557 ),
558 );
559
560 $data['node_revisions']['delete_revision'] = array(
561 'field' => array(
562 'title' => t('Delete link'),
563 'help' => t('Provide a simple link to delete the node revision.'),
564 'handler' => 'views_handler_field_node_revision_link_delete',
565 ),
566 );
7c9d559e 567
2d3898d7 568 // ----------------------------------------------------------------------
29745c93
EM
569 // Node access table
570
571 // Define the base group of this table. Fields that don't
572 // have a group defined will go into this field by default.
573 $data['node_access']['table']['group'] = t('Node access');
574
575 // For other base tables, explain how we join
576 $data['node_access']['table']['join'] = array(
577 // Directly links to node table.
578 'node' => array(
579 'left_field' => 'nid',
580 'field' => 'nid',
581 ),
582 );
583 // nid field
584 $data['node_access']['nid'] = array(
585 'title' => t('Access'),
586 'help' => t('Filter by access.'),
587 'filter' => array(
588 'handler' => 'views_handler_filter_node_access',
589 'help' => t('Filter for nodes by view access. <strong>Not necessary if you are using node as your base table.</strong>'),
590 ),
591 );
592
593 // ----------------------------------------------------------------------
2d3898d7
EM
594 // History table
595
0766852e
EM
596 // We're actually defining a specific instance of the table, so let's
597 // alias it so that we can later add the real table for other purposes if we
598 // need it.
2d3898d7
EM
599 $data['history_user']['table']['group'] = t('Node');
600
601 // Explain how this table joins to others.
602 $data['history_user']['table']['join'] = array(
603 // Directly links to node table.
604 'node' => array(
605 'table' => 'history',
606 'left_field' => 'nid',
607 'field' => 'nid',
608 'extra' => array(
06f6fd84 609 array('field' => 'uid', 'value' => '***CURRENT_USER***', 'numeric' => TRUE),
2d3898d7
EM
610 ),
611 ),
612 );
613
614 $data['history_user']['timestamp'] = array(
0766852e
EM
615 'title' => t('Has new content'),
616 'field' => array(
617 'handler' => 'views_handler_field_history_user_timestamp',
618 'help' => t('Show a marker if the node has new or updated content.'),
619 ),
2d3898d7 620 'filter' => array(
2d3898d7
EM
621 'help' => t('Show only nodes that have new content.'),
622 'handler' => 'views_handler_filter_history_user_timestamp',
623 ),
624 );
625 return $data;
626}
627
cffc1056 628/**
fe44beb7
EM
629 * Implementation of hook_views_handlers() to register all of the basic handlers
630 * views uses.
cffc1056 631 */
fe44beb7
EM
632function node_views_handlers() {
633 return array(
634 'info' => array(
635 'path' => drupal_get_path('module', 'views') . '/modules/node',
636 ),
637 'handlers' => array(
638 // field handlers
639 'views_handler_field_node' => array(
640 'parent' => 'views_handler_field',
641 ),
fe44beb7
EM
642 'views_handler_field_node_type' => array(
643 'parent' => 'views_handler_field_node',
644 ),
645 'views_handler_field_node_link' => array(
646 'parent' => 'views_handler_field',
647 ),
648 'views_handler_field_node_type' => array(
649 'parent' => 'views_handler_field_node',
650 ),
651 'views_handler_field_node_link_edit' => array(
652 'parent' => 'views_handler_field_node_link',
653 ),
654 'views_handler_field_node_link_delete' => array(
655 'parent' => 'views_handler_field_node_link',
656 ),
657 'views_handler_field_node_revision_link_revert' => array(
658 'parent' => 'views_handler_field_node_link',
659 ),
660 'views_handler_field_node_revision_link_delete' => array(
661 'parent' => 'views_handler_field_node_link',
662 ),
663 'views_handler_field_history_user_timestamp' => array(
664 'parent' => 'views_handler_field_node',
665 ),
3f301ee7 666
fe44beb7
EM
667 // argument handlers
668 'views_handler_argument_node_type' => array(
669 'parent' => 'views_handler_argument',
670 ),
671 'views_handler_argument_node_nid' => array(
672 'parent' => 'views_handler_argument_numeric',
673 ),
674 'views_handler_argument_node_vid' => array(
675 'parent' => 'views_handler_argument_numeric',
676 ),
fe44beb7
EM
677 'views_handler_argument_node_created_fulldate' => array(
678 // put several handlers in the same file
679 'file' => 'views_handler_argument_dates_various.inc',
7b77f990 680 'parent' => 'views_handler_argument_date',
fe44beb7
EM
681 ),
682 'views_handler_argument_node_created_year' => array(
683 // put several handlers in the same file
684 'file' => 'views_handler_argument_dates_various.inc',
7b77f990 685 'parent' => 'views_handler_argument_date',
fe44beb7
EM
686 ),
687 'views_handler_argument_node_created_year_month' => array(
688 // put several handlers in the same file
689 'file' => 'views_handler_argument_dates_various.inc',
7b77f990 690 'parent' => 'views_handler_argument_date',
fe44beb7
EM
691 ),
692 'views_handler_argument_node_created_month' => array(
693 // put several handlers in the same file
694 'file' => 'views_handler_argument_dates_various.inc',
7b77f990 695 'parent' => 'views_handler_argument_date',
fe44beb7
EM
696 ),
697 'views_handler_argument_node_created_day' => array(
698 // put several handlers in the same file
699 'file' => 'views_handler_argument_dates_various.inc',
7b77f990 700 'parent' => 'views_handler_argument_date',
fe44beb7
EM
701 ),
702 'views_handler_argument_node_created_week' => array(
703 // put several handlers in the same file
704 'file' => 'views_handler_argument_dates_various.inc',
7b77f990 705 'parent' => 'views_handler_argument_date',
fe44beb7 706 ),
3f301ee7 707
fe44beb7
EM
708 // filters
709 'views_handler_filter_node_type' => array(
710 'parent' => 'views_handler_filter_in_operator',
711 ),
fe44beb7
EM
712 'views_handler_filter_history_user_timestamp' => array(
713 'parent' => 'views_handler_filter',
714 ),
715 'views_handler_filter_node_status' => array(
716 'parent' => 'views_handler_filter',
717 ),
29745c93
EM
718 'views_handler_filter_node_access' => array(
719 'parent' => 'views_handler_filter',
720 ),
fe44beb7
EM
721 ),
722 );
3f301ee7
EM
723}
724
2d3898d7 725/**
c01f577a
EM
726 * Implementation of hook_views_plugins
727 */
728function node_views_plugins() {
729 return array(
730 'module' => 'views', // This just tells our themes are elsewhere.
731 'row' => array(
732 'node' => array(
733 'title' => t('Node'),
734 'help' => t('Display the node with standard node view.'),
6b92ee49 735 'handler' => 'views_plugin_row_node_view',
fe44beb7 736 'path' => drupal_get_path('module', 'views') . '/modules/node', // not necessary for most modules
c01f577a
EM
737 'theme' => 'views_view_row_node',
738 'base' => array('node'), // only works with 'node' as base.
d3b06159 739 'uses options' => TRUE,
6df3ce20 740 'type' => 'normal',
e00a3647 741 'help topic' => 'style-node',
6df3ce20
EM
742 ),
743 'node_rss' => array(
744 'title' => t('Node'),
745 'help' => t('Display the node with standard node view.'),
746 'handler' => 'views_plugin_row_node_rss',
fe44beb7 747 'path' => drupal_get_path('module', 'views') . '/modules/node', // not necessary for most modules
229cfd7c 748 'theme' => 'views_view_row_rss',
6df3ce20
EM
749 'base' => array('node'), // only works with 'node' as base.
750 'uses options' => TRUE,
751 'type' => 'feed',
e00a3647 752 'help topic' => 'style-node-rss',
c01f577a
EM
753 ),
754 ),
d5a58088
EM
755 'argument validator' => array(
756 'node' => array(
757 'title' => t('Node'),
758 'handler' => 'views_plugin_argument_validate_node',
fe44beb7 759 'path' => drupal_get_path('module', 'views') . '/modules/node', // not necessary for most modules
d5a58088
EM
760 ),
761 ),
e5addfbb
EM
762 'argument default' => array(
763 'node' => array(
764 'title' => t('Node ID from URL'),
765 'handler' => 'views_plugin_argument_default_node',
fe44beb7
EM
766 'path' => drupal_get_path('module', 'views') . '/modules/node', // not necessary for most modules
767 'parent' => 'fixed', // so that the parent class is included
e5addfbb
EM
768 ),
769 ),
c01f577a
EM
770 );
771}
772
773/**
c01f577a
EM
774 * Template helper for theme_views_view_row_node
775 */
776function template_preprocess_views_view_row_node(&$vars) {
7c9d559e 777 $options = $vars['options'];
efde0b6a
EM
778
779 // Make sure the variables are defined.
780 $vars['node'] = '';
781 $vars['comments'] = '';
782
783 $nid = $vars['row']->{$vars['field_alias']};
c01f577a
EM
784 if (!is_numeric($nid)) {
785 return;
786 }
787
788 $node = node_load($nid);
789
790 if (empty($node)) {
791 return;
792 }
793
10146edb
EM
794 $node->view = $vars['view'];
795 $node->build_mode = ($options['build_mode'] == 'teaser' || $options['build_mode'] == 'full') ? NODE_BUILD_NORMAL : $options['build_mode'];
796 $vars['node'] = node_view($node, $options['build_mode'] == 'teaser', FALSE, $options['links']);
797
b7c37c97 798 if (!empty($options['comments']) && function_exists('comment_render')) {
003da250 799 $vars['comments'] = comment_render($node);
928e6b86 800 }
7c9d559e
EM
801}
802
803/**
d6eb26c3
EM
804 * Implementation of hook_views_query_substitutions().
805 */
806function node_views_query_substitutions() {
34fcaba8
EM
807 return array(
808 '***ADMINISTER_NODES***' => intval(user_access('administer nodes')),
809 );
d6eb26c3
EM
810}
811
812/**
813 * Implementation of hook_views_analyze().
814 */
815function node_views_analyze($view) {
816 $ret = array();
817 // Check for something other than the default display:
818 if ($view->base_table == 'node') {
819 foreach ($view->display as $id => $display) {
820 if (!$display->handler->is_defaulted('access') || !$display->handler->is_defaulted('filters')) {
821 // check for no access control
822 $access = $display->handler->get_option('access');
823 if (empty($access['type']) || $access['type'] == 'none') {
824 $filters = $display->handler->get_option('filters');
825 foreach ($filters as $filter) {
826 if ($filter['table'] == 'node' && ($filter['field'] == 'status' || $filter['field'] == 'status_extra')) {
827 continue 2;
828 }
829 }
830 $ret[] = views_ui_analysis(t('Display %display has no access control but does not contain a filter for published nodes.', array('%display' => $display->display_title)), 'warning');
831 }
832 }
833 }
834 }
835
836 return $ret;
837}
838
839/**
0225248a
EM
840 * @}
841 */