function views_plugin_row_heartbeat_rss::render in Heartbeat 7
Same name and namespace in other branches
- 6.4 views/views_plugin_row_heartbeat_rss.inc \views_plugin_row_heartbeat_rss::render()
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
- views/
views_plugin_row_heartbeat_rss.inc, line 86 - Contains the heartbeat activity view row style plugin.
Class
- views_plugin_row_heartbeat_rss
- Plugin which performs a heartbeat_activity_view on the resulting object.
Code
function render($row) {
// For the most part, this code is taken from node_feed() in node.module
global $base_url;
$uaid = $row->{$this->field_alias};
if (!is_numeric($uaid)) {
return;
}
$item_length = $this->options['item_length'];
// Load the specified activity:
if (!isset($this->activities[$uaid])) {
return;
}
$activity = $this->activities[$uaid];
$item_text = '';
$activity->rss_namespaces = array(
'xmlns:dc' => 'http://purl.org/dc/elements/1.1/',
);
$activity->rss_elements = array(
array(
'key' => 'pubDate',
'value' => gmdate('r', $activity->timestamp),
),
array(
'key' => 'dc:creator',
'value' => $activity->actor->name,
),
array(
'key' => 'guid',
'value' => $activity->uaid . ' at ' . $base_url,
'attributes' => array(
'isPermaLink' => 'false',
),
),
);
// The node gets built and modules add to or modify $node->rss_elements
// and $node->rss_namespaces.
// Remove previously built content, if exists.
$activity->content = array();
$view_mode = 'default';
// Build fields content.
field_attach_prepare_view('heartbeat_activity', array(
$activity->uaid => $activity,
), $view_mode);
entity_prepare_view('heartbeat_activity', array(
$activity->uaid => $activity,
));
$activity->content += field_attach_view('heartbeat_activity', $activity, $view_mode, $activity->language);
// Populate $message->content with a render() array.
$hook = 'heartbeat_activity_view';
foreach (module_implements($hook) as $module) {
$function = $module . '_' . $hook;
if (function_exists($function)) {
$result = $function($activity, $activity->view_mode, $activity->language);
}
}
$this->view->style_plugin->namespaces = array_merge($this->view->style_plugin->namespaces, $activity->rss_namespaces);
// Unset the attachements and buttons.
unset($activity->content['attachments']);
unset($activity->content['buttons']);
if (!empty($activity->message)) {
$item_text .= drupal_render($activity->content);
}
$item = new stdClass();
$item->description = $item_text;
$item->title = '';
$item->link = url("heartbeat/message/{$activity->uaid}", array(
'absolute' => TRUE,
));
$item->elements = $activity->rss_elements;
$item->uaid = $activity->uaid;
return theme($this
->theme_functions(), array(
'view' => $this->view,
'options' => $this->options,
'row' => $item,
));
}