|
@@ -72,12 +72,12 @@ $fullpathselecteddir='<none>';
|
|
|
if ($modulepart == 'ecm')
|
|
|
{
|
|
|
$fullpathselecteddir=$conf->ecm->dir_output.'/'.($selecteddir != '/' ? $selecteddir : '');
|
|
|
- $fullpathopeneddir=$conf->ecm->dir_output.'/'.($openeddir != '/' ? $openeddir : '');
|
|
|
+ $fullpathpreopened=$conf->ecm->dir_output.'/'.($preopened != '/' ? $preopened : '');
|
|
|
}
|
|
|
if ($modulepart == 'medias')
|
|
|
{
|
|
|
$fullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($selecteddir != '/' ? $selecteddir : '');
|
|
|
- $fullpathopeneddir=$dolibarr_main_data_root.'/medias/'.($openeddir != '/' ? $openeddir : '');
|
|
|
+ $fullpathpreopened=$dolibarr_main_data_root.'/medias/'.($preopened != '/' ? $preopened : '');
|
|
|
}
|
|
|
|
|
|
|
|
@@ -132,161 +132,9 @@ foreach($sqltree as $keycursor => $val)
|
|
|
|
|
|
if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))
|
|
|
{
|
|
|
+ treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened);
|
|
|
|
|
|
-/**
|
|
|
- * 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);
|
|
|
-
|
|
|
- if ($files)
|
|
|
- {
|
|
|
- natcasesort($files);
|
|
|
- if (count($files) > 2) /* The 2 accounts for . and .. */
|
|
|
- {
|
|
|
- echo '<ul class="ecmjqft" style="display: none;">'."\n";
|
|
|
-
|
|
|
- // All dirs
|
|
|
- foreach ($files as $file) // $file can be '.', '..', or 'My dir' or 'My file'
|
|
|
- {
|
|
|
- if ($file == 'temp') continue;
|
|
|
-
|
|
|
- $nbofsubdir=0;
|
|
|
- $nboffilesinsubdir=0;
|
|
|
-
|
|
|
- $val=array();
|
|
|
-
|
|
|
- // Loop on all database entries (sqltree) to find the one matching the subdir found into dir to scan
|
|
|
- foreach($sqltree as $key => $tmpval)
|
|
|
- {
|
|
|
- //print "-- key=".$key." - ".$tmpval['fullrelativename']." vs ".(($selecteddir != '/'?$selecteddir.'/':'').$file)."<br>\n";
|
|
|
- if ($tmpval['fullrelativename'] == (($selecteddir != '/'?$selecteddir.'/':'').$file)) // We found equivalent record into database
|
|
|
- {
|
|
|
- $val=$tmpval;
|
|
|
- $resarray=tree_showpad($sqltree,$key,1);
|
|
|
-
|
|
|
- // Refresh cache for this subdir
|
|
|
- if (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] < 0) // Cache is not up to date, so we update it for this directory t
|
|
|
- {
|
|
|
- $result=$ecmdirstatic->fetch($val['id']);
|
|
|
- $ecmdirstatic->ref=$ecmdirstatic->label;
|
|
|
-
|
|
|
- $result=$ecmdirstatic->refreshcachenboffile(0);
|
|
|
- $val['cachenbofdoc']=$result;
|
|
|
- }
|
|
|
-
|
|
|
- $a=$resarray[0];
|
|
|
- $nbofsubdir=$resarray[1];
|
|
|
- $nboffilesinsubdir=$resarray[2];
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //print 'modulepart='.$modulepart.' fullpathselecteddir='.$fullpathselecteddir.' - val[fullrelativename] (in database)='.$val['fullrelativename'].' - val[id]='.$val['id'].' - is_dir='.dol_is_dir($fullpathselecteddir . $file).' - file='.$file."\n";
|
|
|
- if ($file != '.' && $file != '..' && ((! empty($val['fullrelativename']) && $val['id'] >= 0) || dol_is_dir($fullpathselecteddir . (preg_match('/\/$/',$fullpathselecteddir)?'':'/') . $file)))
|
|
|
- {
|
|
|
- if (empty($val['fullrelativename'])) // If we did not find entry into database, but found a directory (dol_is_dir was ok at previous test)
|
|
|
- {
|
|
|
- $val['fullrelativename']=(($selecteddir && $selecteddir != '/')?$selecteddir.'/':'').$file;
|
|
|
- $val['id']=0;
|
|
|
- $val['label']=$file;
|
|
|
- $val['description']='';
|
|
|
- $nboffilesinsubdir=$langs->trans("Unknown");
|
|
|
- }
|
|
|
-
|
|
|
- print '<li class="directory collapsed">'; // collapsed is opposite if expanded
|
|
|
-
|
|
|
- print "<a class=\"fmdirlia jqft ecmjqft\" href=\"";
|
|
|
- print "#";
|
|
|
- print "\" rel=\"" . dol_escape_htmltag($val['fullrelativename'].'/') . "\" id=\"fmdirlia_id_".$val['id']."\"";
|
|
|
- print " onClick=\"loadandshowpreview('".dol_escape_js($val['fullrelativename'])."',".$val['id'].")";
|
|
|
- print "\">";
|
|
|
- print dol_escape_htmltag($file);
|
|
|
- print "</a>";
|
|
|
-
|
|
|
- print '<div class="ecmjqft">';
|
|
|
-
|
|
|
- print '<table class="nobordernopadding"><tr>';
|
|
|
-
|
|
|
- /*print '<td align="left">';
|
|
|
- print dol_escape_htmltag($file);
|
|
|
- print '</td>';*/
|
|
|
-
|
|
|
- // Nb of docs
|
|
|
- print '<td align="right">';
|
|
|
- print (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0)?$val['cachenbofdoc']:' ';
|
|
|
- print '</td>';
|
|
|
- print '<td align="left">';
|
|
|
- if ($nbofsubdir > 0 && $nboffilesinsubdir > 0) print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> ';
|
|
|
- print '</td>';
|
|
|
-
|
|
|
- // Edit link
|
|
|
- print '<td align="right" width="18"><a href="';
|
|
|
- print DOL_URL_ROOT.'/ecm/dir_card.php?module='.urlencode($modulepart).'§ion='.$val['id'].'&relativedir='.urlencode($val['fullrelativename']);
|
|
|
- print '&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid);
|
|
|
- print '">'.img_edit($langs->trans("Edit").' - '.$langs->trans("View"), 0, 'class="valignmiddle opacitymedium"').'</a></td>';
|
|
|
-
|
|
|
- // Add link
|
|
|
- //print '<td align="right"><a href="'.DOL_URL_ROOT.'/ecm/dir_add_card.php?action=create&catParent='.$val['id'].'">'.img_edit_add().'</a></td>';
|
|
|
- //print '<td align="right" width="14"> </td>';
|
|
|
-
|
|
|
- // Info
|
|
|
- if ($modulepart == 'ecm')
|
|
|
- {
|
|
|
- print '<td align="right" width="18">';
|
|
|
- $userstatic->id=isset($val['fk_user_c'])?$val['fk_user_c']:0;
|
|
|
- $userstatic->lastname=isset($val['login_c'])?$val['login_c']:0;
|
|
|
- $htmltooltip='<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>';
|
|
|
- $htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionManual").'<br>';
|
|
|
- $htmltooltip.='<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1, '', false, 1).'<br>';
|
|
|
- $htmltooltip.='<b>'.$langs->trans("ECMCreationDate").'</b>: '.(isset($val['date_c'])?dol_print_date($val['date_c'],"dayhour"):$langs->trans("NeedRefresh")).'<br>';
|
|
|
- $htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>';
|
|
|
- $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.((isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0)?$val['cachenbofdoc']:$langs->trans("NeedRefresh")).'<br>';
|
|
|
- if ($nboffilesinsubdir > 0) $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir;
|
|
|
- else $htmltooltip.='<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.($nbofsubdir >= 0 ? $nbofsubdir : $langs->trans("NeedRefresh")).'<br>';
|
|
|
- print $form->textwithpicto('',$htmltooltip,1,"info");
|
|
|
- print "</td>";
|
|
|
- }
|
|
|
-
|
|
|
- print "</tr></table>\n";
|
|
|
- print '</div>';
|
|
|
-
|
|
|
- if (0)
|
|
|
- {
|
|
|
- treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid);
|
|
|
- }
|
|
|
-
|
|
|
- //print '<div> </div>';
|
|
|
- print "</li>\n";
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- echo "</ul>\n";
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- else print "PermissionDenied";
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
- treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid);
|
|
|
-
|
|
|
+ // TODO Find a solution to not output this code for each leaf we open
|
|
|
// 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";
|
|
@@ -472,3 +320,175 @@ if (empty($conf->use_javascript_ajax) || ! empty($conf->global->MAIN_ECM_DISABLE
|
|
|
|
|
|
// Close db if mode is not noajax
|
|
|
if ((! isset($mode) || $mode != 'noajax') && is_object($db)) $db->close();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 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
|
|
|
+ * @param string $preopened Current open dir
|
|
|
+ * @param string $fullpathpreopened Full path of current open dir
|
|
|
+ * @param int $depth Depth
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth=0)
|
|
|
+{
|
|
|
+ global $conf, $db, $langs, $form;
|
|
|
+ global $dolibarr_main_data_root;
|
|
|
+
|
|
|
+ $ecmdirstatic = new EcmDirectory($db);
|
|
|
+ $userstatic = new User($db);
|
|
|
+
|
|
|
+ if (file_exists($fullpathselecteddir))
|
|
|
+ {
|
|
|
+ $files = @scandir($fullpathselecteddir);
|
|
|
+
|
|
|
+ if ($files)
|
|
|
+ {
|
|
|
+ natcasesort($files);
|
|
|
+ if (count($files) > 2) /* The 2 accounts for . and .. */
|
|
|
+ {
|
|
|
+ echo '<ul class="ecmjqft" style="display: none;">'."\n";
|
|
|
+
|
|
|
+ // All dirs
|
|
|
+ foreach ($files as $file) // $file can be '.', '..', or 'My dir' or 'My file'
|
|
|
+ {
|
|
|
+ if ($file == 'temp') continue;
|
|
|
+
|
|
|
+ $nbofsubdir=0;
|
|
|
+ $nboffilesinsubdir=0;
|
|
|
+
|
|
|
+ $val=array();
|
|
|
+
|
|
|
+ // Loop on all database entries (sqltree) to find the one matching the subdir found into dir to scan
|
|
|
+ foreach($sqltree as $key => $tmpval)
|
|
|
+ {
|
|
|
+ //print "-- key=".$key." - ".$tmpval['fullrelativename']." vs ".(($selecteddir != '/'?$selecteddir.'/':'').$file)."<br>\n";
|
|
|
+ if ($tmpval['fullrelativename'] == (($selecteddir != '/'?$selecteddir.'/':'').$file)) // We found equivalent record into database
|
|
|
+ {
|
|
|
+ $val=$tmpval;
|
|
|
+ $resarray=tree_showpad($sqltree,$key,1);
|
|
|
+
|
|
|
+ // Refresh cache for this subdir
|
|
|
+ if (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] < 0) // Cache is not up to date, so we update it for this directory t
|
|
|
+ {
|
|
|
+ $result=$ecmdirstatic->fetch($val['id']);
|
|
|
+ $ecmdirstatic->ref=$ecmdirstatic->label;
|
|
|
+
|
|
|
+ $result=$ecmdirstatic->refreshcachenboffile(0);
|
|
|
+ $val['cachenbofdoc']=$result;
|
|
|
+ }
|
|
|
+
|
|
|
+ $a=$resarray[0];
|
|
|
+ $nbofsubdir=$resarray[1];
|
|
|
+ $nboffilesinsubdir=$resarray[2];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //print 'modulepart='.$modulepart.' fullpathselecteddir='.$fullpathselecteddir.' - val[fullrelativename] (in database)='.$val['fullrelativename'].' - val[id]='.$val['id'].' - is_dir='.dol_is_dir($fullpathselecteddir . $file).' - file='.$file."\n";
|
|
|
+ if ($file != '.' && $file != '..' && ((! empty($val['fullrelativename']) && $val['id'] >= 0) || dol_is_dir($fullpathselecteddir . (preg_match('/\/$/',$fullpathselecteddir)?'':'/') . $file)))
|
|
|
+ {
|
|
|
+ if (empty($val['fullrelativename'])) // If we did not find entry into database, but found a directory (dol_is_dir was ok at previous test)
|
|
|
+ {
|
|
|
+ $val['fullrelativename']=(($selecteddir && $selecteddir != '/')?$selecteddir.'/':'').$file;
|
|
|
+ $val['id']=0;
|
|
|
+ $val['label']=$file;
|
|
|
+ $val['description']='';
|
|
|
+ $nboffilesinsubdir=$langs->trans("Unknown");
|
|
|
+ }
|
|
|
+
|
|
|
+ $collapsedorexpanded='collapsed';
|
|
|
+ if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened)) $collapsedorexpanded='expanded';
|
|
|
+ print '<li class="directory '.$collapsedorexpanded.'">'; // collapsed is opposite if expanded
|
|
|
+
|
|
|
+ print "<a class=\"fmdirlia jqft ecmjqft\" href=\"";
|
|
|
+ print "#";
|
|
|
+ print "\" rel=\"" . dol_escape_htmltag($val['fullrelativename'].'/') . "\" id=\"fmdirlia_id_".$val['id']."\"";
|
|
|
+ print " onClick=\"loadandshowpreview('".dol_escape_js($val['fullrelativename'])."',".$val['id'].")";
|
|
|
+ print "\">";
|
|
|
+ print dol_escape_htmltag($file);
|
|
|
+ print "</a>";
|
|
|
+
|
|
|
+ print '<div class="ecmjqft">';
|
|
|
+
|
|
|
+ print '<table class="nobordernopadding"><tr>';
|
|
|
+
|
|
|
+ /*print '<td align="left">';
|
|
|
+ print dol_escape_htmltag($file);
|
|
|
+ print '</td>';*/
|
|
|
+
|
|
|
+ // Nb of docs
|
|
|
+ print '<td align="right">';
|
|
|
+ print (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0)?$val['cachenbofdoc']:' ';
|
|
|
+ print '</td>';
|
|
|
+ print '<td align="left">';
|
|
|
+ if ($nbofsubdir > 0 && $nboffilesinsubdir > 0) print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> ';
|
|
|
+ print '</td>';
|
|
|
+
|
|
|
+ // Edit link
|
|
|
+ print '<td align="right" width="18"><a href="';
|
|
|
+ print DOL_URL_ROOT.'/ecm/dir_card.php?module='.urlencode($modulepart).'§ion='.$val['id'].'&relativedir='.urlencode($val['fullrelativename']);
|
|
|
+ print '&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid);
|
|
|
+ print '">'.img_edit($langs->trans("Edit").' - '.$langs->trans("View"), 0, 'class="valignmiddle opacitymedium"').'</a></td>';
|
|
|
+
|
|
|
+ // Add link
|
|
|
+ //print '<td align="right"><a href="'.DOL_URL_ROOT.'/ecm/dir_add_card.php?action=create&catParent='.$val['id'].'">'.img_edit_add().'</a></td>';
|
|
|
+ //print '<td align="right" width="14"> </td>';
|
|
|
+
|
|
|
+ // Info
|
|
|
+ if ($modulepart == 'ecm')
|
|
|
+ {
|
|
|
+ print '<td align="right" width="18">';
|
|
|
+ $userstatic->id=isset($val['fk_user_c'])?$val['fk_user_c']:0;
|
|
|
+ $userstatic->lastname=isset($val['login_c'])?$val['login_c']:0;
|
|
|
+ $htmltooltip='<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>';
|
|
|
+ $htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionManual").'<br>';
|
|
|
+ $htmltooltip.='<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1, '', false, 1).'<br>';
|
|
|
+ $htmltooltip.='<b>'.$langs->trans("ECMCreationDate").'</b>: '.(isset($val['date_c'])?dol_print_date($val['date_c'],"dayhour"):$langs->trans("NeedRefresh")).'<br>';
|
|
|
+ $htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>';
|
|
|
+ $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.((isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0)?$val['cachenbofdoc']:$langs->trans("NeedRefresh")).'<br>';
|
|
|
+ if ($nboffilesinsubdir > 0) $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir;
|
|
|
+ else $htmltooltip.='<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.($nbofsubdir >= 0 ? $nbofsubdir : $langs->trans("NeedRefresh")).'<br>';
|
|
|
+ print $form->textwithpicto('',$htmltooltip,1,"info");
|
|
|
+ print "</td>";
|
|
|
+ }
|
|
|
+
|
|
|
+ print "</tr></table>\n";
|
|
|
+ print '</div>';
|
|
|
+
|
|
|
+ //print 'selecteddir='.$selecteddir.' preopened='.$preopened.' $val[\'fullrelativename\']='.$val['fullrelativename']."<br>\n";
|
|
|
+ if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened))
|
|
|
+ {
|
|
|
+ //print 'modulepart='.$modulepart.' fullpathselecteddir='.$fullpathselecteddir.' - val[fullrelativename] (in database)='.$val['fullrelativename'].' - val[id]='.$val['id'].' - is_dir='.dol_is_dir($fullpathselecteddir . $file).' - file='.$file."\n";
|
|
|
+ $newselecteddir = $val['fullrelativename'];
|
|
|
+ if ($modulepart == 'ecm')
|
|
|
+ {
|
|
|
+ $newfullpathselecteddir=$conf->ecm->dir_output.'/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : '');
|
|
|
+ }
|
|
|
+ if ($modulepart == 'medias')
|
|
|
+ {
|
|
|
+ $newfullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : '');
|
|
|
+ }
|
|
|
+
|
|
|
+ treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth+1);
|
|
|
+ }
|
|
|
+
|
|
|
+ print "</li>\n";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ echo "</ul>\n";
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else print "PermissionDenied";
|
|
|
+ }
|
|
|
+}
|
|
|
+
|