2009-10-02 09:24:43 +00:00
|
|
|
<?php
|
2010-04-06 12:56:25 +00:00
|
|
|
require_once realpath(dirname(__FILE__)).'/menu_liens.php';
|
|
|
|
require_once realpath(dirname(__FILE__)).'/defineMenu.php';
|
2009-10-02 09:24:43 +00:00
|
|
|
|
|
|
|
function menu()
|
|
|
|
{
|
2010-04-06 12:56:25 +00:00
|
|
|
$menu = array();
|
|
|
|
$menu = defineMenu();
|
2009-10-02 09:24:43 +00:00
|
|
|
$html = '';
|
|
|
|
foreach($menu as $item)
|
|
|
|
{
|
|
|
|
$href = false;
|
2010-03-02 15:50:11 +00:00
|
|
|
//Gestion des permissions sur le menu
|
2010-01-28 09:32:35 +00:00
|
|
|
$displayMenu = true;
|
2010-02-19 08:13:46 +00:00
|
|
|
if( isset($item['perm']) )
|
2009-10-02 09:24:43 +00:00
|
|
|
{
|
2010-02-19 08:13:46 +00:00
|
|
|
$permStatut = false;
|
|
|
|
foreach($item['perm']['list'] as $perm)
|
|
|
|
{
|
|
|
|
$permStatut = $permStatut || hasPerm($perm);
|
|
|
|
}
|
|
|
|
if(!$permStatut)
|
|
|
|
{
|
2010-03-02 15:50:11 +00:00
|
|
|
if( !isset($item['perm']['hidden']) ||
|
|
|
|
$item['perm']['hidden']===false )
|
2010-02-19 08:13:46 +00:00
|
|
|
{
|
|
|
|
$displayMenu = true;
|
|
|
|
}
|
2010-03-02 15:50:11 +00:00
|
|
|
elseif( isset($item['perm']['hidden']) &&
|
2010-02-19 08:13:46 +00:00
|
|
|
$item['perm']['hidden']===true )
|
|
|
|
{
|
|
|
|
$displayMenu = false;
|
|
|
|
}
|
|
|
|
}
|
2010-01-28 09:32:35 +00:00
|
|
|
}
|
2010-03-02 15:50:11 +00:00
|
|
|
|
2010-01-28 09:32:35 +00:00
|
|
|
if($displayMenu)
|
|
|
|
{
|
|
|
|
$html.= '<h3><a href="#">'.$item['data'].'</a></h3>'."\n";
|
|
|
|
$html.= '<div>'."\n";
|
|
|
|
$html.= '<ul>'."\n";
|
|
|
|
foreach($item['children'] as $children)
|
2009-10-02 09:24:43 +00:00
|
|
|
{
|
2010-01-28 09:32:35 +00:00
|
|
|
$html.= menu_children($children);
|
2009-10-02 09:24:43 +00:00
|
|
|
}
|
2010-01-28 09:32:35 +00:00
|
|
|
$html.= '</ul>'."\n";
|
|
|
|
$html.= '</div>'."\n";
|
2009-10-02 09:24:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
2010-01-28 09:32:35 +00:00
|
|
|
function menu_children($children)
|
2009-12-07 08:07:04 +00:00
|
|
|
{
|
2010-01-28 09:32:35 +00:00
|
|
|
global $firephp;
|
2010-03-02 15:50:11 +00:00
|
|
|
//Génération du lien
|
2010-01-28 09:32:35 +00:00
|
|
|
$href = false;
|
|
|
|
if( $children['href']!='' && function_exists($children['href']) )
|
2010-03-02 15:50:11 +00:00
|
|
|
{
|
2010-01-28 09:32:35 +00:00
|
|
|
$href = $children['href']();
|
|
|
|
}
|
|
|
|
//Traitement des permissions
|
|
|
|
if( isset($children['perm']) )
|
2009-12-07 08:07:04 +00:00
|
|
|
{
|
2010-02-17 14:44:28 +00:00
|
|
|
$permStatut = false;
|
|
|
|
foreach($children['perm']['list'] as $perm)
|
2009-12-07 08:07:04 +00:00
|
|
|
{
|
2010-02-17 14:44:28 +00:00
|
|
|
$permStatut = $permStatut || hasPerm($perm);
|
2010-01-28 09:32:35 +00:00
|
|
|
}
|
2010-02-17 14:44:28 +00:00
|
|
|
if(!$permStatut)
|
2010-01-28 09:32:35 +00:00
|
|
|
{
|
2010-03-02 15:50:11 +00:00
|
|
|
if( !isset($children['perm']['hidden']) ||
|
|
|
|
$children['perm']['hidden']===false )
|
2010-02-17 14:44:28 +00:00
|
|
|
{
|
|
|
|
$href = '#';
|
|
|
|
}
|
2010-03-02 15:50:11 +00:00
|
|
|
elseif( isset($children['perm']['hidden']) &&
|
2010-02-17 14:44:28 +00:00
|
|
|
$children['perm']['hidden']===true )
|
|
|
|
{
|
|
|
|
$href = false;
|
|
|
|
}
|
2010-01-28 09:32:35 +00:00
|
|
|
}
|
2010-03-02 15:50:11 +00:00
|
|
|
|
2010-01-28 09:32:35 +00:00
|
|
|
}
|
2010-03-02 15:50:11 +00:00
|
|
|
|
2010-01-28 09:32:35 +00:00
|
|
|
//Traitement profil
|
|
|
|
if(isset($children['profil']))
|
2010-03-02 15:50:11 +00:00
|
|
|
{
|
|
|
|
if( ( !isset($children['profil']['hidden']) ||
|
2010-01-28 09:32:35 +00:00
|
|
|
$children['profil']['hidden']===false ) &&
|
2010-01-29 11:07:24 +00:00
|
|
|
hasProfil($children['profil']['name'])===false )
|
2010-01-28 09:32:35 +00:00
|
|
|
{
|
|
|
|
$href = '#';
|
|
|
|
}
|
2010-03-02 15:50:11 +00:00
|
|
|
elseif( isset($children['profil']['hidden']) &&
|
2010-01-29 11:07:24 +00:00
|
|
|
$children['profil']['hidden'] &&
|
|
|
|
hasProfil($children['profil']['name'])===false )
|
2010-03-02 15:50:11 +00:00
|
|
|
{
|
2010-01-28 09:32:35 +00:00
|
|
|
$href = false;
|
2010-03-02 15:50:11 +00:00
|
|
|
}
|
2010-01-28 09:32:35 +00:00
|
|
|
}
|
2010-03-02 15:50:11 +00:00
|
|
|
|
2010-01-28 09:32:35 +00:00
|
|
|
//Output
|
|
|
|
$html = '';
|
|
|
|
if($href!==false)
|
|
|
|
{
|
|
|
|
$html.= '<li><a href="'.$href.'">';
|
2010-03-02 15:50:11 +00:00
|
|
|
if($href=='#'){
|
2010-01-28 09:32:35 +00:00
|
|
|
$html.= '<font color="gray">'.
|
|
|
|
$children['data'].
|
|
|
|
'</font>';
|
2009-12-07 08:07:04 +00:00
|
|
|
}
|
2010-01-28 09:32:35 +00:00
|
|
|
else{ $html.= $children['data']; }
|
|
|
|
$html.= '</a></li>';
|
|
|
|
$html.= "\n";
|
2009-12-07 08:07:04 +00:00
|
|
|
}
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|