comment.views.inc 21 KB

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