'; $main_direction["table_ende"]=''; $main_direction["start"]=''; $main_direction["ende"]='';*/ if(!isset($site) or $site=='') { $site='home'; //$tmptop="Home"; } //switch($site){ default: standard(); break;} mkMenu(); mkMenuString(); mkSubMenuString(); getReplaceArray(); phraseTemplate(); exit; // Funktionen und Prozeduren -------------------------------------------------- function end_element( $parser, $name ){ global $xmlname; $xmlname=''; return 0; } function daten( $parser, $data ){ global $xmlname, $arrMenu, $arrSubMenu; switch($xmlname){ case 'link': $arrMenu[count($arrMenu)-1]["caption"]=$data; break; case 'sublink': $arrSubMenu[count($arrSubMenu)-1]["caption"]=$data; break; } return 0; } function start_element($parser, $name, $atts) { global $menuString, $site, $submenuString, $tmptop, $arrMenu, $arrSubMenu, $xmlname; switch (strtolower($name)) { case 'link': $xmlname=strtolower($name); $arrMenu[]=array("id"=>$atts["ID"], "idref"=>$atts["IDREF"], "target"=>$atts["TARGET"], "class"=>$atts["CLASS"], "hassub"=>$atts["HASSUB"], "dest"=>$atts["DEST"]); break; case 'sublink': $xmlname=strtolower($name); $arrSubMenu[]=array("id"=>$atts["ID"], "idref"=>$atts["IDREF"], "target"=>$atts["TARGET"], "class"=>$atts["CLASS"], "hassub"=>$atts["HASSUB"], "dest"=>$atts["DEST"]); break; } return 0; } function mkMenu(){ global $rootdir, $menuString, $site, $submenuString, $tmptop, $arrMenu, $arrSubMenu, $xmlname; $datei='menu.xml'; $parser = xml_parser_create(); xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, true ); xml_set_element_handler( $parser, "start_element", "end_element" ); xml_set_character_data_handler( $parser, "daten" ); $fp = fopen( "$rootdir/dat/$datei", "r"); while($data=fread($fp, 4096)){ xml_parse( $parser, $data, feof($fp));} xml_parser_free( $parser ); return 0; } function mkMenuString(){ global $rootdir, $menuString, $site, $submenuString, $tmptop, $arrMenu, $arrSubMenu, $xmlname, $ParentMenuID; $menuString.=''."\n"; if(is_array($arrMenu) && count($arrMenu)>0){ foreach($arrMenu as $tmp){ $parent=$_GET["top"]; $active=''; $top='&top='.$tmp["id"]; if(substr($tmp["dest"], 0, 7)=='http://') $top=''; if($parent==$tmp["id"] && $parent!='') { $active='»'; } $menuString.= '\n"; } $menuString.="
'.$active; $menuString.= ''.$tmp["caption"].""; $menuString.= "
\n"; } return 0; } function mkSubMenuString(){ global $rootdir, $menuString, $site, $submenuString, $tmptop, $arrMenu, $arrSubMenu, $xmlname, $id; if(is_array($arrSubMenu) && count($arrSubMenu)>0){ $submenuString=''."\n"; $parent=$_GET["top"]; $child=$_GET["sub"]; foreach($arrSubMenu as $tmp){ if($tmp["idref"]==$parent){ $active=''; $top='&top='.$parent.'&sub='.$tmp["id"]; if(substr($tmp["dest"], 0, 7)=='http://') $top=''; if($child==$tmp["id"] && $child!='') $active='»'; $submenuString.= '\n"; } } $submenuString.="
 '.$active.'

'; //$submenuString.= '
'; $submenuString.= ''.$tmp["caption"].""; $submenuString.= "

\n"; } return 0; } //-- function File2String ($filename){ global $dir_proj; $tmpfile=file("$dir_proj$filename"); foreach($tmpfile as $tmprow) { $str_out.="$tmprow\n"; } return $str_out; } //-- function getReplaceArray(){ global $submenuString, $menuString; global $arr_replace, $dir_proj; $repl_file=file("$dir_proj/dat/repl.dat"); if(is_array($repl_file)){ foreach($repl_file as $line){ if(!ereg('###',$line)){ $tmparr=split(';;;',$line); array_push($arr_replace, $tmparr); } } $tmparr=array('!--HorizMenu--!',$menuString,'text'); array_push($arr_replace, $tmparr); $tmparr=array('!--SubMenu--!',$submenuString,'text'); array_push($arr_replace, $tmparr); } return 0; } //-- function phraseTemplate(){ global $dir_proj, $site, $arr_replace; $template=file("$dir_proj/template.tpl"); if(is_array($template)){ foreach($template as $zeile){ foreach($arr_replace as $row){ if(ereg($row[0], $zeile)){ if($row[2]=="text") { $zeile=ereg_replace($row[0], $row[1], $zeile); } if($row[2]=='datei') { $tmpstring=file2string("dat/$row[1]"); $zeile=ereg_replace($row[0],$tmpstring,$zeile); } } } $zeile=ereg_replace('!--MainText--!',file2string("sites/$site.dat"),$zeile); //$zeile=ereg_replace('!--MainText--!',include_once "sites/$site.dat",$zeile); print "$zeile\n"; } } return 0; } //-- function standard(){ global $dir_proj, $site, $arr_replace; getReplaceArray(); phraseTemplate(); return 0; } ?>