<%@ Language=VBScript %>
<% Option Explicit
'==========================
' list.asp
'
' 記事の一覧表示
'==========================
Dim page, max
'--------------------------
' Formの提出データをデコード
'--------------------------
page = Request("page") '表示するページ
max = Request("max") '1ページに表示する親記事の数
If page = "" Then
page = 1
ElseIf page < 1 Then
page = 1
End If
If max = "" Then max = MAX_REC_COUNT
'Integer型に変換
page = CInt(page)
max = CInt(max)
'以下サブルーチン
'------------------------
' タイトルのスレッド表示
'------------------------
Sub PrintSubjectTree(th_level, refer_id, abpage, recmax)
On Error Resume Next
Dim Sql
' SQL文作成
Sql = "SELECT mess_id, refer_id, sender, subject, status, " & _
"update_date " & _
"FROM tbl_article " & _
"WHERE th_level = " & th_level
' 子記事を検索する場合 == refer_idが設定されている
If refer_id <> "" Then
Sql = Sql & " AND refer_id = " & refer_id
End If
' 投稿日時の降順でソート
Sql = Sql & " ORDER BY update_date DESC"
Dim objRecset
' レコードセット作成
Set objRecset = objDBCon.Execute(Sql)
' 抽出されるレコードがない場合、実行中止
If objRecset.RecordCount < 1 Then
' 最上層の記事がない場合は、メッセージ表示
If th_level = 0 Then
Response.Write "<FONT size=3 color=""#ff1493"">" &
_
"<STRONG>記事はありません</STRONG></FONT>"
End If
objRecset.Close
set objRecset = nothing
Exit Sub
End If
' 最上層の記事が処理対象の場合、1ページの最大表示件数をセットし、
' 総ページ数とこれから表示するページ数をPrintHeaderに渡して実行
If th_level = 0 Then
objRecset.PageSize = recmax
If objRecset.PageCount < abpage Then
abpage = objRecset.PageCount
End If
objRecset.AbsolutePage = abpage
PrintHeader abpage, objRecset.PageCount
End If
' HTMLのリストタグによるツリー表示
Dim HrefStr, lc
Response.Write "<UL>" & VbCrLf
lc = 1
Do Until objRecset.EOF Or (lc > recmax And th_level = 0)
' 有効な記事か? == status列の値が1
If objRecset("status") = 1 Then
HrefStr = " <A href=""article.asp?mess_id=" & _
objRecset("mess_id") & _
""">"
Response.Write "<LI>"
Response.Write objRecset("mess_id")
Response.Write HrefStr & objRecset("subject") & "</A> -
"
Response.Write objRecset("sender") & " - "
Response.Write objRecset("update_date") & VbCrLf
Else
Response.Write "<LI>"
Response.Write "<FONT size=2
color=""#ff1493""><STRONG>" & _
"この記事は削除されました</STRONG></FONT>" & VbCrLf
End If
'
このプロシージャ自身を再帰呼出して、表示した記事の子記事を検索
PrintSubjectTree th_level+1,objRecset("mess_id"), abpage, recmax
objRecset.MoveNext
lc = lc + 1
Loop
Response.Write "</UL>" & VbCrLf
If th_level = 0 Then
PrintFooter abpage, objRecset.PageCount, recmax
End If
objRecset.Close
set objRecset = nothing
End Sub
'-------------------------------
'ヘッダ
'-------------------------------
Sub PrintHeader(abpage, pgcount)
Response.Write "<FONT size=2 color=""#ff1493"">" &
VbCrLf
Response.Write "<STRONG>PAGE:" & abpage & "/" &
pgcount
Response.Write "</STRONG></FONT>" & VbCrLf
Response.Write "<FONT size=2 color=""#333333"">"
End Sub
'-------------------------------
'フッタ
'-------------------------------
Sub PrintFooter(abpage, pgcount, recmax)
Response.Write "</FONT>"
Response.Write "<HR noshade color=""#333333"" size=2
align=""left"">" & VbCrLF
Response.Write "<TABLE>" & VbCrLf
Response.Write "<TR>"
If abpage > 1 Then
Response.Write "<TH valign=""top""><A
href=""list.asp?page=" & abpage - 1 & _
"&max=" & recmax & """>前のページ</A>"
End If
If pgcount > 1 And pgcount > abpage then
Response.Write "<TH valign=""top""><A
href=""list.asp?page=" & abpage + 1 & _
"&max=" & recmax & """>次のページ</A>"
End If
'ページ数を直接指定してジャンプさせるフォーム
Response.Write "<FORM action=""list.asp"">" &
VbCrLf
Response.Write "<INPUT type=""hidden""
name=""max"" value=" & recmax & ">"
Response.Write "<TH valign=""top""><INPUT
type=""text"" name=""page"" size=3>"
Response.Write "<TH valign=""top""><INPUT
type=""submit"" value=""JUMP"">"
Response.Write "</FORM>"
Response.Write "</TR></TABLE></STRONG></FONT>"
End Sub
%>
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" Content="text/html;
charset=x-sjis">
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY bgColor="#fff8dc">
<FONT size=4 color="#333333"><STRONG>記事の一覧</STRONG></FONT>
<HR noshade color="#ff1493" width=95 size=5 align=left>
<FONT size=2>
<A href="post.asp">新規投稿</A>
<A href="search.asp">記事の検索</A>
</FONT>
<HR noshade color="#333333" size=2 align="left">
<% PrintSubjectTree 0, "", page, max %>
</BODY>
</HTML>
<!-- #include file="mod_const.inc"-->