diff --git a/htdocs/core/ajax/ajaxdirtree.php b/htdocs/core/ajax/ajaxdirtree.php index ea4bf830e21..2390e163239 100644 --- a/htdocs/core/ajax/ajaxdirtree.php +++ b/htdocs/core/ajax/ajaxdirtree.php @@ -23,25 +23,35 @@ // This script is called with a POST method. -// Directory to scan (full path) is inside POST['dir']. +// Directory to scan (full path) is inside POST['dir'] and encode by js escape() if ajax is used or encoded by urlencode if mode=noajax if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -$res=@include '../../main.inc.php'; -include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; -include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -include_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; -include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; -include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; +if (! isset($mode) || $mode != 'noajax') // For ajax call +{ + $res=@include '../../main.inc.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; + include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; -$openeddir = GETPOST('openeddir'); -$modulepart= GETPOST('modulepart'); -$selecteddir = jsUnEscape(GETPOST('dir')); // relative path. We must decode using same encoding function used by javascript: escape() -if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/','',$selecteddir); // We removed last '/' except if it is '/' + $openeddir = GETPOST('openeddir'); + $modulepart= GETPOST('modulepart'); + $selecteddir = jsUnEscape(GETPOST('dir')); // relative path. We must decode using same encoding function used by javascript: escape() + if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/','',$selecteddir); // We removed last '/' except if it is '/' +} +else // For no ajax call +{ + $openeddir = GETPOST('openeddir'); + $modulepart= GETPOST('modulepart'); + $selecteddir = GETPOST('dir'); + if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/','',$selecteddir); // We removed last '/' except if it is '/' + if (empty($url)) $url=DOL_URL_ROOT.'/ecm/index.php'; +} $langs->load("ecm"); @@ -76,7 +86,10 @@ if ($modulepart == 'medias') * View */ -top_httphead(); +if (! isset($mode) || $mode != 'noajax') +{ + top_httphead(); +} //print ''."\n"; $userstatic=new User($db); @@ -97,151 +110,320 @@ foreach($sqltree as $keycursor => $val) } } - -if (file_exists($fullpathselecteddir)) +if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) { - $files = @scandir($fullpathselecteddir); + if (file_exists($fullpathselecteddir)) + { + $files = @scandir($fullpathselecteddir); - if ($files) - { - natcasesort($files); - if ( count($files) > 2 ) /* The 2 accounts for . and .. */ - { - echo "
| '; - print dol_escape_htmltag($file); - print ' | ';*/ + /*print ''; + print dol_escape_htmltag($file); + print ' | ';*/ - // Nb of docs - print ''; - print (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0)?$val['cachenbofdoc']:' '; - print ' | '; - print ''; - if ($nbofsubdir > 0 && $nboffilesinsubdir > 0) print '+'.$nboffilesinsubdir.' '; - print ' | '; + // Nb of docs + print ''; + print (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0)?$val['cachenbofdoc']:' '; + print ' | '; + print ''; + if ($nbofsubdir > 0 && $nboffilesinsubdir > 0) print '+'.$nboffilesinsubdir.' '; + print ' | '; - // Edit link - print ''.img_view($langs->trans("Edit").' - '.$langs->trans("View"), 0, 'class="valignmiddle"').' | '; + // Edit link + print ''.img_view($langs->trans("Edit").' - '.$langs->trans("View"), 0, 'class="valignmiddle"').' | '; - // Add link - //print ''.img_edit_add().' | '; - //print ''; + // Add link + //print ' | '.img_edit_add().' | '; + //print ''; - // Info - print ' | ';
- $userstatic->id=isset($val['fk_user_c'])?$val['fk_user_c']:0;
- $userstatic->lastname=isset($val['login_c'])?$val['login_c']:0;
- $htmltooltip=''.$langs->trans("ECMSection").': '.$val['label'].' '; - $htmltooltip=''.$langs->trans("Type").': '.$langs->trans("ECMSectionManual").' '; - $htmltooltip.=''.$langs->trans("ECMCreationUser").': '.$userstatic->getNomUrl(1, '', false, 1).' '; - $htmltooltip.=''.$langs->trans("ECMCreationDate").': '.(isset($val['date_c'])?dol_print_date($val['date_c'],"dayhour"):$langs->trans("NeedRefresh")).' '; - $htmltooltip.=''.$langs->trans("Description").': '.$val['description'].' '; - $htmltooltip.=''.$langs->trans("ECMNbOfFilesInDir").': '.((isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0)?$val['cachenbofdoc']:$langs->trans("NeedRefresh")).' '; - if ($nboffilesinsubdir > 0) $htmltooltip.=''.$langs->trans("ECMNbOfFilesInSubDir").': '.$nboffilesinsubdir; - else $htmltooltip.=''.$langs->trans("ECMNbOfSubDir").': '.($nbofsubdir >= 0 ? $nbofsubdir : $langs->trans("NeedRefresh")).' '; - print $form->textwithpicto('',$htmltooltip,1,"info"); - print " | ";
+ // Info
+ print '';
+ $userstatic->id=isset($val['fk_user_c'])?$val['fk_user_c']:0;
+ $userstatic->lastname=isset($val['login_c'])?$val['login_c']:0;
+ $htmltooltip=''.$langs->trans("ECMSection").': '.$val['label'].' '; + $htmltooltip=''.$langs->trans("Type").': '.$langs->trans("ECMSectionManual").' '; + $htmltooltip.=''.$langs->trans("ECMCreationUser").': '.$userstatic->getNomUrl(1, '', false, 1).' '; + $htmltooltip.=''.$langs->trans("ECMCreationDate").': '.(isset($val['date_c'])?dol_print_date($val['date_c'],"dayhour"):$langs->trans("NeedRefresh")).' '; + $htmltooltip.=''.$langs->trans("Description").': '.$val['description'].' '; + $htmltooltip.=''.$langs->trans("ECMNbOfFilesInDir").': '.((isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0)?$val['cachenbofdoc']:$langs->trans("NeedRefresh")).' '; + if ($nboffilesinsubdir > 0) $htmltooltip.=''.$langs->trans("ECMNbOfFilesInSubDir").': '.$nboffilesinsubdir; + else $htmltooltip.=''.$langs->trans("ECMNbOfSubDir").': '.($nbofsubdir >= 0 ? $nbofsubdir : $langs->trans("NeedRefresh")).' '; + print $form->textwithpicto('',$htmltooltip,1,"info"); + print " | ";
- print "
| '; + print $val['cachenbofdoc']; + print ' | '; + print ''; + if ($nbofsubdir && $nboffilesinsubdir) print '+'.$nboffilesinsubdir.' '; + print ' | '; + + // Info + print '';
+ $userstatic->id=$val['fk_user_c'];
+ $userstatic->lastname=$val['login_c'];
+ $htmltooltip=''.$langs->trans("ECMSection").': '.$val['label'].' '; + $htmltooltip=''.$langs->trans("Type").': '.$langs->trans("ECMSectionManual").' '; + $htmltooltip.=''.$langs->trans("ECMCreationUser").': '.$userstatic->getNomUrl(1, '', false, 1).' '; + $htmltooltip.=''.$langs->trans("ECMCreationDate").': '.dol_print_date($val['date_c'],"dayhour").' '; + $htmltooltip.=''.$langs->trans("Description").': '.$val['description'].' '; + $htmltooltip.=''.$langs->trans("ECMNbOfFilesInDir").': '.$val['cachenbofdoc'].' '; + if ($nbofsubdir) $htmltooltip.=''.$langs->trans("ECMNbOfFilesInSubDir").': '.$nboffilesinsubdir; + else $htmltooltip.=''.$langs->trans("ECMNbOfSubDir").': '.$nbofsubdir.' '; + print $form->textwithpicto('', $htmltooltip, 1, 'info'); + print " | ";
+
+ print '
| '; - print $val['cachenbofdoc']; - print ' | '; - print ''; - if ($nbofsubdir && $nboffilesinsubdir) print '+'.$nboffilesinsubdir.' '; - print ' | '; - - // Info - print '';
- $userstatic->id=$val['fk_user_c'];
- $userstatic->lastname=$val['login_c'];
- $htmltooltip=''.$langs->trans("ECMSection").': '.$val['label'].' '; - $htmltooltip=''.$langs->trans("Type").': '.$langs->trans("ECMSectionManual").' '; - $htmltooltip.=''.$langs->trans("ECMCreationUser").': '.$userstatic->getNomUrl(1, '', false, 1).' '; - $htmltooltip.=''.$langs->trans("ECMCreationDate").': '.dol_print_date($val['date_c'],"dayhour").' '; - $htmltooltip.=''.$langs->trans("Description").': '.$val['description'].' '; - $htmltooltip.=''.$langs->trans("ECMNbOfFilesInDir").': '.$val['cachenbofdoc'].' '; - if ($nbofsubdir) $htmltooltip.=''.$langs->trans("ECMNbOfFilesInSubDir").': '.$nboffilesinsubdir; - else $htmltooltip.=''.$langs->trans("ECMNbOfSubDir").': '.$nbofsubdir.' '; - print $form->textwithpicto('', $htmltooltip, 1, 'info'); - print " | ";
-
- print '