<%
'新闻列表 调用方法：NewsList(分类ID,分类路径)
Function NewsList(ID, SortPath,lx)
    Dim rs, sql,StringText
    Dim HideSort
	StringText=""   
    If ID = "" Then SortPath = "0,"
    
    Dim idCount
    Dim pages
    pages = NewInfo
    Dim pagec
    Dim page
    page = CLng(request("Page"))
    Dim pagenc
    pagenc = 5
    Dim pagenmax
    Dim pagenmin
    Dim pageprevious
    Dim pagenext
    'datafrom = ""&Datapre&"_News"
    Dim datawhere
    datawhere = "where ViewFlag and Instr(SortPath,'"&SortPath&"')>0 "&HideSort& " "
    Dim sqlid
    Dim Myself, PATH_INFO, QUERY_STRING
    PATH_INFO = request.servervariables("PATH_INFO")
    QUERY_STRING = request.ServerVariables("QUERY_STRING")
    If QUERY_STRING = "" Then
        Myself = PATH_INFO & "?"
    ElseIf InStr(PATH_INFO & "?" & QUERY_STRING, "Page=") = 0 Then
        Myself = PATH_INFO & "?" & QUERY_STRING & "&"
    Else
        Myself = Left(PATH_INFO & "?" & QUERY_STRING, InStr(PATH_INFO & "?" & QUERY_STRING, "Page=") -1)
    End If
    Dim taxis
    taxis = "order by id desc "
    Dim i
    sql = "select count(ID) as idCount from ["&Datapre&"_News]" & datawhere
    Set rs = db(sql,4)
    idCount = rs("idCount")
    If(idcount>0) Then
    If(idcount Mod pages = 0)Then
    pagec = Int(idcount / pages)
Else
    pagec = Int(idcount / pages) + 1
End If
sql = "select id from ["&Datapre&"_News] " & datawhere & taxis
Set rs = db(sql,2)
rs.pagesize = pages
If page < 1 Then page = 1
If page > pagec Then page = pagec
If pagec > 0 Then rs.absolutepage = page
For i = 1 To rs.pagesize
    If rs.EOF Then Exit For
    If(i = 1)Then
    sqlid = rs("id")
Else
    sqlid = sqlid &","&rs("id")
End If
rs.movenext
Next
End If
If(idcount>0 And sqlid<>"") Then
sql = "select ID,NewsName,AddTime from ["&Datapre&"_News] where id in("& sqlid &") "&taxis
Set rs = db(sql,4)
if lx=1 then
StringText=StringText&"<table border=""0"" align=""center"">"&vbCrLf
StringText=StringText&"<tr><th class=""news-time"">日期</th><th class=""news-title"" style='text-align:left;text-indent:1em;'>新闻标题</th></tr>"&vbCrLf
else
	StringText=StringText&"<div class='newslist'><ul>"&vbcrlf
end if
Dim AutoLink
While Not rs.EOF
    If ISHTML = 1 Then
        AutoLink = ""&NewName&""&Separated&""&rs("ID")&"."&HTMLName&""
    Else
        AutoLink = "NewsView.Asp?ID="&rs("ID")&""
    End If
	if lx=1 then
StringText=StringText&"<tr><td class=""time-list""><span>"&FormatDate(rs("Addtime"), 13)&"</span></td><td><a title="""&rs("NewsName")&""" href="""&AutoLink&""">"&rs("NewsName")&"</a></td></tr>"&vbCrLf
	else
	StringText=StringText&"<li><a title="""&rs("NewsName")&""" href="""&AutoLink&""">◎"&rs("NewsName")&"</a><span>["&FormatDate(rs("Addtime"), 9)&"]</span></li>"&vbcrlf
	end if
    rs.movenext
Wend
if lx=1 then
StringText=StringText&"</table>"&vbCrLf
else
StringText=StringText&"</ul></div>"&vbCrLf
end if
Else
StringText=StringText&"<center>暂无相关信息</center>"
    Exit Function
End If
StringText=StringText&"<div class=""page_list"">"&vbcrlf
StringText=StringText&"<div class=""list_info"">共"&idcount&"条&nbsp;&nbsp;"&pages&"条/页&nbsp;&nbsp;<span class=""disabled"">&nbsp;"&vbcrlf

pagenmin = page - pagenc
pagenmax = page+pagenc
If(pagenmin<1) Then pagenmin = 1
If ISHTML = 1 Then
    If ID = "" Then
        If(page>1) Then StringText=StringText&"<span><a href="""&NewSortName&""&Separated&"1."&HTMLName&""" title=""回到第一页"">&nbsp;&lt;&lt;&nbsp;</a></span>"
    Else
        If(page>1) Then StringText=StringText&"<span><a href="""&NewSortName&""&Separated&""&ID&""&Separated&"1."&HTMLName&""" title=""回到第一页"">&nbsp;&lt;&lt;&nbsp;</a></span> "
    End If
Else
    If(page>1) Then StringText=StringText&"<span><a href="""& myself &"Page=1"" title=""回到第一页"">&nbsp;&lt;&lt;&nbsp;</a> </span>"
End If
If page - (pagenc * 2 + 1)<= 0 Then
    pageprevious = 1
Else
    pageprevious = page - (pagenc * 2 + 1)
End If
If ISHTML = 1 Then
    If ID = "" Then
        If(pagenmin>1) Then StringText=StringText&"<span><a href="""&NewSortName&""&Separated&""&pageprevious&"."&HTMLName&""" title=""第"& pageprevious &"页"">&nbsp;&lt;&nbsp;</a></span>"
    Else
        If(pagenmin>1) Then StringText=StringText&"<span><a href="""&NewSortName&""&Separated&""&ID&""&Separated&""&pageprevious&"."&HTMLName&""" title=""第"& pageprevious &"页"">&nbsp;&lt;&lt;&nbsp;</a></span>"
    End If
Else
    If(pagenmin>1) Then StringText=StringText&"<a href="""& myself &"Page="& pageprevious &""" title=""第"& pageprevious &"页"">&nbsp;&lt;&lt;&nbsp;</a> "
End If
If(pagenmax>pagec) Then pagenmax = pagec
For i = pagenmin To pagenmax
    If(i = page) Then
    StringText=StringText&"&nbsp;<span class=""current"">"& i &"</span>&nbsp;"
Else
    If ISHTML = 1 Then
        If ID = "" Then
           StringText=StringText&"<a href="""&NewSortName&""&Separated&""&i&"."&HTMLName&""">"& i &"</a>"
        Else
           StringText=StringText&"<a href="""&NewSortName&""&Separated&""&ID&""&Separated&""&i&"."&HTMLName&""">"& i &"</a>"
        End If
    Else
       StringText=StringText&"<a href="""& myself &"Page="&i&""">"& i &"</a>"
    End If
End If
Next
If page+(pagenc * 2 + 1)>= pagec Then
    pagenext = pagec
Else
    pagenext = page+(pagenc * 2 + 1)
End If
If ISHTML = 1 Then
    If ID = "" Then
        If(pagenmax<pagec) Then StringText=StringText&" <a href="""&NewSortName&""&Separated&""&pagenext&"."&HTMLName&""" title=""跳转到第"&pagenext&"页"">&nbsp;&gt;&gt;&nbsp;</a> "
        If(page<pagec) Then StringText=StringText&" <a href="""&NewSortName&""&Separated&""&pagec&"."&HTMLName&""" title=""跳转到第"&pagec&"页"">&nbsp;&gt;&gt;&nbsp;</a>"
    Else
        If(pagenmax<pagec) Then StringText=StringText&" <a href="""&NewSortName&""&Separated&""&ID&""&Separated&""&pagenext&"."&HTMLName&""" title=""跳转到第"&pagenext&"页"">&nbsp;&gt;&gt;&nbsp;</a> "
        If(page<pagec) Then StringText=StringText&" <a href="""&NewSortName&""&Separated&""&ID&""&Separated&""&pagec&"."&HTMLName&""" title=""跳转到第"&pagec&"页"">&nbsp;&gt;&gt;&nbsp;</a>"
    End If
Else
    If(pagenmax<pagec) Then StringText=StringText&" <a href="""& myself &"Page="& pagenext &""" title=""跳转到第"&pagenext&"页"">&nbsp;&gt;&gt;&nbsp;</a> "
    If(page<pagec) Then StringText=StringText&" <a href="""& myself &"Page="& pagec &""" title=""跳转到第"&pagec&"页"">&nbsp;&gt;&gt;&nbsp;</a>"
End If
StringText=StringText&"</div></div>"&vbCrLf
rs.Close
Set rs = Nothing
NewsList=StringText
End Function

function NewsMenu(PID)
Dim str,rs,sql,AutoUrl
if PID="" then PID=0
sql="select ID,SortName from ["&Datapre&"_NewsSort] where Viewflag and ParentID="&PID&" order by ID"
set rs=db(sql,2)
if rs.eof then
PID=db("select ParentID from ["&Datapre&"_NewsSort] where Viewflag and ID="&PID&"",1)(0)
rs.close:set rs=nothing
sql="select ID,SortName from ["&Datapre&"_NewsSort] where Viewflag and ParentID="&PID&" order by ID"
set rs=db(sql,2)
end if
if not rs.eof then
do while not rs.eof
if IsHtml=1 then
AutoUrl=""&NewSortName&""&Separated&""&rs("ID")&Separated&"1."&HTMLName&""
else
AutoUrl="NewsList.asp?SortID="&rs(0)&""
end if
str=str&"<li><a href='"&AutoUrl&"'><span>"&rs(1)&"</span></a></li>"
rs.movenext
loop
end if
rs.close:set rs=nothing
NewsMenu=str
end function
%>