l3.cas-d-astre/includes/libsecuremenu.inc.php

73 lines
1.5 KiB
PHP
Raw Permalink Normal View History

2009-05-01 08:39:36 +00:00
<?php
if (!defined("LIBSECUREMENU_INC")){
define(LIBSECUREMENU_INC,1);
/* Definition de la classe pour le menu */
class SecureMenu {
var $_defaultLevel;
var $_params;
var $_name;
var $_url;
var $_level;
var $_currentLevel;
/*
* Cr<EFBFBD>e un menu vide
*/
function SecureMenu($title,$level=0){
$this->_title=$title;
$this->_name=array();
$this->_url=array();
$this->_visible=array();
$this->_params=array();
$this->_defaultLevel=$level;
}
/*
* Ajoute une entr<EFBFBD>e au menu
*/
function addItem($param,$name="",$url=""){
array_push($this->_params,$param);
/* Verifie s'il s'agit d'un s<>parateur */
$this->_name[$param]="$name";
$this->_url[$param]="$url";
$this->_level[$param]=$this->_defaultLevel;
}
/*
* Active une entr<EFBFBD>e du menu
*/
function setItemLevel($param,$level){
$this->_level[$param]=$level;
}
function setCurrentLevel($level){
if ($level<0) { $level =0; }
$this->_currentLevel=$level;
}
function toHTML(){
$answer="<h1>".$this->_title."</h1>";
$answer.="<ul\n";
foreach ($this->_params as $param){
if (($this->_level[$param] ^ $this->_currentLevel)>0){
$answer.="<li>"
."<a href=\""
.$this->_url[$param]
."\">"
.$this->_name[$param]
."</a>"
."</li>\n";
}
}
$answer.="</ul>";
return $answer;
}
}
}
?>