This commit is contained in:
Thomas Zilio 2020-06-30 13:25:21 +02:00
parent 5ab5ac2bf6
commit e71d4dcce2
1 changed files with 35 additions and 39 deletions

View File

@ -61,9 +61,9 @@ class FileManager implements ManagerInterface
<div class="box box-success"> <div class="box box-success">
<div class="box-header with-border"> <div class="box-header with-border">
<h3 class="box-title">'.(!empty($category) ? $category : tr('Generale')).'</h3> <h3 class="box-title">'.(!empty($category) ? $category : tr('Generale')).'</h3>
{[ "type": "text", "class": "hide category-name", "value": "'.$category.'" ]} {[ "type": "text", "class": "hide category-name", "value": "'.$category.'" ]}
<div class="box-tools pull-right">'; <div class="box-tools pull-right">';
if (!empty($category)) { if (!empty($category)) {
@ -71,7 +71,7 @@ class FileManager implements ManagerInterface
<button type="button" class="btn btn-box-tool category-save hide"> <button type="button" class="btn btn-box-tool category-save hide">
<i class="fa fa-check"></i> <i class="fa fa-check"></i>
</button> </button>
<button type="button" class="btn btn-box-tool category-edit"> <button type="button" class="btn btn-box-tool category-edit">
<i class="fa fa-edit"></i> <i class="fa fa-edit"></i>
</button>'; </button>';
@ -106,7 +106,7 @@ class FileManager implements ManagerInterface
<img class="attachment-img tip" src="'.$file->user->photo.'" title="'.$file->user->nome_completo.'">'; <img class="attachment-img tip" src="'.$file->user->photo.'" title="'.$file->user->nome_completo.'">';
} else { } else {
$result .= ' $result .= '
<i class="fa fa-user-circle-o attachment-img tip" title="'.tr('OpenSTAManager').'"></i>'; <i class="fa fa-user-circle-o attachment-img tip" title="'.tr('OpenSTAManager').'"></i>';
} }
@ -115,12 +115,12 @@ class FileManager implements ManagerInterface
<a href="'.ROOTDIR.'/view.php?file_id='.$r['id'].'" target="_blank"> <a href="'.ROOTDIR.'/view.php?file_id='.$r['id'].'" target="_blank">
<i class="fa fa-external-link"></i> '.$r['name'].' <i class="fa fa-external-link"></i> '.$r['name'].'
</a> </a>
<small> ('.$file->extension.')'.((!empty($file->size)) ? ' ('.\Util\FileSystem::formatBytes($file->size).')' : '').' '.(($r['name'] == 'Logo stampe' or $r['name'] == 'Filigrana stampe') ? '<i class="fa fa-file-text-o"></i>' : '').'</small>'.' <small> ('.$file->extension.')'.((!empty($file->size)) ? ' ('.\Util\FileSystem::formatBytes($file->size).')' : '').' '.(($r['name'] == 'Logo stampe' or $r['name'] == 'Filigrana stampe') ? '<i class="fa fa-file-text-o"></i>' : '').'</small>'.'
</td> </td>
<td>'.\Translator::timestampToLocale($r['created_at']).'</td> <td>'.\Translator::timestampToLocale($r['created_at']).'</td>
<td class="text-center"> <td class="text-center">
<a class="btn btn-xs btn-primary" href="'.ROOTDIR.'/actions.php?id_module='.$options['id_module'].'&op=download_file&id='.$r['id'].'&filename='.$r['filename'].'" target="_blank"> <a class="btn btn-xs 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> <i class="fa fa-download"></i>
@ -177,7 +177,7 @@ class FileManager implements ManagerInterface
</div> </div>
<div class="col-md-12"> <div class="col-md-12">
<div class="dropzone dz-clickable" id="dragdrop"> <div class="dropzone dz-clickable" id="dragdrop">
</div> </div>
</div> </div>
</div>'; </div>';
@ -200,7 +200,7 @@ class FileManager implements ManagerInterface
$source = array_clean(array_column($categories, 'category')); $source = array_clean(array_column($categories, 'category'));
$upload_max_filesize = \Util\FileSystem::formatBytes(ini_get('upload_max_filesize'), 0); $upload_max_filesize = \Util\FileSystem::formatBytes(ini_get('upload_max_filesize'), 0);
//remove unit //remove unit
$upload_max_filesize = substr($upload_max_filesize, 0, strrpos($upload_max_filesize, ' ')); $upload_max_filesize = substr($upload_max_filesize, 0, strrpos($upload_max_filesize, ' '));
@ -214,9 +214,10 @@ class FileManager implements ManagerInterface
Dropzone.autoDiscover = false; Dropzone.autoDiscover = false;
$(document).ready(function() { $(document).ready(function() {
var dragdrop = new Dropzone("#'.$attachment_id.' .dropzone", {
var dropzoneOptions = { dictDefaultMessage: "'.tr('Clicca o trascina qui per caricare uno o più file').'.<br>('.tr('Max upload: _SIZE_', [
dictDefaultMessage: "'.tr('Clicca o trascina qui per caricare uno o più file.<br>(Max ulpload: '.$upload_max_filesize.' MB)').'", '_SIZE_' => $upload_max_filesize.' MB'
]).')",
paramName: "file", paramName: "file",
maxFilesize: '.$upload_max_filesize.', // MB maxFilesize: '.$upload_max_filesize.', // MB
uploadMultiple: false, uploadMultiple: false,
@ -227,45 +228,40 @@ $(document).ready(function() {
url: "'.ROOTDIR.'/actions.php?op=link_file&id_module='.$options['id_module'].'&id_record='.$options['id_record'].'&id_plugin='.$options['id_plugin'].'", url: "'.ROOTDIR.'/actions.php?op=link_file&id_module='.$options['id_module'].'&id_record='.$options['id_record'].'&id_plugin='.$options['id_plugin'].'",
init: function (file, xhr, formData) { init: function (file, xhr, formData) {
this.on("sending", function(file, xhr, formData) { this.on("sending", function(file, xhr, formData) {
formData.append("categoria", $("#categoria").val()); formData.append("categoria", $("#categoria").val());
formData.append("nome_allegato", $("#nome_allegato").val()); formData.append("nome_allegato", $("#nome_allegato").val());
}), });
this.on("success", function (file) { this.on("success", function (file) {
//console.log("success > " + file.name);
dragdrop.removeFile(file); dragdrop.removeFile(file);
}), });
this.on("complete", function (file) { this.on("complete", function (file) {
// Ricarico solo quando ho finito
//Ricarico solo quando ho finito
if (this.getUploadingFiles().length === 0 && this.getQueuedFiles().length === 0) { if (this.getUploadingFiles().length === 0 && this.getQueuedFiles().length === 0) {
reload_'.$attachment_id.'(); reload_'.$attachment_id.'();
} }
}); });
} }
}; });
var dragdrop = new Dropzone("div#dragdrop", dropzoneOptions);
// Modifica categoria // Modifica categoria
$("#'.$attachment_id.' .category-edit").click(function() { $("#'.$attachment_id.' .category-edit").click(function() {
var nome = $(this).parent().parent().find(".box-title"); var nome = $(this).parent().parent().find(".box-title");
var save_button = $(this).parent().find(".category-save"); var save_button = $(this).parent().find(".category-save");
var input = $(this).parent().parent().find(".category-name"); var input = $(this).parent().parent().find(".category-name");
nome.hide(); nome.hide();
$(this).hide(); $(this).hide();
input.removeClass("hide"); input.removeClass("hide");
save_button.removeClass("hide"); save_button.removeClass("hide");
}); });
$("#'.$attachment_id.' .category-save").click(function() { $("#'.$attachment_id.' .category-save").click(function() {
var nome = $(this).parent().parent().find(".box-title"); var nome = $(this).parent().parent().find(".box-title");
var input = $(this).parent().parent().find(".category-name"); var input = $(this).parent().parent().find(".category-name");
show_'.$attachment_id.'(); show_'.$attachment_id.'();
$.ajax({ $.ajax({
@ -288,30 +284,30 @@ $(document).ready(function() {
} }
}); });
}); });
function getFilenameAndExtension(pathfilename){ function getFilenameAndExtension(pathfilename){
var filenameextension = pathfilename.replace(/^.*[\\\/]/, \'\'); var filenameextension = pathfilename.replace(/^.*[\\\/]/, \'\');
var filename = filenameextension.substring(0, filenameextension.lastIndexOf(\'.\')); var filename = filenameextension.substring(0, filenameextension.lastIndexOf(\'.\'));
var ext = filenameextension.split(\'.\').pop(); var ext = filenameextension.split(\'.\').pop();
return [filename, ext]; return [filename, ext];
} }
// Autocompletamento nome // Autocompletamento nome
$("#'.$attachment_id.' #blob").change(function(){ $("#'.$attachment_id.' #blob").change(function(){
var nome = $("#'.$attachment_id.' #nome_allegato"); var nome = $("#'.$attachment_id.' #nome_allegato");
if (!nome.val()) { if (!nome.val()) {
var fullPath = $(this).val(); var fullPath = $(this).val();
var filename = getFilenameAndExtension(fullPath); var filename = getFilenameAndExtension(fullPath);
nome.val(filename[0]); nome.val(filename[0]);
} }
}); });
// Autocompletamento categoria // Autocompletamento categoria
$("#'.$attachment_id.' #categoria").autocomplete({ $("#'.$attachment_id.' #categoria").autocomplete({
source: '.json_encode($source).', source: '.json_encode($source).',
@ -366,13 +362,13 @@ function reload_'.$attachment_id.'() {
$("#'.$attachment_id.'").load(globals.rootdir + "/ajax.php?op=list_attachments&id_module='.$options['id_module'].'&id_record='.$options['id_record'].'&id_plugin='.$options['id_plugin'].'", function() { $("#'.$attachment_id.'").load(globals.rootdir + "/ajax.php?op=list_attachments&id_module='.$options['id_module'].'&id_record='.$options['id_record'].'&id_plugin='.$options['id_plugin'].'", function() {
$("#loading_'.$attachment_id.'").addClass("hide"); $("#loading_'.$attachment_id.'").addClass("hide");
var id = $("#'.$attachment_id.' table tr").eq(-1).attr("id"); var id = $("#'.$attachment_id.' table tr").eq(-1).attr("id");
if (id !== undefined) if (id !== undefined)
$("#"+id).effect("highlight", {}, 1500); $("#"+id).effect("highlight", {}, 1500);
}); });
} }
</script>'; </script>';