forked from Wavyzz/dolibarr
Isolate code of treeview in a lib
This commit is contained in:
@@ -18,14 +18,15 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/admin/menus/index.php
|
* \file htdocs/admin/menus/index.php
|
||||||
\ingroup core
|
* \ingroup core
|
||||||
\brief Index page for menu editor
|
* \brief Index page for menu editor
|
||||||
\version $Id$
|
* \version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require("./pre.inc.php");
|
require("./pre.inc.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/html.formadmin.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/html.formadmin.class.php");
|
||||||
|
require_once(DOL_DOCUMENT_ROOT."/lib/treeview.lib.php");
|
||||||
|
|
||||||
$langs->load("other");
|
$langs->load("other");
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
@@ -250,7 +251,7 @@ $rangLast = 0;
|
|||||||
$idLast = -1;
|
$idLast = -1;
|
||||||
if ($conf->use_javascript_ajax)
|
if ($conf->use_javascript_ajax)
|
||||||
{
|
{
|
||||||
print '<script src="menu.js" type="text/javascript"></script>';
|
tree_addjs();
|
||||||
|
|
||||||
/*-------------------- MAIN -----------------------
|
/*-------------------- MAIN -----------------------
|
||||||
tableau des <20>l<EFBFBD>ments de l'arbre:
|
tableau des <20>l<EFBFBD>ments de l'arbre:
|
||||||
@@ -289,12 +290,10 @@ if ($conf->use_javascript_ajax)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//appelle de la fonction r<>cursive (ammorce)
|
// Appelle de la fonction r<>cursive (ammorce)
|
||||||
// avec recherche depuis la racine.
|
// avec recherche depuis la racine.
|
||||||
print '<ul class="arbre">';
|
// array($menu['rowid'],$menu['fk_menu'],$titre);
|
||||||
recur($data,0,0);
|
tree_recur($data,0,0);
|
||||||
print '<script type="text/javascript">imgDel('.$idLast.')</script>';
|
|
||||||
print '</ul>';
|
|
||||||
|
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
@@ -324,101 +323,5 @@ $db->close();
|
|||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
llxFooter('$Date$ - $Revision$');
|
llxFooter('$Date$ - $Revision$');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* cette fonction g<>re le d<>callage des <20>l<EFBFBD>ments
|
|
||||||
suivant leur position dans l'arborescence
|
|
||||||
*/
|
|
||||||
function affiche($tab,$rang)
|
|
||||||
{
|
|
||||||
global $conf, $rangLast, $idLast, $menu_handler;
|
|
||||||
|
|
||||||
if ($conf->use_javascript_ajax)
|
|
||||||
{
|
|
||||||
if($rang == $rangLast)
|
|
||||||
{
|
|
||||||
print '<script type="text/javascript">imgDel('.$idLast.');</script>';
|
|
||||||
//print '<a href="'.DOL_URL_ROOT.'/admin/menus/index.php?menu_handler=eldy&action=delete&menuId='.$idLast.'">aa</a>';
|
|
||||||
}
|
|
||||||
elseif($rang > $rangLast)
|
|
||||||
{
|
|
||||||
|
|
||||||
print '<li><ul>';
|
|
||||||
|
|
||||||
}
|
|
||||||
elseif($rang < $rangLast)
|
|
||||||
{
|
|
||||||
print '<script type="text/javascript">imgDel('.$idLast.')</script>';
|
|
||||||
|
|
||||||
for($i=$rang; $i < $rangLast; $i++)
|
|
||||||
{
|
|
||||||
print '</ul></li>';
|
|
||||||
echo "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if($rang > $rangLast)
|
|
||||||
{
|
|
||||||
|
|
||||||
print '<li><ul>';
|
|
||||||
|
|
||||||
}
|
|
||||||
elseif($rang < $rangLast)
|
|
||||||
{
|
|
||||||
|
|
||||||
for($i=$rang; $i < $rangLast; $i++)
|
|
||||||
{
|
|
||||||
print '</ul></li>';
|
|
||||||
echo "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print '<li id=li'.$tab[0].'>';
|
|
||||||
print '<strong>';
|
|
||||||
print '<a href="edit.php?menu_handler='.$menu_handler.'&action=edit&menuId='.$tab[0].'">'.$tab[2].'</a></strong>';
|
|
||||||
print '<div class="menuEdit"><a href="edit.php?menu_handler='.$menu_handler.'&action=edit&menuId='.$tab[0].'">'.img_edit('default',0,'class="menuEdit" id="edit'.$tab[0].'"').'</a></div>';
|
|
||||||
print '<div class="menuNew"><a href="edit.php?menu_handler='.$menu_handler.'&action=create&menuId='.$tab[0].'">'.img_edit_add('default',0,'class="menuNew" id="new'.$tab[0].'"').'</a></div>';
|
|
||||||
print '<div class="menuDel"><a href="index.php?menu_handler='.$menu_handler.'&action=delete&menuId='.$tab[0].'">'.img_delete('default',0,'class="menuDel" id="del'.$tab[0].'"').'</a></div>';
|
|
||||||
print '<div class="menuFleche"><a href="index.php?menu_handler='.$menu_handler.'&action=up&menuId='.$tab[0].'">'.img_picto("Monter","1uparrow").'</a><a href="index.php?menu_handler='.$menu_handler.'&action=down&menuId='.$tab[0].'">'.img_picto("Descendre","1downarrow").'</a></div>';
|
|
||||||
print '</li>';
|
|
||||||
echo "\n";
|
|
||||||
|
|
||||||
$rangLast = $rang;
|
|
||||||
$idLast = $tab[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*fonction r<>cursive d'affichage de l'arbre
|
|
||||||
$tab :tableau des <20>l<EFBFBD>ments
|
|
||||||
$pere :index de l'<27>l<EFBFBD>ment courrant
|
|
||||||
$rang :d<>callage de l'<27>l<EFBFBD>ment
|
|
||||||
*/
|
|
||||||
function recur($tab,$pere,$rang) {
|
|
||||||
|
|
||||||
if ($rang > 10) return; // Protection contre boucle infinie
|
|
||||||
|
|
||||||
//ballayage du tableau
|
|
||||||
for ($x=0;$x<count($tab);$x++)
|
|
||||||
{
|
|
||||||
//si un <20>l<EFBFBD>ment a pour p<>re : $pere
|
|
||||||
if ($tab[$x][1]==$pere) {
|
|
||||||
|
|
||||||
//on l'affiche avec le d<>callage courrant
|
|
||||||
affiche($tab[$x],$rang);
|
|
||||||
|
|
||||||
/*et on recherche ses fils
|
|
||||||
en rappelant la fonction recur()
|
|
||||||
(+ incr<63>mentation du d<>callage)*/
|
|
||||||
recur($tab,$tab[$x][0],$rang+1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ function arbre() {
|
|||||||
// Choix de la balise contenant le texte. <strong> par defaut.
|
// Choix de la balise contenant le texte. <strong> par defaut.
|
||||||
balise = "STRONG";
|
balise = "STRONG";
|
||||||
// Presentation de l'arbre au depart : deployee ('yes') ou fermee ('no')
|
// Presentation de l'arbre au depart : deployee ('yes') ou fermee ('no')
|
||||||
extend = "yes";
|
extend = "no";
|
||||||
// Textes du lien plier / deplier
|
// Textes du lien plier / deplier
|
||||||
plier_text = 'Replier tout';
|
plier_text = 'Replier tout';
|
||||||
plier_title = 'Replier tous les noeuds de l\'arbre'
|
plier_title = 'Replier tous les noeuds de l\'arbre'
|
||||||
@@ -27,6 +27,7 @@ function arbre() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------
|
// -------------------------------------------------------
|
||||||
// Creation des liens plier /deplier tout
|
// Creation des liens plier /deplier tout
|
||||||
function linkSwitch(ul) {
|
function linkSwitch(ul) {
|
||||||
@@ -165,7 +166,7 @@ function imgDel(id)
|
|||||||
var delId='del'+id;
|
var delId='del'+id;
|
||||||
|
|
||||||
var imgDel = document.getElementById('del'+id);
|
var imgDel = document.getElementById('del'+id);
|
||||||
imgDel.style.display='block';
|
if (imgDel != null) imgDel.style.display='block';
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ $user->getrights('ecm');
|
|||||||
|
|
||||||
// Get parameters
|
// Get parameters
|
||||||
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
|
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
|
||||||
|
$action = isset($_GET["action"])?$_GET["action"]:$_POST['action'];
|
||||||
|
|
||||||
$section=$_GET["section"];
|
$section=$_GET["section"];
|
||||||
if (! $section) $section='misc';
|
if (! $section) $section='misc';
|
||||||
@@ -140,6 +141,19 @@ print $langs->trans("ECMAreaDesc")."<br>";
|
|||||||
print $langs->trans("ECMAreaDesc2")."<br>";
|
print $langs->trans("ECMAreaDesc2")."<br>";
|
||||||
print "<br>\n";
|
print "<br>\n";
|
||||||
|
|
||||||
|
// Tool bar
|
||||||
|
$colspan=3;
|
||||||
|
print '<table class="notopnoleftnoright" width="100%"><tr class="liste_titre"><td colspan="'.$colspan.'">';
|
||||||
|
print $langs->trans("Toolbar").'</td></tr>';
|
||||||
|
print '<tr '.$bc[0].'>';
|
||||||
|
print '<td>'.img_picto('','object_list').' <a href="'.$_SERVER["PHP_SELF"].'">'.$langs->trans("ECMFileManager").'</td>';
|
||||||
|
print '<td align="right">'.img_picto('','search').' <a href="'.$_SERVER["PHP_SELF"].'?action=search_form">'.$langs->trans("Search").'</td>';
|
||||||
|
print '</tr></table>';
|
||||||
|
print '<br>';
|
||||||
|
|
||||||
|
|
||||||
|
if (eregi('search',$action))
|
||||||
|
{
|
||||||
print '<table class="notopnoleftnoright" width="100%"><tr><td width="50%" valign="top">';
|
print '<table class="notopnoleftnoright" width="100%"><tr><td width="50%" valign="top">';
|
||||||
|
|
||||||
//print_fiche_titre($langs->trans("ECMManualOrg"));
|
//print_fiche_titre($langs->trans("ECMManualOrg"));
|
||||||
@@ -187,14 +201,11 @@ print "</table></form><br>";
|
|||||||
|
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//***********************
|
if (empty($action) || $action == 'refresh')
|
||||||
// Files
|
{
|
||||||
//***********************
|
|
||||||
print_fiche_titre($langs->trans("ECMSectionOfDocuments"));
|
|
||||||
//print '<br>';
|
|
||||||
|
|
||||||
// Confirmation de la suppression d'une ligne categorie
|
// Confirmation de la suppression d'une ligne categorie
|
||||||
if ($_GET['action'] == 'delete_section')
|
if ($_GET['action'] == 'delete_section')
|
||||||
{
|
{
|
||||||
@@ -212,11 +223,18 @@ if (sizeof($sectionauto))
|
|||||||
{
|
{
|
||||||
// Automatic sections
|
// Automatic sections
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<td class="liste_titre" align="left">'.$langs->trans("ECMSectionAuto").'</td>';
|
print '<td class="liste_titre" align="left">'.$langs->trans("ECMSectionOfDocuments").'</td>';
|
||||||
print '<td class="liste_titre" align="left">'.$langs->trans("Description").'</td>';
|
print '<td class="liste_titre" align="left">'.$langs->trans("Type").'</td>';
|
||||||
print '<td class="liste_titre" align="right">'.$langs->trans("ECMNbOfDocsSmall").'</td>';
|
print '<td class="liste_titre" align="right">'.$langs->trans("ECMNbOfDocsSmall").' <a href="'.$_SERVER["PHP_SELF"].'?action=refresh">'.img_picto($langs->trans("Refresh"),'refresh').'</a></td>';
|
||||||
print '<td class="liste_titre">';
|
print '<td class="liste_titre" width="16px">';
|
||||||
|
if ($user->rights->ecm->setup)
|
||||||
|
{
|
||||||
|
print '<a href="'.DOL_URL_ROOT.'/ecm/docdir.php?action=create">'.img_picto($langs->trans("ECMNewSection"),'edit_add').'</a>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
print ' ';
|
print ' ';
|
||||||
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
@@ -239,13 +257,14 @@ if (sizeof($sectionauto))
|
|||||||
print '</a>';
|
print '</a>';
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
|
|
||||||
// Description
|
// Type
|
||||||
print '<td align="left">'.$val['desc'].'</td>';
|
print '<td align="left">'.$langs->trans('ECMTypeAuto').'</td>';
|
||||||
print '<td align="right">?</td>';
|
print '<td align="right">?</td>';
|
||||||
print '<td align="right">';
|
print '<td align="right">';
|
||||||
$htmltooltip='<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>';
|
$htmltooltip='<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>';
|
||||||
$htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMAutoOrg").'<br>';
|
$htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMAutoOrg").'<br>';
|
||||||
$htmltooltip.='<b>'.$langs->trans("ECMCreationUser").'</b>: '.$langs->trans("ECMTypeAuto");
|
$htmltooltip.='<b>'.$langs->trans("ECMCreationUser").'</b>: '.$langs->trans("ECMTypeAuto").'<br>';
|
||||||
|
$htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['desc'];
|
||||||
print $form->textwithhelp('',$htmltooltip,1,0);
|
print $form->textwithhelp('',$htmltooltip,1,0);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
@@ -255,27 +274,6 @@ if (sizeof($sectionauto))
|
|||||||
|
|
||||||
|
|
||||||
// Manual sections
|
// Manual sections
|
||||||
|
|
||||||
print '<tr class="liste_titre">';
|
|
||||||
$param='&socid='.$socid;
|
|
||||||
|
|
||||||
print '<td class="liste_titre" align="left">'.$langs->trans("ECMSectionManual").'</td>';
|
|
||||||
print '<td class="liste_titre" align="left">'.$langs->trans("Description").'</td>';
|
|
||||||
print '<td class="liste_titre" align="right">'.$langs->trans("ECMNbOfDocsSmall");
|
|
||||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=refreshauto">'.img_picto($langs->trans("Refresh"),'refresh').'</a>';
|
|
||||||
print '</td>';
|
|
||||||
print '<td class="liste_titre" align="right">';
|
|
||||||
if ($user->rights->ecm->setup)
|
|
||||||
{
|
|
||||||
print '<a href="'.DOL_URL_ROOT.'/ecm/docdir.php?action=create">'.img_picto($langs->trans("ECMNewSection"),'edit_add').'</a>';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print ' ';
|
|
||||||
}
|
|
||||||
print '</td>';
|
|
||||||
print '</tr>';
|
|
||||||
|
|
||||||
$ecmdirstatic = new ECMDirectory($db);
|
$ecmdirstatic = new ECMDirectory($db);
|
||||||
$rub=$ecmdirstatic->get_full_arbo();
|
$rub=$ecmdirstatic->get_full_arbo();
|
||||||
|
|
||||||
@@ -310,7 +308,7 @@ foreach($rub as $key => $val)
|
|||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
|
|
||||||
// Description
|
// Description
|
||||||
print '<td align="left">'.dolibarr_trunc($val['description'],48).'</td>';
|
print '<td align="left">'.$langs->trans("ECMTypeManual").'</td>';
|
||||||
|
|
||||||
// Nb of docs
|
// Nb of docs
|
||||||
//print '<td align="right">'.$obj->cachenbofdoc.'</td>';
|
//print '<td align="right">'.$obj->cachenbofdoc.'</td>';
|
||||||
@@ -322,7 +320,8 @@ foreach($rub as $key => $val)
|
|||||||
$htmltooltip='<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>';
|
$htmltooltip='<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>';
|
||||||
$htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMManualOrg").'<br>';
|
$htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMManualOrg").'<br>';
|
||||||
$htmltooltip.='<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1).'<br>';
|
$htmltooltip.='<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1).'<br>';
|
||||||
$htmltooltip.='<b>'.$langs->trans("ECMCreationDate").'</b>: '.dolibarr_print_date($val['date_c'],"dayhour");
|
$htmltooltip.='<b>'.$langs->trans("ECMCreationDate").'</b>: '.dolibarr_print_date($val['date_c'],"dayhour").'<br>';
|
||||||
|
$htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'];
|
||||||
print $form->textwithhelp('',$htmltooltip,1,0);
|
print $form->textwithhelp('',$htmltooltip,1,0);
|
||||||
print "</td></tr>\n";
|
print "</td></tr>\n";
|
||||||
|
|
||||||
@@ -338,6 +337,7 @@ if ($nbofentries == 0)
|
|||||||
print "</table>";
|
print "</table>";
|
||||||
// Fin de zone Ajax
|
// Fin de zone Ajax
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Actions buttons
|
// Actions buttons
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ require ("../main.inc.php");
|
|||||||
|
|
||||||
$user->getrights('ecm');
|
$user->getrights('ecm');
|
||||||
|
|
||||||
function llxHeader($head = "", $title="", $help_url='')
|
function llxHeader($head = "", $title="", $help_url='', $morehtml='')
|
||||||
{
|
{
|
||||||
global $conf,$langs,$user;
|
global $conf,$langs,$user;
|
||||||
$langs->load("ecm");
|
$langs->load("ecm");
|
||||||
@@ -50,6 +50,6 @@ function llxHeader($head = "", $title="", $help_url='')
|
|||||||
if ($conf->commande->enabled) $menu->add_submenu(DOL_URL_ROOT."/ecm/docother.php?mainmenu=ecm&idmenu=".$_SESSION["idmenu"], $langs->trans("DocsOrders"),2);
|
if ($conf->commande->enabled) $menu->add_submenu(DOL_URL_ROOT."/ecm/docother.php?mainmenu=ecm&idmenu=".$_SESSION["idmenu"], $langs->trans("DocsOrders"),2);
|
||||||
if ($conf->facture->enabled) $menu->add_submenu(DOL_URL_ROOT."/ecm/docother.php?mainmenu=ecm&idmenu=".$_SESSION["idmenu"], $langs->trans("DocsInvoices"),2);
|
if ($conf->facture->enabled) $menu->add_submenu(DOL_URL_ROOT."/ecm/docother.php?mainmenu=ecm&idmenu=".$_SESSION["idmenu"], $langs->trans("DocsInvoices"),2);
|
||||||
*/
|
*/
|
||||||
left_menu($menu->liste, $help_url);
|
left_menu($menu->liste, $help_url, $morehtml);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ class modECM extends DolibarrModules
|
|||||||
// Left menu linked to top menu
|
// Left menu linked to top menu
|
||||||
$this->menu[$r]=array('fk_menu'=>'r=0',
|
$this->menu[$r]=array('fk_menu'=>'r=0',
|
||||||
'type'=>'left',
|
'type'=>'left',
|
||||||
'titre'=>'ECMArea',
|
'titre'=>'ECMFileManager',
|
||||||
'mainmenu'=>'ecm',
|
'mainmenu'=>'ecm',
|
||||||
'url'=>'/ecm/index.php',
|
'url'=>'/ecm/index.php',
|
||||||
'langs'=>'ecm',
|
'langs'=>'ecm',
|
||||||
|
|||||||
@@ -45,3 +45,4 @@ DeleteSection=Remove directory
|
|||||||
ConfirmDeleteSection=Can you confirm you want to delete the directory <b>%s</b> ?
|
ConfirmDeleteSection=Can you confirm you want to delete the directory <b>%s</b> ?
|
||||||
ECMDirectoryForFiles=Relative directory for files
|
ECMDirectoryForFiles=Relative directory for files
|
||||||
CannotRemoveDirectoryContainsFiles=Removed not possible because it contains some files
|
CannotRemoveDirectoryContainsFiles=Removed not possible because it contains some files
|
||||||
|
ECMFileManager=File manager
|
||||||
@@ -45,3 +45,4 @@ DeleteSection=Suppression rubrique
|
|||||||
ConfirmDeleteSection=Confirmez-vous la suppression de la rubrique <b>%s</b> ?
|
ConfirmDeleteSection=Confirmez-vous la suppression de la rubrique <b>%s</b> ?
|
||||||
ECMDirectoryForFiles=R<>pertoire relatif pour les fichiers
|
ECMDirectoryForFiles=R<>pertoire relatif pour les fichiers
|
||||||
CannotRemoveDirectoryContainsFiles=Suppression impossible car des fichiers sont pr<70>sents
|
CannotRemoveDirectoryContainsFiles=Suppression impossible car des fichiers sont pr<70>sents
|
||||||
|
ECMFileManager=Gestionnaire fichier
|
||||||
135
htdocs/lib/treeview.lib.php
Normal file
135
htdocs/lib/treeview.lib.php
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
|
||||||
|
* Copyright (C) 2007-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file htdocs/lib/treeview.lib.php
|
||||||
|
* \ingroup core
|
||||||
|
* \brief Libraries for tree views
|
||||||
|
* \version $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Ad javascript tree functions
|
||||||
|
*/
|
||||||
|
function tree_addjs()
|
||||||
|
{
|
||||||
|
print '<script src="'.DOL_URL_ROOT.'/admin/menus/menu.js" type="text/javascript"></script>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* cette fonction g<>re le d<>callage des <20>l<EFBFBD>ments
|
||||||
|
suivant leur position dans l'arborescence
|
||||||
|
*/
|
||||||
|
function tree_showline($tab,$rang)
|
||||||
|
{
|
||||||
|
global $conf, $rangLast, $idLast, $menu_handler;
|
||||||
|
|
||||||
|
if ($conf->use_javascript_ajax)
|
||||||
|
{
|
||||||
|
if($rang == $rangLast)
|
||||||
|
{
|
||||||
|
print '<script type="text/javascript">imgDel('.$idLast.');</script>';
|
||||||
|
//print '<a href="'.DOL_URL_ROOT.'/admin/menus/index.php?menu_handler=eldy&action=delete&menuId='.$idLast.'">aa</a>';
|
||||||
|
}
|
||||||
|
elseif($rang > $rangLast)
|
||||||
|
{
|
||||||
|
|
||||||
|
print '<li><ul>';
|
||||||
|
|
||||||
|
}
|
||||||
|
elseif($rang < $rangLast)
|
||||||
|
{
|
||||||
|
print '<script type="text/javascript">imgDel('.$idLast.')</script>';
|
||||||
|
|
||||||
|
for($i=$rang; $i < $rangLast; $i++)
|
||||||
|
{
|
||||||
|
print '</ul></li>';
|
||||||
|
echo "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if($rang > $rangLast)
|
||||||
|
{
|
||||||
|
|
||||||
|
print '<li><ul>';
|
||||||
|
|
||||||
|
}
|
||||||
|
elseif($rang < $rangLast)
|
||||||
|
{
|
||||||
|
|
||||||
|
for($i=$rang; $i < $rangLast; $i++)
|
||||||
|
{
|
||||||
|
print '</ul></li>';
|
||||||
|
echo "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print '<li id=li'.$tab[0].'>';
|
||||||
|
|
||||||
|
// Content of line
|
||||||
|
print '<strong><a href="edit.php?menu_handler='.$menu_handler.'&action=edit&menuId='.$tab[0].'">'.$tab[2].'</a></strong>';
|
||||||
|
print '<div class="menuEdit"><a href="edit.php?menu_handler='.$menu_handler.'&action=edit&menuId='.$tab[0].'">'.img_edit('default',0,'class="menuEdit" id="edit'.$tab[0].'"').'</a></div>';
|
||||||
|
print '<div class="menuNew"><a href="edit.php?menu_handler='.$menu_handler.'&action=create&menuId='.$tab[0].'">'.img_edit_add('default',0,'class="menuNew" id="new'.$tab[0].'"').'</a></div>';
|
||||||
|
print '<div class="menuDel"><a href="index.php?menu_handler='.$menu_handler.'&action=delete&menuId='.$tab[0].'">'.img_delete('default',0,'class="menuDel" id="del'.$tab[0].'"').'</a></div>';
|
||||||
|
print '<div class="menuFleche"><a href="index.php?menu_handler='.$menu_handler.'&action=up&menuId='.$tab[0].'">'.img_picto("Monter","1uparrow").'</a><a href="index.php?menu_handler='.$menu_handler.'&action=down&menuId='.$tab[0].'">'.img_picto("Descendre","1downarrow").'</a></div>';
|
||||||
|
|
||||||
|
print '</li>';
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
$rangLast = $rang;
|
||||||
|
$idLast = $tab[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*fonction r<>cursive d'affichage de l'arbre
|
||||||
|
$tab :tableau des <20>l<EFBFBD>ments
|
||||||
|
$pere :index de l'<27>l<EFBFBD>ment courant
|
||||||
|
$rang :d<>callage de l'<27>l<EFBFBD>ment
|
||||||
|
*/
|
||||||
|
function tree_recur($tab,$pere,$rang)
|
||||||
|
{
|
||||||
|
if ($pere == 0) print '<ul class="arbre">';
|
||||||
|
|
||||||
|
if ($rang > 10) return; // Protection contre boucle infinie
|
||||||
|
|
||||||
|
//ballayage du tableau
|
||||||
|
for ($x=0;$x<count($tab);$x++)
|
||||||
|
{
|
||||||
|
//si un <20>l<EFBFBD>ment a pour p<>re : $pere
|
||||||
|
if ($tab[$x][1]==$pere)
|
||||||
|
{
|
||||||
|
//on l'affiche avec le d<>callage courrant
|
||||||
|
tree_showline($tab[$x],$rang);
|
||||||
|
|
||||||
|
/*et on recherche ses fils
|
||||||
|
en rappelant la fonction recur()
|
||||||
|
(+ incr<63>mentation du d<>callage)*/
|
||||||
|
tree_recur($tab,$tab[$x][0],$rang+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($pere == 0) print '</ul>';
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user