29 if (!defined(
'NOTOKENRENEWAL')) define(
'NOTOKENRENEWAL', 1);
30 if (!defined(
'NOREQUIREMENU')) define(
'NOREQUIREMENU',
'1');
31 if (!defined(
'NOREQUIREHTML')) define(
'NOREQUIREHTML',
'1');
32 if (!defined(
'NOREQUIREAJAX')) define(
'NOREQUIREAJAX',
'1');
34 if (!isset($mode) || $mode !=
'noajax')
36 $res = @include
'../../main.inc.php';
37 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
38 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
39 include_once DOL_DOCUMENT_ROOT.
'/core/lib/treeview.lib.php';
40 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
41 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
45 $openeddir =
GETPOST(
'openeddir');
46 $modulepart =
GETPOST(
'modulepart');
49 $preopened =
GETPOST(
'preopened');
51 if ($selecteddir !=
'/') $selecteddir = preg_replace(
'/\/$/',
'', $selecteddir);
56 $openeddir =
GETPOST(
'openeddir');
57 $modulepart =
GETPOST(
'modulepart');
60 $preopened =
GETPOST(
'preopened');
62 if ($selecteddir !=
'/') $selecteddir = preg_replace(
'/\/$/',
'', $selecteddir);
63 if (empty($url)) $url = DOL_URL_ROOT.
'/ecm/index.php';
70 $fullpathselecteddir =
'<none>';
71 if ($modulepart ==
'ecm')
73 $fullpathselecteddir = $conf->ecm->dir_output.
'/'.($selecteddir !=
'/' ? $selecteddir :
'');
74 $fullpathpreopened = $conf->ecm->dir_output.
'/'.($preopened !=
'/' ? $preopened :
'');
75 } elseif ($modulepart ==
'medias')
77 $fullpathselecteddir = $dolibarr_main_data_root.
'/medias/'.($selecteddir !=
'/' ? $selecteddir :
'');
78 $fullpathpreopened = $dolibarr_main_data_root.
'/medias/'.($preopened !=
'/' ? $preopened :
'');
84 if (preg_match(
'/\.\./', $fullpathselecteddir) || preg_match(
'/[<>|]/', $fullpathselecteddir))
86 dol_syslog(
"Refused to deliver file ".$original_file);
93 if ($modulepart ==
'ecm')
96 } elseif ($modulepart ==
'medias')
106 if (!isset($mode) || $mode !=
'noajax')
112 $userstatic =
new User($db);
113 $form =
new Form($db);
117 if (empty($sqltree)) $sqltree = $ecmdirstatic->get_full_arbo(0);
120 $current_ecmdir_id = -1;
121 foreach ($sqltree as $keycursor => $val)
124 if ($val[
'fullrelativename'] == $selecteddir)
126 $current_ecmdir_id = $keycursor;
130 if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))
132 treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened);
137 print "\n<!-- JS CODE TO ENABLE Tooltips on all object with class classfortooltip (reload into ajaxdirtree) -->\n";
138 print '<script type="text/javascript">
139 jQuery(document).ready(function () {
140 jQuery(".classfortooltip").tooltip({
141 show: { collision: "flipfit", effect:\'toggle\', delay:50 },
142 hide: { delay: 50 }, /* If I enable effect:\'toggle\' here, a bug appears: the tooltip is shown when collpasing a new dir if it was shown before */
143 tooltipClass: "mytooltip",
144 content: function () {
145 return $(this).prop(\'title\'); /* To force to get title as is */
158 if (empty($conf->use_javascript_ajax) || !empty($conf->global->MAIN_ECM_DISABLE_JS))
160 print '<ul class="ecmjqft">';
163 if (empty($sqltree)) $sqltree = $ecmdirstatic->get_full_arbo(0);
170 $fullpathselected =
'';
171 foreach ($sqltree as $key => $val)
174 if ($val[
'id'] == $section)
176 $fullpathselected = $val[
'fullpath'];
183 $expandedsectionarray = array();
184 if (isset($_SESSION[
'dol_ecmexpandedsectionarray'])) $expandedsectionarray = explode(
',', $_SESSION[
'dol_ecmexpandedsectionarray']);
186 if ($section &&
GETPOST(
'sectionexpand') ==
'true')
189 $pathtosection = explode(
'_', $fullpathselected);
190 foreach ($pathtosection as $idcursor)
192 if ($idcursor && !in_array($idcursor, $expandedsectionarray))
194 $expandedsectionarray[] = $idcursor;
197 $_SESSION[
'dol_ecmexpandedsectionarray'] = join(
',', $expandedsectionarray);
199 if ($section &&
GETPOST(
'sectionexpand') ==
'false')
202 $oldexpandedsectionarray = $expandedsectionarray;
203 $expandedsectionarray = array();
204 foreach ($oldexpandedsectionarray as $sectioncursor)
209 $_SESSION[
'dol_ecmexpandedsectionarray'] = join(
',', $expandedsectionarray);
215 foreach ($sqltree as $key => $val)
217 $ecmdirstatic->id = $val[
'id'];
218 $ecmdirstatic->ref = $val[
'label'];
221 if (preg_match(
'/refresh/i', $action))
223 $result = $ecmdirstatic->fetch($val[
'id']);
224 $ecmdirstatic->ref = $ecmdirstatic->label;
226 $result = $ecmdirstatic->refreshcachenboffile(0);
227 $val[
'cachenbofdoc'] = $result;
236 if (in_array($val[
'id_mere'], $expandedsectionarray)) $showline = 4;
238 elseif ($val[
'id'] != $section && $val[
'id_mere'] == $ecmdirstatic->motherof[$section]) $showline = 3;
240 elseif (preg_match('/'.$val['fullpath'].'_/i', $fullpathselected.'_')) $showline = 2;
242 elseif ($val['level'] < 2) $showline = 1;
246 if (in_array($val[
'id'], $expandedsectionarray)) $option =
'indexexpanded';
247 else $option =
'indexnotexpanded';
250 print '<li class="directory collapsed">';
254 while ($cpt < $sqltree[$key][
'level'])
256 print ' ';
261 $nbofsubdir = $resarray[1];
262 $nboffilesinsubdir = $resarray[2];
265 print $ecmdirstatic->getNomUrl(0, $option, 32,
'class="fmdirlia jqft ecmjqft"');
267 print '<div class="ecmjqft">';
270 print '<table class="nobordernopadding"><tr><td>';
271 print $val[
'cachenbofdoc'];
273 print '<td class="left">';
274 if ($nbofsubdir && $nboffilesinsubdir)
print '<font color="#AAAAAA">+'.$nboffilesinsubdir.
'</font> ';
278 print '<td class="center">';
279 $userstatic->id = $val[
'fk_user_c'];
280 $userstatic->lastname = $val[
'login_c'];
281 $htmltooltip =
'<b>'.$langs->trans(
"ECMSection").
'</b>: '.$val[
'label'].
'<br>';
282 $htmltooltip =
'<b>'.$langs->trans(
"Type").
'</b>: '.$langs->trans(
"ECMSectionManual").
'<br>';
283 $htmltooltip .=
'<b>'.$langs->trans(
"ECMCreationUser").
'</b>: '.$userstatic->getNomUrl(1,
'',
false, 1).
'<br>';
284 $htmltooltip .=
'<b>'.$langs->trans(
"ECMCreationDate").
'</b>: '.
dol_print_date($val[
'date_c'],
"dayhour").
'<br>';
285 $htmltooltip .=
'<b>'.$langs->trans(
"Description").
'</b>: '.$val[
'description'].
'<br>';
286 $htmltooltip .=
'<b>'.$langs->trans(
"ECMNbOfFilesInDir").
'</b>: '.$val[
'cachenbofdoc'].
'<br>';
287 if ($nbofsubdir) $htmltooltip .=
'<b>'.$langs->trans(
"ECMNbOfFilesInSubDir").
'</b>: '.$nboffilesinsubdir;
288 else $htmltooltip .=
'<b>'.$langs->trans(
"ECMNbOfSubDir").
'</b>: '.$nbofsubdir.
'<br>';
289 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
292 print '</tr></table>';
299 $oldvallevel = $val[
'level'];
304 if ($nbofentries == 0)
306 print '<li class="directory collapsed">';
307 print '<div class="ecmjqft">';
308 print $langs->trans(
"ECMNoDirectoryYet");
318 if ((!isset($mode) || $mode !=
'noajax') && is_object($db)) $db->close();
336 function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth = 0)
338 global $conf, $db, $langs, $form;
339 global $dolibarr_main_data_root;
342 $userstatic =
new User($db);
344 if (file_exists($fullpathselecteddir))
346 $files = @scandir($fullpathselecteddir);
351 if (count($files) > 2)
353 echo
'<ul class="ecmjqft" style="display: none;">'.
"\n";
356 foreach ($files as $file)
358 if ($file ==
'temp')
continue;
361 $nboffilesinsubdir = 0;
366 foreach ($sqltree as $key => $tmpval)
369 if ($tmpval[
'fullrelativename'] == (($selecteddir !=
'/' ? $selecteddir.
'/' :
'').$file))
375 if (isset($val[
'cachenbofdoc']) && $val[
'cachenbofdoc'] < 0)
377 $result = $ecmdirstatic->fetch($val[
'id']);
378 $ecmdirstatic->ref = $ecmdirstatic->label;
380 $result = $ecmdirstatic->refreshcachenboffile(0);
381 $val[
'cachenbofdoc'] = $result;
385 $nbofsubdir = $resarray[1];
386 $nboffilesinsubdir = $resarray[2];
392 if ($file !=
'.' && $file !=
'..' && ((!empty($val[
'fullrelativename']) && $val[
'id'] >= 0) ||
dol_is_dir($fullpathselecteddir.(preg_match(
'/\/$/', $fullpathselecteddir) ?
'' :
'/').$file)))
394 if (empty($val[
'fullrelativename']))
396 $val[
'fullrelativename'] = (($selecteddir && $selecteddir !=
'/') ? $selecteddir.
'/' :
'').$file;
398 $val[
'label'] = $file;
399 $val[
'description'] =
'';
400 $nboffilesinsubdir = $langs->trans(
"Unknown");
403 $collapsedorexpanded =
'collapsed';
404 if (preg_match(
'/^'.preg_quote($val[
'fullrelativename'].
'/',
'/').
'/', $preopened)) $collapsedorexpanded =
'expanded';
405 print '<li class="directory '.$collapsedorexpanded.
'">';
407 print "<a class=\"fmdirlia jqft ecmjqft\" href=\"";
409 print "\" rel=\"".dol_escape_htmltag($val[
'fullrelativename'].
'/').
"\" id=\"fmdirlia_id_".$val[
'id'].
"\"";
410 print " onClick=\"loadandshowpreview('".dol_escape_js($val[
'fullrelativename']).
"',".$val[
'id'].
")";
415 print '<div class="ecmjqft">';
417 print '<table class="nobordernopadding"><tr>';
424 print '<td class="right">';
425 print (isset($val[
'cachenbofdoc']) && $val[
'cachenbofdoc'] >= 0) ? $val[
'cachenbofdoc'] :
' ';
427 print '<td class="left">';
428 if ($nbofsubdir > 0 && $nboffilesinsubdir > 0)
print '<font class="opacitymedium">+'.$nboffilesinsubdir.
'</font> ';
432 print '<td class="right" width="18"><a class="editfielda" href="';
433 print DOL_URL_ROOT.
'/ecm/dir_card.php?module='.urlencode($modulepart).
'§ion='.$val[
'id'].
'&relativedir='.urlencode($val[
'fullrelativename']);
434 print '&backtopage='.urlencode(
$_SERVER[
"PHP_SELF"].
'?file_manager=1&website='.$websitekey.
'&pageid='.$pageid);
435 print '">'.img_edit($langs->trans(
"Edit").
' - '.$langs->trans(
"View"), 0,
'class="valignmiddle opacitymedium"').
'</a></td>';
442 if ($modulepart ==
'ecm')
444 print '<td class="right" width="18">';
445 $userstatic->id = isset($val[
'fk_user_c']) ? $val[
'fk_user_c'] : 0;
446 $userstatic->lastname = isset($val[
'login_c']) ? $val[
'login_c'] : 0;
447 $htmltooltip =
'<b>'.$langs->trans(
"ECMSection").
'</b>: '.$val[
'label'].
'<br>';
448 $htmltooltip =
'<b>'.$langs->trans(
"Type").
'</b>: '.$langs->trans(
"ECMSectionManual").
'<br>';
449 $htmltooltip .=
'<b>'.$langs->trans(
"ECMCreationUser").
'</b>: '.$userstatic->getNomUrl(1,
'',
false, 1).
'<br>';
450 $htmltooltip .=
'<b>'.$langs->trans(
"ECMCreationDate").
'</b>: '.(isset($val[
'date_c']) ?
dol_print_date($val[
'date_c'],
"dayhour") : $langs->trans(
"NeedRefresh")).
'<br>';
451 $htmltooltip .=
'<b>'.$langs->trans(
"Description").
'</b>: '.$val[
'description'].
'<br>';
452 $htmltooltip .=
'<b>'.$langs->trans(
"ECMNbOfFilesInDir").
'</b>: '.((isset($val[
'cachenbofdoc']) && $val[
'cachenbofdoc'] >= 0) ? $val[
'cachenbofdoc'] : $langs->trans(
"NeedRefresh")).
'<br>';
453 if ($nboffilesinsubdir > 0) $htmltooltip .=
'<b>'.$langs->trans(
"ECMNbOfFilesInSubDir").
'</b>: '.$nboffilesinsubdir;
454 else $htmltooltip .=
'<b>'.$langs->trans(
"ECMNbOfSubDir").
'</b>: '.($nbofsubdir >= 0 ? $nbofsubdir : $langs->trans(
"NeedRefresh")).
'<br>';
455 print $form->textwithpicto(
'', $htmltooltip, 1,
"info");
459 print "</tr></table>\n";
463 if (preg_match(
'/^'.preg_quote($val[
'fullrelativename'].
'/',
'/').
'/', $preopened))
466 $newselecteddir = $val[
'fullrelativename'];
467 $newfullpathselecteddir =
'';
468 if ($modulepart ==
'ecm')
470 $newfullpathselecteddir = $conf->ecm->dir_output.
'/'.($val[
'fullrelativename'] !=
'/' ? $val[
'fullrelativename'] :
'');
471 } elseif ($modulepart ==
'medias')
473 $newfullpathselecteddir = $dolibarr_main_data_root.
'/medias/'.($val[
'fullrelativename'] !=
'/' ? $val[
'fullrelativename'] :
'');
476 if ($newfullpathselecteddir)
treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth + 1);
485 }
else print "PermissionDenied";
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
tree_showpad(&$fulltree, $key, $silent=0)
Show indent and picto of a tree line.
Class to manage Dolibarr users.
dol_is_dir($folder)
Test if filename is a directory.
if(!defined('NOREQUIREMENU')) if(!function_exists("llxHeader")) top_httphead($contenttype= 'text/html', $forcenocache=0)
Show HTTP header.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
jsUnEscape($source)
Same function than javascript unescape() function but in PHP.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
print $_SERVER["PHP_SELF"]
Edit parameters.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth=0)
treeOutputForAbsoluteDir
Class to manage ECM directories.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...