You are here

function theme_biblio_download_links in Bibliography Module 7

Same name and namespace in other branches
  1. 6.2 includes/biblio_theme.inc \theme_biblio_download_links()
  2. 6 biblio_theme.inc \theme_biblio_download_links()
  3. 7.2 includes/biblio.theme.inc \theme_biblio_download_links()
3 theme calls to theme_biblio_download_links()
biblio_entry in includes/biblio.pages.inc
biblio_handler_citation::render in views/biblio_handler_citation.inc
Render the field.
theme_biblio_entry in includes/biblio_theme.inc

File

includes/biblio_theme.inc, line 987

Code

function theme_biblio_download_links($variables) {
  static $langcode = NULL;
  $file_links = array();
  $node = $variables['node'];
  if (!isset($langcode)) {
    $langcode = $GLOBALS['language_content']->language;
  }
  $fields = field_attach_view('node', $node, 'full', $langcode);
  foreach (element_children($fields) as $field) {
    if ($fields[$field]['#access'] && $fields[$field]['#field_type'] == 'file') {
      foreach ($fields[$field]['#items'] as $delta => $item) {
        if (module_exists('filefield_paths')) {
          $alias = drupal_get_path_alias('filefield_paths/alias/' . $item['fid']);
        }
        $link_type = variable_get('biblio_file_link_type', 'text');
        if ($link_type == 'icon') {
          $url = file_create_url($item['uri']);
          $icon = theme('file_icon', array(
            'file' => (object) $item,
          ));
          $options['html'] = TRUE;
          $options['attributes']['title'] = check_plain($item['filename']);
          $file_links[] = array(
            l($icon, $url, $options),
            format_size($item['filesize']),
          );
        }
        elseif ($link_type == 'text') {
          $file_links[] = array(
            theme('file_link', array(
              'file' => (object) $item,
            )),
            format_size($item['filesize']),
          );
        }
      }
    }
  }
  $files = '';
  if (count($file_links) > 0 && (user_access('show download links') || user_access('show own download links'))) {
    $files .= '<span class="biblio_file_links">';

    // $files .= '&nbsp;' . t('Download') . ':&nbsp;';.
    $file_count = 0;
    foreach ($file_links as $file) {
      $files .= $file[0] . '&nbsp;(' . $file[1] . ')';
    }
    $files .= '</span>';
  }
  return $files;
}