function upload_link

6.x upload.module upload_link($type, $node = NULL, $teaser = FALSE)

Implementation of hook_link().

File

drupal-6.x/modules/upload/upload.module, line 51
File-handling and attaching files to nodes.

Code

function upload_link($type, $node = NULL, $teaser = FALSE) {
  $links = array();

  // Display a link with the number of attachments
  if ($teaser && $type == 'node' && isset($node->files) && user_access('view uploaded files')) {
    $num_files = 0;
    foreach ($node->files as $file) {
      if ($file->list) {
        $num_files++;
      }
    }
    if ($num_files) {
      $links['upload_attachments'] = array(
        'title' => format_plural($num_files, '1 attachment', '@count attachments'),
        'href' => "node/$node->nid",
        'attributes' => array('title' => t('Read full article to view attachments.')),
        'fragment' => 'attachments'
      );
    }
  }

  return $links;
}