You are here

function views_handler_file_all_files in Views (for Drupal 7) 5

Display all files attached to a given node.

1 call to views_handler_file_all_files()
views_handler_file_listed_files in modules/views_upload.inc

File

modules/views_upload.inc, line 179

Code

function views_handler_file_all_files($fieldinfo, $fielddata, $value, $data, $listed = false) {
  if ($listed) {
    $and = " AND list = 1";
  }
  $links = array();
  $result = db_query("SELECT f.*, fr.* FROM {file_revisions} fr INNER JOIN {files} f ON f.fid = fr.fid WHERE fr.vid = %d {$and}", $data->vid);
  while ($file = db_fetch_object($result)) {

    // link/nolink use file filename; linkdesc/nolinkdesc use file description
    if ($fielddata['options'] == 'link' || $fielddata['options'] == 'nolink') {
      $display_string = $file->filename;
    }
    else {
      $display_string = $file->description;
    }
    if ($fielddata['options'] == 'nolink' || $fielddata['options'] == 'nolinkdesc') {
      $links[] = check_plain($display_string);
    }
    else {
      $links[] = l($display_string, check_url(file_create_url($file->filepath)));
    }
  }
  return implode(' | ', $links);
}