You are here

function template_preprocess_views_view_row_heartbeat in Heartbeat 7

Same name and namespace in other branches
  1. 6.3 views/theme/theme.inc \template_preprocess_views_view_row_heartbeat()

Template helper for theme_views_view_row_heartbeat.

File

./heartbeat.views.inc, line 257
Heartbeat Views support. Declares the required tables for Views.

Code

function template_preprocess_views_view_row_heartbeat(&$vars) {
  $options = $vars['options'];

  // Make sure the variables are defined.
  $vars['heartbeat_activity'] = '';
  $vars['comments'] = '';
  $row_plugin = $vars['view']->style_plugin->row_plugin;
  if (!empty($vars['row']->uaid)) {
    $uaid = $vars['row']->uaid;
  }

  // Invalid messages, messages restricted by access or grouped messages
  // result in the absense of a  user activity ID.
  if (!is_numeric($uaid) || !isset($row_plugin->activities[$uaid])) {
    return;
  }
  $heartbeat_activity = $row_plugin->activities[$uaid];

  // This needs to represent what
  // $build = heartbeat_stream_view($heartbeatStream);
  // does for built-in blocks and pages.
  if ($row_plugin->stream
    ->needsModal()) {

    // Add CTools modal requirements.
    heartbeat_ctools_modal_prepare();
  }
  if (variable_get('heartbeat_debug', 0)) {
    drupal_set_message($row_plugin->stream
      ->getErrors());
  }

  // Add the javascript and css files.
  drupal_add_js(drupal_get_path('module', 'heartbeat') . '/js/heartbeat.js');
  if (variable_get('heartbeat_include_default_style', 1)) {
    drupal_add_css(drupal_get_path('module', 'heartbeat') . '/css/heartbeat.css');
  }
  $heartbeat_activity->view = $vars['view'];

  // Detect which build module should be used.
  $heartbeat_activity->view_mode = !empty($options['view_mode']) ? $options['view_mode'] : 'full';
  $content = heartbeat_activity_view($heartbeat_activity);

  //$content = $content['heartbeat_activities'][$heartbeat_activity->uaid];
  $vars['heartbeat_activity'] = drupal_render($content);
}