diff --git a/htdocs/ecm/ecmdirectory.class.php b/htdocs/ecm/ecmdirectory.class.php
index f8a17f66992..fd483a61488 100644
--- a/htdocs/ecm/ecmdirectory.class.php
+++ b/htdocs/ecm/ecmdirectory.class.php
@@ -378,6 +378,8 @@ class EcmDirectory // extends CommonObject
$lien = '';
if ($option == 'index') $lien = '';
+ if ($option == 'indexexpanded') $lien = '';
+ if ($option == 'indexnotexpanded') $lien = '';
$lienfin='';
//$picto=DOL_URL_ROOT.'/theme/common/treemenu/folder.gif';
diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php
index 87511996077..959a96076d5 100644
--- a/htdocs/ecm/index.php
+++ b/htdocs/ecm/index.php
@@ -17,11 +17,11 @@
*/
/**
- \file htdoc/ecm/index.php
- \ingroup ecm
- \brief Main page for ECM section area
- \version $Id$
- \author Laurent Destailleur
+ * \file htdoc/ecm/index.php
+ * \ingroup ecm
+ * \brief Main page for ECM section area
+ * \version $Id$
+ * \author Laurent Destailleur
*/
require("./pre.inc.php");
@@ -396,6 +396,7 @@ if (empty($action) || $action == 'file_manager' || eregi('refresh',$action) || $
print '';
print '';
+ // Load full tree
$fulltree=$ecmdirstatic->get_full_arbo();
// Define fullpathselected ( _x_y_z )
@@ -411,6 +412,35 @@ if (empty($action) || $action == 'file_manager' || eregi('refresh',$action) || $
}
//print "fullpathselected=".$fullpathselected."
";
+ // Update expandedsectionarray in session
+ $expandedsectionarray=split(',',$_SESSION['expandedsectionarray']);
+ if ($section && $_GET['sectionexpand'] == 'true')
+ {
+ // We add all sections that are parent of opened section
+ $pathtosection=split('_',$fullpathselected);
+ foreach($pathtosection as $idcursor)
+ {
+ if ($idcursor && ! in_array($idcursor,$expandedsectionarray)) // Not already in array
+ {
+ $expandedsectionarray[]=$idcursor;
+ }
+ }
+ $_SESSION['expandedsectionarray']=join(',',$expandedsectionarray);
+ }
+ if ($section && $_GET['sectionexpand'] == 'false')
+ {
+ // We removed all expanded sections that are child of the closed section
+ $oldexpandedsectionarray=$expandedsectionarray;
+ $expandedsectionarray=array();
+ foreach($oldexpandedsectionarray as $sectioncursor)
+ {
+ // is_in_subtree(fulltree,sectionparent,sectionchild)
+ if ($sectioncursor && ! is_in_subtree($fulltree,$section,$sectioncursor)) $expandedsectionarray[]=$sectioncursor;
+ }
+ $_SESSION['expandedsectionarray']=join(',',$expandedsectionarray);
+ }
+ //print $_SESSION['expandedsectionarray'].'
';
+
$nbofentries=0;
$oldvallevel=0;
$var=true;
@@ -431,22 +461,26 @@ if (empty($action) || $action == 'file_manager' || eregi('refresh',$action) || $
$val['cachenbofdoc']=$result;
}
- // Show line if level 1 or level selected
+ //$fullpathparent=eregi_replace('_[^_]+$','',$val['fullpath']);
+
+ // Define showline
$showline=0;
- $fullpathparent=eregi_replace('_[^_]+$','',$val['fullpath']);
- // If directory is son of selected directory, we show line
- if ($val['id_mere'] == $section) $showline=5;
+
+ // 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=4;
+ 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 (eregi($val['fullpath'].'_',$fullpathselected.'_')) $showline=3;
- // If parent directory is in a same path than selected directory
- elseif (eregi($fullpathparent.'_',$fullpathselected.'_')) $showline=2;
+ elseif (eregi($val['fullpath'].'_',$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 '