class navigation {
var $items = array();
var $admin_menu = "admin";
var $xml_file = "";
var $set = FALSE;
var $init = 0;
function init( &$stream ){
$this->init++;
echo $this->init;
if( !$this->set ){
stdio::error_message("class/navigation/set/false");
}
else {
$this->config = new xml;
// read config file for
$this->config->read_file($this->xml_file);
// initalize sub_classes
$hwdb = $this->init_sub_classes("hwdb","class","name");
$category = new $hwdb["category"];
#$xml->show_file();
$out = '';
$out .= $this->show_tables($stream);
return $out;
}//fi
}
function settings( $set_array ){
if( array($set_array) ){
$this->set = TRUE;
extract($set_array);
if( isset($xml_file) ) $this->xml_file = $xml_file;
}//fi
else
return FALSE;
}//fi
function init_sub_classes( $xpath, $element, $attribute ){
$classes = $this->config->read_attribute($xpath,$element,$attribute);
foreach( $classes as $key ){
$val = $this->config->read_xpath($xpath."/".$element."[@name='".$key."']/".$attribute);
$class["$key"] = $val;
}
return $class;
}
function add_item( $name ) {
if( !isset($this->items[$name]) ){
$i = 0;
$this->items[$name][$i] = $name;
}//fi
else {
echo "item: '$name' already exist
";
}//fi
}//fend
function add_sub_item( $parent, $name ){
if( !isset($this->items[$parent]) ){
$this->additem($parent);
$this->items[$parent][0] = $name;
}//fi
else {
$i = count($this->items[$parent]);
$this->items[$parent][$i] = $name;
}//eend
}//fend
function add_login() {
if( $this->state()==TRUE ){
$this->add_item("logout");
$this->items["logout"][0] = "navlogout";
}//fi
else{
if( !isset($this->items["login"]) ){
$this->add_item("login");
$this->items["login"][0] = "navlogin";
}//fi
}//eend
}//fend
function calc_item( $item ){
$str = str_split($item);
$sum = 0;
foreach ( $str as $value ){
$sum += ord($value)* 3;
}//feend
#return $sum + 1000;
return $item;
}//fend
function state(){
if(
(isset($_POST["state"]) || isset($_GET["auth"])) &&
$_GET["PHPSESSID"]=$_SERVER["HTTP_COOKIE"]
){
$state = "&auth=granted";
return $state;
}//fi
}//fend
function show_tables( &$stream ){
$out = "\n";
$out .= '
'."\n"; $out .= ' '.$this->show_items_left()."\n"; $out .= ' | '."\n"; $out .= ''."\n"; $out .= ' '.$stream."\n"; $out .= ' | '."\n"; $out .= ''."\n"; $out .= ' '.$this->show_items_right()."\n"; $out .= ' | '."\n"; $out .= '