|||
במידה ואתם רוצים לעצב את הרשימה של הקבצים המצורפים כמו זה

אתם יכולים לבצע Override ל upload_attachments
יצרו מחיצה icons תחת ה theme, פתחו את ה tar המצורף לשם, הוסיפו icons נוספים לפי הצורך
הוסיפו את קטע הקוד הבא ל template.php
function phptemplate_upload_attachments($files) {
$header = array(t('Attachment'), t('לחץ להורדה'));
$rows = array();
foreach ($files as $file) {
$file = (object)$file;
if ($file->list && !$file->remove) {
// Generate valid URL for both existing attachments and preview of new attachments (these have 'upload' in fid)
$href = file_create_url((strpos($file->fid, 'upload') === FALSE ? $file->filepath : file_create_filename($file->filename, file_create_path())));
$text = $file->description ? $file->description : $file->filename;
$rows[] = array(theme('file_icon', $file) ,l($text, $href,array("title" => " גודל הקובץ :" . format_size($file->filesize))));
}
}
if (count($rows)) {
return theme('table', $header, $rows, array('id' => 'attachments'));
}
}
/**
* Theme file icon according to mime type
* an 'icons' directory should be placed inside your default files direcotry
* containing the file icons. Icon names should follow their Mime sub-type.
* Apart from the two generic types 'image' & 'text'
*
* @param file drupal file object
* @return HTML themed icon
*/
function phptemplate_file_icon($file) {
//Check if directory icons in current theme exists otherwise, no point, right
$icon_ext = '.png'; //Change your supported format png for example
$path = path_to_theme().'/icons';
if( !is_dir($path) ) {
return;
}
//Get filemime type act accordingly
$mime = explode('/', $file->filemime);
$type = $mime[0];
$sub_type = $mime[1];
$output = '';
$defult_icn = $path.'/default'.$icon_ext;
switch($type) {
case 'image':
$img_path = $path.'/image'.$icon_ext;
if( is_file($img_path) ){
$output .= theme_image($img_path, $file->filename, $file->description);
}
else if( is_file($defult_icn) ) {
$output .= theme_image($defult_icn, $file->filename, $file->description);
}
break;
case 'text':
$txt_path = $path.'/text'.$icon_ext;
if( is_file($txt_path) ){
$output .= theme_image($txt_path, $file->filename, $file->description);
}
else if( is_file($defult_icn) ) {
$output .= theme_image($defult_icn, $file->filename, $file->description);
}
break;
case 'application':
$app_path = $path.'/'.$sub_type.$icon_ext;
if( is_file($app_path) ){
$output .= theme_image($app_path, $file->filename, $file->description);
}
else if( is_file($defult_icn) ) {
$output .= theme_image($defult_icn, $file->filename, $file->description);
}
break;
default:
if( is_file($defult_icn) ) {
$output .= theme_image($defult_icn, $file->filename, $file->description);
}
break;
}
return $output;
}| קובץ מצורף | גודל |
|---|---|
| attachments.txt | 2.78 קילו-בית |
| attachments.tar | 10.5 קילו-בית |


