30@phan-var-force string $param
34 print
"Error, template enablefiletreeajax.tpl.php can't be called as URL";
40<!-- BEGIN PHP TEMPLATE ecm/tpl/enablefiletreeajax.tpl.php -->
41<!-- Doc of fileTree plugin at https:
43<script
type=
"text/javascript">
49if (empty($nameforformuserfile)) {
50 $nameforformuserfile =
'';
52$paramwithoutsection = preg_replace(
'/&?section=(\d+)/',
'', $param);
59$paramsdirtree = array(
61 'modulepart' => $module,
62 'openeddir' => $openeddir,
64if (!empty($preopened)) {
65 $paramsdirtree[
'preopened'] = $preopened;
69$dirtreeurl =
dolBuildUrl(DOL_URL_ROOT.
'/core/ajax/ajaxdirtree.php', $paramsdirtree).(empty($paramwithoutsection) ?
'' : $paramwithoutsection);
73$(document).ready(
function() {
75 $(
'#filetree').fileTree({
76 root:
'<?php print dol_escape_js($openeddir); ?>',
78 script:
'<?php echo $dirtreeurl; ?>',
83 console.log(
"We click on a file "+file);
85 loadandshowpreview(file,0);
89 id=elem.attr(
'id').substr(12);
91 console.log(
"We click on a dir id="+
id+
", we call the ajaxdirtree.php with modulepart=<?php echo $module; ?>, param=<?php echo $paramwithoutsection; ?>");
92 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);
93 jQuery(
"#<?php echo $nameforformuserfile ?>_section_dir").val(rel);
94 jQuery(
"#<?php echo $nameforformuserfile ?>_section_id").val(
id);
95 jQuery(
"#section_dir").val(rel);
96 jQuery(
"#section_id").val(
id);
97 jQuery(
"#section").val(
id);
98 jQuery(
'#<?php echo $nameforformuserfile ?>').show();
99 console.log(
"We also execute the loadandshowpreview() that is on the onclick of each li defined by ajaxdirtree");
104 $(
'#refreshbutton').click(
function() {
105 console.log(
"Click on refreshbutton");
107 dolBlockUI(
"<?php echo $langs->transnoentities('PleaseBePatient'); ?>");
109 $.get(
"<?php echo DOL_URL_ROOT.'/ecm/ajax/ecmdatabase.php'; ?>", {
111 token:
'<?php echo currentToken(); ?>',
113 },
function(response) {
117 location.href=
'<?php echo $_SERVER['PHP_SELF
']; ?>';
123function loadandshowpreview(filedirname,section)
129 $(
'#ecmfileview').empty();
131 var url =
'<?php echo dol_escape_js(dolBuildUrl(dol_buildpath('/core/ajax/ajaxdirpreview.php
', 1), array('action
' => 'preview
', 'module
' => $module))); ?>§ion='+urlencode(section)+
'&file='+urlencode(filedirname)<?php echo (empty($paramwithoutsection) ?
'' :
"+'".
dol_escape_js($paramwithoutsection).
"'"); ?>;
132 $.get(url,
function(data) {
134 pos=data.indexOf(
"TYPE=directory",0);
136 if ((pos > 0) && (pos < 20))
138 filediractive=filedirname;
139 filetypeactive=
'directory';
143 filediractive=filedirname;
144 filetypeactive=
'file';
146 $(
'#ecmfileview').append(data);
151<!-- END PHP TEMPLATE ecm/tpl/enablefiletreeajax.tpl.php -->
currentToken()
Return the value of token currently saved into session with name 'token'.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into JavaScript code.
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...