views_plugin_row_comment_view.inc

  1. 3.x modules/comment/views_plugin_row_comment_view.inc
  2. 2.x modules/comment/views_plugin_row_comment_view.inc

Contains the node RSS row style plugin.

File

modules/comment/views_plugin_row_comment_view.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Contains the node RSS row style plugin.
  5. */
  6. /**
  7. * Plugin which performs a comment_view on the resulting object.
  8. */
  9. class views_plugin_row_comment_view extends views_plugin_row {
  10. function option_definition() {
  11. $options = parent::option_definition();
  12. $options['links'] = array('default' => TRUE);
  13. return $options;
  14. }
  15. function options_form(&$form, &$form_state) {
  16. $form['links'] = array(
  17. '#type' => 'checkbox',
  18. '#title' => t('Display links'),
  19. '#default_value' => $this->options['links'],
  20. );
  21. }
  22. function pre_render($result) {
  23. $cids = array();
  24. $this->comments = array();
  25. foreach ($result as $row) {
  26. $cids[] = $row->cid;
  27. }
  28. if (count($cids) > 1) {
  29. $placeholder = " IN (" . implode(', ', array_fill(0, sizeof($cids), '%d')) . ")";
  30. }
  31. else {
  32. $placeholder = " = %d";
  33. }
  34. $cresult = db_query("SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.signature, u.picture, u.data, c.thread, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid $placeholder", $cids);
  35. while ($comment = db_fetch_object($cresult)) {
  36. $comment = drupal_unpack($comment);
  37. $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
  38. $comment->depth = count(explode('.', $comment->thread)) - 1;
  39. $this->comments[$comment->cid] = $comment;
  40. }
  41. }
  42. }