Code comment and debug filemanager
This commit is contained in:
parent
66cb06eca9
commit
d4bc53660b
@ -82,9 +82,16 @@ else // For no ajax call
|
||||
dol_print_error($db,$ecmdir->error);
|
||||
exit;
|
||||
}
|
||||
|
||||
$relativepath=$ecmdir->getRelativePath(); // Example 'mydir/'
|
||||
}
|
||||
$relativepath=$ecmdir->getRelativePath();
|
||||
$upload_dir = $rootdirfordoc.'/'.$relativepath;
|
||||
elseif (GETPOST('section_dir'))
|
||||
{
|
||||
$relativepath=GETPOST('section_dir');
|
||||
}
|
||||
//var_dump($section.'-'.GETPOST('section_dir').'-'.$relativepath);
|
||||
|
||||
$upload_dir = $rootdirfordoc.'/'.$relativepath;
|
||||
}
|
||||
|
||||
if (empty($url))
|
||||
@ -226,7 +233,18 @@ if ($type == 'directory')
|
||||
{
|
||||
if ($module == 'medias')
|
||||
{
|
||||
$relativepath=GETPOST('file','alpha');
|
||||
/*
|
||||
$_POST is array like
|
||||
'token' => string '062380e11b7dcd009d07318b57b71750' (length=32)
|
||||
'action' => string 'file_manager' (length=12)
|
||||
'website' => string 'template' (length=8)
|
||||
'pageid' => string '124' (length=3)
|
||||
'section_dir' => string 'mydir/' (length=3)
|
||||
'section_id' => string '0' (length=1)
|
||||
'max_file_size' => string '2097152' (length=7)
|
||||
'sendit' => string 'Envoyer fichier' (length=15)
|
||||
*/
|
||||
$relativepath=GETPOST('file','alpha')?GETPOST('file','alpha'):GETPOST('section_dir','alpha');
|
||||
if ($relativepath && $relativepath!= '/') $relativepath.='/';
|
||||
$upload_dir = $dolibarr_main_data_root.'/'.$module.'/'.$relativepath;
|
||||
if (GETPOSTISSET('website') || GETPOSTISSET('file_manager'))
|
||||
|
||||
@ -30,6 +30,7 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
|
||||
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
|
||||
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
||||
|
||||
|
||||
if (! isset($mode) || $mode != 'noajax') // For ajax call
|
||||
{
|
||||
$res=@include '../../main.inc.php';
|
||||
@ -39,16 +40,26 @@ if (! isset($mode) || $mode != 'noajax') // For ajax call
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
|
||||
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
|
||||
|
||||
//if (GETPOST('preopened')) { $_GET['dir'] = $_POST['dir'] = '/bbb/'; }
|
||||
|
||||
$openeddir = GETPOST('openeddir');
|
||||
$modulepart= GETPOST('modulepart');
|
||||
$selecteddir = jsUnEscape(GETPOST('dir')); // relative path. We must decode using same encoding function used by javascript: escape()
|
||||
|
||||
$preopened = GETPOST('preopened');
|
||||
|
||||
if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/','',$selecteddir); // We removed last '/' except if it is '/'
|
||||
}
|
||||
else // For no ajax call
|
||||
{
|
||||
//if (GETPOST('preopened')) { $_GET['dir'] = $_POST['dir'] = GETPOST('preopened'); }
|
||||
|
||||
$openeddir = GETPOST('openeddir');
|
||||
$modulepart= GETPOST('modulepart');
|
||||
$selecteddir = GETPOST('dir');
|
||||
|
||||
$preopened = GETPOST('preopened');
|
||||
|
||||
if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/','',$selecteddir); // We removed last '/' except if it is '/'
|
||||
if (empty($url)) $url=DOL_URL_ROOT.'/ecm/index.php';
|
||||
}
|
||||
@ -58,8 +69,16 @@ $langs->load("ecm");
|
||||
|
||||
// Define fullpathselecteddir.
|
||||
$fullpathselecteddir='<none>';
|
||||
if ($modulepart == 'ecm') $fullpathselecteddir=$conf->ecm->dir_output.'/'.($selecteddir != '/' ? $selecteddir : '');
|
||||
if ($modulepart == 'medias') $fullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($selecteddir != '/' ? $selecteddir : '');
|
||||
if ($modulepart == 'ecm')
|
||||
{
|
||||
$fullpathselecteddir=$conf->ecm->dir_output.'/'.($selecteddir != '/' ? $selecteddir : '');
|
||||
$fullpathopeneddir=$conf->ecm->dir_output.'/'.($openeddir != '/' ? $openeddir : '');
|
||||
}
|
||||
if ($modulepart == 'medias')
|
||||
{
|
||||
$fullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($selecteddir != '/' ? $selecteddir : '');
|
||||
$fullpathopeneddir=$dolibarr_main_data_root.'/medias/'.($openeddir != '/' ? $openeddir : '');
|
||||
}
|
||||
|
||||
|
||||
// Security:
|
||||
@ -87,20 +106,20 @@ if ($modulepart == 'medias')
|
||||
* View
|
||||
*/
|
||||
|
||||
if (! isset($mode) || $mode != 'noajax')
|
||||
if (! isset($mode) || $mode != 'noajax') // if ajax mode
|
||||
{
|
||||
top_httphead();
|
||||
}
|
||||
|
||||
//print '<!-- selecteddir = '.$selecteddir.', openeddir = '.$openeddir.', modulepart='.$modulepart.' -->'."\n";
|
||||
//print '<!-- selecteddir (relative dir we click on) = '.$selecteddir.', openeddir = '.$openeddir.', modulepart='.$modulepart.', preopened='.$preopened.' -->'."\n";
|
||||
$userstatic=new User($db);
|
||||
$form=new Form($db);
|
||||
$ecmdirstatic = new EcmDirectory($db);
|
||||
|
||||
// Load full tree from database. We will use it to define nbofsubdir and nboffilesinsubdir
|
||||
// Load full tree of ECM module from database. We will use it to define nbofsubdir and nboffilesinsubdir
|
||||
if (empty($sqltree)) $sqltree=$ecmdirstatic->get_full_arbo(0);
|
||||
|
||||
// Try to find key into $sqltree
|
||||
// Try to find selected dir id into $sqltree and save it into $current_ecmdir_id
|
||||
$current_ecmdir_id=-1;
|
||||
foreach($sqltree as $keycursor => $val)
|
||||
{
|
||||
@ -113,6 +132,25 @@ foreach($sqltree as $keycursor => $val)
|
||||
|
||||
if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))
|
||||
{
|
||||
|
||||
/**
|
||||
* treeOutputForAbsoluteDir
|
||||
*
|
||||
* @param array $sqltree Sqltree
|
||||
* @param string $selecteddir Selected dir
|
||||
* @param string $fullpathselecteddir Full path of selected dir
|
||||
* @param string $modulepart Modulepart
|
||||
* @param string $websitekey Website key
|
||||
* @param int $pageid Page id
|
||||
* @return void
|
||||
*/
|
||||
function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid)
|
||||
{
|
||||
global $db, $langs, $form;
|
||||
|
||||
$ecmdirstatic = new EcmDirectory($db);
|
||||
$userstatic = new User($db);
|
||||
|
||||
if (file_exists($fullpathselecteddir))
|
||||
{
|
||||
$files = @scandir($fullpathselecteddir);
|
||||
@ -172,7 +210,7 @@ if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE
|
||||
$nboffilesinsubdir=$langs->trans("Unknown");
|
||||
}
|
||||
|
||||
print '<li class="directory collapsed">';
|
||||
print '<li class="directory collapsed">'; // collapsed is opposite if expanded
|
||||
|
||||
print "<a class=\"fmdirlia jqft ecmjqft\" href=\"";
|
||||
print "#";
|
||||
@ -229,15 +267,30 @@ if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE
|
||||
print "</tr></table>\n";
|
||||
print '</div>';
|
||||
|
||||
if (0)
|
||||
{
|
||||
treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid);
|
||||
}
|
||||
|
||||
//print '<div> </div>';
|
||||
print "</li>\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Enable jquery handlers on new generated HTML objects (same code than into lib_footer.js.php)
|
||||
// Because the content is reloaded by ajax call, we must also reenable some jquery hooks
|
||||
print "\n<!-- JS CODE TO ENABLE Tooltips on all object with class classfortooltip (reload into ajaxdirtree) -->\n";
|
||||
print '<script type="text/javascript">
|
||||
echo "</ul>\n";
|
||||
|
||||
}
|
||||
}
|
||||
else print "PermissionDenied";
|
||||
}
|
||||
}
|
||||
|
||||
treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid);
|
||||
|
||||
// Enable jquery handlers on new generated HTML objects (same code than into lib_footer.js.php)
|
||||
// Because the content is reloaded by ajax call, we must also reenable some jquery hooks
|
||||
print "\n<!-- JS CODE TO ENABLE Tooltips on all object with class classfortooltip (reload into ajaxdirtree) -->\n";
|
||||
print '<script type="text/javascript">
|
||||
jQuery(document).ready(function () {
|
||||
jQuery(".classfortooltip").tooltip({
|
||||
show: { collision: "flipfit", effect:\'toggle\', delay:50 },
|
||||
@ -250,13 +303,6 @@ if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE
|
||||
});
|
||||
</script>';
|
||||
|
||||
echo "</ul>\n";
|
||||
|
||||
}
|
||||
}
|
||||
else print "PermissionDenied";
|
||||
}
|
||||
|
||||
// This ajax service is called only when a directory $selecteddir is opened but not when closed.
|
||||
//print '<script language="javascript">';
|
||||
//print "loadandshowpreview('".dol_escape_js($selecteddir)."');";
|
||||
|
||||
@ -111,7 +111,7 @@ if ((! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABL
|
||||
<?php
|
||||
}
|
||||
|
||||
$sectiondir=GETPOST('file','alpha');
|
||||
$sectiondir=GETPOST('file','alpha')?GETPOST('file','alpha'):GETPOST('section_dir','alpha');
|
||||
print '<!-- Start form to attach new file in filemanager.tpl.php sectionid='.$section.' sectiondir='.$sectiondir.' -->'."\n";
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
$formfile=new FormFile($db);
|
||||
@ -168,14 +168,14 @@ if (empty($action) || $action == 'editfile' || $action == 'file_manager' || preg
|
||||
|
||||
print '<tr><td>';
|
||||
|
||||
// Show filemanager tree (will be filled by call of ajax /ecm/tpl/enablefiletreeajax.tpl.php that execute ajaxdirtree.php)
|
||||
// Show filemanager tree (will be filled by a call of ajax /ecm/tpl/enablefiletreeajax.tpl.php, later, that executes ajaxdirtree.php)
|
||||
print '<div id="filetree" class="ecmfiletree"></div>';
|
||||
|
||||
if ($action == 'deletefile') print $form->formconfirm('eeeee', $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 'deletefile');
|
||||
|
||||
print '</td></tr>';
|
||||
}
|
||||
else
|
||||
else // Show filtree when ajax is disabled (rare)
|
||||
{
|
||||
print '<tr><td style="padding-left: 20px">';
|
||||
|
||||
@ -186,6 +186,9 @@ if (empty($action) || $action == 'editfile' || $action == 'file_manager' || preg
|
||||
// Show filemanager tree (will be filled by direct include of ajaxdirtree.php in mode noajax, this will return all dir - all levels - to show)
|
||||
print '<div id="filetree" class="ecmfiletree">';
|
||||
|
||||
// Variables that may be defined:
|
||||
// $_GET['modulepart'], $_GET['openeddir'], $_GET['sortfield'], $_GET['sortorder']
|
||||
// $_POST['dir']
|
||||
$mode='noajax';
|
||||
if (empty($url)) $url=DOL_URL_ROOT.'/ecm/index.php';
|
||||
include DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirtree.php';
|
||||
@ -211,7 +214,7 @@ if (empty($action) || $action == 'editfile' || $action == 'file_manager' || preg
|
||||
|
||||
$mode='noajax';
|
||||
if (empty($url)) $url=DOL_URL_ROOT.'/ecm/index.php';
|
||||
include DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirpreview.php';
|
||||
include DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirpreview.php'; // Show content of a directory on right side
|
||||
|
||||
|
||||
// End right panel
|
||||
@ -224,7 +227,15 @@ include DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirpreview.php';
|
||||
<?php
|
||||
|
||||
|
||||
if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) {
|
||||
if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) // Show filtree when ajax is enabled
|
||||
{
|
||||
//var_dump($modulepart);
|
||||
// Variables that may be defined:
|
||||
// $_GET['modulepart'], $_GET['openeddir'], $_GET['sortfield'], $_GET['sortorder']
|
||||
// $_POST['dir']
|
||||
// $_POST['section_dir'], $_POST['section_id'], $_POST['token'], $_POST['max_file_size'], $_POST['sendit']
|
||||
if (GETPOST('section_dir','alpha')) { $preopened=GETPOST('section_dir','alpha'); }
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/ecm/tpl/enablefiletreeajax.tpl.php';
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ if (empty($conf) || ! is_object($conf))
|
||||
?>
|
||||
|
||||
<!-- BEGIN PHP TEMPLATE ecm/tpl/enablefiletreeajax.tpl.php -->
|
||||
<!-- Doc of fileTree plugin at https://www.abeautifulsite.net/jquery-file-tree: http://www.abeautifulsite.net/blog/2008/03/jquery-file-tree/ -->
|
||||
<!-- Doc of fileTree plugin at https://www.abeautifulsite.net/jquery-file-tree -->
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
@ -35,7 +35,9 @@ if (empty($conf) || ! is_object($conf))
|
||||
if (empty($module)) $module='ecm';
|
||||
$paramwithoutsection=preg_replace('/&?section=(\d+)/', '', $param);
|
||||
|
||||
$openeddir='/';
|
||||
$openeddir='/'; // The root directory shown
|
||||
// $preopened // The dir to have preopened
|
||||
|
||||
?>
|
||||
|
||||
$(document).ready(function() {
|
||||
@ -43,7 +45,7 @@ $(document).ready(function() {
|
||||
$('#filetree').fileTree({
|
||||
root: '<?php print dol_escape_js($openeddir); ?>',
|
||||
// Ajax called if we click to expand a dir (not a file). Parameter 'dir' is provided as a POST parameter by fileTree code to this following URL.
|
||||
script: '<?php echo DOL_URL_ROOT.'/core/ajax/ajaxdirtree.php?modulepart='.$module.'&openeddir='.urlencode($openeddir).(empty($paramwithoutsection)?'':$paramwithoutsection); ?>',
|
||||
script: '<?php echo DOL_URL_ROOT.'/core/ajax/ajaxdirtree.php?modulepart='.$module.(empty($preopened)?'':'&preopened='.urlencode($preopened)).'&openeddir='.urlencode($openeddir).(empty($paramwithoutsection)?'':$paramwithoutsection); ?>',
|
||||
folderEvent: 'click', // 'dblclick'
|
||||
multiFolder: false },
|
||||
// Called if we click on a file (not a dir)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user