2011-01-06 08:37:20 +00:00

392 lines
7.8 KiB
PHP

<?php
class Menu
{
protected $menu = null;
protected $defineMenu = array(
array(
'label' => 'RECHERCHES',
'pages' => array(
array(
'label' => "Rechercher une entreprise",
'title' => "Rechercher une entreprise",
'controller' => 'recherche',
'action' => 'entreprise',
),
array(
'label' => "Rechercher par dirigeant",
'controller' => 'recherche',
'action' => 'dirigeant',
),
array(
'label' => "Recherche Internationale",
'controller' => '',
'action' => '',
),
array(
'label' => "Rechercher une annonce",
'controller' => '',
'action' => '',
),
array(
'label' => "Dernière recherche",
'controller' => 'recherche',
'action' => 'last',
),
array(
'label' => "Liste des dernières recherches",
'controller' => 'recherche',
'action' => 'list',
),
array(
'label' => "Centrale IparI",
'controller' => '',
'action' => '',
'permission' => 'ipari',
),
),
),
array(
'label' => 'IDENTITE',
'pages' => array(
array(
'label' => "Fiche d'identité",
'controller' => '',
'action' => '',
),
array(
'label' => "Fiche AGS",
'controller' => '',
'action' => '',
),
array(
'label' => "Fiche Procédure Collective",
'controller' => '',
'action' => '',
),
array(
'label' => "Liste des établissements",
'controller' => '',
'action' => '',
),
array(
'label' => "Liens inter-entreprise",
'controller' => '',
'action' => '',
),
array(
'label' => "Modifications Insee",
'controller' => '',
'action' => '',
),
),
),
array(
'label' => 'DIRIGEANTS',
'pages' => array(
array(
'label' => "Liste des dirigeants",
'controller' => '',
'action' => '',
),
array(
'label' => "Historique des dirigeants",
'controller' => '',
'action' => '',
),
),
),
array(
'label' => 'ELEMENTS FINANCIERS',
'pages' => array(
array(
'label' => "Synthèse",
'controller' => '',
'action' => '',
),
array(
'label' => "Bilans, Compte de résultat",
'controller' => '',
'action' => '',
),
array(
'label' => "Ratios",
'controller' => '',
'action' => '',
),
array(
'label' => "Liasse fiscale",
'controller' => '',
'action' => '',
),
array(
'label' => "Bourse & Cotations",
'controller' => '',
'action' => '',
),
array(
'label' => "Relations bancaires",
'controller' => '',
'action' => '',
),
),
),
array(
'label' => 'ELEMENTS JURIDIQUES',
'pages' => array(
array(
'label' => "Annonces Légales",
'controller' => '',
'action' => '',
),
array(
'label' => "Information Réglementée",
'controller' => '',
'action' => '',
),
array(
'label' => "Compétences Territoriales",
'controller' => '',
'action' => '',
),
array(
'label' => "Conventions collectives",
'controller' => '',
'action' => '',
),
array(
'label' => "Marques déposées",
'controller' => '',
'action' => '',
),
),
),
array(
'label' => 'BANQUE DE FRANCE',
'permission' => 'BDF',
'pages' => array(
array(
'label' => "27. Panorama",
'controller' => '',
'action' => '',
),
array(
'label' => "28. Concours Bancaires",
'controller' => '',
'action' => '',
),
array(
'label' => "29. Impayés",
'controller' => '',
'action' => '',
),
array(
'label' => "37. Cotation",
'controller' => '',
'action' => '',
),
array(
'label' => "40. Relations Bancaires",
'controller' => '',
'action' => '',
),
array(
'label' => "51. Dirigeants",
'controller' => '',
'action' => '',
),
array(
'label' => "Autres",
'controller' => '',
'action' => '',
),
),
),
array(
'label' => 'EVALUATION',
'pages' => array(
array(
'label' => "IndiScore",
'controller' => '',
'action' => '',
),
array(
'label' => "Rapport de synthèse",
'controller' => '',
'action' => '',
),
array(
'label' => "Rapport complet",
'controller' => '',
'action' => '',
),
array(
'label' => "Scoring Credit Safe",
'controller' => '',
'action' => '',
),
array(
'label' => "Enquête commerciale",
'controller' => '',
'action' => '',
),
),
),
array(
'label' => 'PIECES OFFICIELLES',
'pages' => array(
array(
'label' => "Commande de Pièces",
'controller' => '',
'action' => '',
),
array(
'label' => "Comptes annuels",
'controller' => '',
'action' => '',
),
array(
'label' => "Actes & Statuts",
'controller' => '',
'action' => '',
),
array(
'label' => "Suivi Privilèges",
'controller' => '',
'action' => '',
),
),
),
array(
'label' => 'OPTIONS',
'pages' => array(
array(
'label' => "Mes options",
'controller' => '',
'action' => '',
),
array(
'label' => "Mes surveillances",
'controller' => '',
'action' => '',
),
array(
'label' => "Mon portefeuille",
'controller' => '',
'action' => '',
),
array(
'label' => "Administration",
'controller' => '',
'action' => '',
),
array(
'label' => "Commandes Greffe",
'controller' => '',
'action' => '',
),
array(
'label' => "Commandes International",
'controller' => '',
'action' => '',
),
array(
'label' => "Commandes Giant",
'controller' => '',
'action' => '',
),
array(
'label' => "Statistiques",
'controller' => '',
'action' => '',
),
array(
'label' => "Surveillances",
'controller' => '',
'action' => '',
),
array(
'label' => "Se déconnecter",
'controller' => 'user',
'action' => 'logout',
),
),
),
);
public function __construct(){
$this->menu = new Zend_Navigation();
$this->computeMenu();
}
public function getMenu(){
return $this->menu;
}
protected function computeMenu(){
foreach($this->defineMenu as $element){
$perm = true;
if (array_key_exists('permission', $element)){
$perm = $this->checkPermission($element['permission']);
}
if ($perm){
$menu = array();
$menu['label'] = $element['label'];
$menu['uri'] = '#';
$menu['class'] = 'header';
if (array_key_exists('pages', $element)){
$menu['pages'] = $this->computePage($element['pages']);
}
$this->menu->addPage($menu);
}
}
}
protected function computePage($pages){
$computePages = array();
foreach($pages as $page){
$visible = false;
if (array_key_exists('visibleSansPermission', $page)){
$visible = $page['visibleSansPermission'];
//unset($page['visibleSansPermission']);
}
$perm = true;
if (array_key_exists('permission', $page)){
$perm = $this->checkPermission($page['permission']);
//unset($page['permission']);
}
if ($perm){
$computePage = array();
$computePage = $page;
$computePages[] = $computePage;
} elseif (!$perm && $visible){
$computePage = array();
$computePage['label'] = $page['label'];
$computePage['uri'] = '#';
$computePages[] = $computePage;
}
}
return $computePages;
}
protected function checkPermission($perm){
$hasPerm = false;
if (is_array($perm)){
$list = $perm;
} else if (is_string($perm)){
$list = (array)$perm;
}
foreach($list as $permission){
if (preg_match('/\b'.$permission.'\b/i', '')){
$hasPerm = true;
break;
}
}
return $hasPerm;
}
protected function checkParams(){
}
}