<!-- #Include File="Include/AMH_Onlogin.asp" -->
<%
'=======================================================
' 欢迎使用《阿赛大型门户网站系统V2.0》，简称“AsaiMHV2”
' 技术支持、商业版咨询、官方唯一指定联系QQ“4941172”
' 官方网站：http://77ya.com      程序负责人：阿赛
'=======================================================

Dim t_id, T_Name, TemplateType
Dim iSkinDir, iSkinCss, iSkinStr, IsDefault ,iskinsid, iSkinID, iSkinCID, iTemplateConfig
Dim WholeStr, iWhole
Dim t_main, TemplateIndexs,  T_Config, TemplateConfig, skintype, skinstr
t_id = Cls.Code_ID("t_id")
TemplateType = Cls.Code_ID("Type")
skintype = Cls.Code_ID("skintype")
if skintype=0 then
   skinstr=" and t_sid=0 "
else
   skinstr=" and t_sid>0 "
end if
'--- 模板数据库地址，可手工编辑地址
Dim TemplateDatePath
	TemplateDatePath = Cls.Web_Dir&"Skin/Template.mdb"
Admins = True
Index_Url = "AsaiMHTemplate"
Data_Name = "AsaiMHTemplate"
tit_fir="模板"
tit="全局"&Tit_Fir
PageUrl = "?Action="&Action&"&skintype="&skintype&"&ChannelIDs="&iChannelIDs&"&t_id="&t_id&"&Type="
Call AMH_Header(1)
%>
<tr><td align=center colspan=2 height=30>
  <table border=0>
  <tr>
  <td><a href='?ChannelIDs=0&skintype=0'<%If skintype=0  Then Response.Write " class=red"%>><b>界面风格</b></a></td>
  <td width=15></td>
<%
	Dim iListStr, Lii
	iListStr = Cls.Channel_Menu
	For Lii =0 To Ubound(iListStr,2)
	If Int(iListStr(8,Lii)) <> 2 And Not Cbool(iListStr(7,Lii)) Then
			Response.Write "<td><a href='?ChannelIDs="&Int(iListStr(0,Lii))&"&skintype=1'"
			tit=iListStr(13,Lii)
			If Int(iChannelIDs) = Int(iListStr(0,Lii)) Then
				Response.Write " class=red"
			End If
			Response.Write ">"&tit&"</a></td>"
			Response.Write "<td width=5></td>"
		End If
	Next
	Erase iListStr
%>
<td><a href='?ChannelIDs=0&skintype=1'<%If skintype=1 and  iChannelIDs=0 Then Response.Write " class=red"%>>其它</a></td>
  </tr>
  </table>
</td></tr>
<%
Call AMH_Table(1)
Select Case LCase(Action)
Case "add"
	AsaiMHTemplate_Add()
Case "edit"
	AsaiMHTemplate_Edit()
Case "copy"
	AsaiMHTemplate_Copy()
Case "export"
	AsaiMHTemplate_Export()
Case "import"
	AsaiMHTemplate_Import()
Case "del"
	AsaiMHTemplate_Delete()
Case "set"
	AsaiMHTemplate_SetDefault()
Case Else
	AsaiMHTemplate_Main()
End Select
Call AMH_Ender(tit)
Sub AsaiMHTemplate_Main()
%>
  <form action='?Action=Export&ChannelIDs=<%=iChannelIDs%>' method=post>
  <tr align=center>
  <td class=td width='5%'><input type=checkbox name=sel_all value='yes' onclick="javascript:select_all(this.form);" class=td></td>
  <td class=td width='5%'>ID</td>
  <td class=td width='20%'><%=tit_fir%>名称</td>
  <td class=td width='20%'>
  <%
  if skintype=0 then 
  response.write "图片目录"
  else
  response.write "界面方案"
  end if
  %>
  </td>
  <td class=td width='10%'>类型</td>
  <td class=td width='40%'>相关属性</td>
  </tr>
<% 
	SQL = "Select * From ["&Data_Name&"] Where t_cid="&iChannelIDs& skinstr&" Order By t_id"
	Set Rs = Cls.Exec(SQL,1)
	Do While Not Rs.eof
		t_id = Rs("t_id")
		T_Name = Rs("t_name")
%>
  <tr align=center>
  <td><input type=checkbox name=sel_id value='<%Response.Write t_id%>'></td>
  <td class=tims><%Response.Write t_id%></td>
  <td><a href='?Action=Edit&t_id=<%Response.Write t_id%>&skintype=<%=skintype%>&ChannelIDs=<%=iChannelIDs%>'><%Response.Write Cls.Code_Html(T_Name,1,(22+tnum))%></a></td>
  <td class=blue>
    <%
  if skintype=0 then 
  response.write Cls.Web_Dir&"Skin/"&Rs("t_Dir")&"/"
  else
  response.write Rs("t_sid")
  end if
  %>
 </td>
  <td>
    <%
  if skintype=0 then 
  response.write "界面方案"
  else
  response.write "频道模板"
  end if
  %>
 </td>
  <td>
  <%If Rs("IsDefault")=false Then%><a href='?Action=Set&skintype=<%=skintype%>&t_id=<%Response.Write t_id%>&ChannelIDs=<%=iChannelIDs%>' onclick="return click_return(' (<%Response.Write T_Name%>) 设为默认<%=tit_fir%>',0);">默 认</a><%Else%><font class=Gys>默 认</font><%End If%>&nbsp;&nbsp;
  <%If Rs("IsDefault")=True Then%><font class=Gys>删 除</font><%Else%><a href='?Action=Del&skintype=<%=skintype%>&t_id=<%Response.Write t_id%>&ChannelIDs=<%=iChannelIDs%>' onclick="return click_return('删除 (<%Response.Write T_Name%>) ',0);">删 除</a><%End If%>&nbsp;&nbsp;
  <a href='?Action=Copy&skintype=<%=skintype%>&t_id=<%Response.Write t_id%>&ChannelIDs=<%=iChannelIDs%>'>复 制</a>&nbsp;&nbsp;
  </td>
  </tr>
<%
		Rs.MoveNext
	Loop
	Rs.Close
%>
  <tr class=tr1>
  <td colspan=4 height=40 align=center>
    <table border=0>
    <tr class=tr1>
    <td>目标数据库：</td>
    <td><input type=text name=SkinPath value='<%=TemplateDatePath%>' size=20></td>
    <td><input type=checkbox name=eType value='yes' class=tr1>&nbsp;删除目标数据&nbsp;</td>
    <td><input type=submit value='导出' onclick="return sel_click(this.form);" class=btn></td>
    </tr>
    </table>
  </td>
  </form>
  <td align=center  colspan=2>
    <table border=0>
    <form action='?Action=Import&ChannelIDs=<%=iChannelIDs%>' method=post>
    <tr class=tr1>
    <td>来源数据库：</td>
    <td><input type=text name=SkinPath value='<%=TemplateDatePath%>' size=20></td>
    <td><input type=submit value='导入' onclick="javascript:return click_return('导入外部<%Response.Write tit_fir%>数据库',0);" class=btn></td>
    </tr>
    </form>
    </table>
  </td></tr>
<%
End Sub
'//编辑模板
Sub AsaiMHTemplate_Edit()
	SQL = "Select Top 1 * From ["&Data_Name&"] Where t_cid="&iChannelIDs &" And t_id="&t_id
	Call Cls.Exe_Conn(Rs,SQL,3)
	If Rs.Eof Then
		Call AMH_Msg("要进行编辑的"&tit_fir&"（ID："&t_id&"）不存在！","?ChannelIDs="&iChannelIDs&"&skintype="&skintype,1)
		Exit Sub
	End If
	T_Name = Rs("t_Name")
	iSkinCss = Rs("t_Css")
	iSkinDir = Rs("t_Dir")
	iSkinID = Rs("t_sid")
        iSkinCID = Rs("t_cid")
	T_Main = Rs("T_Main")
	T_Config = Rs("T_Config")
	IsDefault = Rs("IsDefault")
	Rs.Close
	Call AMH_Td("编辑"&tit_fir&"("&T_Name&")")
%>
<tr align=center>
<td width='20%'><font class=blue><b><%Response.Write T_Name%></b></font></td>
<td width='80%' align=left>
  <table border=0>
  <tr>
  <td width=180>
  <% if iSkinID>0 then%>
  <a href='<%Response.Write pageurl%>0'<%if TemplateType<>1 then Response.Write " class=red"%>>模板编辑</a>
  &nbsp;&nbsp;<a href='<%Response.Write pageurl%>1'<%if TemplateType=1 then Response.Write " class=red"%>>常规配置</a>
  &nbsp;&nbsp;<a  href='?Action=Edit&t_id=<%Response.Write iSkinID%>&skintype=0&ChannelIDs=0'>界面方案</a>
  <%end if%>
  </td><td width=100></td>
   <td><b>使用标签：</b>[<a href="javascript:;" onclick="open_win('AMH_Label.asp','选择标签','550','500','yes')" class="red2">常用标签</a>]&nbsp;
   [<a href="javascript:;" onclick="open_win('AMH_Label.asp?action=list&channelIDs=<%=iSkinCID%>','选择标签','550','480','no')" class="red2">文字列表</a>]&nbsp;
   [<a href="javascript:;" onclick="open_win('AMH_Label.asp?action=image&channelIDs=<%=iSkinCID%>','选择标签','550','460','no')" class="red2">图片标签</a>]
  </td>
  </tr>
  </table>
</td>
</tr>
<% 
    If iSkinID=0  then  TemplateType=1
		Call AsaiMHTemplate_Edit_Main()
End Sub
'//* 模板字符串、分页编辑 *//
Sub AsaiMHTemplate_Edit_Main()
	Dim mystr,rnum
	Dim AllStr,AllNum,Qstr
	Dim HelpStr,NameStr,HtmlStr,TypeStr,LenStr,OtherStr
	Dim FieldStr
	Select Case TemplateType
	Case 1
		AllStr=T_Config
		FieldStr="T_Config"
		mystr="常规配置"
		rnum=0
		If skintype=0 Then rnum=0
	Case Else
		AllStr=T_Main
		FieldStr="T_Main"
		mystr="模板编辑"
		rnum=0
	End Select
	If Chk() Then
	    If TemplateType=1 then
		T_Name = Cls.Code_Admin("T_Name",1,20)
		iSkinDir = Replace(Cls.Code_Admin("SkinDir",1,20),"|||","")
		iSkinCss = Replace(Cls.Code_Remark("SkinCss"),"|||","")
		iSkinID = Cls.Code_Int("iSkinID",0)
		If T_Name="" Then
			Call AMH_Error(tit_fir&"名称请填写完整！")
			Exit Sub
		End If
		If iSkinID=0 And (iSkinCss="" or iSkinDir="") Then
			Call AMH_Error(tit_fir&"路径，CSS 内容请填写完整！")
			Exit Sub
		End If
		SQL="Select * From ["&Data_Name&"] Where t_cid="&iChannelIDs&" And t_id="&t_id
		Call Cls.Exe_Conn(Rs,SQL,3)
			Rs("T_Name")	= T_Name
			Rs("t_Dir")	= iSkinDir
			Rs("t_Css")	= iSkinCss
			Rs("t_sid") = iSkinID
		Rs.Update
		Rs.Close
		If iSkinID=0 Then
			iSkinDir=Cls.Web_Dir&"Skin/"&iSkinDir&"/"
            Dim TmpCls
			Set TmpCls = New Cls_FileSystem
			  Call TmpCls.Make_Dir(iSkinDir)
			  iSkinCss=Replace(iSkinCss,"{$skin_dir}",iSkinDir)
			  Call TmpCls.Create_File(Cls.Web_Dir&"Skin/Template_"&t_id&".css",iSkinCss)		 
			  Set TmpCls = Nothing
		End If
		End if
		Dim HelpNum,NameNum,HtmlNum,TypeNum,LenNum
		HtmlStr=AMH_Str("HtmlStr",0)
		NameStr=AMH_Str("NameStr",0)
		HelpStr=AMH_Str("HelpStr",0)
		TypeStr=AMH_Str("TypeStr",1)
		LenStr=AMH_Str("LenStr",1)
		HelpNum=Ubound(Split(HelpStr,"|||"))
		NameNum=Ubound(Split(NameStr,"|||"))
		HtmlNum=Ubound(Split(HtmlStr,"|||"))
		TypeNum=Ubound(Split(TypeStr,"|||"))
		LenNum=Ubound(Split(LenStr,"|||"))
		If HtmlNum<>NameNum or HtmlNum<>HelpNum or HtmlNum<>TypeNum or HtmlNum<>LenNum  Then
			Call AMH_Error("提交错误，各项内容填写完整，请勿随意留空！")
			Exit Sub
		End If
		Qstr=HtmlStr & "@@@" & NameStr & "@@@" & HelpStr & "###"& TypeStr &"###"& LenStr
		SQL="Select * From ["&Data_Name&"] Where t_cid="&iChannelIDs&" And t_id="&t_id
		Call Cls.Exe_Conn(Rs,SQL,3)
			Rs(FieldStr) = Qstr
		Rs.Update
		Rs.Close
		TemplateCacheDel()
		Call AMH_Msg("已成功编辑了"&tit_fir&"（"&T_Name&"）的 "&mystr&" 信息！",PageUrl&TemplateType,1)
		Exit Sub
	End If
	If Cls.Is_Null(AllStr) = "" Then AllStr = "|||@@@|||@@@|||###|||###|||"
	AllStr=Split(AllStr,"@@@")
	HtmlStr=Split(AllStr(0),"|||")
	NameStr=Split(AllStr(1),"|||")
	OtherStr=Split(AllStr(2),"###")
	'HelpStr=Split(AllStr(2),"|||")
	HelpStr=Split(OtherStr(0),"|||")
	TypeStr=Split(OtherStr(1),"|||")
	LenStr=Split(OtherStr(2),"|||")
	AllNum=Ubound(HtmlStr)
	Call Form_First()
%>
   <form name=frm_edit action='<%Response.Write PageUrl&TemplateType%>' method=post>
  <input type=hidden name=chk value='yes'>
  <%if TemplateType=1 then%>
  <tr class=tr1>
  <td width='20%'><%Response.Write tit_fir%>名称：</td>
  <td width='80%'><input type=text name=T_Name value='<%=Cls.Code_Html(T_Name,1,0)%>' size=20 maxlength=20>&nbsp;&nbsp;<%=Redx%>&nbsp;&nbsp;最多20个字符</td>
 </tr>
 <% if  iSkinID=0 then%>
  <tr >
  <td>风格目录：</td>
  <td><input type=text name=SkinDir value='<%=iSkinDir%>' size=20 maxlength=20>&nbsp;&nbsp;<font class=red>请勿随意修改</font></td>
  </tr>
  <%else%>
    <tr >
  <td>界面方案：</td>
  <td><select name="iSkinID">
  <% 
    dim skrs,skSQL
    skSQL = "Select t_id,t_name  From ["&Data_Name&"] Where t_sid=0"
	set skrs=Cls.Exec(sksql,1)
	do while not skrs.eof
	response.Write "<option value='"&skrs(0)&"'"
	if iSkinID=skrs(0) then response.Write " selected "
	response.Write ">"&skrs(1)&"</option>"
	skrs.movenext
	loop
	skrs.Close
   %>
  </select>
  &nbsp;&nbsp;<font class=red>请选择所属界面方案</font></td>
  </tr>
  <%end if%>
  <tr valign=top>
  <td>CSS样式：<br /><br />可以设置频道独立样式</td>
  <td><%Call AMH_ReSize("SkinCss",105,10,Cls.Code_Word(iSkinCss),-1)%></td>
  </tr>
  <tr valign=top>
  <td class=td colspan=2>自定义变量</td>
  </tr>
  <%end if%>
<SCRIPT LANGUAGE="JavaScript">
<!--
function deldata(n){
	if (document.frm_edit.delall[n].checked==true){
	document.frm_edit.NameStr[n].disabled = true;
	document.frm_edit.HelpStr[n].disabled = true;
	document.frm_edit.HtmlStr[n].disabled = true;
	document.frm_edit.TypeStr[n].disabled = true;
	document.frm_edit.LenStr[n].disabled = true;
	}else{
	document.frm_edit.NameStr[n].disabled = false;
	document.frm_edit.HelpStr[n].disabled = false;
	document.frm_edit.HtmlStr[n].disabled = false;
    document.frm_edit.TypeStr[n].disabled = false;
	document.frm_edit.LenStr[n].disabled = false;
	}
}
function editdata(n){
	if (document.frm_edit.edits[n].checked==true){	
	eval("et"+n+".style.display='';");
	}else{
	eval("et"+n+".style.display='none';");
	}
}
function chknew(n){
	if (document.frm_edit.newtps.checked==true){	
	    newtp.style.display='';
		document.frm_edit.edits[n].checked=true		
		document.frm_edit.NameStr[n].disabled = false;
	    document.frm_edit.HelpStr[n].disabled = false;
	    document.frm_edit.HtmlStr[n].disabled = false;
        document.frm_edit.TypeStr[n].disabled = false;
	    document.frm_edit.LenStr[n].disabled = false;
		eval("et"+n+".style.display='';");
	}else{
	    newtp.style.display='none';
		document.frm_edit.edits[n].checked=false
		document.frm_edit.NameStr[n].disabled = true;
	    document.frm_edit.HelpStr[n].disabled = true;
	    document.frm_edit.HtmlStr[n].disabled = true;
	    document.frm_edit.TypeStr[n].disabled = true;
	    document.frm_edit.LenStr[n].disabled = true;		
		eval("et"+n+".style.display='none';");
	}
}
//-->
</SCRIPT>
  <tr class=tr1 align=center>
  <td class=Gys>序 列</td>
  <td class=Gys width=*>操 作</td></tr>
<%
  For i=0 To AllNum
  if TypeStr(i)="" then TypeStr(i)="1"
  if LenStr(i)="" then LenStr(i)="15"
  if i = AllNum then
  %>
<tr class=tr1><td colspan=2 class=red><input type=checkbox name=newtps onclick="chknew(<%=i%>)"><b>添加新的模板</b>（每一项都要填写完整）</td></tr>
<tr id=newtp style="display:none"><td> 
<b>新增内容：</b>
</td>
<td align=left>
<%
  else
%>
<tr><td> 
调用：<b><%Response.Write i%></b>&nbsp;|&nbsp;<%Response.Write NameStr(i)%><br />
说明：<%Response.Write HelpStr(i)%>
</td>
<td align=left>
<%
  end if
	If TypeStr(i)="0" Then
'Response.Write "<input type=text name=HtmlStr id=tp"&i&" size="&LenStr(i)&" value='"&Cls.Code_Word(HtmlStr(i))&"'>&nbsp;&nbsp;<img src='images/viewpic.gif' onclick=runscript(tp"&i&")  align=absmiddle border=0><br />"

Response.Write "<input type=text name=HtmlStr id=tp"&i&" size="&LenStr(i)&" value='"&Cls.Code_Word(HtmlStr(i))&"'><br />"

	Else
		   Call AMH_Resize("HtmlStr",120,LenStr(i),Cls.code_word(HtmlStr(i)),i)
	End If
%>
 <input type=checkbox name=delall onclick="deldata(<%=i%>)"<%if i=AllNum or i<rnum then Response.Write " disabled"%>> 删除此项
 &nbsp;&nbsp;&nbsp;&nbsp;<input type=checkbox name=edits onclick="editdata(<%=i%>)"> 显示属性</td></tr>
<tr id=et<%=i%>   style="display:none"><td class=tr1 colspan=2>
标 签：<input type=text name=NameStr id=n<%=i%> size=12 maxlength=20 value="<%Response.Write NameStr(i)%>"<%if i<rnum then Response.Write " readonly"%>>&nbsp;&nbsp;说 明：<input type=text name=HelpStr id=h<%=i%> size=35 maxlength=100 value="<%Response.Write HelpStr(i)%>"<%if i<rnum then Response.Write " readonly"%>>
&nbsp;&nbsp;类 型：<select name=TypeStr id=t<%=i%>>
<option value=0 <%If TypeStr(i)="1"  then Response.Write " Selected"%>>文本行</option>
<option value=1 <%If TypeStr(i)<>"0" then Response.Write " Selected"%>>文本框</option>
</Select>&nbsp;&nbsp;长/高：<input type=text name=LenStr id=l<%=i%> size=5  value="<%Response.Write LenStr(i)%>">
</td></tr>
<%
	Next
%>
<SCRIPT LANGUAGE="JavaScript">
<!--
   	    document.frm_edit.NameStr[<%=AllNum%>].disabled = true;
	    document.frm_edit.HelpStr[<%=AllNum%>].disabled = true;
	    document.frm_edit.HtmlStr[<%=AllNum%>].disabled = true;
	    document.frm_edit.TypeStr[<%=AllNum%>].disabled = true;
	    document.frm_edit.LenStr[<%=AllNum%>].disabled = true;
//-->
</SCRIPT>
<%
	Erase AllStr
	Erase HtmlStr
	Erase NameStr
	Erase HelpStr
	Call Submit_Edit()
End Sub
'//* 复制模板 *//
Sub AsaiMHTemplate_Copy()
	Dim nT_Name,nSkinID ,oChannelIDs, nChannelIDs
	SQL = "Select Top 1 * From ["&Data_Name&"] Where t_id="&t_id
	Call Cls.Exe_Conn(Rs,SQL,3)
	If Rs.Eof Then
		Call AMH_Msg("要进行编辑的"&tit_fir&"（ID："&t_id&"）不存在！","?ChannelIDs="&iChannelIDs&"&skintype="&skintype,1)
		Exit Sub
	End If
	T_Name = Rs("T_name")
	iSkinDir = Rs("t_dir")
	iSkinCss = Rs("t_css")
	iSkinID = Rs("t_sid")	
	oChannelIDs = Rs("t_cid")
	T_Main = Rs("T_Main")
	T_Config = Rs("T_Config")
	Rs.Close
	Call AMH_Td("复制"&T_Name)
	If Chk() Then
		nT_Name = Cls.Code_Admin("T_Name",1,20)
		nChannelIDs = Cls.Code_Int("ChannelIDs",0)
		nSkinID = Cls.Code_Int("nSkinID",0)
		If nT_Name = "" Then
			Call AMH_Error("请输入新的模板名称！")
			Exit Sub
		End If
		SQL="Select * From "&Data_Name
		Call Cls.Exe_Conn(Rs,SQL,3)
		Rs.AddNew
			Rs("t_cid")	= nChannelIDs
			Rs("t_name")	= nT_Name
			Rs("t_dir")	= iSkinDir
			Rs("t_Css") = iSkinCss
			Rs("t_sid") = nSkinID 
			Rs("t_main")	= t_main
			Rs("T_Config")	= T_Config
            Rs("IsDefault")	= False
		Rs.Update
		Rs.Close
		TemplateCacheDel()
		Call AMH_Msg("已成功复制了（"&T_Name&"）到（"&nT_Name&"）！","?ChannelIDs="&nChannelIDs&"&skintype="&skintype,1)
		Exit Sub
	End If
	Call Form_First()
%>
  <form action='?Action=Copy&skintype=<%=skintype%>&ChannelIDs=<%=iChannelIDs%>&t_id=<%=t_id%>' method=post>
  <input type=hidden name=chk value='yes'>
  <tr class=tr1>
  <td width='20%'>原<%Response.Write tit_fir%>名称：</td>
  <td width='80%' class=blue><%=Cls.Code_Html(T_Name,1,0)%></td>
  </tr>
  <tr>
  <td width='20%'>更改名称：</td>
  <td width='80%'><input type=text name=T_Name value='' size=20 maxlength=20>&nbsp;&nbsp;<%=Redx%>&nbsp;&nbsp;最多20个字符</td>
  </tr>
  <%if iSkinID <> 0 then%>
  <tr class=tr1>
  <td>原属频道：</td>
  <td><%=Cls.Get_ChannelRes(iChannelIDs,1)%></td>
  </tr>
  <tr>
  <td>现属频道：</td>
  <td><%=Get_CopyChannelList("ChannelIDs",iChannelIDs,1)%>&nbsp;&nbsp;<font class=red>请注意每个频道的模板设置都不一样，请慎重选择同类型的频道。</font></td>
  </tr>
      <tr >
  <td>界面方案：</td>
  <td><select name="nSkinID">
  <% 
    dim skrs,skSQL
    skSQL = "Select t_id,t_name  From ["&Data_Name&"] Where t_sid=0"
	set skrs=Cls.Exec(sksql,1)
	do while not skrs.eof
	response.Write "<option value='"&skrs(0)&"'"
	if iSkinID=skrs(0) then response.Write " selected "
	response.Write ">"&skrs(1)&"</option>"
	skrs.movenext
	loop
	skrs.Close
   %>
  </select>
  &nbsp;&nbsp;<font class=red>请选择所属界面方案</font></td>
  </tr>
  <%end if%>
<%
	Call Submit_Edit()
End Sub
'//* 删除模板 *//
Sub AsaiMHTemplate_Delete()
	Dim IsDefault
	SQL = "Select Top 1 T_Name,IsDefault From ["&Data_Name&"] Where t_cid="&iChannelIDs&" And t_id="&t_id
	Call Cls.Exe_Conn(Rs,SQL,3)
	If Rs.Eof Then
		Rs.Close
		Call AMH_Msg(" ID（"&t_id&"）或 所属频道不存在！","?ChannelIDs="&iChannelIDs&"&skintype="&skintype,1)
		Exit Sub
	End If
	T_Name=Rs("T_Name")
	IsDefault=Rs("IsDefault")
	Rs.Close
	If IsDefault Then
		Call AMH_Msg(" 默认风格无法删除！","?ChannelIDs="&iChannelIDs&"&skintype="&skintype,1)
		Exit Sub
	End If
	Call Cls.Exec("Delete From ["&Data_Name&"] Where t_cid="&iChannelIDs&" And t_id="&t_id,0)
	TemplateCacheDel()
	Call AMH_Msg("成功删除 ("&T_Name&") "&tit_fir&"！","?ChannelIDs="&iChannelIDs&"&skintype="&skintype,1)
End Sub
'//* 设置默认模板 *//
Sub AsaiMHTemplate_SetDefault()
	SQL = "Select Top 1 T_Name From ["&Data_Name&"] Where t_cid="&iChannelIDs&" And t_id="&t_id
	Call Cls.Exe_Conn(Rs,SQL,3)
	If Rs.Eof Then
		Rs.Close
		Call AMH_Msg(" ID（"&t_id&"）或 所属频道不存在！","?ChannelIDs="&iChannelIDs&"&skintype="&skintype,1)
		Exit Sub
	End If
	T_Name=Rs("T_Name")
	Rs.Close
	if skintype=0 then
	Call Cls.Exec("Update ["&Data_Name&"] Set IsDefault=0 where t_cid=0 and t_sid=0",0)
	Call Cls.Exec("Update ["&Data_Name&"] Set IsDefault=1 Where t_id="&t_id,0)
	else
	Call Cls.Exec("Update ["&Data_Name&"] Set IsDefault=0 where t_cid="&iChannelIDs&" and t_sid > 0",0)
	Call Cls.Exec("Update ["&Data_Name&"] Set IsDefault=1 Where t_id="&t_id,0)
	end if
	TemplateCacheDel()
	Call AMH_Msg("成功更新 ("&T_Name&") 风格为默认风格！","?ChannelIDs="&iChannelIDs&"&skintype="&skintype,1)
End Sub
'//* 导出模板 *//
Sub AsaiMHTemplate_Export()
	Dim Sel_id
	Sel_id=Cls.Code_Admin("sel_id",1,0)
	Sel_id=Replace(Sel_id," ","")
	If Sel_id="" Then
		Call AMH_Msg("没有选择可操作的记录！","?",1)
		Exit Sub
	End If
	Dim SkinPath, eType, eConn, FieldsNum, Dim_Skin, Dim_Fields, j
	SkinPath=Cls.Code_Admin("SkinPath",1,0)
	eType = False
	If Cls.Code_Admin("eType",1,0)="yes" Then eType=True
	If SkinPath="" Then
		Call AMH_Msg("导出的数据库路径不能为空！","?ChannelIDs="&iChannelIDs&"&skintype="&skintype,1)
		Exit Sub
	End If
  Dim TmpCls
	Set TmpCls = New Cls_FileSystem
	  If Not TmpCls.Chk_Exist(SkinPath,1) Then
		  Call AMH_Msg("目标数据库文件不存在，请检查后再进行导出操作！","?ChannelIDs="&iChannelIDs&"&skintype="&skintype,1)
		  Exit Sub
	  End If
	Set TmpCls = Nothing
	SQL = "Select * From ["&Data_Name&"] Where t_id In("&Sel_id&") Order By t_id"
	Set Rs = Cls.Exec(SQL,1)
	If Rs.Eof Then
		Rs.Close
		Call AMH_Msg("没有选择可操作的记录！","?ChannelIDs="&iChannelIDs&"&skintype="&skintype,1)
		Exit Sub
	End If
	Dim_Skin = Rs.GetRows()
	FieldsNum=Rs.Fields.Count-1
	Redim Dim_Fields(FieldsNum)
	For i=0 To FieldsNum
		Dim_Fields(i)=Rs(i).name
	Next
	Rs.Close
	On Error Resume Next
	Set eConn=Server.CreateObject("Adodb.Connection")
	eConn.Open "Provider=Microsoft.Jet.Oledb.4.0;Data Source="&Server.Mappath(SkinPath)
	If eType Then
		eConn.Execute("Delete * From "&Data_Name)
	End If
	Rs.Open "Select * From ["&Data_Name&"]",eConn,1,3
	If Err.Number=-2147467259 Then
		Erase Dim_Skin
		Erase Dim_Fields
		Rs.Close
		eConn.Close
		Set eConn=Nothing
		Err.Clear
		Call AMH_Msg("导出的数据库或数据表出现异常（可能不存在）！","?ChannelIDs="&iChannelIDs&"&skintype="&skintype,1)
		Exit Sub
	End If
	For j=0 To Ubound(Dim_Skin,2)
		Rs.AddNew
		For i=1 To FieldsNum
			If Dim_Fields(i) = "IsDefault" Then
				Rs(Dim_Fields(i)) = False
			Else
				Rs(Dim_Fields(i))=Dim_Skin(i,j)
			End If
		Next
		Rs.Update
	Next
	Rs.Close
	eConn.Close
	Set eConn=Nothing
	Erase Dim_Skin
	Erase Dim_Fields
	Call AMH_Msg("成功导出所选择的"&tit_fir&"数据！","?ChannelIDs="&iChannelIDs&"&skintype="&skintype,1)
End Sub
'//* 导入模板 *//
Sub AsaiMHTemplate_Import()
	Dim SkinPath, eType, eConn, FieldsNum, Dim_Skin, Dim_Fields, j
	Dim k
	SkinPath=Cls.Code_Admin("SkinPath",1,0)
	If SkinPath="" Then
		Call AMH_Msg("导出的数据库路径不能为空！","?",1)
		Exit Sub
	End If
  Dim TmpCls
	Set TmpCls = New Cls_FileSystem
	  If Not TmpCls.Chk_Exist(SkinPath,1) Then
		  Call AMH_Msg("目标数据库文件不存在，请检查后再进行导出操作！","?ChannelIDs="&iChannelIDs&"&skintype="&skintype,1)
		  Exit Sub
	  End If
	Set TmpCls = Nothing
	If Chk() Then
		Dim Sel_id
		Sel_id=Cls.Code_Admin("sel_id",1,0)
		Sel_id=Replace(Sel_id," ","")
		If Sel_id="" Then
			Call AMH_Msg("没有选择可操作的记录！","?ChannelIDs="&iChannelIDs&"&skintype="&skintype,1)
			Exit Sub
		End If
		On Error Resume Next
		Set eConn=Server.CreateObject("Adodb.Connection")
		eConn.Open "Provider=Microsoft.Jet.Oledb.4.0;Data Source="&Server.Mappath(SkinPath)
		Set Rs = eConn.Execute("Select * From ["&Data_Name&"] Where t_id In("&Sel_id&") Order By t_id")
		If Err.Number=-2147467259 Then
			Rs.Close
			eConn.Close
			Set eConn=Nothing
			Err.Clear
			Call AMH_Msg("导入的数据库数据表出现异常（可能不存在）！","?ChannelIDs="&iChannelIDs&"&skintype="&skintype,1)
			Exit Sub
		End If
		If Rs.Eof Then
			Rs.Close
			Call AMH_Msg("没有选择可操作的记录！","?ChannelIDs="&iChannelIDs&"&skintype="&skintype,1)
			Exit Sub
		End If
		Dim_Skin = Rs.GetRows()
		FieldsNum=Rs.Fields.Count-1
		Redim Dim_Fields(FieldsNum)
		For i=0 To FieldsNum
			Dim_Fields(i)=Rs(i).name
		Next
		Rs.Close
		eConn.Close
		Set eConn=Nothing
		SQL = "Select * From ["&Data_Name&"]"
		Call Cls.Exe_Conn(Rs,SQL,3)
		For j=0 To Ubound(Dim_Skin,2)
			Rs.AddNew
			For i=0 To FieldsNum
				If LCase(Dim_Fields(i)) = LCase("IsDefault") Then
					Rs(Dim_Fields(i)) = False
				ElseIf LCase(Dim_Fields(i)) = LCase("t_cid") Then
					Rs(Dim_Fields(i)) = Cls.Code_Int("ChannelIDs"&Dim_Skin(0,j),0)
				ElseIf i>0 Then
					Rs(Dim_Fields(i))=Dim_Skin(i,j)
				End If
			Next
			Rs.Update
		Next
		Rs.Close
		Erase Dim_Skin
		Erase Dim_Fields
		TemplateCacheDel()
		Call AMH_Msg("成功导入所选择的"&tit_fir&"数据！","?ChannelIDs="&iChannelIDs&"&skintype="&skintype,1)
		Exit Sub
	End If
	k = 0
	Call Form_First()
%>
  <form action='?Action=Import&ChannelIDs=<%=iChannelIDs%>' method=post>
  <input type=hidden name=chk value='yes'>
  <input type=hidden name=SkinPath value='<%=SkinPath%>'>
  <tr align=center>
  <td class=td width='5%'><input type=checkbox name=sel_all value='yes' onclick="javascript:select_all(this.form);" class=td></td>
  <td class=td width='5%'>序号</td>
  <td class=td width='50%'><%=tit_fir%>名称</td>
  <td class=td width='45%'>目标频道</td>
  </tr>
<%
	On Error Resume Next
	Set eConn=Server.CreateObject("Adodb.Connection")
	eConn.Open "Provider=Microsoft.Jet.Oledb.4.0;Data Source="&Server.Mappath(SkinPath)
	Set Rs = eConn.Execute("Select * From ["&Data_Name&"] Order By t_id")
	If Err.Number=-2147467259 Then
		Rs.Close
		eConn.Close
		Set eConn=Nothing
		Err.Clear
		Call AMH_Msg("导入的数据库数据表出现异常（可能不存在）！","?ChannelIDs="&iChannelIDs&"&skintype="&skintype,1)
		Exit Sub
	End If
	Do While Not Rs.eof
		t_id = Rs("t_id")
		T_Name = Rs("T_Name")
%>
  <tr align=center>
  <td><input type=checkbox name=sel_id value='<%Response.Write t_id%>'></td>
  <td class=tims><%Response.Write k+1%></td>
  <td><%Response.Write Cls.Code_Html(T_Name,1,(22+tnum))%></td>
  <td>分配到：<%Response.Write Get_CopyChannelList("ChannelIDs"&t_id,Rs("t_cid"),1)%></td>
  </tr>
<%
		Rs.MoveNext
		k = k + 1
	Loop
	Rs.Close
	eConn.Close
	Set eConn=Nothing
%>
    <tr class=tr1>
    <td colspan=2></td>
    <td colspan=2>&nbsp;&nbsp;<input type=submit value='导入所选的风格' onclick="return sel_click(this.form);" class=btn></td>
    </tr>
<%
End Sub
'//* 频道模板列表 *//
Function Get_CopyChannelList(ByVal FieldID, ByVal Mcid,ByVal CopyType)
	Dim Mii, ChannelMenus, Tmpstr, TmpMcid
	TmpMcid = Mcid
	ChannelMenus = Cls.Channel_Menu
	For Mii = 0 To Ubound(ChannelMenus,2)
		If ChannelMenus(8,Mii) < 2 And ( Cls.Get_ChannelRes(Mcid,1) = ChannelMenus(13,Mii) Or CopyType = 1 ) Then
			Tmpstr = Tmpstr & "<option value='"&ChannelMenus(0,Mii)&"'"
			If Int(Mcid) = Int(ChannelMenus(0,Mii)) Then Tmpstr = Tmpstr & " selected"
			Tmpstr = Tmpstr & ">"&ChannelMenus(13,Mii)&"模板</option>"
		End If
	Next
	Erase ChannelMenus
	Get_CopyChannelList = "<select name="&FieldID&" size=1><option value='0'"
	If Int(Mcid) = 0 Then Get_CopyChannelList = Get_CopyChannelList & " selected"
	Get_CopyChannelList = Get_CopyChannelList & ">全局模板</option>"&Tmpstr&"</select>"
End Function
'//* 缓存清除 *//
Sub TemplateCacheDel()
		Call Cls.Cache_Del("CT_"&iChannelIDs)
		Call Cls.Cache_Del("IT_"&t_id)
End Sub
%>
