Code comment and debug filemanager
This commit is contained in:
parent
66cb06eca9
commit
d4bc53660b
@ -82,8 +82,15 @@ else // For no ajax call
|
|||||||
dol_print_error($db,$ecmdir->error);
|
dol_print_error($db,$ecmdir->error);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$relativepath=$ecmdir->getRelativePath(); // Example 'mydir/'
|
||||||
}
|
}
|
||||||
$relativepath=$ecmdir->getRelativePath();
|
elseif (GETPOST('section_dir'))
|
||||||
|
{
|
||||||
|
$relativepath=GETPOST('section_dir');
|
||||||
|
}
|
||||||
|
//var_dump($section.'-'.GETPOST('section_dir').'-'.$relativepath);
|
||||||
|
|
||||||
$upload_dir = $rootdirfordoc.'/'.$relativepath;
|
$upload_dir = $rootdirfordoc.'/'.$relativepath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,7 +233,18 @@ if ($type == 'directory')
|
|||||||
{
|
{
|
||||||
if ($module == 'medias')
|
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.='/';
|
if ($relativepath && $relativepath!= '/') $relativepath.='/';
|
||||||
$upload_dir = $dolibarr_main_data_root.'/'.$module.'/'.$relativepath;
|
$upload_dir = $dolibarr_main_data_root.'/'.$module.'/'.$relativepath;
|
||||||
if (GETPOSTISSET('website') || GETPOSTISSET('file_manager'))
|
if (GETPOSTISSET('website') || GETPOSTISSET('file_manager'))
|
||||||
|
|||||||
@ -30,6 +30,7 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
|
|||||||
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
|
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
|
||||||
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
||||||
|
|
||||||
|
|
||||||
if (! isset($mode) || $mode != 'noajax') // For ajax call
|
if (! isset($mode) || $mode != 'noajax') // For ajax call
|
||||||
{
|
{
|
||||||
$res=@include '../../main.inc.php';
|
$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.'/core/class/html.form.class.php';
|
||||||
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
|
||||||
|
|
||||||
|
//if (GETPOST('preopened')) { $_GET['dir'] = $_POST['dir'] = '/bbb/'; }
|
||||||
|
|
||||||
$openeddir = GETPOST('openeddir');
|
$openeddir = GETPOST('openeddir');
|
||||||
$modulepart= GETPOST('modulepart');
|
$modulepart= GETPOST('modulepart');
|
||||||
$selecteddir = jsUnEscape(GETPOST('dir')); // relative path. We must decode using same encoding function used by javascript: escape()
|
$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 '/'
|
if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/','',$selecteddir); // We removed last '/' except if it is '/'
|
||||||
}
|
}
|
||||||
else // For no ajax call
|
else // For no ajax call
|
||||||
{
|
{
|
||||||
|
//if (GETPOST('preopened')) { $_GET['dir'] = $_POST['dir'] = GETPOST('preopened'); }
|
||||||
|
|
||||||
$openeddir = GETPOST('openeddir');
|
$openeddir = GETPOST('openeddir');
|
||||||
$modulepart= GETPOST('modulepart');
|
$modulepart= GETPOST('modulepart');
|
||||||
$selecteddir = GETPOST('dir');
|
$selecteddir = GETPOST('dir');
|
||||||
|
|
||||||
|
$preopened = GETPOST('preopened');
|
||||||
|
|
||||||
if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/','',$selecteddir); // We removed last '/' except if it is '/'
|
if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/','',$selecteddir); // We removed last '/' except if it is '/'
|
||||||
if (empty($url)) $url=DOL_URL_ROOT.'/ecm/index.php';
|
if (empty($url)) $url=DOL_URL_ROOT.'/ecm/index.php';
|
||||||
}
|
}
|
||||||
@ -58,8 +69,16 @@ $langs->load("ecm");
|
|||||||
|
|
||||||
// Define fullpathselecteddir.
|
// Define fullpathselecteddir.
|
||||||
$fullpathselecteddir='<none>';
|
$fullpathselecteddir='<none>';
|
||||||
if ($modulepart == 'ecm') $fullpathselecteddir=$conf->ecm->dir_output.'/'.($selecteddir != '/' ? $selecteddir : '');
|
if ($modulepart == 'ecm')
|
||||||
if ($modulepart == 'medias') $fullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($selecteddir != '/' ? $selecteddir : '');
|
{
|
||||||
|
$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:
|
// Security:
|
||||||
@ -87,20 +106,20 @@ if ($modulepart == 'medias')
|
|||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (! isset($mode) || $mode != 'noajax')
|
if (! isset($mode) || $mode != 'noajax') // if ajax mode
|
||||||
{
|
{
|
||||||
top_httphead();
|
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);
|
$userstatic=new User($db);
|
||||||
$form=new Form($db);
|
$form=new Form($db);
|
||||||
$ecmdirstatic = new EcmDirectory($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);
|
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;
|
$current_ecmdir_id=-1;
|
||||||
foreach($sqltree as $keycursor => $val)
|
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))
|
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))
|
if (file_exists($fullpathselecteddir))
|
||||||
{
|
{
|
||||||
$files = @scandir($fullpathselecteddir);
|
$files = @scandir($fullpathselecteddir);
|
||||||
@ -172,7 +210,7 @@ if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE
|
|||||||
$nboffilesinsubdir=$langs->trans("Unknown");
|
$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 "<a class=\"fmdirlia jqft ecmjqft\" href=\"";
|
||||||
print "#";
|
print "#";
|
||||||
@ -229,11 +267,26 @@ if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE
|
|||||||
print "</tr></table>\n";
|
print "</tr></table>\n";
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
|
if (0)
|
||||||
|
{
|
||||||
|
treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid);
|
||||||
|
}
|
||||||
|
|
||||||
//print '<div> </div>';
|
//print '<div> </div>';
|
||||||
print "</li>\n";
|
print "</li>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
// 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
|
// 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 "\n<!-- JS CODE TO ENABLE Tooltips on all object with class classfortooltip (reload into ajaxdirtree) -->\n";
|
||||||
@ -250,13 +303,6 @@ if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE
|
|||||||
});
|
});
|
||||||
</script>';
|
</script>';
|
||||||
|
|
||||||
echo "</ul>\n";
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else print "PermissionDenied";
|
|
||||||
}
|
|
||||||
|
|
||||||
// This ajax service is called only when a directory $selecteddir is opened but not when closed.
|
// This ajax service is called only when a directory $selecteddir is opened but not when closed.
|
||||||
//print '<script language="javascript">';
|
//print '<script language="javascript">';
|
||||||
//print "loadandshowpreview('".dol_escape_js($selecteddir)."');";
|
//print "loadandshowpreview('".dol_escape_js($selecteddir)."');";
|
||||||
|
|||||||
@ -111,7 +111,7 @@ if ((! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABL
|
|||||||
<?php
|
<?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";
|
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';
|
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||||
$formfile=new FormFile($db);
|
$formfile=new FormFile($db);
|
||||||
@ -168,14 +168,14 @@ if (empty($action) || $action == 'editfile' || $action == 'file_manager' || preg
|
|||||||
|
|
||||||
print '<tr><td>';
|
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>';
|
print '<div id="filetree" class="ecmfiletree"></div>';
|
||||||
|
|
||||||
if ($action == 'deletefile') print $form->formconfirm('eeeee', $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 'deletefile');
|
if ($action == 'deletefile') print $form->formconfirm('eeeee', $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 'deletefile');
|
||||||
|
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
else
|
else // Show filtree when ajax is disabled (rare)
|
||||||
{
|
{
|
||||||
print '<tr><td style="padding-left: 20px">';
|
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)
|
// 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">';
|
print '<div id="filetree" class="ecmfiletree">';
|
||||||
|
|
||||||
|
// Variables that may be defined:
|
||||||
|
// $_GET['modulepart'], $_GET['openeddir'], $_GET['sortfield'], $_GET['sortorder']
|
||||||
|
// $_POST['dir']
|
||||||
$mode='noajax';
|
$mode='noajax';
|
||||||
if (empty($url)) $url=DOL_URL_ROOT.'/ecm/index.php';
|
if (empty($url)) $url=DOL_URL_ROOT.'/ecm/index.php';
|
||||||
include DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirtree.php';
|
include DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirtree.php';
|
||||||
@ -211,7 +214,7 @@ if (empty($action) || $action == 'editfile' || $action == 'file_manager' || preg
|
|||||||
|
|
||||||
$mode='noajax';
|
$mode='noajax';
|
||||||
if (empty($url)) $url=DOL_URL_ROOT.'/ecm/index.php';
|
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
|
// End right panel
|
||||||
@ -224,7 +227,15 @@ include DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirpreview.php';
|
|||||||
<?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';
|
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 -->
|
<!-- 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">
|
<script type="text/javascript">
|
||||||
|
|
||||||
@ -35,7 +35,9 @@ if (empty($conf) || ! is_object($conf))
|
|||||||
if (empty($module)) $module='ecm';
|
if (empty($module)) $module='ecm';
|
||||||
$paramwithoutsection=preg_replace('/&?section=(\d+)/', '', $param);
|
$paramwithoutsection=preg_replace('/&?section=(\d+)/', '', $param);
|
||||||
|
|
||||||
$openeddir='/';
|
$openeddir='/'; // The root directory shown
|
||||||
|
// $preopened // The dir to have preopened
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
@ -43,7 +45,7 @@ $(document).ready(function() {
|
|||||||
$('#filetree').fileTree({
|
$('#filetree').fileTree({
|
||||||
root: '<?php print dol_escape_js($openeddir); ?>',
|
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.
|
// 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'
|
folderEvent: 'click', // 'dblclick'
|
||||||
multiFolder: false },
|
multiFolder: false },
|
||||||
// Called if we click on a file (not a dir)
|
// Called if we click on a file (not a dir)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user