<!-- #include file="include/admin_onlogin.asp" -->
<!-- #include file="include/admin_menu_type.asp" -->
<!-- #include file="include/jk_template.asp" -->
<%
dim mid
mid=trim(request.querystring("m_id"))
if not(isnumeric(mid)) then mid=0
admins=true
nsort="menu"
index_url="menu"
data_name="admin_menu"
tit_fir="菜单"
tit="管理菜单"
call admin_header(0,0)
%>
<tr><td align=center colspan=2 height=30>
  <table border=0>
  <tr>
  <td><a href='?'><%response.write tit%></a></td>
  <td width=10></td>
  <td><a href='?action=add_1'>添加新的<%response.write tit_fir%></a></td>
  <td width=10></td>
  <td><a href='?action=menu'>网站菜单生成</a></td>
  <td width=10></td>
  <td><a href='admins_popedom.asp'>权限管理</a></td>
  <td width=10></td>
  <td><a href='javascript:;' onclick="javascript:parent.frame_left.re_load();">预览<%response.write tit%></a></td>
  </tr>
  </table>
</td></tr>
</table>
<%
call admin_table(1,1)

select case action
case "menu_order"
  call joekoe_chk_menu_order()
case "menu_up","menu_down","menu"
  call joekoe_chk_menu()
case "add_1"
  call joekoe_chk_add_1()
case "add_2"
  call joekoe_chk_add_2()
case "edit_1"
  call joekoe_chk_edit_1()
case "edit_2"
  call joekoe_chk_edit_2()
case "up_1","down_1"
  call joekoe_chk_action_1()
case "up_2","down_2"
  call joekoe_chk_action_2()
case "delete"
  call joekoe_chk_delete()
case else
  call joekoe_chk_main()
end select

call admin_ender(1)

sub joekoe_chk_delete()
  if cint(mid)<1 then
    call joekoe_chk_edit()
    exit sub
  end if
  dim m_sort,m_name,m_order
  set rs=joekoe_cms.exec("select top 1 m_sort,m_name,m_order from "&data_name&" where m_id="&mid,1)
  if rs.eof then
    rs.close
    call admin_msg(tit_fir&"ID（"&mid&"）不存在！","?action=edit",1)
    exit sub
  end if
  m_sort=rs("m_sort")
  m_name=rs("m_name")
  m_order=rs("m_order")
  rs.close
  if cint(m_order)=0 then
    call joekoe_cms.exec("delete from "&data_name&" where m_sort="&m_sort,0)
    call admin_event("删除一项主"&tit_fir&"（"&m_name&"）及其二级"&tit_fir&"。",0,0)
    call admin_msg("成功删除一项主"&tit_fir&"（"&m_name&"）及其二级"&tit_fir&"！","?action=edit",1)
  else
    call joekoe_cms.exec("delete from "&data_name&" where m_id="&mid,0)
    call admin_event("删除一项二级"&tit_fir&"（"&m_name&"）。",0,0)
    call admin_msg("成功删除一项二级"&tit_fir&"（"&m_name&"）！","?action=edit",1)
  end if
end sub

sub joekoe_chk_menu_order()
  i=1
  sql="select m_id from "&data_name&" where m_is_menu=1 order by m_morder,m_id"
  set rs=joekoe_cms.exec(sql,1)
  do while not rs.eof
    call joekoe_cms.exec("update "&data_name&" set m_morder="&i&" where m_id="&rs("m_id"),0)
    i=i+1
    rs.movenext
  loop
  rs.close
  call admin_msg("成功对网站菜单进行了排序！","?action=menu",1)
end sub

sub joekoe_chk_menu_action()
  dim nid,mid,mid1,mid2,mo1,mo2
  mid=id
  if int(mid)<1 then exit sub
  sql_add=""
  if action="menu_up" then sql_add=" desc"
  sql="select m_id,m_morder from "&data_name&" where m_is_menu=1 order by m_morder"&sql_add&",m_id"
  set rs=joekoe_cms.exec(sql,1)
  do while not rs.eof
    nid=int(rs(0))
    if int(mid)=int(nid) then
      mid1=nid
      mo2=rs(1)
      rs.movenext
      if rs.eof then exit do
      mid2=rs(0)
      mo1=rs(1)
      call joekoe_cms.exec("update "&data_name&" set m_morder="&mo1&" where m_id="&mid1,0)
      call joekoe_cms.exec("update "&data_name&" set m_morder="&mo2&" where m_id="&mid2,0)
      exit do
    end if
    rs.movenext
  loop
  
rs.close
end sub

sub joekoe_chk_menu()
  if action="menu_up" or action="menu_down" then call joekoe_chk_menu_action()
  dim mid,m_index_url,m_mname,m_mtit,m_mcolor,nurl,temp1,temp2,temp3,file_name
  file_name="style/joekoe_menu.asp"
  call admin_td("网站菜单生成")
%>
<tr><td colspan=2 align=center>
  <table border=0 cellspacing=2 cellpadding=4>
  <tr>
  <td><a href='./'>首页</a></td>
<%
  temp2=vbcrlf&"<"&"%" & _
        vbcrlf&"function web_menu()" & _
	vbcrlf&"  dim m_var" & _
	vbcrlf&"  m_var=vbcrlf&""<table border=0 cellspacing=0 cellpadding=0 class=tf align=center width='98%'><tr align=center height=18>"" & _" & _
	vbcrlf&"        vbcrlf&""<td width=50><a class=h_menu href='./'>首页</a></td>"" & _"
  web_dim(20)=""
  sql="select m_id,m_index_url,m_mname,m_mtit,m_mcolor,m_mb,m_mtarget,m_murl from "&data_name&" where m_is_menu=1 order by m_morder,m_id"
  set rs=joekoe_cms.exec(sql,1)
  do while not rs.eof
    mid=rs("m_id")
    m_index_url=rs("m_index_url")
    m_mname=rs("m_mname")
    m_mtit=rs("m_mtit")
    m_mcolor=rs("m_mcolor")
    nurl=rs("m_murl")
    if web_dim(20)="" then
      web_dim(20)=m_index_url&":"&m_mname
    else
      web_dim(20)=web_dim(20)&"|"&m_index_url&":"&m_mname
    end if
    if var_null(nurl)="" then nurl=m_index_url&".asp"
    if var_null(m_mname)="" then m_mname="暂无"
    temp1="<a class=h_menu href='"&nurl&"'"
    if rs("m_mtarget") then temp1=temp1&" target=_blank"
    if var_null(m_mcolor)<>"" then temp1=temp1&"><font color='"&m_mcolor&"'"
    if var_null(m_mtit)<>"" then temp1=temp1&" alt='"&m_mtit&"'"
    temp1=temp1&">"&m_mname&"</a>"
    if rs("m_mb") then temp1="<b>"&temp1&"</b>"
    temp2=temp2&vbcrlf&"        vbcrlf&""<td>"&temp1&"</td>"" & _"
    temp3=temp3&vbcrlf&"<tr><td>"&temp1&"</td><td>&nbsp;&nbsp;"&pro_edit("?action=edit_2&m_id="&mid,"编辑该菜单项")&"&nbsp;&nbsp;&nbsp;<a href='?action=menu_up&id="&mid&"'>"&img_admin("up_2","向上移动此菜单")&"</a>&nbsp;&nbsp;&nbsp;<a href='?action=menu_down&id="&mid&"'>"&img_admin("down_2","向下移动此菜单")&"</a></td></tr>"
    response.write vbcrlf&"  <td>"&temp1&"</td>"
    rs.movenext
  loop
  rs.close
  temp2=temp2&vbcrlf&"        vbcrlf&""</tr></table>""" & _
	vbcrlf&"  web_menu=m_var" & _
	vbcrlf&"end function" & _
	vbcrlf&"%"&">"
%>
  </tr>
  </table>
</td></tr>
<tr>
<form name=menu_frm action='?action=<%response.write action%>' method=post>
<input type=hidden name=chk value='yes'>
<td colspan=2 align=center height=50>
<%
  if chk() then
    call create_file(file_name,temp2)
    call joekoe_template_common()
    response.write "<font class=red>已成功更新生成了网站菜单！</font>"
  else
    call form_first()
%>

<% end if %>
</td>
</form>
</tr>
<tr valign=top>
<td class=htd><br>相关操作：<br><br><a href='?action=menu_order' onclick="javascript:return click_return('重新对网站菜单进行排序',0);">重新排序</a></td>
<td>
  <table border=0 cellspacing=2 cellpadding=4>
<% response.write temp3 %>
  </table>
</td>
</tr>
<%
end sub

sub joekoe_chk_main()
  dim m_sort,m_name,m_type,n_sort,n_type,vt
  vt=false
  n_sort=-1
%>
<tr><td class=td colspan=2>编辑管理<%response.write tit_fir%></td></tr>
<tr>
<td></td>
<td>
  <table border=0 cellspacing=1 cellpadding=4 width='80%'>
  <tr><td width='50%'></td><td width='50%'></td></tr>
<%
  sql="select m_id,m_sort,m_name,m_url,m_open,m_hidden,m_sort from "&data_name&" order by m_sort,m_order"
  set rs=joekoe_cms.exec(sql,1)
  do while not rs.eof
    vt=true
    m_sort=rs("m_sort")
    m_name=rs("m_name")
    mid=rs("m_id")
    if cint(n_sort)=cint(m_sort) then
      response.write vbcrlf&"  <tr><td>　"&img_admin("s_minus","")&"&nbsp;<a href='###'>"&m_name&"</a>"
      if rs("m_hidden")=false then response.write " <font class=gray>(隐藏)</font>"
      response.write "</td><td><a href='?action=edit_2&m_id="&mid&"'>修改</a>&nbsp;&nbsp;" & _
		     "<a href='?action=up_2&m_id="&mid&"'>"&img_admin("up_2","向上移动此二级"&tit_fir)&"</a>&nbsp;&nbsp;" & _
		     "<a href='?action=down_2&m_id="&mid&"'>"&img_admin("down_2","向上移动此二级"&tit_fir)&"</a>&nbsp;&nbsp;" & _
		     "<a href='?action=delete&m_id="&mid&"' onclick=""return del_menu("&mid&",'"&m_name&"','no');"">删除</a></td></tr>"
    else
      if i>0 then response.write vbcrlf&"  <tr><td colspan=2 height=10></td></tr>"
      response.write vbcrlf&"  <tr><td>"&img_admin("s_plus","")&"&nbsp;<a href='###'>"&m_name&"</a>"
      if rs("m_hidden")=false then response.write " <font class=gray>(隐藏)</font>"
      if rs("m_open")=false then response.write " <font class=gray>(折叠)</font>"
      response.write " <font class=gray>[<font class=blue>"&rs("m_sort")&"</font>]</font></td><td><a href='?action=edit_1&m_id="&mid&"'>修改</a>&nbsp;&nbsp;" & _
		     "<a href='?action=up_1&m_id="&mid&"'>"&img_admin("up_1","向上移动此主"&tit_fir)&"</a>&nbsp;&nbsp;" & _
		     "<a href='?action=down_1&m_id="&mid&"'>"&img_admin("down_1","向下移动此主"&tit_fir)&"</a>&nbsp;&nbsp;" & _
		     "<a href='?action=delete&m_id="&mid&"' onclick=""return del_menu("&mid&",'"&m_name&"','yes');"">删除</a>&nbsp;&nbsp;" & _
		     "<a href='?action=add_2&m_id="&mid&"'>添加二级"&tit_fir&"</a></td></tr>"
      n_sort=m_sort
    end if
    rs.movenext
    i=i+1
  loop
  rs.close
  if not vt then response.write vbcrlf&"  <tr><td colspan=2 height=50 align=center>暂时没有任何"&tit_fir&"</td></tr>"
%>
  </table>
</td>
</tr>
<script language=javascript>
<!--
function left_menu(meval)
{
  var left_n=eval(meval);
  if (left_n.style.display=="none")
  { eval(meval+".style.display='';"); }
  else
  { eval(meval+".style.display='none';"); }
}

function del_menu(t1,t2,t3)
{
  if (t3=="yes")
  {
    var cf=window.confirm("您确定要删除主<%response.write tit_fir%>（"+t2+"）吗？\n其下的二级<%response.write tit_fir%>也将一并删除！\n\n删除后将不可恢复！是否确定该操作？");
    if (cf)
    { return true; }
    else
    { return false; }
  }
  else
  {
    var cf1=window.confirm("您确定要删除二级<%response.write tit_fir%>（"+t2+"）吗？\n\n删除后将不可恢复！是否确定该操作？");
    if (cf1)
    { return true; }
    else
    { return false; }
  }
  return false;
}
-->
</script>
<%
end sub

sub joekoe_chk_action_1()
  if cint(mid)<1 then
    call joekoe_chk_edit()
    exit sub
  end if
  dim id1,id2,sql1,sql2,sort1,sort2,update_ok,update_1
  update_ok=false
  update_1=false
  sql1=""
  sql2=""
  set rs=joekoe_cms.exec("select top 1 m_id from "&data_name&" where m_order=0 and m_id="&mid,1)
  if rs.eof then
    rs.close
    call admin_msg("主"&tit_fir&"ID（"&mid&"）不存在！","?action=edit",1)
    exit sub
  end if
  rs.close
  sql="select m_id,m_sort from "&data_name&" where m_order=0 order by m_sort"
  if action="up_1" then sql=sql&" desc"
  set rs=joekoe_cms.exec(sql,1)
  do while not rs.eof
    if cint(rs(0))=cint(mid) then
      id1=rs(0)
      sort1=rs(1)
      rs.movenext
      if not rs.eof then
        id2=rs(0)
        sort2=rs(1)
        update_ok=true
      end if
      exit do
    end if
    rs.movenext
  loop
  rs.close
  if update_ok=true then
    set rs=joekoe_cms.exec("select m_id from "&data_name&" where m_sort="&sort1,1)
    do while not rs.eof
      if sql1="" then
        sql1=" m_id="&rs(0)
      else
        sql1=sql1&" or m_id="&rs(0)
      end if
      rs.movenext
    loop
    rs.close
    set rs=joekoe_cms.exec("select m_id from "&data_name&" where m_sort="&sort2,1)
    do while not rs.eof
      if sql2="" then
        sql2=" m_id="&rs(0)
      else
        sql2=sql2&" or m_id="&rs(0)
      end if
      rs.movenext
    loop
    rs.close
    call joekoe_cms.exec("update "&data_name&" set m_sort="&sort2&" where "&sql1,0)
    call joekoe_cms.exec("update "&data_name&" set m_sort="&sort1&" where "&sql2,0)
  end if
  call joekoe_chk_main()
end sub

sub joekoe_chk_action_2()
  if cint(mid)<1 then
    call joekoe_chk_edit()
    exit sub
  end if
  dim n_sort,id1,id2,order1,order2,update_ok
  update_ok=false
  sql="select top 1 m_sort from "&data_name&" where m_order>0 and m_id="&mid
  set rs=joekoe_cms.exec(sql,1)
  if rs.eof then
    rs.close
    call admin_msg("二级"&tit_fir&"ID（"&mid&"）不存在！","?action=edit",1)
    exit sub
  end if
  n_sort=rs(0)
  rs.close
  sql="select m_id,m_order from "&data_name&" where m_order>0 and m_sort="&n_sort&" order by m_order"
  if action="up_2" then sql=sql&" desc"
  set rs=joekoe_cms.exec(sql,1)
  do while not rs.eof
    if cint(rs(0))=cint(mid) then
      id1=rs(0)
      order1=rs(1)
      rs.movenext
      if not rs.eof then
        id2=rs(0)
        order2=rs(1)
        update_ok=true
      end if
      exit do
    end if
    rs.movenext
  loop
  rs.close
  if update_ok=true then
    call joekoe_cms.exec("update "&data_name&" set m_order="&order2&" where m_id="&id1,0)
    call joekoe_cms.exec("update "&data_name&" set m_order="&order1&" where m_id="&id2,0)
  end if
  call joekoe_chk_main()
end sub

sub joekoe_chk_edit_2()
  dim m_sort,m_name,m_url,m_hidden,n_id,n_name,n_hidden,m_is_master,m_is_nsort,m_is_review,m_popedom,m_nsort,m_index_url,m_data_name,m_tit,m_tit_fir
  dim m_is_menu,m_mname,m_mtit,m_mcolor,m_mb,m_mtarget,m_murl
  sql="select top 1 * from "&data_name&" where m_id="&mid
  set rs=joekoe_cms.exec(sql,1)
  if rs.eof then
    rs.close
    call admin_msg("二级"&tit_fir&"ID（"&mid&"）不存在！","?action=edit",1)
    exit sub
  end if
  m_sort=rs("m_sort")
  m_name=rs("m_name")
  m_url=rs("m_url")
  m_hidden=rs("m_hidden")
  m_is_master=rs("m_is_master")
  m_is_nsort=rs("m_is_nsort")
  m_is_review=rs("m_is_review")
  m_popedom=rs("m_popedom")
  m_nsort=rs("m_nsort")
  m_index_url=rs("m_index_url")
  m_data_name=rs("m_data_name")
  m_tit=rs("m_tit")
  m_tit_fir=rs("m_tit_fir")
  m_is_menu=rs("m_is_menu")
  m_mname=rs("m_mname")
  m_mtit=rs("m_mtit")
  m_mcolor=rs("m_mcolor")
  m_mb=rs("m_mb")
  m_mtarget=rs("m_mtarget")
  m_murl=rs("m_murl")
  rs.close
  sql="select top 1 m_id,m_name,m_hidden from "&data_name&" where m_sort="&m_sort&" order by m_order"
  set rs=joekoe_cms.exec(sql,1)
  n_id=rs("m_id")
  n_name=rs("m_name")
  n_hidden=rs("m_hidden")
  rs.close
  if cint(n_id)=cint(mid) then
    call admin_msg("主"&tit_fir&"不存在！","?action=edit",1)
    exit sub
  end if
  call admin_td("修改二级"&tit_fir&"（"&m_name&"）")
  if chk() then
    m_name=code_admin("m_name",1,20)
    m_url=code_admin("m_url",1,100)
    m_hidden=1
    if trim(request.form("m_hidden"))="yes" then m_hidden=0
    if n_hidden=false then m_hidden=0
    m_is_master=0
    if trim(request.form("m_is_master"))="yes" then m_is_master=1
    m_is_nsort=0
    if trim(request.form("m_is_nsort"))="yes" then m_is_nsort=1
    m_is_review=0
    if trim(request.form("m_is_review"))="yes" then m_is_review=1
    m_popedom=trim(request.form("m_popedom"))
    if not joekoe_cms.int_true(m_popedom) then m_popedom=0
    if int(m_popedom)<0 or int(m_popedom)>max_pop then m_popedom=0
    m_nsort=code_admin("m_nsort",1,5)
    m_index_url=code_admin("m_index_url",1,20)
    m_data_name=code_admin("m_data_name",1,20)
    m_tit=code_admin("m_tit",1,20)
    m_tit_fir=code_admin("m_tit_fir",1,20)
    m_is_menu=0
    if trim(request.form("m_is_menu"))="yes" then m_is_menu=1
    m_mname=code_admin("m_mname",1,20)
    m_mtit=code_admin("m_mtit",1,20)
    m_mcolor=code_admin("m_mcolor",1,10)
    m_mb=0
    if trim(request.form("m_mb"))="yes" then m_mb=1
    m_mtarget=0
    if trim(request.form("m_mtarget"))="yes" then m_mtarget=1
    m_murl=code_admin("m_murl",1,200)
    if m_name="" or m_url="" then
      call admin_error("二级"&tit_fir&"的名称和链接地址不能为空！")
      exit sub
    end if
    if int(m_is_master)=1 then
      if m_nsort="" or m_index_url="" or m_data_name="" or m_tit="" or m_tit_fir="" then
        call admin_error("<font class=red>栏目管理参数</font>有一项或多项为空！")
        exit sub
      end if
      sql="select count(m_id) from "&data_name&" where m_id<>"&mid&" and ("
      if int(m_popedom)>0 then sql=sql&" m_popedom="&m_popedom&" or "
      sql=sql&"m_nsort='"&m_nsort&"' or m_index_url='"&m_index_url&"' or m_tit='"&m_tit&"' or m_tit_fir='"&m_tit_fir&"')"
      ' or m_data_name='"&m_data_name&"'
      set rs=conn.execute(sql)
      if int(rs(0))>0 then
        rs.close
        call admin_error("<font class=red>栏目管理参数</font>有一项或多项与其它栏目的设置重复！")
        exit sub
      end if
      rs.close
    end if
    sql="update "&data_name&" set m_name='"&m_name&"',m_url='"&m_url&"',m_hidden="&m_hidden&",m_is_master="&m_is_master&",m_is_nsort="&m_is_nsort&",m_is_review="&m_is_review&",m_popedom="&m_popedom&",m_nsort='"&m_nsort&"',m_index_url='"&m_index_url&"',m_data_name='"&m_data_name&"',m_tit='"&m_tit&"',m_tit_fir='"&m_tit_fir&"',m_is_menu="&m_is_menu&",m_mname='"&m_mname&"',m_mtit='"&m_mtit&"',m_mcolor='"&m_mcolor&"',m_mb="&m_mb&",m_mtarget="&m_mtarget&",m_murl='"&m_murl&"' where m_id="&mid
    call joekoe_cms.exec(sql,0)
    call admin_msg("成功修改了二级"&tit_fir&"："&m_name,"?action=edit",1)
    exit sub
  end if
  call form_first()
%>
<form name=menu_frm action='?action=edit_2&m_id=<%response.write mid%>' method=post>
<input type=hidden name=chk value='yes'>
<tr>
<td>主<%response.write tit_fir%>名称：</td>
<td class=blue><b><%response.write n_name%></b></td>
</tr>
<tr>
<td>二级<%response.write tit_fir%>名称：</td>
<td><input type=text name=m_name value='<%response.write m_name%>' size=15 maxlength=20><%response.write redx%></td>
</tr>
<tr>
<td><%response.write tit_fir%>链接地址：</td>
<td><input type=text name=m_url value='<%response.write m_url%>' size=30 maxlength=100><%response.write redx%>可以为本地或外部地址，建议只使用本地地址。</td>
</tr>
<tr>
<td>隐藏二级<%response.write tit_fir%>：</td>
<td><input type=checkbox name=m_hidden<%if m_hidden=false then response.write " checked"%> value='yes'<%if n_hidden=false then response.write " disabled"%>>&nbsp;选择表示隐藏二级<%response.write tit_fir%></td>
</tr>
<tr class=tr1>
<td class=red>栏目管理参数：</td>
<td><input type=checkbox name=m_is_master value='yes'<%if m_is_master then response.write " checked"%>><%response.write redx%>选择表示设置管理栏目的相关参数</td>
</tr>
<tr class=tr1>
<td class=gray>管理参数说明：</td>
<td><font class=red>如不选择则以下几项可不填</font>，填写时则<font class=red><b>任一项不可与其它栏目的设置重复</b></font>！</td>
</tr>
<tr class=tr1>
<td>栏目权限标识：</td>
<td><input type=text name=m_popedom value='<%response.write m_popedom%>' size=5 maxlength=5>&nbsp;与管理文件里的标识相对应；为大于-1小于51的整数，等于0时为不设权限。</td>
</tr>
<tr class=tr1>
<td>栏目类别代码：</td>
<td><input type=text name=m_nsort value='<%response.write m_nsort%>' size=10 maxlength=5>&nbsp;长度不能大于5，如文章管理可填：art，新闻管理可填：news</td>
</tr>
<tr class=tr1>
<td>栏目类别选项：</td>
<td><input type=checkbox name=m_is_nsort value='yes'<%if m_is_nsort then response.write " checked"%>>&nbsp;分类&nbsp;&nbsp;<input type=checkbox name=m_is_review value='yes'<%if m_is_review then response.write " checked"%>>&nbsp;评论&nbsp;&nbsp;&nbsp;（该栏目没有的可不选）</td>
</tr>
<tr class=tr1>
<td>栏目类别标识：</td>
<td><input type=text name=m_index_url value='<%response.write m_index_url%>' size=15 maxlength=20>&nbsp;完整的类别标识，一般与数据表名相同，如：article</td>
</tr>
<tr class=tr1>
<td>栏目数据表名：</td>
<td><input type=text name=m_data_name value='<%response.write m_data_name%>' size=15 maxlength=20>&nbsp;一般与类别标识相同，如：article</td>
</tr>
<tr class=tr1>
<td>栏目管理标题：</td>
<td><input type=text name=m_tit value='<%response.write m_tit%>' size=15 maxlength=20>&nbsp;如：文章管理</td>
</tr>
<tr class=tr1>
<td>栏目管理简称：</td>
<td><input type=text name=m_tit_fir value='<%response.write m_tit_fir%>' size=15 maxlength=20>&nbsp;如文章管理可填：文章</td>
</tr>
<tr>
<td class=red>前台菜单设置：</td>
<td><input type=checkbox name=m_is_menu value='yes'<%if m_is_menu then response.write " checked"%>>&nbsp;是否作为前台菜单，<font class=red><b>如要想让该项在前台有显示链接，请选择此项并填写相关信息</b></font></td>
</tr>
<tr>
<td>菜单显示名称：</td>
<td><input type=text name=m_mname value='<%response.write m_mname%>' size=20 maxlength=20>&nbsp;必填，如文章栏目可填：技术文栏</td>
</tr>
<tr>
<td>菜单名称显示：</td>
<td><input type=text name=m_mtit value='<%response.write m_mtit%>' size=20 maxlength=20>&nbsp;可选，对菜单的提示说明，如：<a href='javascript:;' alt='这个栏目是讲述有关电脑编程相关的技术文章' class=red>技术文栏</a>&nbsp;←鼠标移至此链接</td>
</tr>
<tr>
<td>菜单名称加色：</td>
<td><input type=text name=m_mcolor value='<%response.write m_mcolor%>' size=10 maxlength=20>&nbsp;可选，对菜单加色的颜色代码，如：<a href='javascript:;' onclick="javascript:document.all.menu_frm.m_mcolor.value='#ff3300';"><font color=#ff3300 alt='点击可将本颜色代码加入到此输入框中'>#ff3300</font></td>
</tr>
<tr>
<td>菜单名称加粗：</td>
<td><input type=checkbox name=m_mb value='yes'<%if m_mb then response.write " checked"%>>&nbsp;可选，是否对该菜单显示名称加粗，如：<b><a href='javascript:;' class=blue>技术文栏</a></b></td>
</tr>
<tr>
<td>新窗口显示：</td>
<td><input type=checkbox name=m_mtarget value='yes'<%if m_mtarget then response.write " checked"%>>&nbsp;可选，是否让该菜单链接在新窗口中显示，如：<a href='http://www.99shik.cn/' target=_blank class=red>新的窗口</a>&nbsp;←鼠标点击此链接</td>
</tr>
<tr>
<td>菜单链接地址：</td>
<td><input type=text name=m_murl value='<%response.write m_murl%>' size=65 maxlength=200>&nbsp;可选</td>
</tr>
<tr><td colspan=2><font class=gray>链接地址说明：</font>在这里可以填写<a alt='什么叫<font class=red><b>绝对地址</b></font>？<br>绝对地址指的是标准的URL地址，即是含有“http”等开头的地址；<br>如：<font class=blue>http://www.99shik.cn/new_menu.asp</font>' class=blue>绝对地址</a>和<a alt='什么叫<font class=red><b>相对地址</b></font>？<br>相对地址指的是相对网页当前的目录地址而相对应的地址；<br>如现在网页的地址为：<font class=blue>http://www.99shik.cn/</font>admins_menu.asp；<br>如果你填写了相对地址为：<font class=red>new_menu.asp</font>；<br>则该菜单的真实地址解释为：<font class=blue>http://www.99shik.cn/</font><font class=red>new_menu.asp</font>' class=blue>相对地址</a>，如果不填则表示按系统默认方式显示，即：<font class=red>“栏目类别标识”</font>.asp，如：<font class=red>article</font>.asp</td></tr>
<%
  call submit_edit()
end sub

sub joekoe_chk_add_2()
  dim m_name,m_url,m_sort,m_order,m_open,m_hidden,n_hidden,m_is_master,m_is_nsort,m_is_review,m_popedom,m_nsort,m_index_url,m_data_name,m_tit,m_tit_fir
  dim m_is_menu,m_morder,m_mname,m_mtit,m_mcolor,m_mb,m_mtarget,m_murl
  sql="select top 1 m_sort,m_name,m_open,m_hidden from "&data_name&" where m_id="&mid
  set rs=joekoe_cms.exec(sql,1)
  if rs.eof then
    rs.close
    call admin_msg("主"&tit_fir&"ID（"&mid&"）不存在！","?action=edit",1)
    exit sub
  end if
  m_sort=rs("m_sort")
  m_name=rs("m_name")
  m_open=1
  if rs("m_open")=false then m_open=0
  n_hidden=rs("m_hidden")
  rs.close
  call admin_td("添加二级"&tit_fir&"（"&m_name&"）")
  if chk() then
    m_name=code_admin("m_name",1,20)
    m_url=code_admin("m_url",1,100)
    m_hidden=1
    if trim(request.form("m_hidden"))="yes" then m_hidden=0
    if n_hidden=false then m_hidden=0
    m_is_master=0
    if trim(request.form("m_is_master"))="yes" then m_is_master=1
    m_is_nsort=0
    if trim(request.form("m_is_nsort"))="yes" then m_is_nsort=1
    m_is_review=0
    if trim(request.form("m_is_review"))="yes" then m_is_review=1
    m_popedom=trim(request.form("m_popedom"))
    if not joekoe_cms.int_true(m_popedom) then m_popedom=0
    if int(m_popedom)<0 or int(m_popedom)>max_pop then m_popedom=0
    m_nsort=code_admin("m_nsort",1,5)
    m_index_url=code_admin("m_index_url",1,20)
    m_data_name=code_admin("m_data_name",1,20)
    m_tit=code_admin("m_tit",1,20)
    m_tit_fir=code_admin("m_tit_fir",1,20)
    m_is_menu=0
    if trim(request.form("m_is_menu"))="yes" then m_is_menu=1
    m_mname=code_admin("m_mname",1,20)
    m_mtit=code_admin("m_mtit",1,20)
    m_mcolor=code_admin("m_mcolor",1,10)
    m_mb=0
    if trim(request.form("m_mb"))="yes" then m_mb=1
    m_mtarget=0
    if trim(request.form("m_mtarget"))="yes" then m_mtarget=1
    m_murl=code_admin("m_murl",1,200)
    if m_name="" or m_url="" then
      call admin_error("二级"&tit_fir&"的名称和链接地址不能为空！")
      exit sub
    end if
    if int(m_is_master)=1 then
      if m_nsort="" or m_index_url="" or m_data_name="" or m_tit="" or m_tit_fir="" then
        call admin_error("<font class=red>栏目管理参数</font>有一项或多项为空！")
        exit sub
      end if
      sql="select count(m_id) from "&data_name&" where "
      if int(m_popedom)>0 then sql=sql&"m_popedom="&m_popedom&" or "
      sql=sql&"m_nsort='"&m_nsort&"' or m_index_url='"&m_index_url&"' or m_tit='"&m_tit&"' or m_tit_fir='"&m_tit_fir&"'"
      ' or m_data_name='"&m_data_name&"'
      set rs=joekoe_cms.exec(sql,1)
      if int(rs(0))>0 then
        rs.close
        call admin_error("<font class=red>栏目管理参数</font>有一项或多项与其它栏目的设置重复！")
        exit sub
      end if
      rs.close
    end if
    m_order=1
    sql="select top 1 m_order from "&data_name&" where m_sort="&m_sort&" order by m_order desc"
    set rs=joekoe_cms.exec(sql,1)
    if not rs.eof then m_order=rs(0)+1
    rs.close
    m_morder=1
    sql="select top 1 m_morder from "&data_name&" where m_is_menu=1 order by m_morder desc"
    set rs=joekoe_cms.exec(sql,1)
    if not rs.eof then m_morder=rs(0)+1
    rs.close
    sql="insert into "&data_name&"(m_sort,m_name,m_url,m_order,m_open,m_hidden,m_is_master,m_is_nsort,m_is_review,m_popedom,m_nsort,m_index_url,m_data_name,m_tit,m_tit_fir,m_is_menu,m_morder,m_mname,m_mtit,m_mcolor,m_mb,m_mtarget,m_murl) " & _
	"values("&m_sort&",'"&m_name&"','"&m_url&"',"&m_order&","&m_open&","&m_hidden&","&m_is_master&","&m_is_nsort&","&m_is_review&","&m_popedom&",'"&m_nsort&"','"&m_index_url&"','"&m_data_name&"','"&m_tit&"','"&m_tit_fir&"',"&m_is_menu&","&m_morder&",'"&m_mname&"','"&m_mtit&"','"&m_mcolor&"',"&m_mb&","&m_mtarget&",'"&m_murl&"')"
    call joekoe_cms.exec(sql,0)
    call admin_msg("成功添加一项新的二级"&tit_fir&"："&m_name,"?action=edit",1)
    exit sub
  end if
  call form_first()
%>
<form name=menu_frm action='?action=add_2&m_id=<%response.write mid%>' method=post>
<input type=hidden name=chk value='yes'>
<tr>
<td>主<%response.write tit_fir%>名称：</td>
<td class=blue><b><%response.write m_name%></b></td>
</tr>
<tr>
<td>二级<%response.write tit_fir%>名称：</td>
<td><input type=text name=m_name size=15 maxlength=20><%response.write redx%></td>
</tr>
<tr>
<td><%response.write tit_fir%>链接地址：</td>
<td><input type=text name=m_url size=30 maxlength=100><%response.write redx%></td>
</tr>
<tr>
<td>隐藏二级<%response.write tit_fir%>：</td>
<td><input type=checkbox name=m_hidden value='yes'>&nbsp;选择表示隐藏二级<%response.write tit_fir%></td>
</tr>
<tr>
<td class=red>栏目管理参数：</td>
<td><input type=checkbox name=m_is_master value='yes'><%response.write redx%>选择表示设置管理栏目的相关参数</td>
</tr>
<tr class=tr1>
<td class=gray>管理参数说明：</td>
<td><font class=red>如不选择则以下几项可不填</font>，填写时则<font class=red><b>任一项不可与其它栏目的设置重复</b></font>！</td>
</tr>
<tr class=tr1>
<td>栏目权限标识：</td>
<td><input type=text name=m_popedom value='0' size=5 maxlength=5>&nbsp;与管理文件里的标识相对应；为大于-1小于51的整数，等于0时为不设权限。</td>
</tr>
<tr class=tr1>
<td>栏目类别代码：</td>
<td><input type=text name=m_nsort size=10 maxlength=5>&nbsp;长度不能大于5，如文章管理可填：art，新闻管理可填：news</td>
</tr>
<tr class=tr1>
<td>栏目类别选项：</td>
<td><input type=checkbox name=m_is_nsort value='yes'>&nbsp;分类&nbsp;&nbsp;<input type=checkbox name=m_is_review value='yes'>&nbsp;评论&nbsp;&nbsp;&nbsp;（该栏目没有的可不选）</td>
</tr>
<tr class=tr1>
<td>栏目类别标识：</td>
<td><input type=text name=m_index_url size=15 maxlength=20>&nbsp;完整的类别标识，一般与数据表名相同，如：article</td>
</tr>
<tr class=tr1>
<td>栏目数据表名：</td>
<td><input type=text name=m_data_name size=15 maxlength=20>&nbsp;一般与类别标识相同，如：article</td>
</tr>
<tr class=tr1>
<td>栏目管理标题：</td>
<td><input type=text name=m_tit size=15 maxlength=20>&nbsp;如：文章管理</td>
</tr>
<tr class=tr1>
<td>栏目管理简称：</td>
<td><input type=text name=m_tit_fir size=15 maxlength=20>&nbsp;如文章管理可填：文章</td>
</tr>
<tr>
<td class=red>前台菜单设置：</td>
<td><input type=checkbox name=m_is_menu value='yes'>&nbsp;是否作为前台菜单，<font class=red><b>如要想让该项在前台有显示链接，请选择此项并填写相关信息</b></font></td>
</tr>
<tr>
<td>菜单显示名称：</td>
<td><input type=text name=m_mname value='' size=20 maxlength=20>&nbsp;必填，如文章栏目可填：技术文栏</td>
</tr>
<tr>
<td>菜单名称显示：</td>
<td><input type=text name=m_mtit value='' size=20 maxlength=20>&nbsp;可选，对菜单的提示说明，如：<a href='javascript:;' alt='这个栏目是讲述有关电脑编程相关的技术文章' class=red>技术文栏</a>&nbsp;←鼠标移至此链接</td>
</tr>
<tr>
<td>菜单名称加色：</td>
<td><input type=text name=m_mcolor value='' size=10 maxlength=20>&nbsp;可选，对菜单加色的颜色代码，如：<a href='javascript:;' onclick="javascript:document.all.menu_frm.m_mcolor.value='#ff3300';"><font color=#ff3300 alt='点击可将本颜色代码加入到此输入框中'>#ff3300</font></td>
</tr>
<tr>
<td>菜单名称加粗：</td>
<td><input type=checkbox name=m_mb value='yes'>&nbsp;可选，是否对该菜单显示名称加粗，如：<b><a href='javascript:;' class=blue>技术文栏</a></b></td>
</tr>
<tr>
<td>新窗口显示：</td>
<td><input type=checkbox name=m_mtarget value='yes'>&nbsp;可选，是否让该菜单链接在新窗口中显示，如：<a href='http://www.joekoe.com/' target=_blank class=red>新的窗口</a>&nbsp;←鼠标点击此链接</td>
</tr>
<tr>
<td>菜单链接地址：</td>
<td><input type=text name=m_murl value='' size=65 maxlength=200>&nbsp;可选</td>
</tr>
<tr><td colspan=2><font class=gray>链接地址说明：</font>在这里可以填写<a alt='什么叫<font class=red><b>绝对地址</b></font>？<br>绝对地址指的是标准的URL地址，即是含有“http”等开头的地址；<br>如：<font class=blue>http://www.99shik.cn/</font>' class=blue>绝对地址</a>和<a alt='什么叫<font class=red><b>相对地址</b></font>？<br>相对地址指的是相对网页当前的目录地址而相对应的地址；<br>如现在网页的地址为：<font class=blue>http://www.99shik.cn/</font>admins_menu.asp；<br>如果你填写了相对地址为：<font class=red>new_menu.asp</font>；<br>则该菜单的真实地址解释为：<font class=blue>http://www.99shik.cn/</font><font class=red>new_menu.asp</font>' class=blue>相对地址</a>，如果不填则表示按系统默认方式显示，即：<font class=red>“栏目类别标识”</font>.asp，如：<font class=red>article</font>.asp</td></tr>
<%
  call submit_add()
end sub

sub joekoe_chk_edit_1()
  dim m_sort,m_name,m_open,m_hidden,n_open,n_hidden
  sql="select top 1 m_sort,m_name,m_open,m_hidden from "&data_name&" where m_id="&mid
  set rs=joekoe_cms.exec(sql,1)
  if rs.eof then
    rs.close
    call admin_msg("主"&tit_fir&"ID（"&mid&"）不存在！","?action=edit",1)
    exit sub
  end if
  m_sort=rs("m_sort")
  m_name=rs("m_name")
  n_open=rs("m_open")
  n_hidden=rs("m_hidden")
  rs.close
  call admin_td("修改主"&tit_fir&"（"&m_name&"）")
  if chk() then
    m_name=code_admin("m_name",1,20)
    m_open=0
    if trim(request.form("m_open"))="yes" then m_open=1
    m_hidden=1
    if trim(request.form("m_hidden"))="yes" then m_hidden=0
    if m_name="" then
      call admin_error("主"&tit_fir&"的名称不能为空！")
      exit sub
    end if
    sql="update "&data_name&" set m_name='"&m_name&"',m_open="&m_open&",m_hidden="&m_hidden&" where m_id="&mid
    call joekoe_cms.exec(sql,0)
    sql="update "&data_name&" set m_hidden="&m_hidden&" where m_sort="&m_sort
    call joekoe_cms.exec(sql,0)
    call admin_msg("成功修改了主"&tit_fir&"："&m_name,"?action=edit",1)
    exit sub
  end if
  call form_first()
%>
<form action='?action=edit_1&m_id=<%response.write mid%>' method=post>
<input type=hidden name=chk value='yes'>
<tr>
<td>主<%response.write tit_fir%>名称：</td>
<td><input type=text name=m_name value='<%response.write m_name%>' size=20 maxlength=20><%response.write redx%></td>
</tr>
<tr>
<td>展开管理<%response.write tit_fir%>：</td>
<td><input type=checkbox name=m_open<%if n_open=true then response.write " checked"%> value='yes'>&nbsp;选择表示展开主<%response.write tit_fir%></td>
</tr>
<tr>
<td>隐藏管理菜单：</td>
<td><input type=checkbox name=m_hidden<%if n_hidden=false then response.write " checked"%> value='yes'>&nbsp;选择表示隐藏主<%response.write tit_fir%></td>
</tr>
<%
  call submit_edit()
end sub

sub joekoe_chk_add_1()
  call admin_td("添加新的主"&tit_fir)
  dim m_name,m_sort,m_open,m_hidden
  if chk() then
    m_name=code_admin("m_name",1,20)
    m_open=0
    if trim(request.form("m_open"))="yes" then m_open=1
    m_hidden=1
    if trim(request.form("m_hidden"))="yes" then m_hidden=0
    if m_name="" then
      call admin_error("主"&tit_fir&"的名称不能为空！")
      exit sub
    end if
    m_sort=0
    sql="select top 1 m_sort from "&data_name&" order by m_sort desc"
    set rs=joekoe_cms.exec(sql,1)
    if not(rs.eof) then m_sort=rs(0)+1
    rs.close
    sql="insert into "&data_name&"(m_sort,m_name,m_url,m_order,m_open,m_hidden,m_is_master,m_is_nsort,m_is_review,m_popedom,m_nsort,m_index_url,m_data_name,m_tit,m_tit_fir,m_is_menu,m_morder,m_mname,m_mtit,m_mcolor,m_mb,m_mtarget,m_murl) " & _
	"values("&m_sort&",'"&m_name&"','',0,"&m_open&","&m_hidden&",0,0,0,0,'','','','','',0,0,'','','',0,0,'')"
    call joekoe_cms.exec(sql,0)
    call admin_msg("成功添加一项新的主"&tit_fir&"："&m_name,"?action=edit",1)
    exit sub
  end if
  call form_first()
%>
<form action='?action=add_1' method=post>
<input type=hidden name=chk value='yes'>
<tr>
<td>主<%response.write tit_fir%>名称：</td>
<td><input type=text name=m_name size=20 maxlength=20><%response.write redx%></td>
</tr>
<tr>
<td>展开主<%response.write tit_fir%>：</td>
<td><input type=checkbox name=m_open checked value='yes'>&nbsp;选择表示展开主<%response.write tit_fir%></td>
</tr>
<tr>
<td>隐藏主<%response.write tit_fir%>：</td>
<td><input type=checkbox name=m_hidden value='yes'>&nbsp;选择表示隐藏主<%response.write tit_fir%></td>
</tr>
<%
  call submit_add()
end sub
%>