<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%option explicit%>
<!--#include file="../Conn.asp"-->
<!--#include file="../KS_Cls/Kesion.CommonCls.asp"-->
<!--#include file="../KS_Cls/Kesion.Label.CommonCls.asp"-->
<%
'****************************************************
' Software name:Kesion CMS 9.5
' Email: service@kesion.com . 营销QQ:4000080263  Tel:400-008-0263
' Web: http://www.kesion.com http://www.kesion.cn
' Copyright (C) Kesion Network All Rights Reserved.
'****************************************************

Dim KSCls
Set KSCls = New SiteIndex
KSCls.Kesion()
Set KSCls = Nothing

Class SiteIndex
        Private KS, KSRFObj,KMRFObj,FileContent
		Private CurrPage,RSObj,PerPageNumber,PageStyle
		Private Sub Class_Initialize()
		  Set KS=New PublicCls
		  Set KSRFObj = New Refresh
		  Set KMRFObj= New RefreshFunction
		End Sub
        Private Sub Class_Terminate()
		 Call CloseConn()
		 Set KS=Nothing
		 Set KMRFObj=Nothing
		End Sub
		Public Sub Kesion()
		 Dim ClassID:ClassID=KS.ChkClng(KS.S("ID"))
		 CurrPage=KS.ChkClng(KS.S("Page"))
		 If CurrPage<=0 Then CurrPage=CurrPage+1
		 IF ClassID=0 Then Exit Sub
		 Set RSObj=Server.CreateObject("ADODB.RECORDSET")
		  RSObj.Open "Select * From KS_SpecialClass Where ClassID=" & ClassID,Conn,1,1
		  If RSObj.Eof And RSObj.Bof Then
		  Call KS.Alert("您要查看的栏目已删除。或是您非法传递注入参数!",""):Exit Sub
		  End If
		  FCls.FromAspPage=True
		  FCls.RefreshType = "ChannelSpecial"
		  FCls.RefreshFolderID = ClassID
		  FileContent = KSRFObj.LoadTemplate(RSObj("TemplateID"))
		  FileContent = KSRFObj.ReplaceSpecialClass(FileContent)
		  FileContent = KSRFObj.KSLabelReplaceAll(FileContent)
		   		  
		  
		   Dim LabelParamStr:LabelParamStr=Application(KS.SiteSN&"PageParam")
		   If LabelParamStr<>"" And Not IsNull(LabelParamStr) Then
				 Dim XMLDoc,XMLSql,LabelStyle
				 Dim ParamNode,IncludeSubClass,ModelID,OrderStr,PrintType,PageStyle,PicStyle,FieldStr,Param
				 Dim PerPageNumber,TotalPut,PageNum,TempStr,SQLStr,RS
				 Set XMLDoc=KS.InitialObject("msxml2.FreeThreadedDOMDocument"& MsxmlVersion)
				 If XMLDoc.loadxml("<label><param " & LabelParamStr & " /></label>") Then
					 Set ParamNode=XMLDoc.DocumentElement.SelectSingleNode("param")
					 PrintType       = ParamNode.getAttribute("printtype") : If Not IsNumeric(PrintType) Then PrintType=1
					 PageStyle       = ParamNode.getAttribute("pagestyle") : If PageStyle="" Or IsNull(PageStyle) Then PageStyle=1
					 PerPageNumber   = ParamNode.getAttribute("num") : If Not IsNumeric(PerPageNumber) Then PerPageNumber=10
						    FCls.PerPageNum=PerPageNumber
					 SqlStr="Select S.specialid,S.classid,S.SpecialName,S.SpecialEname,S.FsoSpecialIndex,S.SpecialAddDate as AddDate,S.PhotoUrl,S.SpecialNote As Intro,S.creater,C.ClassName as SpecialClassName From KS_Special S Inner Join KS_SpecialClass C On S.ClassID=C.ClassID Where S.ClassID=" & ClassID & " Order By S.SpecialID Desc"
					 
						Set RS=Server.CreateObject("ADODB.RECORDSET")
						RS.Open SqlStr, Conn, 1, 1
						If RS.EOF And RS.BOF Then
							TempStr = "<p>此分类下没有专题</p>"
						Else
							PerPageNumber=cint(PerPageNumber)
							TotalPut = Conn.Execute("Select count(S.specialid) From KS_Special S Inner Join KS_SpecialClass C On S.ClassID=C.ClassID Where S.ClassID=" & ClassID)(0)
							if (TotalPut mod PerPageNumber)=0 then
									PageNum = TotalPut \ PerPageNumber
							else
									PageNum = TotalPut \ PerPageNumber + 1
							end if
							If CurrPage >1 and (CurrPage - 1) * PerPageNumber < totalPut Then
								RS.Move (CurrPage - 1) * PerPageNumber
							Else
								CurrPage = 1
							End If
							Set XMLSQL=KS.ArrayToXml(RS.GetRows(PerPageNumber),RS,"row","root")
							Call KMRFObj.LoadPageParam(XMLSQL,ParamNode,0)
							LabelStyle=Application("LabelStyle")
							TempStr = KMRFObj.ExplainSpecialListLabelBody(LabelStyle)
							XMLSql=Empty
							
							FCls.TotalPut=TotalPut
							FCls.PageStyle=PageStyle       '分页样式
							FCls.TotalPage=PageNum         '总页数
							
						End If
							if Instr(tempstr,"[KS:PageStyle]")=0 Then
							tempstr=tempstr & "[KS:PageStyle]"
							End If
							FileContent=Replace(FileContent,"{Tag:Page}",tempstr)
						RS.Close:Set RS=Nothing					
						XMLDoc= Empty : Set ParamNode=Nothing
				 End If
		   End If

		  if Instr(FileContent,"[KS:PageStyle]")<>0 Then
			FileContent=Replace(FileContent,"[KS:PageStyle]",KS.ReplacePage(FCls.PageStyle,-1,classid,CurrPage,FCls.TotalPut,FCls.PerPageNum))
			End If
			

		  Response.Write FileContent 
		  RSObj.Close:Set RSObj=Nothing
		End Sub
		
End Class
%>
