| 1 |
<?php
|
| 2 |
// $Id: webfm_theme.inc,v 1.3 2008/12/02 17:53:50 robmilne Exp $
|
| 3 |
/**
|
| 4 |
* Displays file attachments in table
|
| 5 |
*/
|
| 6 |
function theme_webfm_attachments($files) {
|
| 7 |
global $base_url;
|
| 8 |
$header = array(t('Attachment'));
|
| 9 |
if($enable_date = variable_get('webfm_attach_date', '')) {
|
| 10 |
array_push($header, t('Date'));
|
| 11 |
}
|
| 12 |
if($enable_size = variable_get('webfm_attach_size', '')) {
|
| 13 |
array_push($header, t('Size'));
|
| 14 |
}
|
| 15 |
$rows = array();
|
| 16 |
foreach ($files as $file) {
|
| 17 |
// 0 =inline : 1 = attach
|
| 18 |
$icon_path = $base_url.'/'.variable_get('webfm_icon_dir', drupal_get_path('module', 'webfm').'/image/icon').'/'._webfm_get_icon($file->e);
|
| 19 |
$description = '';
|
| 20 |
if(variable_get('webfm_attach_desc', '') && !empty($file->fdesc)) {
|
| 21 |
$description = '<div class="att-fdesc">'.$file->fdesc.'</div>';
|
| 22 |
}
|
| 23 |
$filename = $file->ftitle ? $file->ftitle : $file->n;
|
| 24 |
if(variable_get('webfm_attach_new_window', '')) {
|
| 25 |
$href = array(
|
| 26 |
'data' => l('<img src="'.$icon_path.'" alt="[file]" title="Download '.$filename .'"/> ', 'webfm_send/'.$file->id.'/1',
|
| 27 |
array('attributes' => array('title' => 'Download '.$filename,'target' => '_blank'), 'html' => TRUE))
|
| 28 |
.l($filename, 'webfm_send/'.$file->id, array('attributes' => array('title' => 'Open '.$filename, 'target' => '_blank')))
|
| 29 |
.$description, 'class' => 'att-title'
|
| 30 |
);
|
| 31 |
} else {
|
| 32 |
$href = array(
|
| 33 |
'data' => l('<img src="'.$icon_path.'" alt="[file]" title="Download '.$filename .'"/> ', 'webfm_send/'.$file->id.'/1',
|
| 34 |
array('attributes' => array('title' => 'Download '.$filename), 'html' => TRUE))
|
| 35 |
.l($filename, 'webfm_send/'.$file->id, array('attributes' => array('title' => 'Open '.$filename)))
|
| 36 |
.$description, 'class' => 'att-title'
|
| 37 |
);
|
| 38 |
}
|
| 39 |
|
| 40 |
$row = array();
|
| 41 |
array_push($row, $href);
|
| 42 |
if($enable_date) {
|
| 43 |
$time = $file->fcreatedate ? date(webfm_get_date_format(), $file->fcreatedate) : date(webfm_get_date_format(), @filemtime($file->p . '/'. $file->n));
|
| 44 |
array_push($row, array('data' => $time, 'class' => 'att-time'));
|
| 45 |
}
|
| 46 |
if($enable_size) {
|
| 47 |
array_push($row, array('data' => format_size($file->s), 'class' => 'att-size'));
|
| 48 |
}
|
| 49 |
array_push($rows, $row);
|
| 50 |
}
|
| 51 |
if (count($rows)) {
|
| 52 |
return theme('table', $header, $rows, array('class' => 'webfm-attach-list'));
|
| 53 |
}
|
| 54 |
}
|