You are here

function views_plugin_style_rss_fields::map_rows in Views RSS 7

Same name and namespace in other branches
  1. 6 views/views_plugin_style_rss_fields.inc \views_plugin_style_rss_fields::map_rows()

Map views row result to an RSS item.

File

views/views_plugin_style_rss_fields.inc, line 162

Class

views_plugin_style_rss_fields
Extend the view_plugin_style class to provide an RSS view style.

Code

function map_rows($rows) {

  // Fields must be rendered in order as of Views 2.3, so we will pre-render everything.
  $renders = array();
  $keys = array_keys($this->view->field);
  foreach ($rows as $count => $row) {
    $this->view->row_index = $count;
    foreach ($keys as $id) {
      $field = $this->view->field[$id];

      // Wut, wuuuut??? crazy, yeah, but tere is no solid way of getting raw
      // query result data.
      // See: http://drupal.org/node/1172970
      if ($field->field_alias == 'nid') {
        $field_alias = 'field_' . $field->field;
      }
      else {
        $field_alias = $field->field_alias;
      }
      $renders[$count][$id]['#markup'] = $field
        ->theme($row);

      // Link field causes problems.
      // Maybe this whole map_rows thing isn't the right way to go.
      // Do we need a custom row plugin?
      if ($field_alias != 'unknown' && isset($row->{$field_alias})) {
        $renders[$count][$id]['#raw'] = $row->{$field_alias};
      }
    }
  }
  $items = array();
  foreach ($renders as $id => $row) {
    $item = array();
    foreach (array_merge($this->options['fields'], $this->options['georss']) as $key => $val) {
      if (isset($this->view->field[$val])) {
        $item[$key] = $row[$val];
      }
    }
    $items[] = $item;
  }
  return $items;
}