<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="java.util.*" %>
<%@ page import="com.gx.webpage.engine.menupage.designdbengine.factory.*" %>
<%@ page import="com.gx.webpage.engine.menupage.designdbengine.valueobject.*" %>
<%@ page import="com.gx.webpage.framework.valueobject.*" %>
<%@ page import="com.gx.webpage.engine.menupage.designdbengine.api.*" %>
<%@ page import="com.gx.webpage.framework.util.inoutformat.DataBean" %>
<%
    String errStr = "";
	  String script = "";
    int menuCount = 0;
    try
    {
        UserInfoCtxModel uicm = new UserInfoCtxModel();
        uicm.setUserId("cc");
				uicm.setNeedAcl(true);
				uicm.setAclType(uicm.ACLTYPE_ROW);
				uicm.setRowCatPath("com.cc.menu");
				Collection colPerIds = new ArrayList();
				colPerIds.add("search");
				uicm.setRowColPerId(colPerIds);
        EbiMenuMgr delegate = MenuFactory.getInstance().getEbiMenuMgr();
				Collection col = delegate.findAllSysMenus(true,uicm);
				Iterator itP = col.iterator();
        menuCount = col.size();
				StringBuffer buffer = new StringBuffer();
				buffer.append("if (document.getElementById) {\r\n");
				if(menuCount>0){
					if("System".equals(UserInfoCtxModel.getSysUicm().getUserId())){
						buffer.append("var tree = new WebTree('菜单列表',\"setScriptStr(this,'menuAdd.jsp')\");\r\n");
					}else{
						buffer.append("var tree = new WebTree('菜单列表');\r\n");
					}
				}else{
					if("cc".equals(UserInfoCtxModel.getSysUicm().getUserId())){
						buffer.append("var tree = new WebTree('菜单列表',\"setScriptStr(this,'menuAdd.jsp?addRoot=true;')\");\r\n");
					}else{
						buffer.append("var tree = new WebTree('菜单列表');\r\n");
					}
				}
        String scriptB = "setScriptStr(this,'menuInfo.jsp?uuid=";
        String scriptT = "')" + '"';
        String puuid = "";
        String name = "";
        int mLelver = 0;
        while(itP.hasNext())
        {
            SysMenuModel model = (SysMenuModel)itP.next();
            puuid = model.getParentUuid();
            name = DataBean.getStr(model.getName());
            mLelver = model.getMenuLevel();
            if(mLelver < 3){
                buffer.append("var a"+model.getUuid()+" = new WebTreeItem('"+name+"',\""+scriptB + model.getUuid() + scriptT+", null, null, null, null, true);\r\n");
            }else{
			    buffer.append("var a"+model.getUuid()+" = new WebTreeItem('"+name+"',\""+scriptB + model.getUuid() + scriptT+");\r\n");
				}
				if(puuid == null || puuid.trim().length() == 0){
					buffer.append("tree.add(a"+model.getUuid()+");");
				}else{
			        buffer.append("a"+puuid+".add(a"+model.getUuid()+");");
				}
            buffer.append("\r\n");
        }
        buffer.append("document.write(tree); }");
		script = buffer.toString();
    }
    catch(Exception ex)
    {
//ex.printStackTrace();
        errStr = DataBean.getErrStr(ex);
        return;
    }
%>
<html>
<head>
    <meta http-equiv="Content-Language" content="zh-cn">
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="./../../../webpage/common/css/common.css" rel="StyleSheet"  type="text/css" />
<script language="javascript" src="./../../../webpage/common/engine/constant.js"></script>
<script language="JScript.Encode" src="./../../../webpage/common/engine/common.js"></script>
<script language="JScript.Encode" src="./../../../webpage/common/js/WebTree.js"></script>
<script language="javascript">
<%= script%>
</script>
<script language="javascript">
<!--
    var curObj = null;
    function setScriptStr(obj,str){
        window.parent.mainFrame.navigate(str);
    }
//-->
</script>
</head>
</body>
</html>
