Exemplo n.º 1
0
function phptemplate_views_rss_feed_recent_blog_posts_rss($view, $nodes, $type)
{
    if ($type == 'block') {
        return;
    }
    global $base_url;
    $channel = array('title' => views_get_title($view, 'page'), 'link' => url($view->feed_url ? $view->feed_url : $view->real_url, NULL, NULL, true), 'description' => $view->description);
    $item_length = 'fulltext';
    $namespaces = array('xmlns:dc="http://purl.org/dc/elements/1.1/"');
    // Except for the original being a while and this being a foreach, this is
    // completely cut & pasted from node.module.
    foreach ($nodes as $node) {
        // Load the specified node:
        $item = node_load($node->nid);
        $link = url("node/{$node->nid}", NULL, NULL, 1);
        if ($item_length != 'title') {
            $teaser = $item_length == 'teaser' ? TRUE : FALSE;
            // Filter and prepare node teaser
            if (node_hook($item, 'view')) {
                node_invoke($item, 'view', $teaser, FALSE);
            } else {
                $item = node_prepare($item, $teaser);
            }
            // Allow modules to change $node->teaser before viewing.
            node_invoke_nodeapi($item, 'view', $teaser, FALSE);
        }
        // Allow modules to add additional item fields
        $extra = node_invoke_nodeapi($item, 'rss item');
        $extra = array_merge($extra, array(array('key' => 'pubDate', 'value' => date('r', $item->created)), array('key' => 'dc:creator', 'value' => $item->name), array('key' => 'guid', 'value' => $item->nid . ' at ' . $base_url, 'attributes' => array('isPermaLink' => 'false'))));
        foreach ($extra as $element) {
            if ($element['namespace']) {
                $namespaces = array_merge($namespaces, $element['namespace']);
            }
        }
        // Prepare the item description
        switch ($item_length) {
            case 'fulltext':
                $item_text = $item->body;
                break;
            case 'teaser':
                $item_text = $item->teaser;
                if ($item->readmore) {
                    $item_text .= '<p>' . l(t('read more'), 'node/' . $item->nid, NULL, NULL, NULL, TRUE) . '</p>';
                }
                break;
            case 'title':
                $item_text = '';
                break;
        }
        $items .= format_rss_item($item->title, $link, $item_text, $extra);
    }
    $channel_defaults = array('version' => '2.0', 'title' => variable_get('site_name', 'drupal') . ' - ' . variable_get('site_slogan', ''), 'link' => $base_url, 'description' => variable_get('site_mission', ''), 'language' => $GLOBALS['locale']);
    $channel = array_merge($channel_defaults, $channel);
    $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
    $output .= "<rss version=\"" . $channel["version"] . "\" xml:base=\"" . $base_url . "\" " . implode(' ', $namespaces) . ">\n";
    $output .= format_rss_channel($channel['title'], $channel['link'], $channel['description'], $items, $channel['language']);
    $output .= "</rss>\n";
    drupal_set_header('Content-Type: text/xml; charset=utf-8');
    print $output;
    module_invoke_all('exit');
    exit;
}
        $datefieldname = "pubDate";
    } else {
        $datefieldname = "ttlr:publishDate";
    }
    $arrobj = (array) $obj;
    $arrobj[$datefieldname] = date('D, d M Y H:i:s O', $post_date);
    $arrobj['ttlr:votes'] = $row->votingapi_cache_node_points_vote_sum_value;
    $arrobj['ttlr:technorati_authority'] = $row->node_data_field_url_field_technorati_authority_value;
    $arrobj['ttlr:source_profile'] = url('node/' . $row->node_node_data_field_source_nid, array('absolute' => TRUE));
    $arrobj['ttlr:orig_url'] = $row->feedapi_node_item_url;
    $source_title = $row->node_node_data_field_source_title;
    if (empty($source_title)) {
        //Use URL instead
        $source_title = $row->node_node_data_field_source_node_data_field_url_field_url_value;
    }
    $source_title = mentions_rss_safe_str($source_title);
    $arrobj[] = array('key' => 'source', 'value' => $source_title, 'attributes' => array('url' => url($row->node_node_data_field_source_node_data_field_url_field_url_value, array('absolute' => TRUE))));
    $items .= format_rss_item($title, $link, $description, $arrobj);
}
drupal_set_header('Content-Type: application/rss+xml; charset=utf-8');
$site_name = variable_get('site_name', 'Tattler Feed');
$url = url('rss/mentions');
$description = 'Mentions feed generated from a Tattler instance';
$output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
$output .= "<rss xmlns:ttlr=\"http://tattlerapp.com/rss/tattler/\" version=\"2.0\">\n";
$output .= format_rss_channel(t('@site_name Feed', array('@site_name' => $site_name)), $url, $description, $items, $langcode);
$output .= "</rss>\n";
print $output;
module_invoke_all('exit');
//e.g. let tokenauth clear the session.
exit;