Ricarico via ajax lista allegati

This commit is contained in:
Luca 2018-05-16 11:03:58 +02:00
parent 473fe4d8d0
commit b0b9a5123f
1 changed files with 23 additions and 9 deletions

View File

@ -1,6 +1,12 @@
<?php
namespace HTMLBuilder\Manager;
include_once __DIR__.'/../../../core.php';
if ($_GET['ajax']) {
echo '{( "name": "filelist_and_upload", "id_module": "'.$id_module.'", "id_record": "'.$id_record.'", "id_plugin": "'.$id_plugin.'", "ajax": "true" )}';
}
/**
* @since 2.3
@ -9,13 +15,15 @@ class FileManager implements ManagerInterface
{
public function manage($options)
{
$options['showpanel'] = isset($options['showpanel']) ? $options['showpanel'] : true;
$options['ajax'] = isset($options['ajax']) ? $options['ajax'] : false;
$options['showpanel'] = isset($options['showpanel']) ? $options['showpanel'] : true;
$options['label'] = isset($options['label']) ? $options['label'] : tr('Nuovo allegato').':';
$dbo = \Database::getConnection();
$result .= '
<a name="attachments"></a>';
$result .= '
<div id="attachments_'.$options['id_record'].((!empty($options['id_plugin'])) ? '_'.$options['id_plugin'] : '').'" >
<a name="attachments_'.rand().'"></a>';
if (!empty($options['showpanel'])) {
$result .= '
@ -117,12 +125,17 @@ class FileManager implements ManagerInterface
dataType : "html",
data: form_data,
success: function(data) {
btn.html(prev_html);
btn.prop("disabled", false);
location.href = globals.rootdir + "/editor.php?id_module='.$options['id_module'].'&id_record='.$options['id_record'].((!empty($options['id_plugin'])) ? '#tab_'.$options['id_plugin'] : '').'";
},
btn.prop("disabled", false);';
if (($options['ajax'])) {
$result .= '$("#attachments_'.$options['id_record'].((!empty($options['id_plugin'])) ? '_'.$options['id_plugin'] : '').'").load( globals.rootdir + "/src/HTMLBuilder/Manager/FileManager.php?id_module='.$options['id_module'].'&id_record='.$options['id_record'].((!empty($options['id_plugin'])) ? '&id_plugin='.$options['id_plugin'] : '').((!empty($options['id_plugin'])) ? '#tab_'.$options['id_plugin'] : '').'&ajax=true" );';
}else{
$result .= 'location.href = globals.rootdir + "/editor.php?id_module='.$options['id_module'].'&id_record='.$options['id_record'].((!empty($options['id_plugin'])) ? '#tab_'.$options['id_plugin'] : '').'";';
}
$result .= '},
error: function(data) {
alert(data);
}
@ -133,9 +146,10 @@ class FileManager implements ManagerInterface
if (!empty($options['showpanel'])) {
$result .= '
</div>
</div>
</div>';
}
return $result;
}
}
}