<?php
require 'inc.php';//初始化系统环境
/*
名称：菜单模块
功能：根据参数调用相关模块菜单列表,参数为空时，调用默认列表
*/
include SYS_ROOT.'/cls_tab/tab.sys.model.php';
$obj_tab_model=new cls_tab_sys_model();
$arr_sysmodel=$obj_tab_model->sysmodel;
$str_model=implode("','",$arr_sysmodel);

$arr_menu=array();
$str_where=" where (model_state>0 or model_regkey in('".$str_model."'))";
if(isset($get_model_regkey)){
	$str_where.=" and model_regkey='".$get_model_regkey."'";
}

$str_sql="SELECT * FROM ".DB_PRE."sys_model".$str_where." order by model_sort,model_id";
$obj_result = $obj_db->query($str_sql);
$str_default_url="";
if($obj_rs = $obj_db->fetch_array($obj_result))
{
	$arr_model_path=$obj_tab_model->get_model_path($obj_rs["model_regkey"]);
	$str_admin_path=$arr_model_path["path"]."/admin";
	if(is_file($str_admin_path."/menu.php")){
		include $str_admin_path."/menu.php";
	}else if(is_file(WEB_ROOT."/".ADMIN_DIR."/admin_".$obj_rs["model_regkey"]."/menu.php")){
		include WEB_ROOT."/".ADMIN_DIR."/admin_".$obj_rs["model_regkey"]."/menu.php";
	}else{
		$str_where=" where page_model_id='".$obj_rs["model_id"]."' and page_ismenu=1";
		$obj_result_next = $obj_db->query("SELECT * FROM ".DB_PRE."sys_admin_page".$str_where." order by page_sort,page_id");
		while($obj_rs_next = $obj_db->fetch_array($obj_result_next))
		{
			if(WEB_ADMIN_DOUBLE!="1" && $obj_rs["model_regkey"]=="sys" && $obj_rs_next["page_url"]=="mypwd.php"){
				continue;
			}
			if($obj_ctl_limit->chk_page($obj_rs["model_regkey"],$obj_rs_next["page_url"])){
				$str_url="admin_".$obj_rs["model_regkey"]."/".$obj_rs_next["page_url"];
				if(is_file($str_admin_path."/".$obj_rs_next["page_url"])) $str_url="model_admin.php?model_key=".$obj_rs["model_regkey"]."&model_page=".$obj_rs_next["page_url"];
				$arr_x= array("url"=>$str_url,"name"=>$obj_rs_next["page_name"],"filename"=>md5($obj_rs_next["page_url"]));
				$arr_menu[]=$arr_x;
				if($str_default_url=="") $str_default_url=$arr_x["url"];
			}
		}
	}
}else{
	$arr_menu[]=array("url"=>"admin_sys/model.php","name"=>"注册模块");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<TITLE></TITLE>
<META http-equiv=Content-Type content="text/html; charset=gbk">
<STYLE type=text/css>
li{list-style-type:none}
BODY {background:url(images/left-repeat-background.gif) repeat-y;font-size:12px}
.me_title{float:left; width:166px;background:url(images/left-background.gif) 0 -19px no-repeat; overflow:hidden; position:relative; z-index:4;height:40px}
.menubox{float:left;width:166px} /*左栏目默认高度*/
.menubox li{float:left;color:#fff;background:url(images/menu_line.jpg) no-repeat left bottom;padding:8px 0px 8px 40px;text-align:left;width:120px;font-size:14px;cursor:pointer}
.menubox li a{ color:#fff;text-decoration:none}
.menubox .x_sel{color:#ffff00;font-weight:bold;}
</style>
</HEAD>
<base target="main">
<BODY>
<div class="me_title"></div>
<div id="right_main_nav" class="menubox">
	<?php
	$ii=0;
	$str_default_li="";
	$str_default_url="";
	if(isset($get_pagename)) $str_default_li=md5($get_pagename);
	foreach($arr_menu as $item){
		if($ii==0 && $str_default_li=="") $str_default_li=$item["filename"];
		if($str_default_li==$item["filename"]){
			$str_default_url=$item["url"];
			if(isset($get_url_parms)) $str_default_url.=$get_url_parms;
		}
		$ii++;
	?>
		<li id="id_li_<?php echo $item["filename"];?>" onclick="me_set_li('<?php echo $item["filename"];?>','<?php echo $item["url"];?>');"><img src="images/menu_ico.jpg">&nbsp;<?php echo $item["name"];?></li>
	<?php }?>
</div>
<?php if($str_default_url!=""){?>
<script>
var lng_old_id="";
window.open("<?php echo $str_default_url?>","main");
function me_set_li(msgid,msgurl){
	if(msgid==lng_old_id) return;
	window.open(msgurl,"main");
	obj_x=document.getElementById("id_li_"+msgid);
	obj_old_x=document.getElementById("id_li_"+lng_old_id);
	if(obj_x){
		obj_x.className="x_sel";
		if(obj_old_x) obj_old_x.className="";
		lng_old_id=msgid;
	}
}
me_set_li('<?php echo $str_default_li;?>','<?php echo $str_default_url;?>');
</script>
<?php }?>
</BODY></HTML>