/[drupal]/contributions/modules/views/modules/node.views.inc
ViewVC logotype

Contents of /contributions/modules/views/modules/node.views.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


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

  ViewVC Help
Powered by ViewVC 1.1.2