You are here

function theme_biblio_download_links in Bibliography Module 6

Same name and namespace in other branches
  1. 6.2 includes/biblio_theme.inc \theme_biblio_download_links()
  2. 7 includes/biblio_theme.inc \theme_biblio_download_links()
  3. 7.2 includes/biblio.theme.inc \theme_biblio_download_links()
1 theme call to theme_biblio_download_links()
theme_biblio_entry in ./biblio_theme.inc

File

./biblio_theme.inc, line 831

Code

function theme_biblio_download_links($node = NULL) {
  $files = '';
  if (!empty($node->files) && count($node->files) > 0 && user_access('view uploaded files')) {
    $files .= '<span class="biblio_file_links">';
    $files .= '&nbsp;' . t('Download') . ':&nbsp;';
    $file_count = 0;
    foreach ($node->files as $file) {
      if ($file->list) {
        if (variable_get('biblio_download_links_to_node', 0)) {
          $href = 'biblio/view/' . $node->nid;
        }
        else {
          $alias = FALSE;
          if (module_exists('filefield_paths')) {
            $alias = drupal_get_path_alias('filefield_paths/alias/' . $file->fid);
          }
          $href = $alias ? $alias : file_create_url($file->filepath);
        }
        $text = $file->description ? $file->description : $file->filename;
        if ($file_count) {
          $files .= '; ';
        }
        $files .= l($text, $href) . '&nbsp;(' . format_size($file->filesize) . ')';
        $file_count++;
      }
    }
    $files .= '</span>';
  }
  if (module_exists('filefield')) {

    // now lets get any CCK FileField files...
    $fields = filefield_get_field_list('biblio');
    foreach ($fields as $field_name => $field) {
      if (filefield_view_access($field_name, $node)) {
        $field_files = filefield_get_node_files($node, $field_name);
        if ($field_files) {
          foreach ($field_files as $file) {
            if ($file['fid']) {
              $files .= theme('filefield_file', $file);
            }
          }
        }
      }
    }
  }
  return $files;
}