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. function option_definition() {
  11. $options = parent::option_definition();
  12. $options['item_length'] = array('default' => 'default');
  13. return $options;
  14. }
  15. function options_form(&$form, &$form_state) {
  16. $form['item_length'] = array(
  17. '#type' => 'select',
  18. '#title' => t('Display type'),
  19. '#options' => array(
  20. 'fulltext' => t('Full text'),
  21. 'teaser' => t('Title plus teaser'),
  22. 'title' => t('Title only'),
  23. 'default' => t('Use default RSS settings'),
  24. ),
  25. '#default_value' => $this->options['item_length'],
  26. );
  27. }
  28. function render($row) {
  29. $sql = "SELECT ai.iid, ai.fid, ai.title, ai.link, ai.author, ai.description, ";
  30. $sql .= "ai.timestamp, ai.guid, af.title AS feed_title, ai.link AS feed_LINK ";
  31. $sql .= "FROM {aggregator_item} ai LEFT JOIN {aggregator_feed} af ON ai.fid = af.fid ";
  32. $sql .= "WHERE ai.iid = %d";
  33. $item = db_fetch_object(db_query($sql, $row->iid));
  34. $item->elements = array(
  35. array('key' => 'pubDate', 'value' => gmdate('r', $item->timestamp)),
  36. array(
  37. 'key' => 'dc:creator',
  38. 'value' => $item->author,
  39. 'namespace' => array('xmlns:dc' => 'http://purl.org/dc/elements/1.1/'),
  40. ),
  41. array(
  42. 'key' => 'guid',
  43. 'value' => $item->guid,
  44. 'attributes' => array('isPermaLink' => 'false')
  45. ),
  46. );
  47. foreach ($item->elements as $element) {
  48. if (isset($element['namespace'])) {
  49. $this->view->style_plugin->namespaces = array_merge($this->view->style_plugin->namespaces, $element['namespace']);
  50. }
  51. }
  52. return theme($this->theme_functions(), $this->view, $this->options, $item);
  53. }
  54. }