function theme_file_formatter_table_itu in iTweak Upload 7.3
Returns HTML for a file attachments table.
Parameters
$variables: An associative array containing:
- items: An array of file attachments.
- icon_directory: (optional) A path to a directory of icons to be used for files. Defaults to the value of the "file_icon_directory" variable.
1 theme call to theme_file_formatter_table_itu()
- itweak_upload_field_formatter_view in ./
itweak_upload.module - Implements hook_field_formatter_view().
File
- ./
itweak_upload.module, line 641 - iTweakUpload - Tweak attachments display and file upload forms.
Code
function theme_file_formatter_table_itu($variables) {
$icon_directory = empty($variables['icon_directory']) ? NULL : $variables['icon_directory'];
$stats = FALSE;
// function_exists('_download_count_stats');
$header = $stats ? array(
array(
'data' => t('Preview'),
'class' => 'preview',
),
array(
'data' => t('Attachment'),
'class' => 'file',
),
// array('data' => t('Downloads'), 'class' => 'download_count', ), array('data' => t('Last download'), 'class' => 'download_last'),
array(
'data' => t('Downloads / Last Download'),
'class' => 'download_stats',
'colspan' => 2,
),
array(
'data' => t('Size'),
'class' => 'size',
),
) : array(
array(
'data' => t('Preview'),
'class' => 'preview',
),
array(
'data' => t('Attachment'),
'class' => 'file',
),
array(
'data' => t('Size'),
'class' => 'size',
),
);
$rows = array();
foreach ($variables['items'] as $delta => $item) {
$file = (object) $item;
if ($file->display && empty($file->remove) && empty($file->hidden)) {
$ext = strtolower(array_pop(explode('.', $file->filename)));
// $url = empty($file->path) ? file_create_url($file->uri) : $file->path;
// $text = !empty($file->description) ? $file->description : $file->filename;
$row = array();
// Column 1 (preview or icon)
if (isset($file->preview)) {
$row[] = array(
'data' => $file->preview['#value'],
'class' => 'mime mime-' . $ext,
);
}
else {
$row[] = array(
'data' => theme('file_icon_itu', array(
'file' => $file,
'icon_directory' => $icon_directory,
)),
'class' => 'mime mime-' . $ext,
);
}
$options = isset($file->preview_options) ? $file->preview_options : array();
if (!$file->access || !(isset($file->preview) || !$file->lightbox_supported || isset($options['custom']))) {
$options = array();
}
// Column 2 (file name / link)
$row[] = array(
// 'data' => l($text, $url, $options),
'data' => theme('file_link_itu', array(
'file' => $file,
'options' => $options,
)),
'class' => 'file',
);
// Column 3/4 (download stats, if available)
if ($stats) {
_download_count_stats($file);
$row[] = array(
'data' => $file->download_count,
'class' => 'download_count',
);
$row[] = array(
'data' => $file->download_last,
'class' => 'download_last',
);
}
// Column 3 (or 5 with download stats, file size)
$row[] = array(
'data' => format_size($file->filesize),
'class' => 'size',
);
$rows[] = $row;
}
}
//drupal_set_message('DEBUG mime='.file_get_mimetype('private://video1.exe').' files=<pre>'.htmlentities(print_r($variables['items'],1)).'</pre> rows=<pre>'.htmlentities(print_r($rows,1)).'</pre>');
return empty($rows) ? '' : '<div class="itu-attachments">' . theme('table', array(
'header' => $header,
'rows' => $rows,
'attributes' => array(
'class' => array(
'itu-attachment-list',
$stats ? 'withstats' : 'withoutstats',
),
),
)) . '</div>';
}