views_plugin_row_aggregator_rss.inc

  1. 3.x modules/aggregator/views_plugin_row_aggregator_rss.inc
  2. 2.x modules/aggregator/views_plugin_row_aggregator_rss.inc

Contains the Aggregator Item RSS row style plugin.

File

modules/aggregator/views_plugin_row_aggregator_rss.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Contains the Aggregator Item RSS row style plugin.
  5. */
  6. /**
  7. * Plugin which loads an aggregator item and formats it as an RSS item.
  8. */
  9. class views_plugin_row_aggregator_rss extends views_plugin_row {
  10. var $base_table = 'aggregator_item';
  11. var $base_field = 'iid';
  12. function option_definition() {
  13. $options = parent::option_definition();
  14. $options['item_length'] = array('default' => 'default');
  15. return $options;
  16. }
  17. function options_form(&$form, &$form_state) {
  18. $form['item_length'] = array(
  19. '#type' => 'select',
  20. '#title' => t('Display type'),
  21. '#options' => array(
  22. 'fulltext' => t('Full text'),
  23. 'teaser' => t('Title plus teaser'),
  24. 'title' => t('Title only'),
  25. 'default' => t('Use default RSS settings'),
  26. ),
  27. '#default_value' => $this->options['item_length'],
  28. );
  29. }
  30. function render($row) {
  31. $iid = $row->{$this->field_alias};
  32. $sql = "SELECT ai.iid, ai.fid, ai.title, ai.link, ai.author, ai.description, ";
  33. $sql .= "ai.timestamp, ai.guid, af.title AS feed_title, ai.link AS feed_LINK ";
  34. $sql .= "FROM {aggregator_item} ai LEFT JOIN {aggregator_feed} af ON ai.fid = af.fid ";
  35. $sql .= "WHERE ai.iid = :iid";
  36. $item = db_query($sql, array(':iid' => $iid))->fetchObject();
  37. $item->elements = array(
  38. array(
  39. 'key' => 'pubDate',
  40. 'value' => gmdate('r', $item->timestamp),
  41. ),
  42. array(
  43. 'key' => 'dc:creator',
  44. 'value' => $item->author,
  45. ),
  46. array(
  47. 'key' => 'guid',
  48. 'value' => $item->guid,
  49. 'attributes' => array('isPermaLink' => 'false')
  50. ),
  51. );
  52. foreach ($item->elements as $element) {
  53. if (isset($element['namespace'])) {
  54. $this->view->style_plugin->namespaces = array_merge($this->view->style_plugin->namespaces, $element['namespace']);
  55. }
  56. }
  57. return theme($this->theme_functions(), array(
  58. 'view' => $this->view,
  59. 'options' => $this->options,
  60. 'row' => $item
  61. ));
  62. }
  63. }