().GetTree("sys", true, true);
if (_allMM != null)
{
Response.Write(_BuildMenu(_allMM));
}
Response.End();
}
///
/// 生成系统菜单
///
///
private string _BuildMenu(Song.Entities.ManageMenu[] mm)
{
string tmp = "";
//当前根节点
Extend.MenuNode root = new Extend.MenuNode(null, mm);
if (root.IsChilds)
{
//递归生成子菜单
tmp += this._BuildMenuItem(root.Childs[0], 0, root.Childs[0].MM_Name);
}
return tmp;
}
//生成下拉菜单,子菜单面板
private string _BuildMenuItem(Song.Entities.ManageMenu m, int level, string path)
{
Extend.MenuNode node = new Song.Extend.MenuNode(m, _allMM);
//如果没有子节点,则直接返回
if (!node.IsChilds) return "";
//
string tmp = "";
if (level == 0)
tmp = "";
//递归生成子菜单
for (int i = 0; i < node.Childs.Length; i++)
{
Song.Entities.ManageMenu n = node.Childs[i];
tmp += this._BuildMenuItem(n, level, path + "," + n.MM_Name);
}
return tmp;
}
//生成节点项文本
//node:当前节点
//data:完整数据源
//clas:当前节点的style
private string _SysBuildNode(Song.Entities.ManageMenu m, string clas, string path)
{
Extend.MenuNode node = new Song.Extend.MenuNode(m, _allMM);
string temp = "";
//菜单节点的自定义样式
string style = " ";
if (m.MM_Color != String.Empty && m.MM_Color != null) style += "color: " + m.MM_Color + ";";
if (m.MM_IsBold) style += "font-weight: bold;";
if (m.MM_IsItalic) style += "font-style: italic;";
if (m.MM_Font != String.Empty && m.MM_Font != null) style += "font-family: '" + m.MM_Font + "';";
string name = "" + m.MM_Name + "";
if (m.MM_Link != "")
{
string link = "";
link += "<{0} href=\"";
link += m.MM_Link + "\" isChild=\"" + node.IsChilds + "\" IsUse=\"" + m.MM_IsUse
+ "\" width=\"" + m.MM_WinWidth + "\" height=\""+m.MM_WinHeight
+ "\" path=\"" + path + "\" target=\"_blank\" class=\"a\">";
link += name + "{0}>";
switch(m.MM_Type.ToLower())
{
case "link":
link = string.Format(link, "a");
break;
default:
link = link.Replace("{0}", "span");
break;
}
temp += link;
}
else
{
temp += name;
}
temp += "
";
return temp;
}
}
}