23 if (empty($conf) || !is_object($conf)) {
24 print
"Error, template enablefiletreeajax.tpl.php can't be called as URL";
30 <!-- BEGIN PHP TEMPLATE ecm/tpl/enablefiletreeajax.tpl.php -->
31 <!-- Doc of fileTree plugin at https:
33 <script
type=
"text/javascript">
39 if (empty($nameforformuserfile)) {
40 $nameforformuserfile =
'';
42 $paramwithoutsection = preg_replace(
'/&?section=(\d+)/',
'', $param);
49 $(document).ready(
function() {
51 $(
'#filetree').fileTree({
52 root:
'<?php print dol_escape_js($openeddir); ?>',
55 script:
'<?php echo DOL_URL_ROOT.'/core/ajax/ajaxdirtree.php?token=
'.currentToken().'&modulepart=
'.urlencode($module).(empty($preopened) ? '' : '&preopened=
'.urlencode($preopened)).'&openeddir=
'.urlencode($openeddir).(empty($paramwithoutsection) ? '' : $paramwithoutsection); ?>',
60 console.log(
"We click on a file");
62 loadandshowpreview(file,0);
66 id=elem.attr(
'id').substr(12);
68 console.log(
"We click on a dir, we call the ajaxdirtree.php with modulepart=<?php echo $module; ?>, param=<?php echo $paramwithoutsection; ?>");
69 console.log(
"We also save id and dir name into <?php echo $nameforformuserfile ?>_section_id|dir (vars into form to attach new file in filemanager.tpl.php) with id="+
id+
" and rel="+rel);
70 jQuery(
"#<?php echo $nameforformuserfile ?>_section_dir").val(rel);
71 jQuery(
"#<?php echo $nameforformuserfile ?>_section_id").val(
id);
72 jQuery(
"#section_dir").val(rel);
73 jQuery(
"#section_id").val(
id);
74 jQuery(
"#section").val(
id);
75 jQuery(
'#<?php echo $nameforformuserfile ?>').show();
76 console.log(
"We also execute the loadandshowpreview() that is on the onclick of each li defined by ajaxdirtree");
81 $(
'#refreshbutton').click(
function() {
82 console.log(
"Click on refreshbutton");
83 $.pleaseBePatient(
"<?php echo $langs->trans('PleaseBePatient'); ?>");
84 $.get(
"<?php echo DOL_URL_ROOT.'/ecm/ajax/ecmdatabase.php'; ?>", {
86 token:
'<?php echo newToken(); ?>',
91 location.href=
'<?php echo $_SERVER['PHP_SELF
']; ?>';
96 function loadandshowpreview(filedirname,section)
102 $(
'#ecmfileview').empty();
104 var url =
'<?php echo dol_buildpath('/core/ajax/ajaxdirpreview.php
', 1); ?>?action=preview&module=<?php echo $module; ?>§ion='+section+
'&file='+urlencode(filedirname)<?php echo (empty($paramwithoutsection) ?
'' :
"+'".$paramwithoutsection.
"'"); ?>;
105 $.get(url,
function(data) {
107 pos=data.indexOf(
"TYPE=directory",0);
109 if ((pos > 0) && (pos < 20))
111 filediractive=filedirname;
112 filetypeactive=
'directory';
116 filediractive=filedirname;
117 filetypeactive=
'file';
119 $(
'#ecmfileview').append(data);
124 <!-- END PHP TEMPLATE ecm/tpl/enablefiletreeajax.tpl.php -->