You are here

function heartbeat_heartbeat_activity_view in Heartbeat 7

Implements hook_heartbeat_activity_view().

Parameters

HeartbeatActivity $heartbeatActivity: The activity message object.

File

./heartbeat.module, line 661
Module file for heartbeat activity. Basic hook implementations and helper functions will be found here.

Code

function heartbeat_heartbeat_activity_view(HeartbeatActivity $heartbeatActivity, $view_mode = 'full', $language = NULL) {

  // Avatar.
  if (!empty($heartbeatActivity->actor->picture)) {
    if (is_numeric($heartbeatActivity->actor->picture)) {
      $uri = file_load($heartbeatActivity->actor->picture)->uri;
    }
    else {
      $uri = $heartbeatActivity->actor->picture->uri;
    }
    $heartbeatActivity->content['avatar'] = theme('heartbeat_activity_avatar', array(
      'heartbeatactivity' => $heartbeatActivity,
      'uri' => $uri,
    ));
  }
  elseif (variable_get('user_picture_default', '')) {
    $heartbeatActivity->content['avatar'] = theme('heartbeat_activity_avatar', array(
      'heartbeatactivity' => $heartbeatActivity,
      'uri' => variable_get('user_picture_default', ''),
    ));
  }
  if ($heartbeatActivity->uid > 0 && $heartbeatActivity->actor) {
    $heartbeatActivity->content['username'] = array(
      '#markup' => theme('username', array(
        'account' => $heartbeatActivity->actor,
      )),
    );
  }

  // Activity message.
  $filter = new stdClass();
  $filter->settings = array(
    'filter_url_length' => 60,
  );
  $heartbeatActivity->content['message'] = array(
    '#attributes' => array(
      'class' => array(
        'activity-message',
      ),
    ),
    '#title' => t('Heartbeat activity message'),
    '#markup' => _filter_url($heartbeatActivity->message, $filter),
  );

  // Timestamp of occurrence.
  $heartbeatActivity->content['time'] = array(
    '#title' => t('Activity on'),
    '#markup' => theme('heartbeat_time_ago', array(
      'heartbeat_activity' => $heartbeatActivity,
    )),
  );

  // Buttons for this message.
  $heartbeatActivity->content['buttons'] = array(
    '#markup' => theme('heartbeat_buttons', array(
      'heartbeat_activity' => $heartbeatActivity,
    )),
  );
}