You are here

function theme_download_count_upload_attachments in Download Count 7.2

Same name and namespace in other branches
  1. 6.2 includes/download_count.theme.inc \theme_download_count_upload_attachments()

@file Theme related functions for the download_count module.

1 theme call to theme_download_count_upload_attachments()
download_count_node_view in ./download_count.module
Implements hook_node_view().

File

includes/download_count.theme.inc, line 7
Theme related functions for the download_count module.

Code

function theme_download_count_upload_attachments($variables) {
  $files = $variables['files'];
  $downloads = $variables['downloads'];
  $header = array(
    t('Attachment'),
    t('Size'),
    t('Downloads'),
    t('Last Download'),
  );
  $rows = array();
  foreach ($files as $file) {
    $file = (object) $file;
    if (isset($file->list) && empty($file->remove)) {
      $href = function_exists('_private_upload_create_url') ? _private_upload_create_url($file) : file_create_url($file->filepath);
      $text = $file->description ? $file->description : $file->filename;
      $last = isset($downloads[$file->filename]['last']) ? t('@time ago', array(
        '@time' => format_interval(REQUEST_TIME - $downloads[$file->filename]['last']),
      )) : 'never';
      $count = isset($downloads[$file->filename]['count']) ? $downloads[$file->filename]['count'] : 0;
      $rows[] = array(
        l($text, $href),
        format_size($file->filesize),
        $count,
        $last,
      );
    }
  }
  if (count($rows)) {
    return theme('table', array(
      'header' => $header,
      'rows' => $rows,
      'attributes' => array(
        'id' => 'attachments',
      ),
    ));
  }
}