forked from Wavyzz/dolibarr
Clean code of the filemanager
This commit is contained in:
@@ -23,14 +23,15 @@
|
|||||||
|
|
||||||
|
|
||||||
// This script is called with a POST method.
|
// 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('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal
|
||||||
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
|
|
||||||
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
|
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
|
||||||
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
|
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
|
||||||
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
||||||
|
|
||||||
|
if (! isset($mode) || $mode != 'noajax') // For ajax call
|
||||||
|
{
|
||||||
$res=@include '../../main.inc.php';
|
$res=@include '../../main.inc.php';
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.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/functions2.lib.php';
|
||||||
@@ -42,6 +43,15 @@ $openeddir = GETPOST('openeddir');
|
|||||||
$modulepart= GETPOST('modulepart');
|
$modulepart= GETPOST('modulepart');
|
||||||
$selecteddir = jsUnEscape(GETPOST('dir')); // relative path. We must decode using same encoding function used by javascript: escape()
|
$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 '/'
|
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");
|
$langs->load("ecm");
|
||||||
|
|
||||||
@@ -76,7 +86,10 @@ if ($modulepart == 'medias')
|
|||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if (! isset($mode) || $mode != 'noajax')
|
||||||
|
{
|
||||||
top_httphead();
|
top_httphead();
|
||||||
|
}
|
||||||
|
|
||||||
//print '<!-- selecteddir = '.$selecteddir.', openeddir = '.$openeddir.', modulepart='.$modulepart.' -->'."\n";
|
//print '<!-- selecteddir = '.$selecteddir.', openeddir = '.$openeddir.', modulepart='.$modulepart.' -->'."\n";
|
||||||
$userstatic=new User($db);
|
$userstatic=new User($db);
|
||||||
@@ -97,7 +110,8 @@ foreach($sqltree as $keycursor => $val)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))
|
||||||
|
{
|
||||||
if (file_exists($fullpathselecteddir))
|
if (file_exists($fullpathselecteddir))
|
||||||
{
|
{
|
||||||
$files = @scandir($fullpathselecteddir);
|
$files = @scandir($fullpathselecteddir);
|
||||||
@@ -107,7 +121,7 @@ if (file_exists($fullpathselecteddir))
|
|||||||
natcasesort($files);
|
natcasesort($files);
|
||||||
if (count($files) > 2) /* The 2 accounts for . and .. */
|
if (count($files) > 2) /* The 2 accounts for . and .. */
|
||||||
{
|
{
|
||||||
echo "<ul class=\"ecmjqft\" style=\"display: none;\">\n";
|
echo '<ul class="ecmjqft" style="display: none;">'."\n";
|
||||||
|
|
||||||
// All dirs
|
// All dirs
|
||||||
foreach ($files as $file) // $file can be '.', '..', or 'My dir' or 'My file'
|
foreach ($files as $file) // $file can be '.', '..', or 'My dir' or 'My file'
|
||||||
@@ -159,8 +173,11 @@ if (file_exists($fullpathselecteddir))
|
|||||||
|
|
||||||
print '<li class="directory collapsed">';
|
print '<li class="directory collapsed">';
|
||||||
|
|
||||||
print "<a class=\"fmdirlia jqft ecmjqft\" href=\"#\" rel=\"" . dol_escape_htmltag($val['fullrelativename'].'/') . "\" id=\"fmdirlia_id_".$val['id']."\"";
|
print "<a class=\"fmdirlia jqft ecmjqft\" href=\"";
|
||||||
print " onClick=\"loadandshowpreview('".dol_escape_js($val['fullrelativename'])."',".$val['id'].")\">";
|
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 dol_escape_htmltag($file);
|
||||||
print "</a>";
|
print "</a>";
|
||||||
|
|
||||||
@@ -243,5 +260,170 @@ if (file_exists($fullpathselecteddir))
|
|||||||
//print '<script language="javascript">';
|
//print '<script language="javascript">';
|
||||||
//print "loadandshowpreview('".dol_escape_js($selecteddir)."');";
|
//print "loadandshowpreview('".dol_escape_js($selecteddir)."');";
|
||||||
//print '</script>';
|
//print '</script>';
|
||||||
|
}
|
||||||
|
|
||||||
if (is_object($db)) $db->close();
|
|
||||||
|
if (empty($conf->use_javascript_ajax) || ! empty($conf->global->MAIN_ECM_DISABLE_JS))
|
||||||
|
{
|
||||||
|
print '<ul class="ecmjqft">';
|
||||||
|
|
||||||
|
// Load full tree from database. We will use it to define nbofsubdir and nboffilesinsubdir
|
||||||
|
if (empty($sqltree)) $sqltree=$ecmdirstatic->get_full_arbo(0); // Slow
|
||||||
|
|
||||||
|
// ----- This section will show a tree from a fulltree array -----
|
||||||
|
// $section must also be defined
|
||||||
|
// ----------------------------------------------------------------
|
||||||
|
|
||||||
|
// Define fullpathselected ( _x_y_z ) of $section parameter (!! not into ajaxdirtree)
|
||||||
|
$fullpathselected='';
|
||||||
|
foreach($sqltree as $key => $val)
|
||||||
|
{
|
||||||
|
//print $val['id']."-".$section."<br>";
|
||||||
|
if ($val['id'] == $section)
|
||||||
|
{
|
||||||
|
$fullpathselected=$val['fullpath'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//print "fullpathselected=".$fullpathselected."<br>";
|
||||||
|
|
||||||
|
// Update expandedsectionarray in session
|
||||||
|
$expandedsectionarray=array();
|
||||||
|
if (isset($_SESSION['dol_ecmexpandedsectionarray'])) $expandedsectionarray=explode(',',$_SESSION['dol_ecmexpandedsectionarray']);
|
||||||
|
|
||||||
|
if ($section && GETPOST('sectionexpand') == 'true')
|
||||||
|
{
|
||||||
|
// We add all sections that are parent of opened section
|
||||||
|
$pathtosection=explode('_',$fullpathselected);
|
||||||
|
foreach($pathtosection as $idcursor)
|
||||||
|
{
|
||||||
|
if ($idcursor && ! in_array($idcursor,$expandedsectionarray)) // Not already in array
|
||||||
|
{
|
||||||
|
$expandedsectionarray[]=$idcursor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$_SESSION['dol_ecmexpandedsectionarray']=join(',',$expandedsectionarray);
|
||||||
|
}
|
||||||
|
if ($section && GETPOST('sectionexpand') == 'false')
|
||||||
|
{
|
||||||
|
// We removed all expanded sections that are child of the closed section
|
||||||
|
$oldexpandedsectionarray=$expandedsectionarray;
|
||||||
|
$expandedsectionarray=array(); // Reset
|
||||||
|
foreach($oldexpandedsectionarray as $sectioncursor)
|
||||||
|
{
|
||||||
|
// TODO is_in_subtree(fulltree,sectionparent,sectionchild) does nox exists. Enable or remove this...
|
||||||
|
//if ($sectioncursor && ! is_in_subtree($sqltree,$section,$sectioncursor)) $expandedsectionarray[]=$sectioncursor;
|
||||||
|
}
|
||||||
|
$_SESSION['dol_ecmexpandedsectionarray']=join(',',$expandedsectionarray);
|
||||||
|
}
|
||||||
|
//print $_SESSION['dol_ecmexpandedsectionarray'].'<br>';
|
||||||
|
|
||||||
|
$nbofentries=0;
|
||||||
|
$oldvallevel=0;
|
||||||
|
$var=true;
|
||||||
|
foreach($sqltree as $key => $val)
|
||||||
|
{
|
||||||
|
$var=false;
|
||||||
|
|
||||||
|
$ecmdirstatic->id=$val['id'];
|
||||||
|
$ecmdirstatic->ref=$val['label'];
|
||||||
|
|
||||||
|
// Refresh cache
|
||||||
|
if (preg_match('/refresh/i',$action))
|
||||||
|
{
|
||||||
|
$result=$ecmdirstatic->fetch($val['id']);
|
||||||
|
$ecmdirstatic->ref=$ecmdirstatic->label;
|
||||||
|
|
||||||
|
$result=$ecmdirstatic->refreshcachenboffile(0);
|
||||||
|
$val['cachenbofdoc']=$result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//$fullpathparent=preg_replace('/(_[^_]+)$/i','',$val['fullpath']);
|
||||||
|
|
||||||
|
// Define showline
|
||||||
|
$showline=0;
|
||||||
|
|
||||||
|
// If directory is son of expanded directory, we show line
|
||||||
|
if (in_array($val['id_mere'],$expandedsectionarray)) $showline=4;
|
||||||
|
// If directory is brother of selected directory, we show line
|
||||||
|
elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) $showline=3;
|
||||||
|
// If directory is parent of selected directory or is selected directory, we show line
|
||||||
|
elseif (preg_match('/'.$val['fullpath'].'_/i',$fullpathselected.'_')) $showline=2;
|
||||||
|
// If we are level one we show line
|
||||||
|
elseif ($val['level'] < 2) $showline=1;
|
||||||
|
|
||||||
|
if ($showline)
|
||||||
|
{
|
||||||
|
if (in_array($val['id'],$expandedsectionarray)) $option='indexexpanded';
|
||||||
|
else $option='indexnotexpanded';
|
||||||
|
//print $option;
|
||||||
|
|
||||||
|
print '<li class="directory collapsed">';
|
||||||
|
|
||||||
|
// Show tree graph pictos
|
||||||
|
$cpt=1;
|
||||||
|
while ($cpt < $sqltree[$key]['level'])
|
||||||
|
{
|
||||||
|
print ' ';
|
||||||
|
$cpt++;
|
||||||
|
}
|
||||||
|
$resarray=tree_showpad($sqltree,$key,1);
|
||||||
|
$a=$resarray[0];
|
||||||
|
$nbofsubdir=$resarray[1];
|
||||||
|
$nboffilesinsubdir=$resarray[2];
|
||||||
|
|
||||||
|
// Show link
|
||||||
|
print $ecmdirstatic->getNomUrl(0,$option,32,'class="fmdirlia jqft ecmjqft"');
|
||||||
|
|
||||||
|
print '<div class="ecmjqft">';
|
||||||
|
|
||||||
|
// Nb of docs
|
||||||
|
print '<table class="nobordernopadding"><tr><td>';
|
||||||
|
print $val['cachenbofdoc'];
|
||||||
|
print '</td>';
|
||||||
|
print '<td align="left">';
|
||||||
|
if ($nbofsubdir && $nboffilesinsubdir) print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> ';
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
// Info
|
||||||
|
print '<td align="center">';
|
||||||
|
$userstatic->id=$val['fk_user_c'];
|
||||||
|
$userstatic->lastname=$val['login_c'];
|
||||||
|
$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>: '.dol_print_date($val['date_c'],"dayhour").'<br>';
|
||||||
|
$htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>';
|
||||||
|
$htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.$val['cachenbofdoc'].'<br>';
|
||||||
|
if ($nbofsubdir) $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir;
|
||||||
|
else $htmltooltip.='<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.$nbofsubdir.'<br>';
|
||||||
|
print $form->textwithpicto('', $htmltooltip, 1, 'info');
|
||||||
|
print "</td>";
|
||||||
|
|
||||||
|
print '</tr></table>';
|
||||||
|
|
||||||
|
print '</div>';
|
||||||
|
|
||||||
|
print "</li>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$oldvallevel=$val['level'];
|
||||||
|
$nbofentries++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If nothing to show
|
||||||
|
if ($nbofentries == 0)
|
||||||
|
{
|
||||||
|
print '<li class="directory collapsed">';
|
||||||
|
print '<div class="ecmjqft">';
|
||||||
|
print $langs->trans("ECMNoDirectoryYet");
|
||||||
|
print '</div>';
|
||||||
|
print "</li>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
print '</ul>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Close db if mode is not noajax
|
||||||
|
if ((! isset($mode) || $mode != 'noajax') && is_object($db)) $db->close();
|
||||||
|
|||||||
@@ -14,13 +14,14 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* You can call this page with param module=medias to get a filemanager for medias.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file htdocs/ecm/index.php
|
* \file htdocs/ecm/index.php
|
||||||
* \ingroup ecm
|
* \ingroup ecm
|
||||||
* \brief Main page for ECM section area
|
* \brief Main page for ECM section area
|
||||||
* \author Laurent Destailleur
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require '../main.inc.php';
|
require '../main.inc.php';
|
||||||
@@ -31,14 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
|
||||||
|
|
||||||
// Load traductions files
|
// Load traductions files
|
||||||
$langs->load("ecm");
|
$langs->loadLangs(array("ecm","companies","other","users","orders","propal","bills","contracts"));
|
||||||
$langs->load("companies");
|
|
||||||
$langs->load("other");
|
|
||||||
$langs->load("users");
|
|
||||||
$langs->load("orders");
|
|
||||||
$langs->load("propal");
|
|
||||||
$langs->load("bills");
|
|
||||||
$langs->load("contracts");
|
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
if ($user->societe_id) $socid=$user->societe_id;
|
if ($user->societe_id) $socid=$user->societe_id;
|
||||||
@@ -145,7 +139,6 @@ if ($action == 'confirm_deletefile')
|
|||||||
{
|
{
|
||||||
// GETPOST('urlfile','alpha') is full relative URL from ecm root dir. Contains path of all sections.
|
// GETPOST('urlfile','alpha') is full relative URL from ecm root dir. Contains path of all sections.
|
||||||
//var_dump(GETPOST('urlfile'));exit;
|
//var_dump(GETPOST('urlfile'));exit;
|
||||||
$langs->load("other");
|
|
||||||
|
|
||||||
$upload_dir = $conf->ecm->dir_output.($relativepath?'/'.$relativepath:'');
|
$upload_dir = $conf->ecm->dir_output.($relativepath?'/'.$relativepath:'');
|
||||||
$file = $upload_dir . "/" . GETPOST('urlfile','alpha'); // Do not use urldecode here ($_GET and $_POST are already decoded by PHP).
|
$file = $upload_dir . "/" . GETPOST('urlfile','alpha'); // Do not use urldecode here ($_GET and $_POST are already decoded by PHP).
|
||||||
@@ -443,7 +436,7 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$acti
|
|||||||
{
|
{
|
||||||
print '<tr><td colspan="6">';
|
print '<tr><td colspan="6">';
|
||||||
|
|
||||||
// Show filemanager tree
|
// Show filemanager tree (will be filled by call of ajax enablefiletreeajax.tpl.php that execute ajaxdirtree.php)
|
||||||
print '<div id="filetree" class="ecmfiletree"></div>';
|
print '<div id="filetree" class="ecmfiletree"></div>';
|
||||||
|
|
||||||
if ($action == 'deletefile') print $form->formconfirm('eeeee', $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 'deletefile');
|
if ($action == 'deletefile') print $form->formconfirm('eeeee', $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 'deletefile');
|
||||||
@@ -453,164 +446,20 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$acti
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
print '<tr><td colspan="6" style="padding-left: 20px">';
|
print '<tr><td colspan="6" style="padding-left: 20px">';
|
||||||
|
|
||||||
|
if (empty($module)) $module='ecm';
|
||||||
|
|
||||||
|
$_POST['modulepart'] = $module;
|
||||||
|
$_POST['openeddir'] = GETPOST('openeddir');
|
||||||
|
$_POST['dir'] = empty($_POST['dir'])?'/':$_POST['dir'];
|
||||||
|
|
||||||
|
// Show filemanager tree (will be filled by direct include of ajaxdirtree.php in mode noajax, this will return all dir - all levels - to show)
|
||||||
print '<div id="filetree" class="ecmfiletree">';
|
print '<div id="filetree" class="ecmfiletree">';
|
||||||
print '<ul class="ecmjqft">';
|
|
||||||
|
|
||||||
// Load full tree
|
$mode='noajax';
|
||||||
if (empty($sqltree)) $sqltree=$ecmdirstatic->get_full_arbo(0); // Slow
|
$url=DOL_URL_ROOT.'/ecm/index.php';
|
||||||
|
include DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirtree.php';
|
||||||
|
|
||||||
// ----- This section will show a tree from a fulltree array -----
|
|
||||||
// $section must also be defined
|
|
||||||
// ----------------------------------------------------------------
|
|
||||||
|
|
||||||
// Define fullpathselected ( _x_y_z ) of $section parameter
|
|
||||||
$fullpathselected='';
|
|
||||||
foreach($sqltree as $key => $val)
|
|
||||||
{
|
|
||||||
//print $val['id']."-".$section."<br>";
|
|
||||||
if ($val['id'] == $section)
|
|
||||||
{
|
|
||||||
$fullpathselected=$val['fullpath'];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//print "fullpathselected=".$fullpathselected."<br>";
|
|
||||||
|
|
||||||
// Update expandedsectionarray in session
|
|
||||||
$expandedsectionarray=array();
|
|
||||||
if (isset($_SESSION['dol_ecmexpandedsectionarray'])) $expandedsectionarray=explode(',',$_SESSION['dol_ecmexpandedsectionarray']);
|
|
||||||
|
|
||||||
if ($section && GETPOST('sectionexpand') == 'true')
|
|
||||||
{
|
|
||||||
// We add all sections that are parent of opened section
|
|
||||||
$pathtosection=explode('_',$fullpathselected);
|
|
||||||
foreach($pathtosection as $idcursor)
|
|
||||||
{
|
|
||||||
if ($idcursor && ! in_array($idcursor,$expandedsectionarray)) // Not already in array
|
|
||||||
{
|
|
||||||
$expandedsectionarray[]=$idcursor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$_SESSION['dol_ecmexpandedsectionarray']=join(',',$expandedsectionarray);
|
|
||||||
}
|
|
||||||
if ($section && GETPOST('sectionexpand') == 'false')
|
|
||||||
{
|
|
||||||
// We removed all expanded sections that are child of the closed section
|
|
||||||
$oldexpandedsectionarray=$expandedsectionarray;
|
|
||||||
$expandedsectionarray=array(); // Reset
|
|
||||||
foreach($oldexpandedsectionarray as $sectioncursor)
|
|
||||||
{
|
|
||||||
// is_in_subtree(fulltree,sectionparent,sectionchild)
|
|
||||||
if ($sectioncursor && ! is_in_subtree($sqltree,$section,$sectioncursor)) $expandedsectionarray[]=$sectioncursor;
|
|
||||||
}
|
|
||||||
$_SESSION['dol_ecmexpandedsectionarray']=join(',',$expandedsectionarray);
|
|
||||||
}
|
|
||||||
//print $_SESSION['dol_ecmexpandedsectionarray'].'<br>';
|
|
||||||
|
|
||||||
$nbofentries=0;
|
|
||||||
$oldvallevel=0;
|
|
||||||
$var=true;
|
|
||||||
foreach($sqltree as $key => $val)
|
|
||||||
{
|
|
||||||
$var=false;
|
|
||||||
|
|
||||||
$ecmdirstatic->id=$val['id'];
|
|
||||||
$ecmdirstatic->ref=$val['label'];
|
|
||||||
|
|
||||||
// Refresh cache
|
|
||||||
if (preg_match('/refresh/i',$action))
|
|
||||||
{
|
|
||||||
$result=$ecmdirstatic->fetch($val['id']);
|
|
||||||
$ecmdirstatic->ref=$ecmdirstatic->label;
|
|
||||||
|
|
||||||
$result=$ecmdirstatic->refreshcachenboffile(0);
|
|
||||||
$val['cachenbofdoc']=$result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//$fullpathparent=preg_replace('/(_[^_]+)$/i','',$val['fullpath']);
|
|
||||||
|
|
||||||
// Define showline
|
|
||||||
$showline=0;
|
|
||||||
|
|
||||||
// If directory is son of expanded directory, we show line
|
|
||||||
if (in_array($val['id_mere'],$expandedsectionarray)) $showline=4;
|
|
||||||
// If directory is brother of selected directory, we show line
|
|
||||||
elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) $showline=3;
|
|
||||||
// If directory is parent of selected directory or is selected directory, we show line
|
|
||||||
elseif (preg_match('/'.$val['fullpath'].'_/i',$fullpathselected.'_')) $showline=2;
|
|
||||||
// If we are level one we show line
|
|
||||||
elseif ($val['level'] < 2) $showline=1;
|
|
||||||
|
|
||||||
if ($showline)
|
|
||||||
{
|
|
||||||
if (in_array($val['id'],$expandedsectionarray)) $option='indexexpanded';
|
|
||||||
else $option='indexnotexpanded';
|
|
||||||
//print $option;
|
|
||||||
|
|
||||||
print '<li class="directory collapsed">';
|
|
||||||
|
|
||||||
// Show tree graph pictos
|
|
||||||
$cpt=1;
|
|
||||||
while ($cpt < $sqltree[$key]['level'])
|
|
||||||
{
|
|
||||||
print ' ';
|
|
||||||
$cpt++;
|
|
||||||
}
|
|
||||||
$resarray=tree_showpad($sqltree,$key,1);
|
|
||||||
$a=$resarray[0];
|
|
||||||
$nbofsubdir=$resarray[1];
|
|
||||||
$nboffilesinsubdir=$resarray[2];
|
|
||||||
|
|
||||||
// Show link
|
|
||||||
print $ecmdirstatic->getNomUrl(0,$option,32,'class="fmdirlia jqft ecmjqft"');
|
|
||||||
|
|
||||||
print '<div class="ecmjqft">';
|
|
||||||
|
|
||||||
// Nb of docs
|
|
||||||
print '<table class="nobordernopadding"><tr><td>';
|
|
||||||
print $val['cachenbofdoc'];
|
|
||||||
print '</td>';
|
|
||||||
print '<td align="left">';
|
|
||||||
if ($nbofsubdir && $nboffilesinsubdir) print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> ';
|
|
||||||
print '</td>';
|
|
||||||
|
|
||||||
// Info
|
|
||||||
print '<td align="center">';
|
|
||||||
$userstatic->id=$val['fk_user_c'];
|
|
||||||
$userstatic->lastname=$val['login_c'];
|
|
||||||
$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>: '.dol_print_date($val['date_c'],"dayhour").'<br>';
|
|
||||||
$htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>';
|
|
||||||
$htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.$val['cachenbofdoc'].'<br>';
|
|
||||||
if ($nbofsubdir) $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir;
|
|
||||||
else $htmltooltip.='<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.$nbofsubdir.'<br>';
|
|
||||||
print $form->textwithpicto('', $htmltooltip, 1, 'info');
|
|
||||||
print "</td>";
|
|
||||||
|
|
||||||
print '</tr></table>';
|
|
||||||
|
|
||||||
print '</div>';
|
|
||||||
|
|
||||||
print "</li>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
$oldvallevel=$val['level'];
|
|
||||||
$nbofentries++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If nothing to show
|
|
||||||
if ($nbofentries == 0)
|
|
||||||
{
|
|
||||||
print '<li class="directory collapsed">';
|
|
||||||
print '<div class="ecmjqft">';
|
|
||||||
print $langs->trans("ECMNoDirectoryYet");
|
|
||||||
print '</div>';
|
|
||||||
print "</li>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
print '</ul>';
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,14 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
|
||||||
|
|
||||||
// Load traductions files
|
// Load traductions files
|
||||||
$langs->load("ecm");
|
$langs->loadLangs(array("ecm","companies","other","users","orders","propal","bills","contracts"));
|
||||||
$langs->load("companies");
|
|
||||||
$langs->load("other");
|
|
||||||
$langs->load("users");
|
|
||||||
$langs->load("orders");
|
|
||||||
$langs->load("propal");
|
|
||||||
$langs->load("bills");
|
|
||||||
$langs->load("contracts");
|
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
if ($user->societe_id) $socid=$user->societe_id;
|
if ($user->societe_id) $socid=$user->societe_id;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
$('#filetree').fileTree({
|
$('#filetree').fileTree({
|
||||||
root: '<?php print dol_escape_js($openeddir); ?>',
|
root: '<?php print dol_escape_js($openeddir); ?>',
|
||||||
// Ajax called if we click to expand a dir (not a file). Parameter of dir is provided as a POST parameter.
|
// Ajax called if we click to expand a dir (not a file). Parameter 'dir' is provided as a POST parameter by fileTree code.
|
||||||
script: '<?php echo DOL_URL_ROOT.'/core/ajax/ajaxdirtree.php?modulepart='.$module.'&openeddir='.urlencode($openeddir); ?>',
|
script: '<?php echo DOL_URL_ROOT.'/core/ajax/ajaxdirtree.php?modulepart='.$module.'&openeddir='.urlencode($openeddir); ?>',
|
||||||
folderEvent: 'click', // 'dblclick'
|
folderEvent: 'click', // 'dblclick'
|
||||||
multiFolder: false },
|
multiFolder: false },
|
||||||
|
|||||||
Reference in New Issue
Block a user