You are here

function event_link in Event 5.2

Same name and namespace in other branches
  1. 5 event.module \event_link()

Provides the links that should be displayed when viewing events.

Parameters

$type the type of link (for example, 'node', 'page', or 'system') being requested:

$node the node that is requesting the link. This is used in conjunction with $type to further determine: what sort of link to display.

$main unused in this method.:

Return value

an array of links, or an empty array if no links apply for the criteria passed to this method.

Related topics

File

./event.module, line 37

Code

function event_link($type, $node = NULL, $teaser = FALSE) {
  $links = array();
  if ($type == 'node') {

    // node links
    if (event_enabled_state($node->type) == 'all') {
      $links['event_calendar'] = array(
        'title' => t('Calendar'),
        'href' => 'event/' . _event_format_url($node->event['start_exploded']),
      );
    }
    elseif (event_enabled_state($node->type) == 'solo') {
      $links['event_calendar'] = array(
        'title' => t('Calendar'),
        'href' => 'event/' . _event_format_url($node->event['start_exploded']) . '/month/' . $node->type,
      );
    }
  }
  elseif (user_access('access content')) {

    // calendar links
    // build a full list of links...
    $base = 'event/' . _event_format_url($node->event['start_exploded']) . '/';
    $links['event_month'] = array(
      'title' => t('Month'),
      'href' => $base . 'month/' . $node->filter,
      'attributes' => array(
        'title' => t('Month view'),
      ),
    );
    $links['event_week'] = array(
      'title' => t('Week'),
      'href' => $base . 'week/' . $node->filter,
      'attributes' => array(
        'title' => t('Week view'),
      ),
    );
    $links['event_day'] = array(
      'title' => t('Day'),
      'href' => $base . 'day/' . $node->filter,
      'attributes' => array(
        'title' => t('Day view'),
      ),
    );
    $links['event_table'] = array(
      'title' => t('Table'),
      'href' => $base . 'table/' . $node->filter,
      'attributes' => array(
        'title' => t('Table view'),
      ),
    );
    $links['event_list'] = array(
      'title' => t('List'),
      'href' => $base . 'list/' . $node->filter,
      'attributes' => array(
        'title' => t('List view'),
      ),
    );

    // ...then subtract out the one we're viewing.
    switch ($type) {
      case 'event_month':
        unset($links['event_month']);
        break;
      case 'event_week':
        unset($links['event_week']);
        break;
      case 'event_day':
        unset($links['event_day']);
        break;
      case 'event_table':
        unset($links['event_table']);
        break;
      case 'event_list':
        unset($links['event_list']);
        break;
      default:
        $links = array();
    }
  }
  return $links;
}