You are here

function video_link in Video 5

Same name and namespace in other branches
  1. 6 video.module \video_link()
  2. 6.2 video.module \video_link()

Internal Drupal links hook

Parameters

$type: string type of link to show

$node: object of node information

Return value

array of link information

File

./video.module, line 138
Display video in Quicktime MOV, Realmedia RM, Flash FLV & SWF, or Windows Media WMV formats.

Code

function video_link($type, $node = NULL) {
  $link = array();

  // Node links for a video
  if ($type == 'node' && $node->type == 'video' && $node->vidfile && user_access('access video')) {

    //If the video is of type youtube and multi-file downloads aren't turned on don't show the download link.
    if (!video_support_download($node) || $node->disable_multidownload == 1) {
      $display_download_link = 0;
    }
    else {
      $display_download_link = variable_get('video_displaydownloadlink', 1);
    }
    if ($display_download_link == 1) {
      $link['video_download'] = array(
        'title' => t('download'),
        'href' => "node/{$node->nid}/download",
        'attributes' => array(
          'class' => 'outgoing',
          'title' => t('download @link', array(
            '@link' => $node->title,
          )),
        ),
      );
    }
    if (variable_get('video_displayplaytime', 1) && $node->playtime_seconds > 0) {

      // hide the duration if the admin hided it or we don't have playtime informations
      $link['playtime'] = array(
        'title' => format_interval($node->playtime_seconds),
      );
    }
    if (variable_get('video_displayfilesize', 1) && $node->size != 0) {
      $link['size'] = array(
        'title' => format_size($node->size),
      );
    }
    if (variable_get('video_playcounter', 1) && user_access('view play counter')) {
      $link['play_counter'] = array(
        'title' => format_plural($node->play_counter, '1 play', '@count plays'),
      );
    }
    if (variable_get('video_downloadcounter', 1) && user_access('view download counter') && video_support_download($node)) {
      $link['download_counter'] = array(
        'title' => format_plural($node->download_counter, '1 download', '@count downloads'),
      );
    }
    return $link;
  }
  return array();
}