You are here

function theme_heartbeat_stream_more_link in Heartbeat 6.4

Helper function for a more link on streams (older messages) Should only be called when hasMoreMessages resulted to TRUE

2 theme calls to theme_heartbeat_stream_more_link()
heartbeat_block in ./heartbeat.module
Implementation of hook_blocks().
heartbeat_messages_page in ./heartbeat.pages.inc
Page callback function to load an activity stream page.

File

./heartbeat.module, line 1801

Code

function theme_heartbeat_stream_more_link($heartbeatAccess, $offset_time, $page = TRUE, $absolute = FALSE) {
  $ajax_pager = $page ? $heartbeatAccess
    ->getStream()->page_pager_ajax : $heartbeatAccess
    ->getStream()->block_show_pager == 2 || $heartbeatAccess
    ->getStream()->block_show_pager == 3;
  $attributes = array(
    'html' => FALSE,
    'attributes' => array(
      'class' => 'heartbeat-older-messages',
    ),
  );
  if ($_GET['group_nid']) {
    $attributes['query'] .= 'group_nid=' . $_GET['group_nid'];
  }
  elseif (module_exists('og')) {
    if ($group = og_get_group_context()) {
      $attributes['query'] .= 'group_nid=' . $group->nid;
    }
  }
  if (isset($_GET['filters'])) {
    $attributes['query'] = 'filters=' . $_GET['filters'];
  }
  if ($absolute) {
    $attributes['absolute'] = TRUE;
  }
  $content = '';
  $content .= '<div class="heartbeat-more-messages-wrapper">';
  if ($ajax_pager) {
    $path = 'heartbeat/' . $heartbeatAccess
      ->getAccess();
    $path .= '/' . $offset_time;

    // Add a fourth parameter to indicate that where on a profile page.
    $account = -1;
    if (arg(0) == 'user' && is_numeric(arg(1)) && variable_get('heartbeat_show_user_profile_messages_' . $heartbeatAccess
      ->getStream()->name, 1)) {
      $path .= '/' . arg(1);
      $account = arg(1);
    }
    elseif (isset($_REQUEST['account'])) {
      $path .= '/' . $_REQUEST['account'];
      $account = $_REQUEST['account'];
    }
    if ($ajax_pager) {
      $attributes['attributes']['onclick'] = 'javascript:Drupal.heartbeat.getOlderMessages(this, ' . (int) $page . ', ' . $account . '); return false;';
      if (method_exists($heartbeatAccess, 'getGroup')) {
        $attributes['attributes']['class'] = 'heartbeat-group-' . $heartbeatAccess
          ->getGroup()->nid;
      }
    }
    $formattedlink = l(t('Older messages'), $path, $attributes) . '<span class="heartbeat-messages-throbber">&nbsp;</span>';
    $content .= $formattedlink;
  }

  // Blocks link to the pages.
  if (!$page && (!$ajax_pager || $heartbeatAccess
    ->getStream()->block_show_pager == 3)) {
    $path = 'heartbeat/' . $heartbeatAccess
      ->getAccess();
    if (isset($attributes['attributes']['onclick'])) {
      unset($attributes['attributes']['onclick']);
    }
    $fulllink = '<div class="more fullarchive heartbeat-full">' . l(t('Full list'), $path, $attributes) . '</div>';
    $content .= $fulllink;
  }
  $content .= '</div>';
  return $content;
}