Aggiunte anteprime per filelist_and_upload

This commit is contained in:
Luca 2018-05-22 17:17:08 +02:00
parent 8f1fcdd6ca
commit e698c479f7
1 changed files with 31 additions and 0 deletions

View File

@ -3,10 +3,22 @@
namespace HTMLBuilder\Manager;
/**
* Gestione allegati.
*
* @since 2.3
*/
class FileManager implements ManagerInterface
{
/**
* Gestione "filelist_and_upload".
* Esempio: {( "name": "filelist_and_upload", "id_module": "2", "id_record": "1", "readonly": "false", "ajax": "true" )}.
*
* @param array $options
*
* @return string
*/
public function manage($options)
{
$options['readonly'] = ($options['readonly']=='true') ? true : false;
@ -54,10 +66,29 @@ $result .= '
</td>
<td>'.\Translator::timestampToLocale($r['created_at']).'</td>
<td class="text-center">
<a class="btn btn-sm btn-primary" href="'.ROOTDIR.'/actions.php?id_module='.$options['id_module'].'&op=download_file&id='.$r['id'].'&filename='.$r['filename'].'" target="_blank">
<i class="fa fa-download"></i>
</a>';
//Anteprime supportate dal browser
// <iframe src=\"".ROOTDIR.'/files/'.\Modules::get($options['id_module'])['directory'].'/'.$r['filename']."\" allowfullscreen=\"\" webkitallowfullscreen=\"\" frameborder=\"0\" width=\"100%\" height=\"550\"></iframe>
$extension = end((explode('.', $r['nome'])));
$supported_extensions = ['pdf','jpg','png','gif','jpeg','bmp'];
if ( in_array($extension, $supported_extensions)){
$result .= "
<div class='hide' id='view-".$r['id']."' >
<object data=\"".ROOTDIR.'/files/'.\Modules::get($options['id_module'])['directory'].'/'.$r['filename']."#view=fitH&scrollbar=0&toolbar=0&navpanes=0\" type=\"application/".$extension."\" allowfullscreen=\"\" webkitallowfullscreen=\"\" width=\"100%\" height=\"550\">
alt : <a href=\"".ROOTDIR.'/files/'.\Modules::get($options['id_module'])['directory'].'/'.$r['filename']."\">".$r['filename']."</a>
<span>plugin ".$extension." mancante.</span>
</object>
</div>
<button class=\"btn btn-sm btn-info\" data-target=\"#bs-popup\" type=\"button\" data-title=\"".htmlentities($r['nome'], ENT_QUOTES, "UTF-8")." <small><em>(".$r['filename'].")</em></small>\" data-href=\"#view-".$r['id']."\" ><i class='fa fa-eye'></i></button>";
}else{
$result .= "<button class=\"btn btn-sm btn-default\" title=\"".tr('Anteprima file non disponibile').".\" onclick=\"alert('".tr('Anteprima file di tipo "'.$extension.'" non supportata.')."');\" ><i class='fa fa-eye'></i></button>\n";
}
if (!$options['readonly']){
$result .= '
<a class="btn btn-sm btn-danger ask" data-backto="record-edit" data-msg="'.tr('Vuoi eliminare questo file?').'" data-op="unlink_file" data-id="'.$r['id'].'" data-filename="'.$r['filename'].'">