function views_plugin_row_rss_fields::render

Overrides views_plugin_row::render

File

plugins/views_plugin_row_rss_fields.inc, line 122

Class

views_plugin_row_rss_fields
Renders an RSS item based on fields.

Code

public function render($row) {
    static $row_index;
    if (!isset($row_index)) {
        $row_index = 0;
    }
    if (function_exists('rdf_get_namespaces')) {
        // Merge RDF namespaces in the XML namespaces in case they are used
        // further in the RSS content.
        $xml_rdf_namespaces = array();
        foreach (rdf_get_namespaces() as $prefix => $uri) {
            $xml_rdf_namespaces['xmlns:' . $prefix] = $uri;
        }
        $this->view->style_plugin->namespaces += $xml_rdf_namespaces;
    }
    // Create the RSS item object.
    $item = new stdClass();
    $item->title = $this->get_field($row_index, $this->options['title_field']);
    $item->link = url($this->get_field($row_index, $this->options['link_field']), array(
        'absolute' => TRUE,
    ));
    $item->description = $this->get_field($row_index, $this->options['description_field']);
    $item->elements = array(
        array(
            'key' => 'pubDate',
            'value' => $this->get_field($row_index, $this->options['date_field']),
        ),
        array(
            'key' => 'dc:creator',
            'value' => $this->get_field($row_index, $this->options['creator_field']),
            'namespace' => array(
                'xmlns:dc' => 'http://purl.org/dc/elements/1.1/',
            ),
        ),
    );
    $guid_is_permalink_string = 'false';
    $item_guid = $this->get_field($row_index, $this->options['guid_field_options']['guid_field']);
    if ($this->options['guid_field_options']['guid_field_is_permalink']) {
        $guid_is_permalink_string = 'true';
        $item_guid = url($item_guid, array(
            'absolute' => TRUE,
        ));
    }
    $item->elements[] = array(
        'key' => 'guid',
        'value' => $item_guid,
        'attributes' => array(
            'isPermaLink' => $guid_is_permalink_string,
        ),
    );
    $row_index++;
    foreach ($item->elements as $element) {
        if (isset($element['namespace'])) {
            $this->view->style_plugin->namespaces = array_merge($this->view->style_plugin->namespaces, $element['namespace']);
        }
    }
    return theme($this->theme_functions(), array(
        'view' => $this->view,
        'options' => $this->options,
        'row' => $item,
        'field_alias' => isset($this->field_alias) ? $this->field_alias : '',
    ));
}