node.views.inc

  1. nittany7 modules/contrib/views/modules/node.views.inc
  2. cis7 modules/contrib/views/modules/node.views.inc
  3. mooc7 modules/contrib/views/modules/node.views.inc

Provide views data and handlers for node.module.

Functions

Namesort descending Description
node_row_node_view_preprocess_node Implements hook_preprocess_node().
node_views_analyze Implements hook_views_analyze().
node_views_data Implements hook_views_data().
node_views_plugins Implements hook_views_plugins().
node_views_query_substitutions Implements hook_views_query_substitutions().

File

modules/contrib/views/modules/node.views.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Provide views data and handlers for node.module.
  5. *
  6. * @ingroup views_module_handlers
  7. */
  8. /**
  9. * Implements hook_views_data().
  10. */
  11. function node_views_data() {
  12. // ----------------------------------------------------------------
  13. // node table -- basic table information.
  14. // Define the base group of this table. Fields that don't
  15. // have a group defined will go into this field by default.
  16. $data['node']['table']['group'] = t('Content');
  17. // Advertise this table as a possible base table
  18. $data['node']['table']['base'] = array(
  19. 'field' => 'nid',
  20. 'title' => t('Content'),
  21. 'weight' => -10,
  22. 'access query tag' => 'node_access',
  23. 'defaults' => array(
  24. 'field' => 'title',
  25. ),
  26. );
  27. $data['node']['table']['entity type'] = 'node';
  28. $data['node']['table']['default_relationship'] = array(
  29. 'node_revision' => array(
  30. 'table' => 'node_revision',
  31. 'field' => 'vid',
  32. ),
  33. );
  34. // ----------------------------------------------------------------
  35. // node table -- fields
  36. // nid
  37. $data['node']['nid'] = array(
  38. 'title' => t('Nid'),
  39. 'help' => t('The node ID.'), // The help that appears on the UI,
  40. // Information for displaying the nid
  41. 'field' => array(
  42. 'handler' => 'views_handler_field_node',
  43. 'click sortable' => TRUE,
  44. ),
  45. // Information for accepting a nid as an argument
  46. 'argument' => array(
  47. 'handler' => 'views_handler_argument_node_nid',
  48. 'name field' => 'title', // the field to display in the summary.
  49. 'numeric' => TRUE,
  50. 'validate type' => 'nid',
  51. ),
  52. // Information for accepting a nid as a filter
  53. 'filter' => array(
  54. 'handler' => 'views_handler_filter_numeric',
  55. ),
  56. // Information for sorting on a nid.
  57. 'sort' => array(
  58. 'handler' => 'views_handler_sort',
  59. ),
  60. );
  61. // title
  62. // This definition has more items in it than it needs to as an example.
  63. $data['node']['title'] = array(
  64. 'title' => t('Title'), // The item it appears as on the UI,
  65. 'help' => t('The content title.'), // The help that appears on the UI,
  66. // Information for displaying a title as a field
  67. 'field' => array(
  68. 'field' => 'title', // the real field. This could be left out since it is the same.
  69. 'group' => t('Content'), // The group it appears in on the UI. Could be left out.
  70. 'handler' => 'views_handler_field_node',
  71. 'click sortable' => TRUE,
  72. 'link_to_node default' => TRUE,
  73. ),
  74. 'sort' => array(
  75. 'handler' => 'views_handler_sort',
  76. ),
  77. // Information for accepting a title as a filter
  78. 'filter' => array(
  79. 'handler' => 'views_handler_filter_string',
  80. ),
  81. 'argument' => array(
  82. 'handler' => 'views_handler_argument_string',
  83. ),
  84. );
  85. // created field
  86. $data['node']['created'] = array(
  87. 'title' => t('Post date'), // The item it appears as on the UI,
  88. 'help' => t('The date the content was posted.'), // The help that appears on the UI,
  89. 'field' => array(
  90. 'handler' => 'views_handler_field_date',
  91. 'click sortable' => TRUE,
  92. ),
  93. 'sort' => array(
  94. 'handler' => 'views_handler_sort_date',
  95. ),
  96. 'filter' => array(
  97. 'handler' => 'views_handler_filter_date',
  98. ),
  99. );
  100. // changed field
  101. $data['node']['changed'] = array(
  102. 'title' => t('Updated date'), // The item it appears as on the UI,
  103. 'help' => t('The date the content was last updated.'), // The help that appears on the UI,
  104. 'field' => array(
  105. 'handler' => 'views_handler_field_date',
  106. 'click sortable' => TRUE,
  107. ),
  108. 'sort' => array(
  109. 'handler' => 'views_handler_sort_date',
  110. ),
  111. 'filter' => array(
  112. 'handler' => 'views_handler_filter_date',
  113. ),
  114. );
  115. // Content type
  116. $data['node']['type'] = array(
  117. 'title' => t('Type'), // The item it appears as on the UI,
  118. 'help' => t('The content type (for example, "blog entry", "forum post", "story", etc).'), // The help that appears on the UI,
  119. 'field' => array(
  120. 'handler' => 'views_handler_field_node_type',
  121. 'click sortable' => TRUE,
  122. ),
  123. 'sort' => array(
  124. 'handler' => 'views_handler_sort',
  125. ),
  126. 'filter' => array(
  127. 'handler' => 'views_handler_filter_node_type',
  128. ),
  129. 'argument' => array(
  130. 'handler' => 'views_handler_argument_node_type',
  131. ),
  132. );
  133. // published status
  134. $data['node']['status'] = array(
  135. 'title' => t('Published'),
  136. 'help' => t('Whether or not the content is published.'),
  137. 'field' => array(
  138. 'handler' => 'views_handler_field_boolean',
  139. 'click sortable' => TRUE,
  140. 'output formats' => array(
  141. 'published-notpublished' => array(t('Published'), t('Not published')),
  142. ),
  143. ),
  144. 'filter' => array(
  145. 'handler' => 'views_handler_filter_boolean_operator',
  146. 'label' => t('Published'),
  147. 'type' => 'yes-no',
  148. 'use equal' => TRUE, // Use status = 1 instead of status <> 0 in WHERE statment
  149. ),
  150. 'sort' => array(
  151. 'handler' => 'views_handler_sort',
  152. ),
  153. );
  154. // published status + extra
  155. $data['node']['status_extra'] = array(
  156. 'title' => t('Published or admin'),
  157. 'help' => t('Filters out unpublished content if the current user cannot view it.'),
  158. 'filter' => array(
  159. 'field' => 'status',
  160. 'handler' => 'views_handler_filter_node_status',
  161. 'label' => t('Published or admin'),
  162. ),
  163. );
  164. // promote status
  165. $data['node']['promote'] = array(
  166. 'title' => t('Promoted to front page'),
  167. 'help' => t('Whether or not the content is promoted to the front page.'),
  168. 'field' => array(
  169. 'handler' => 'views_handler_field_boolean',
  170. 'click sortable' => TRUE,
  171. 'output formats' => array(
  172. 'promoted-notpromoted' => array(t('Promoted'), t('Not promoted')),
  173. ),
  174. ),
  175. 'filter' => array(
  176. 'handler' => 'views_handler_filter_boolean_operator',
  177. 'label' => t('Promoted to front page'),
  178. 'type' => 'yes-no',
  179. ),
  180. 'sort' => array(
  181. 'handler' => 'views_handler_sort',
  182. ),
  183. );
  184. // sticky
  185. $data['node']['sticky'] = array(
  186. 'title' => t('Sticky'), // The item it appears as on the UI,
  187. 'help' => t('Whether or not the content is sticky.'), // The help that appears on the UI,
  188. // Information for displaying a title as a field
  189. 'field' => array(
  190. 'handler' => 'views_handler_field_boolean',
  191. 'click sortable' => TRUE,
  192. 'output formats' => array(
  193. 'sticky' => array(t('Sticky'), t('Not sticky')),
  194. ),
  195. ),
  196. 'filter' => array(
  197. 'handler' => 'views_handler_filter_boolean_operator',
  198. 'label' => t('Sticky'),
  199. 'type' => 'yes-no',
  200. ),
  201. 'sort' => array(
  202. 'handler' => 'views_handler_sort',
  203. 'help' => t('Whether or not the content is sticky. To list sticky content first, set this to descending.'),
  204. ),
  205. );
  206. // Define some fields based upon views_handler_field_entity in the entity
  207. // table so they can be re-used with other query backends.
  208. // @see views_handler_field_entity
  209. $data['views_entity_node']['table']['group'] = t('Content');
  210. $data['node']['view_node']['moved to'] = array('views_entity_node', 'view_node');
  211. $data['views_entity_node']['view_node'] = array(
  212. 'field' => array(
  213. 'title' => t('Link'),
  214. 'help' => t('Provide a simple link to the content.'),
  215. 'handler' => 'views_handler_field_node_link',
  216. ),
  217. );
  218. $data['node']['edit_node']['moved to'] = array('views_entity_node', 'edit_node');
  219. $data['views_entity_node']['edit_node'] = array(
  220. 'field' => array(
  221. 'title' => t('Edit link'),
  222. 'help' => t('Provide a simple link to edit the content.'),
  223. 'handler' => 'views_handler_field_node_link_edit',
  224. ),
  225. );
  226. $data['node']['delete_node']['moved to'] = array('views_entity_node', 'delete_node');
  227. $data['views_entity_node']['delete_node'] = array(
  228. 'field' => array(
  229. 'title' => t('Delete link'),
  230. 'help' => t('Provide a simple link to delete the content.'),
  231. 'handler' => 'views_handler_field_node_link_delete',
  232. ),
  233. );
  234. $data['node']['path'] = array(
  235. 'field' => array(
  236. 'title' => t('Path'),
  237. 'help' => t('The aliased path to this content.'),
  238. 'handler' => 'views_handler_field_node_path',
  239. ),
  240. );
  241. // Bogus fields for aliasing purposes.
  242. $data['node']['created_fulldate'] = array(
  243. 'title' => t('Created date'),
  244. 'help' => t('Date in the form of CCYYMMDD.'),
  245. 'argument' => array(
  246. 'field' => 'created',
  247. 'handler' => 'views_handler_argument_node_created_fulldate',
  248. ),
  249. );
  250. $data['node']['created_year_month'] = array(
  251. 'title' => t('Created year + month'),
  252. 'help' => t('Date in the form of YYYYMM.'),
  253. 'argument' => array(
  254. 'field' => 'created',
  255. 'handler' => 'views_handler_argument_node_created_year_month',
  256. ),
  257. );
  258. $data['node']['created_year'] = array(
  259. 'title' => t('Created year'),
  260. 'help' => t('Date in the form of YYYY.'),
  261. 'argument' => array(
  262. 'field' => 'created',
  263. 'handler' => 'views_handler_argument_node_created_year',
  264. ),
  265. );
  266. $data['node']['created_month'] = array(
  267. 'title' => t('Created month'),
  268. 'help' => t('Date in the form of MM (01 - 12).'),
  269. 'argument' => array(
  270. 'field' => 'created',
  271. 'handler' => 'views_handler_argument_node_created_month',
  272. ),
  273. );
  274. $data['node']['created_day'] = array(
  275. 'title' => t('Created day'),
  276. 'help' => t('Date in the form of DD (01 - 31).'),
  277. 'argument' => array(
  278. 'field' => 'created',
  279. 'handler' => 'views_handler_argument_node_created_day',
  280. ),
  281. );
  282. $data['node']['created_week'] = array(
  283. 'title' => t('Created week'),
  284. 'help' => t('Date in the form of WW (01 - 53).'),
  285. 'argument' => array(
  286. 'field' => 'created',
  287. 'handler' => 'views_handler_argument_node_created_week',
  288. ),
  289. );
  290. $data['node']['changed_fulldate'] = array(
  291. 'title' => t('Updated date'),
  292. 'help' => t('Date in the form of CCYYMMDD.'),
  293. 'argument' => array(
  294. 'field' => 'changed',
  295. 'handler' => 'views_handler_argument_node_created_fulldate',
  296. ),
  297. );
  298. $data['node']['changed_year_month'] = array(
  299. 'title' => t('Updated year + month'),
  300. 'help' => t('Date in the form of YYYYMM.'),
  301. 'argument' => array(
  302. 'field' => 'changed',
  303. 'handler' => 'views_handler_argument_node_created_year_month',
  304. ),
  305. );
  306. $data['node']['changed_year'] = array(
  307. 'title' => t('Updated year'),
  308. 'help' => t('Date in the form of YYYY.'),
  309. 'argument' => array(
  310. 'field' => 'changed',
  311. 'handler' => 'views_handler_argument_node_created_year',
  312. ),
  313. );
  314. $data['node']['changed_month'] = array(
  315. 'title' => t('Updated month'),
  316. 'help' => t('Date in the form of MM (01 - 12).'),
  317. 'argument' => array(
  318. 'field' => 'changed',
  319. 'handler' => 'views_handler_argument_node_created_month',
  320. ),
  321. );
  322. $data['node']['changed_day'] = array(
  323. 'title' => t('Updated day'),
  324. 'help' => t('Date in the form of DD (01 - 31).'),
  325. 'argument' => array(
  326. 'field' => 'changed',
  327. 'handler' => 'views_handler_argument_node_created_day',
  328. ),
  329. );
  330. $data['node']['changed_week'] = array(
  331. 'title' => t('Updated week'),
  332. 'help' => t('Date in the form of WW (01 - 53).'),
  333. 'argument' => array(
  334. 'field' => 'changed',
  335. 'handler' => 'views_handler_argument_node_created_week',
  336. ),
  337. );
  338. // uid field
  339. $data['node']['uid'] = array(
  340. 'title' => t('Author uid'),
  341. 'help' => t('The user authoring the content. If you need more fields than the uid add the content: author relationship'),
  342. 'relationship' => array(
  343. 'title' => t('Author'),
  344. 'help' => t('Relate content to the user who created it.'),
  345. 'handler' => 'views_handler_relationship',
  346. 'base' => 'users',
  347. 'field' => 'uid',
  348. 'label' => t('author'),
  349. ),
  350. 'filter' => array(
  351. 'handler' => 'views_handler_filter_user_name',
  352. ),
  353. 'argument' => array(
  354. 'handler' => 'views_handler_argument_numeric',
  355. ),
  356. 'field' => array(
  357. 'handler' => 'views_handler_field_user',
  358. ),
  359. );
  360. $data['node']['uid_revision'] = array(
  361. 'title' => t('User has a revision'),
  362. 'help' => t('All nodes where a certain user has a revision'),
  363. 'real field' => 'nid',
  364. 'filter' => array(
  365. 'handler' => 'views_handler_filter_node_uid_revision',
  366. ),
  367. 'argument' => array(
  368. 'handler' => 'views_handler_argument_node_uid_revision',
  369. ),
  370. );
  371. // ----------------------------------------------------------------------
  372. // Content revision table
  373. // Define the base group of this table. Fields that don't
  374. // have a group defined will go into this field by default.
  375. $data['node_revisions']['moved to'] = 'node_revision';
  376. $data['node_revision']['table']['entity type'] = 'node';
  377. $data['node_revision']['table']['group'] = t('Content revision');
  378. // Support the conversion of the field body
  379. $data['node_revisions']['body']['moved to'] = array('field_revision_data', 'body-revision_id');
  380. // Advertise this table as a possible base table
  381. $data['node_revision']['table']['base'] = array(
  382. 'field' => 'vid',
  383. 'title' => t('Content revision'),
  384. 'help' => t('Content revision is a history of changes to content.'),
  385. 'defaults' => array(
  386. 'field' => 'title',
  387. ),
  388. );
  389. // For other base tables, explain how we join
  390. $data['node_revision']['table']['join'] = array(
  391. // Directly links to node table.
  392. 'node' => array(
  393. 'left_field' => 'vid',
  394. 'field' => 'vid',
  395. ),
  396. );
  397. $data['node_revision']['table']['default_relationship'] = array(
  398. 'node' => array(
  399. 'table' => 'node',
  400. 'field' => 'nid',
  401. ),
  402. );
  403. // uid field for node revision
  404. $data['node_revision']['uid'] = array(
  405. 'title' => t('User'),
  406. 'help' => t('Relate a content revision to the user who created the revision.'),
  407. 'relationship' => array(
  408. 'handler' => 'views_handler_relationship',
  409. 'base' => 'users',
  410. 'base field' => 'uid',
  411. 'label' => t('revision user'),
  412. ),
  413. );
  414. // nid
  415. $data['node_revision']['nid'] = array(
  416. 'title' => t('Nid'),
  417. // The help that appears on the UI.
  418. 'help' => t('The revision NID of the content revision.'),
  419. // Information for displaying the nid.
  420. 'field' => array(
  421. 'click sortable' => TRUE,
  422. ),
  423. // Information for accepting a nid as an argument.
  424. 'argument' => array(
  425. 'handler' => 'views_handler_argument_node_nid',
  426. 'click sortable' => TRUE,
  427. 'numeric' => TRUE,
  428. ),
  429. // Information for accepting a nid as a filter.
  430. 'filter' => array(
  431. 'handler' => 'views_handler_filter_numeric',
  432. ),
  433. // Information for sorting on a nid.
  434. 'sort' => array(
  435. 'handler' => 'views_handler_sort',
  436. ),
  437. 'relationship' => array(
  438. 'handler' => 'views_handler_relationship',
  439. 'base' => 'node',
  440. 'base field' => 'nid',
  441. 'title' => t('Content'),
  442. 'label' => t('Get the actual content from a content revision.'),
  443. ),
  444. );
  445. // vid
  446. $data['node_revision']['vid'] = array(
  447. 'title' => t('Vid'),
  448. // The help that appears on the UI.
  449. 'help' => t('The revision ID of the content revision.'),
  450. // Information for displaying the vid.
  451. 'field' => array(
  452. 'click sortable' => TRUE,
  453. ),
  454. // Information for accepting a vid as an argument.
  455. 'argument' => array(
  456. 'handler' => 'views_handler_argument_node_vid',
  457. 'click sortable' => TRUE,
  458. 'numeric' => TRUE,
  459. ),
  460. // Information for accepting a vid as a filter.
  461. 'filter' => array(
  462. 'handler' => 'views_handler_filter_numeric',
  463. ),
  464. // Information for sorting on a vid.
  465. 'sort' => array(
  466. 'handler' => 'views_handler_sort',
  467. ),
  468. 'relationship' => array(
  469. 'handler' => 'views_handler_relationship',
  470. 'base' => 'node',
  471. 'base field' => 'vid',
  472. 'title' => t('Content'),
  473. 'label' => t('Get the actual content from a content revision.'),
  474. ),
  475. );
  476. // title
  477. $data['node_revision']['title'] = array(
  478. 'title' => t('Title'), // The item it appears as on the UI,
  479. 'help' => t('The content title.'), // The help that appears on the UI,
  480. // Information for displaying a title as a field
  481. 'field' => array(
  482. 'field' => 'title', // the real field
  483. 'handler' => 'views_handler_field_node_revision',
  484. 'click sortable' => TRUE,
  485. ),
  486. 'sort' => array(
  487. 'handler' => 'views_handler_sort',
  488. ),
  489. 'filter' => array(
  490. 'handler' => 'views_handler_filter_string',
  491. ),
  492. 'argument' => array(
  493. 'handler' => 'views_handler_argument_string',
  494. ),
  495. );
  496. // log field
  497. $data['node_revision']['log'] = array(
  498. 'title' => t('Log message'), // The item it appears as on the UI,
  499. 'help' => t('The log message entered when the revision was created.'), // The help that appears on the UI,
  500. // Information for displaying a title as a field
  501. 'field' => array(
  502. 'handler' => 'views_handler_field_xss',
  503. ),
  504. 'filter' => array(
  505. 'handler' => 'views_handler_filter_string',
  506. ),
  507. );
  508. // revision timestamp
  509. // changed field
  510. $data['node_revision']['timestamp'] = array(
  511. 'title' => t('Updated date'), // The item it appears as on the UI,
  512. 'help' => t('The date the node was last updated.'), // The help that appears on the UI,
  513. 'field' => array(
  514. 'handler' => 'views_handler_field_date',
  515. 'click sortable' => TRUE,
  516. ),
  517. 'sort' => array(
  518. 'handler' => 'views_handler_sort_date',
  519. ),
  520. 'filter' => array(
  521. 'handler' => 'views_handler_filter_date',
  522. ),
  523. );
  524. $data['node_revision']['link_to_revision'] = array(
  525. 'field' => array(
  526. 'title' => t('Link'),
  527. 'help' => t('Provide a simple link to the revision.'),
  528. 'handler' => 'views_handler_field_node_revision_link',
  529. ),
  530. );
  531. $data['node_revision']['revert_revision'] = array(
  532. 'field' => array(
  533. 'title' => t('Revert link'),
  534. 'help' => t('Provide a simple link to revert to the revision.'),
  535. 'handler' => 'views_handler_field_node_revision_link_revert',
  536. ),
  537. );
  538. $data['node_revision']['delete_revision'] = array(
  539. 'field' => array(
  540. 'title' => t('Delete link'),
  541. 'help' => t('Provide a simple link to delete the content revision.'),
  542. 'handler' => 'views_handler_field_node_revision_link_delete',
  543. ),
  544. );
  545. // ----------------------------------------------------------------------
  546. // Node access table
  547. // Define the base group of this table. Fields that don't
  548. // have a group defined will go into this field by default.
  549. $data['node_access']['table']['group'] = t('Content access');
  550. // For other base tables, explain how we join
  551. $data['node_access']['table']['join'] = array(
  552. // Directly links to node table.
  553. 'node' => array(
  554. 'left_field' => 'nid',
  555. 'field' => 'nid',
  556. ),
  557. );
  558. // nid field
  559. $data['node_access']['nid'] = array(
  560. 'title' => t('Access'),
  561. 'help' => t('Filter by access.'),
  562. 'filter' => array(
  563. 'handler' => 'views_handler_filter_node_access',
  564. 'help' => t('Filter for content by view access. <strong>Not necessary if you are using node as your base table.</strong>'),
  565. ),
  566. );
  567. // ----------------------------------------------------------------------
  568. // History table
  569. // We're actually defining a specific instance of the table, so let's
  570. // alias it so that we can later add the real table for other purposes if we
  571. // need it.
  572. $data['history_user']['moved to'] = 'history';
  573. $data['history']['table']['group'] = t('Content');
  574. // Explain how this table joins to others.
  575. $data['history']['table']['join'] = array(
  576. // Directly links to node table.
  577. 'node' => array(
  578. 'table' => 'history',
  579. 'left_field' => 'nid',
  580. 'field' => 'nid',
  581. 'extra' => array(
  582. array('field' => 'uid', 'value' => '***CURRENT_USER***', 'numeric' => TRUE),
  583. ),
  584. ),
  585. );
  586. $data['history']['timestamp'] = array(
  587. 'title' => t('Has new content'),
  588. 'field' => array(
  589. 'handler' => 'views_handler_field_history_user_timestamp',
  590. 'help' => t('Show a marker if the content is new or updated.'),
  591. ),
  592. 'filter' => array(
  593. 'help' => t('Show only content that is new or updated.'),
  594. 'handler' => 'views_handler_filter_history_user_timestamp',
  595. ),
  596. );
  597. return $data;
  598. }
  599. /**
  600. * Implements hook_views_plugins().
  601. */
  602. function node_views_plugins() {
  603. return array(
  604. 'module' => 'views', // This just tells our themes are elsewhere.
  605. 'row' => array(
  606. 'node' => array(
  607. 'title' => t('Content'),
  608. 'help' => t('Display the content with standard node view.'),
  609. 'handler' => 'views_plugin_row_node_view',
  610. 'path' => drupal_get_path('module', 'views') . '/modules/node', // not necessary for most modules
  611. 'base' => array('node'), // only works with 'node' as base.
  612. 'uses options' => TRUE,
  613. 'type' => 'normal',
  614. 'help topic' => 'style-node',
  615. ),
  616. 'node_rss' => array(
  617. 'title' => t('Content'),
  618. 'help' => t('Display the content with standard node view.'),
  619. 'handler' => 'views_plugin_row_node_rss',
  620. 'path' => drupal_get_path('module', 'views') . '/modules/node', // not necessary for most modules
  621. 'theme' => 'views_view_row_rss',
  622. 'base' => array('node'), // only works with 'node' as base.
  623. 'uses options' => TRUE,
  624. 'type' => 'feed',
  625. 'help topic' => 'style-node-rss',
  626. ),
  627. ),
  628. 'argument validator' => array(
  629. 'node' => array(
  630. 'title' => t('Content'),
  631. 'handler' => 'views_plugin_argument_validate_node',
  632. ),
  633. ),
  634. 'argument default' => array(
  635. 'node' => array(
  636. 'title' => t('Content ID from URL'),
  637. 'handler' => 'views_plugin_argument_default_node'
  638. ),
  639. ),
  640. );
  641. }
  642. /**
  643. * Implements hook_preprocess_node().
  644. */
  645. function node_row_node_view_preprocess_node(&$vars) {
  646. $node = $vars['node'];
  647. $options = $vars['view']->style_plugin->row_plugin->options;
  648. // Prevent the comment form from showing up if this is not a page display.
  649. if ($vars['view_mode'] == 'full' && !$vars['view']->display_handler->has_path()) {
  650. $node->comment = FALSE;
  651. }
  652. if (!$options['links']) {
  653. unset($vars['content']['links']);
  654. }
  655. if (!empty($options['comments']) && user_access('access comments') && $node->comment) {
  656. $vars['content']['comments'] = comment_node_page_additions($node);
  657. }
  658. }
  659. /**
  660. * Implements hook_views_query_substitutions().
  661. */
  662. function node_views_query_substitutions() {
  663. return array(
  664. '***ADMINISTER_NODES***' => intval(user_access('administer nodes')),
  665. '***VIEW_OWN_UNPUBLISHED_NODES***' => intval(user_access('view own unpublished content')),
  666. '***BYPASS_NODE_ACCESS***' => intval(user_access('bypass node access')),
  667. );
  668. }
  669. /**
  670. * Implements hook_views_analyze().
  671. */
  672. function node_views_analyze($view) {
  673. $ret = array();
  674. // Check for something other than the default display:
  675. if ($view->base_table == 'node') {
  676. foreach ($view->display as $id => $display) {
  677. if (empty($display->handler)) {
  678. continue;
  679. }
  680. if (!$display->handler->is_defaulted('access') || !$display->handler->is_defaulted('filters')) {
  681. // check for no access control
  682. $access = $display->handler->get_option('access');
  683. if (empty($access['type']) || $access['type'] == 'none') {
  684. $select = db_select('role', 'r');
  685. $select->innerJoin('role_permission', 'p', 'r.rid = p.rid');
  686. $result = $select->fields('r', array('name'))
  687. ->fields('p', array('permission'))
  688. ->condition('r.name', array('anonymous user', 'authenticated user'), 'IN')
  689. ->condition('p.permission', 'access content')
  690. ->execute();
  691. foreach ($result as $role) {
  692. $role->safe = TRUE;
  693. $roles[$role->name] = $role;
  694. }
  695. if (!($roles['anonymous user']->safe && $roles['authenticated user']->safe)) {
  696. $ret[] = views_ui_analysis(t('Some roles lack permission to access content, but display %display has no access control.', array('%display' => $display->display_title)), 'warning');
  697. }
  698. $filters = $display->handler->get_option('filters');
  699. foreach ($filters as $filter) {
  700. if ($filter['table'] == 'node' && ($filter['field'] == 'status' || $filter['field'] == 'status_extra')) {
  701. continue 2;
  702. }
  703. }
  704. $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');
  705. }
  706. }
  707. }
  708. }
  709. foreach ($view->display as $id => $display) {
  710. if ($display->display_plugin == 'page') {
  711. if ($display->handler->get_option('path') == 'node/%') {
  712. $ret[] = views_ui_analysis(t('Display %display has set node/% as path. This will not produce what you want. If you want to have multiple versions of the node view, use panels.', array('%display' => $display->display_title)), 'warning');
  713. }
  714. }
  715. }
  716. return $ret;
  717. }

Related topics