1 views_plugin_row_comment_rss.inc | views_plugin_row_comment_rss::render($row) |
Render a row object. This usually passes through to a theme template of some form, but not always.
Parameters
stdClass $row: A single row of the query result, so an element of $view->result.
Return value
string: The rendered output of a single row, used by the style plugin.
Overrides views_plugin_row::render
File
- core/
modules/ comment/ views/ views_plugin_row_comment_rss.inc, line 78 - Contains the comment RSS row style plugin.
Class
- views_plugin_row_comment_rss
- Plugin which formats the comments as RSS items.
Code
function render($row) {
global $base_url;
$cid = $row->{$this->field_alias};
if (!is_numeric($cid)) {
return;
}
$item_length = $this->options['item_length'];
if ($item_length == 'default') {
$item_length = config_get('system.core', 'rss_viewmode');
}
// Load the specified comment and its associated node:
$comment = $this->comments[$cid];
if (empty($comment) || empty($this->nodes[$comment->nid])) {
return;
}
$item_text = '';
$uri = entity_uri('comment', $comment);
$comment->link = url($uri['path'], $uri['options'] + array('absolute' => TRUE));
$comment->rss_namespaces = array();
$comment->rss_elements = array(
array(
'key' => 'pubDate',
'value' => gmdate('r', $comment->created),
),
array(
'key' => 'dc:creator',
'value' => user_format_name($comment),
),
array(
'key' => 'guid',
'value' => 'comment ' . $comment->cid . ' at ' . $base_url,
'attributes' => array('isPermaLink' => 'false'),
),
);
// The comment gets built and modules add to or modify
// $comment->rss_elements and $comment->rss_namespaces.
$build = comment_view($comment, $this->nodes[$comment->nid], 'rss');
unset($build['#theme']);
if (!empty($comment->rss_namespaces)) {
$this->view->style_plugin->namespaces = array_merge($this->view->style_plugin->namespaces, $comment->rss_namespaces);
}
// Hide the links if desired.
if (!$this->options['links']) {
hide($build['links']);
}
if ($item_length != 'title') {
// We render comment contents and force links to be last.
$build['links']['#weight'] = 1000;
$item_text .= backdrop_render($build);
}
$item = new stdClass();
$item->description = $item_text;
$item->title = $comment->subject;
$item->link = $comment->link;
$item->elements = $comment->rss_elements;
$item->cid = $comment->cid;
return theme($this->theme_functions(), array(
'view' => $this->view,
'options' => $this->options,
'row' => $item
));
}