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


'* ----------------------------------------
'* 文件说明
'* 作  用：用于前、后台频道分类基本信息处理
'* ----------------------------------------
Dim ChannelSort			'频道识别码，一般与字段名相同
Dim Cid					'频道分类ID
Dim Cname				'频道分类名称
Dim ClassTrue			'判断分类是否存在
Dim ClassArr			'分类数组
Dim ClassNum			'分类数组个数
Dim ClassColNum			'余数
Cid = 0
ClassTrue = True
ClassNum = -1
ClassColNum = 7

'//* 分类数据初始化 *//
Sub Class_Load()
	Cls.Name = "Class_"&ChannelIDs
	If Cls.Cache_Chk() Then
		Call Class_LoadData()
	End If
	ClassArr = Cls.Value
	If Not IsArray(ClassArr) Then
		ClassTrue = False
		Exit Sub
	End If
	ClassNum = Ubound(ClassArr,2)
End Sub

'//* 分类数据读取 *//
Sub Class_LoadData()
	SQL = "Select C_ID,ClassName,ClassParent,ClassParentStr,ClassDepth,ClassChild,ClassID,ClassDir,HtmlFileDir,ClassChildStr from AsaiMHClass Where ChannelIDs="&ChannelIDs&" And ClassDepth<"&Cls.ClassDepth&" Order By ClassID,ClassOrder,ClassDepth"
	Set Rs = Cls.Exec(SQL,1)
	If Rs.Eof Then
		Rs.Close
		Cls.Value = "kong"
		Exit Sub
	End If
	Cls.Value = Rs.GetRows()
	Rs.Close
	Exit Sub
End Sub

Function Class_Grade(vCid,vDepth)
	Dim Tmpstr, vClassParentStr, CurrenCid, Vii
	If vCid = 0 Then Exit Function
	'Tmpstr = ChannelName
	For Vii = 0 To ClassNum
		If Int(ClassArr(0,Vii)) = Int(vCid) Then
			vClassParentStr = ClassArr(3,Vii)
			Exit For
		End If
	Next
	Vii = 0
	If Instr(vClassParentStr,",")<>0 Then
		vClassParentStr = Split(vClassParentStr,",")
		For Vii = 0 To Ubound(vClassParentStr)
			CurrenCid = vClassParentStr(Vii)
			If Cls.ChannelIsCreatHtml = True then
			    Tmpstr = Tmpstr & "&nbsp;<a href='"&Cls.Web_Dir & Cls.ChannelDir & "/"&Class_Path_Get(CurrenCid) & "index_1"&Cls.ChannelHtmlExtName&"'>"&Class_Name_Get(CurrenCid)&"</a>&nbsp;→&nbsp;"
			Else
			    Tmpstr = Tmpstr & "&nbsp;<a href='List.asp?c_id="&CurrenCid&"'>"&Class_Name_Get(CurrenCid)&"</a>&nbsp;→&nbsp;"
			End If
			If Vii=vDepth-1 Then Exit For
		Next
		Erase vClassParentStr
	Else
		If Cls.ChannelIsCreatHtml = True then
			  Tmpstr = Tmpstr & "&nbsp;<a href='"&Cls.Web_Dir & Cls.ChannelDir & "/"&Class_Path_Get(vCid) & "index_1"&Cls.ChannelHtmlExtName&"'>"&Class_Name_Get(vCid)&"</a>&nbsp;→&nbsp;"
		Else
			  Tmpstr = Tmpstr & "&nbsp;<a href='List.asp?c_id="&vCid&"'>"&Class_Name_Get(vCid)&"</a>&nbsp;→&nbsp;"
		End If
	End If
	Class_Grade = Tmpstr
End Function

'//* 当前所在分类Xml *//
Function Class_Grade_Xml(vCid,vDepth)
	Dim Tmpstr, vClassParentStr, CurrenCid, Vii
	If vCid = 0 Then Exit Function
	'Tmpstr = ChannelName
	For Vii = 0 To ClassNum
		If Int(ClassArr(0,Vii)) = Int(vCid) Then
			vClassParentStr = ClassArr(3,Vii)
			Exit For
		End If
	Next
	Vii = 0
	If Instr(vClassParentStr,",")<>0 Then
		vClassParentStr = Split(vClassParentStr,",")
		For Vii = 0 To Ubound(vClassParentStr)
			CurrenCid = vClassParentStr(Vii)	
			    Tmpstr = Tmpstr &Class_Name_Get(CurrenCid)&" - "
			If Vii=vDepth-1 Then Exit For
		Next
		Erase vClassParentStr
	Else	
			  Tmpstr = Tmpstr & Class_Name_Get(vCid)&" - "
	End If
	Class_Grade_Xml = Tmpstr
End Function

'//* 当前所在分类名称 *//
Function Class_Name_Get(vCid)
	Dim Ni
	Class_Name_Get=""
	If Not ClassTrue Then Exit Function
	if Int(vCid)=0 Then Exit Function
	For Ni=0 To ClassNum
		If Int(ClassArr(0,Ni))=Int(vCid) Then
			Class_Name_Get=ClassArr(1,Ni)
			Exit For
		End If
	Next
End Function

'//* 当前所在分类目录 *//
Function Class_Path_Get(vCid)
	Dim Ni
	Class_Path_Get=""
	If Not ClassTrue Then Exit Function
	if Int(vCid)=0 Then Exit Function
	For Ni=0 To ClassNum
		If Int(ClassArr(0,Ni))=Int(vCid) Then
			Class_Path_Get=ClassArr(8,Ni)
			Exit For
		End If
	Next
End Function

'//* 当前所在分类的父分类ID *//
Function Class_Parent_Get(vCid)
	Dim Ni
	Class_Parent_Get=0
	If Not ClassTrue Then Exit Function
	if Int(vCid)=0 Then Exit Function
	For Ni=0 To ClassNum
		If Int(ClassArr(0,Ni))=Int(vCid) Then
			Class_Parent_Get=ClassArr(2,Ni)
			Exit For
		End If
	Next
End Function

'//* 当前所在分类的子分类数量 *//
Function Class_Child_Get(vCid)
	Dim Ni
	Class_Child_Get=0
	If Not ClassTrue Then Exit Function
	if Int(vCid)=0 Then Exit Function
	For Ni=0 To ClassNum
		If Int(ClassArr(0,Ni))=Int(vCid) Then
			Class_Child_Get=ClassArr(5,Ni)
			Exit For
		End If
	Next
End Function

'//* 当前分类及子分类 *//
Function Class_Cid_Get(vCid)
	Dim Ni, TmpStr, nCid, ClassParent
	nCid=0
	Class_Cid_Get=""
	If Not ClassTrue Then Exit Function
	If Int(vCid)=0 Then Exit Function
	If Int(vCid)=0 Then TmpStr = ""
	For Ni=0 To ClassNum
		If Int(ClassArr(0,Ni))=Int(vCid) Then
			Class_Cid_Get=ClassArr(9,Ni)
			Exit For
		End If
	Next
End Function

Function Class_Cid_Get2(vCid)
	Dim Ni, TmpStr, nCid, ClassParent
	nCid=0
	Class_Cid_Get2=""
	If Not ClassTrue Then Exit Function
	If Int(vCid)=0 Then Exit Function
	If Int(vCid)=0 Then TmpStr = ""
	SQL = "Select ClassParent from AsaiMHClass Where C_ID="&vCid
	Set Rs = Cls.Exec(SQL,1)
	If Not Rs.Eof Then
		ClassParent = Rs("ClassParent")
	End If
	Rs.Close
	If Int(Request("vCid")) = Int(ClassParent) Then
	For Ni=0 To ClassNum
		If Int(ClassArr(0,Ni))=Int(vCid) Then
			nCid=Int(ClassArr(6,Ni))
		End If
		If Int(ClassArr(0,Ni))<>Int(vCid) And Int(ClassArr(6,Ni))=nCid Then
			TmpStr=TmpStr & "," & ClassArr(0,Ni)
		End If
	Next
	Else
		TmpStr = vCid
	End If
	If Int(Request("vCid")) = Int(ClassParent) Then
			TmpStr="( ClassID in(" & vCid & TmpStr & ") )"
	Else
			TmpStr="( ClassID in(" & TmpStr & ") )"
	End If
	Class_Cid_Get2=TmpStr
End Function

'//* 分类列表(左) *//
Function LoadClass(c_id,c_type,t_type)
  dim temp1,Tmpurl,tmpimg,ShowClsTrue,p_id,si,n
  if not ClassTrue then
    temp1="暂无分类"
    LoadClass=temp1
    exit function
  End If
  n =3
  If c_type = 1 Then p_id = Class_Parent_Get(c_id)
  for si=0 to ClassNum
    ShowClsTrue = False
    If c_type = 0 Then
	   If ClassArr(2,si) = c_id Then ShowClsTrue = True
	Else
	   If ClassArr(2,si) = p_id Then ShowClsTrue = True
	End If
	If ShowClsTrue Then
      TmpImg="sorts_c1"
	  If c_id = ClassArr(0,si) Then TmpImg="sorts_c2"
	  If t_type Then
	     Tmpurl = Cls.Web_Dir&Cls.ChannelDir&"/"&ClassArr(8,si)&"Index_1"&Cls.ChannelHtmlExtName 
	  Else
	     Tmpurl = Cls.Web_Dir&Cls.ChannelDir&"/List.asp?c_id="&ClassArr(0,si)
	  End If
      If n mod 2 = 1 then
	     temp1 = temp1 &"<li><div class=slis>"   &VbCrlf&img_skin(TmpImg)&"<a href='"&Tmpurl&"'>"&ClassArr(1,si)&"</a></div>"&VbCrlf
		 if si =  ClassNum then temp1 = temp1 & "</li>"
	  Else
	     temp1 = temp1   &VbCrlf&"<div class=slis>"&img_skin(TmpImg)&"<a href='"&Tmpurl&"'>"&ClassArr(1,si)&"</a></div>"&VbCrlf&"</li>"&VbCrlf	  
	  End If
      n=n+1 
	End If  
  next
  LoadClass=temp1
End Function

'//* 分类列表(下拉菜单) *//
Function Class_Select_Type(t_tit,t1,t2)
  dim si,temp1,ncid
  dim classid,nfid,classn
  temp1="<select name=c_id size=1>" & _
        "<option value=''>请选择"&t_tit&"类型</option>"
  if not ClassTrue then
    temp1=temp1&"</select>"
    Class_Select_Type=temp1
    exit function
  End If
  ncid=0
  for si=0 to ClassNum
    nfid=ClassArr(0,si)
    if int(ClassArr(2,si))=0 then
      temp1=temp1&vbcrlf&"<option class=bg_2 value='"&nfid&"'"
      if int(nfid)=int(cid) then temp1=temp1&" selected"
      temp1=temp1&">"&ClassArr(1,si)&"</option>"
      nfid=ClassArr(0,si)
    else
		If ClassArr(4,si)<t1 Or t1=0 Then
			temp1=temp1&vbcrlf&"<option value='"&nfid&"'"
			if int(nfid)=int(cid) then temp1=temp1&" selected"
			temp1=temp1&">"
			for i=1 to ClassArr(4,si)-1
				temp1=temp1&"│"
			next
			temp1=temp1&"├"&ClassArr(1,si)
			temp1=temp1&"</option>"
		End If
	End If
  next
  temp1=temp1&"</select>"
  Class_Select_Type=temp1
End Function

'//* 分类结束 *//
Sub Class_End()
	If IsArray(ClassArr) Then
		Erase ClassArr
	End If
End Sub

'//* Cid初始 *//
Sub Cid_Load()
	Cid=Cls.Code_ID("c_id")
End Sub

'//* SQL拼接 *//
Sub Cid_SQL(csst,csstt)
  dim temp
  temp=csstt
  if cid>0 then
    sqladd=sqladd&" and c_id="&cid
    pageurl=pageurl&"c_id="&cid&"&"
  End If
  if csst=1 or csst=2 then
    if len(keyword)>0 then
      sqladd=sqladd&" and "&temp&" like '%"&keyword&"%'"
      pageurl=pageurl&"keyword="&server.urlencode(keyword)&"&"
      if csst=2 then pageurl=pageurl&"sea_type="&sea_type&"&"
    End If
  End If
End Sub

Function sel_mod_num(n1,n2)
  sel_mod_num=false
  dim nn1
  nn1=n2/n1
  if instr(nn1,".")=0 then
    sel_mod_num=true
  End If
End Function

'//* 当前标题所在分类 *//
Function Class_Name_Topic(vCid)
  if Int(vCid)=0 Then Exit Function
  Class_Name_Topic="<font class=Gys>[<a href=List.asp?c_id="&vCid&">"&Class_Name_Get(vCid)&"</a>]</font>"
End Function

'//* 当前Xml所在分类 *//
Function Class_Grade_Xml(vCid,vDepth)
	Dim Tmpstr, vClassParentStr, CurrenCid, Vii
	If vCid = 0 Then Exit Function
	'Tmpstr = ChannelName
	For Vii = 0 To ClassNum
		If Int(ClassArr(0,Vii)) = Int(vCid) Then
			vClassParentStr = ClassArr(3,Vii)
			Exit For
		End If
	Next
	Vii = 0
	If Instr(vClassParentStr,",")<>0 Then
		vClassParentStr = Split(vClassParentStr,",")
		For Vii = 0 To Ubound(vClassParentStr)
			CurrenCid = vClassParentStr(Vii)	
			    Tmpstr = Tmpstr &Class_Name_Get(CurrenCid)&" - "
			If Vii=vDepth-1 Then Exit For
		Next
		Erase vClassParentStr
	Else	
			  Tmpstr = Tmpstr & Class_Name_Get(vCid)&" - "
	End If
	Class_Grade_Xml = Tmpstr
End Function
%>
