<!--#include file="../fy.Function.asp"-->
<!--#include file="../../fy_inc/fy.Code.asp"-->
<%
	Dim Save_Rs,ClassIDValue,Save_Rs1,Getrootid,Articleadd,EnName,ShowErr,Save_SQL,Save_SQL1,ClassID
	Dim ClassName,Extension,ClassKeywords,ClassDescription,ChangesLinkUrl 
	dim ismenu,tg,classename,ConTentTemplate,sitepath,moresite,siteurl,ACTlink
	Dim TGGroupID,OrderID,FolderTemplate,ModeID,FilePathName,content,makehtmlname,pageTemplate
	dim ClassPurview,ClassArrGroupID,ClassReadPoint,ClassChargeType ,ClassPitchTime,ClassReadTimes,ClassDividePercent
	Dim SEOtitle,ClassPicUrl,labelfor,classmake
	 ModeID = ChkNumeric(Request("ModeID"))
	 labelfor= ChkNumeric(Request("labelfor"))
	 if ModeID=0 or ModeID="" Then ModeID=1
		If Not fycms.fycms_QXYZ(ModeID,"","") Then   Call fycms.Alert("对不起，您没有"&fycms.ACT_C(ModeID,1)&"系该项操作权限！","")
	ClassPicUrl=Request.Form("ClassPicUrl")
	TGGroupID=Request.Form("TGGroupID")
	ClassID = ChkNumeric(Request.form("ClassID"))
	SEOtitle=Request.form("SEOtitle")
	OrderID = ChkNumeric(Request.form("OrderID"))
	classmake = ChkNumeric(Request.form("classmake"))
	
	Getrootid = Request.form("rootid")
	Extension = Trim(Request.Form("Extension"))
	If Extension<>"" Then Extension="index.html"
	ClassDescription = Request.Form("ClassDescription")
	ClassKeywords = Request.Form("ClassKeywords")
	FolderTemplate = Request.Form("FolderTemplate")
	ChangesLinkUrl = Request.Form("ChangesLinkUrl")
	ismenu = ChkNumeric(Request.Form("ismenu"))
	tg = ChkNumeric(Request.Form("tg"))
	ACTlink = 1

	FolderTemplate = Request.Form("FolderTemplate")
	ConTentTemplate = Request.Form("ConTentTemplate")
	FilePathName = fycms.S("FilePathName")

 
	ClassPurview = ChkNumeric(Request.form("ClassPurview"))
	ClassReadPoint = ChkNumeric(Request.form("ClassReadPoint"))
	ClassChargeType = ChkNumeric(Request.form("ClassChargeType"))
	ClassPitchTime = ChkNumeric(Request.form("ClassPitchTime"))
	ClassReadTimes = ChkNumeric(Request.form("ClassReadTimes"))
	ClassDividePercent = ChkNumeric(Request.form("ClassDividePercent"))
	ClassArrGroupID = Request.form("ClassArrGroupID")
 
	content= fycms.S("content")
	makehtmlname= fycms.S("makehtmlname")
	pageTemplate= fycms.S("pageTemplate")

	If ActLink="2"  Then  makehtmlname=fycms.S("LinkUrl")
 '----------------------------------------------------------
	moresite = ChkNumeric(Request.Form("moresite"))
	siteurl = Request.Form("siteurl")
	sitepath = Request.Form("sitepath")
'----------------------------------------------------------
	If Trim(TGGroupID)="" Then TGGroupID=0
 

	IF Trim(FolderTemplate) = ""  Then
  
		ShowErr = "栏目模板地址不能为空"
		Call fycms.ActErr(ShowErr,"","1")
		Response.End
	  
	End If

	IF Trim(ConTentTemplate) = ""  Then
 		ShowErr = "内容页模板地址不能为空"
		Call fycms.ActErr(ShowErr,"","1")
		Response.End
	 
	End If

	IF fycms.s("ChangesLink") = "1"  Then 
		IF Trim(ChangesLinkUrl) = ""  Then
			ShowErr = "请填写转向链接地址"
			Call fycms.ActErr(ShowErr,"","1")
			Response.End
		End If
	Else
		ChangesLinkUrl=""
	End If
	ClassName=fycms.S("ClassName")
	Dim carr
	carr=Split(ClassName, vbCrLf)
	For i=0 To ubound(carr)
		ClassEname=""
		ClassName= carr(i)
		If Trim(carr(i))="" Then  Exit For
		Getrootid=ChkNumeric(Request.form("ClassID"))
		ClassIDValue = fycms.GetRand&fycms.MakeRandom(3)'随机生成15位字符
		Set Save_SQL = server.CreateObject("adodb.recordset")
		
			Dim TemplateContent,makenames
			Dim MakePage,namearr,i,namearrs
			Set MakePage =New ACT_Code
			If  Request.Form("IFPinYin") = "1" Then
				EnName = fycms.GetEn(fycms.PinYin(ClassName))
			Else
				IF fycms.Chkchars(Request.Form("EnName")) = False    Then :Exit For
					 
				 EnName = Trim(Request.Form("EnName"))
				 
			End If
		
		
		
 		Dim gtf
		Call fycms.getran(ClassIDValue)
		ClassIDValue=gtf

		Set Save_Rs = Nothing
  		If  ChkNumeric(Request.form("ClassID")) <> "0" Then
 			Set Save_Rs = server.CreateObject("adodb.recordset")
			Save_Rs.Open "Select top 1 ID,ClassEname from Class_fy where ClassID="& ChkNumeric(Request.form("ClassID")) &" order by id desc",Conn,1,3
 			ClassEname = Save_Rs("ClassEname")&EnName&"/"
  		Else 
	
			ClassEname = EnName&"/"
			Set Save_Rs = nothing
		End IF
			
 		Set Save_Rs1 = server.CreateObject("adodb.recordset")
		
		If Getrootid="0" Then 
			Articleadd ="Select ID from Class_fy where EnName='"& trim(EnName) &"' And rootid=0 "
			'添加根目录
		Else
			Articleadd ="Select ID from Class_fy where rootid="&ClassID&" and EnName='"& trim(EnName) &"' "
			'下级分类
		End If
		
		Save_Rs1.Open Articleadd,Conn,1,3
		if Not (Save_Rs1.eof and Save_Rs1.bof)  then
			if trim(request("ChangesLink"))<>"0" Then :Exit For
				 
		End If
		
	
		set Save_Rs1 = nothing
		Save_SQL1 = "Select * from Class_fy where 1=2"
		Save_SQL.Open Save_SQL1,Conn,1,3
		Save_SQL.AddNew
		Save_SQL("ClassName") = ClassName
		Save_SQL("ClassEName") = ClassEName
		Save_SQL("EnName") = EnName
		Save_SQL("ModeID") = ModeID
		Save_SQL("ClassID") = ClassIDValue
		Save_SQL("rootid") = Getrootid
		Save_SQL("OrderID") = OrderID
		Save_SQL("Extension") = Extension
		Save_SQL("ClassKeywords") = ClassKeywords
		Save_SQL("ClassDescription") = ClassDescription
 		Save_SQL("ConTentTemplate") = ConTentTemplate
 		Save_SQL("ismenu") = ismenu
 		Save_SQL("SEOtitle") = SEOtitle
		Save_SQL("tg") = tg
		Save_SQL("ModeID") = ModeID
		Save_SQL("TGGroupID") = TGGroupID
		Save_SQL("moresite") = moresite
		Save_SQL("siteurl") = siteurl
		Save_SQL("sitepath") = sitepath
		Save_SQL("FilePathName")=FilePathName
		Save_SQL("content")=content
		Save_SQL("makehtmlname")=makehtmlname
		Save_SQL("ClassPurview")=ClassPurview
		Save_SQL("ClassReadPoint")=ClassReadPoint
		Save_SQL("ClassChargeType")=ClassChargeType
		Save_SQL("ClassPitchTime")=ClassPitchTime
		Save_SQL("ClassReadTimes")=ClassReadTimes
		Save_SQL("ClassDividePercent")=ClassDividePercent
		Save_SQL("ClassArrGroupID")=ClassArrGroupID
		Save_SQL("ClassPicUrl")=ClassPicUrl
		Save_SQL("labelfor")=labelfor
 		Save_SQL("FolderTemplate")=FolderTemplate
 		Save_SQL("ACTlink")=1
 		Save_SQL("classmake")=classmake
 		Save_SQL.update
  		Dim rs:Set rs=fycms.actexe("Select top 1 * from Class_fy order by id desc")
		If Not rs.eof Then ClassID = rs("ClassID")
   		If ActLink=3 Then 
 			makenames=makehtmlname
			Application(fycmsN & "fycms_TCJ_Type")= "Folder"
			Application(fycmsN & "classid")=  ClassID
			Application(fycmsN & "modeid")= fycms.ACT_L(ClassID,10)
 			TemplateContent = MakePage.CreateArticleList(ModeID,rs)
 	    End If 
   		Application.Contents.RemoveAll
    
	If ActLink=3 Then 
			Application(fycmsN & "fycms_TCJ_Type")= "Folder"
			Application(fycmsN & "classid")=  ClassID
			Application(fycmsN & "modeid")= fycms.ACT_L(ClassID,10)
  			TemplateContent = MakePage.CreateArticleList(ModeID,rs)
    	End If 
	
	Application.Contents.RemoveAll
	Save_SQL.close
	Next 
  	Call fycms.ActErr("栏目添加成功","fy_Mode/fy.Class.asp?ModeID="&ModeID&"","")
   %>