<%
'================================================
' By KANGK.L
' Date 2006-04-07
' Program Name Kangk PAGEAC
' Class Name CLS_PAGEAC
'
'
'---------Property Let--------
' listhtml list looping Template: Character type, HTML code and substitution tags < required >
' (Replace the label description: Each field name separated by the "," Number Fieldstr "$")
' Pages current page: Long integer, if empty, 0
' PageSize per page list: Long integer < required >
' TABLESTR SQL statement data table name: Character < required >
' FIELDSTR SQL statement data field: Character < required > (with "," number delimited)
' Fieldlen data field character Length: Character < required > (number with "," number separated, must be equal to the number of data fields, 0 value is not the length of the change)
' WHERESTR SQL statement where Condition: character type, null if length is <3 or empty
' Ordermode SQL statement sorting method: Numeric type, 0 is "ASC", non 0 is "Desc", if NULL, "ASC"
' Keyfield SQL statement primary Key name: character type, if null, then ' Id '
' Textfromhtml Filter HTML code: Numeric type (0 or 1, default 0, 0: No filter 1: Filter)
' Redword get red keyword, if empty, no red
' Redwordcontrol get red keyword control, such as empty, then do not add red (by "," the 0 or 1 separated, if not empty, you must be equal to the number of data fields, 0: Red 1: No red)
'
'--------Property Get--------
' RecCount Total Records
' Total Pagenum Paging
'
'--------Function--------
' Pageaccontent Content List body display
' Pageacname Paging distinguished Name
'================================================
' Response.Cookies ("Pageac") ("pagenum") = ""
' Response.Cookies ("Pageac") ("pageacname") = ""
' Response.Cookies ("Pageac") ("reccount") = ""
Class CLS_PAGEAC
Private Strpageacname
Private Lngendid,templisthtml,templisthtmlstr
Private Rs,sqlstr
Private Strfieldstr,strfieldlen,strtablestr,strwherestr,strkeyfield,strredword,strredwordcontrol
Private intordermode,lngpages,lngreccount,lngpagenum,intpagesize,inttextfromhtml
Private I,j,n
Private Arrfieldstr,arrfieldlen,arrrshtml,arrredword,arrredwordcontrol
' ### #内容列表主体显示
Public Function pageaccontent ()
' Response. Write (Request.Cookies ("Pageac") ("Pagenum"))
sqlstr = ' select ' &strFieldStr& ' from ' &strTableStr& ' &strWhereStr& ' ORDER BY ' & strkeyfield& "" &intOrderMode& ""
' Sqlstr = ' select * FROM Test '
' Response. Write (SQLSTR)
Set Rs = Server.CreateObject ("Adodb.recordset")
Rs.Open sqlstr,conn,1,1
If not (rs.eof and RS.BOF) Then
Rs.absoluteposition = (lngPages-1) * intpagesize + 1
For i = 1 to Intpagesize
If rs.eof Or rs.bof Then Exit for
Arrfieldstr = Split (Strfieldstr, ",")
Arrfieldlen = Split (Strfieldlen, ",")
arrrshtml = Split (Strfieldlen, ",")
Arrredwordcontrol = Split (Strredwordcontrol, ",")
Templisthtmlstr = templisthtml
for j = LBound (ARRFIELDSTR) to UBound (ARRFIELDSTR)
' Response. Write (Arrfieldlen (j) & "<br>")
If inttextfromhtml = 1 Then
Arrrshtml (j) = Gettextfromhtml (Rs (Arrfieldstr (j)))
Else
Arrrshtml (j) = Rs (Arrfieldstr (j))
End If
Arrfieldlen (j) = Cint (Arrfieldlen (j))
If Arrfieldlen (j) = 0 Then
Arrrshtml (j) = Arrrshtml (j)
Else
Arrrshtml (j) = Keeplen (Arrrshtml (j), Arrfieldlen (j))
End If
If Strredword <> "" and Strredwordcontrol <> "" Then
If Arrredwordcontrol (j) <> 0 Then
Arrredword = Split (Strredword, "")
For n = LBound (Arrredword) to UBound (Arrredword)
If Instr ("<span style=color: #f00 ></span>", Arrredword (n)) > 0 Then Exit for
Arrrshtml (j) = Replace (Arrrshtml (j), Arrredword (n), "<span Style=color: #f00 >" &arrredword (N) & "</ Span> ", 1)
Next
End If
End If
Templisthtmlstr = Replace (Templisthtmlstr, "$" &arrfieldstr (j) & "$", arrrshtml (j))
' Lngendid = Rs (' Id ')
Next
' Response.Write (i)
' Response.Write (RS ("id"))
Response.Write (TEMPLISTHTMLSTR)
Rs.movenext
Next
Else
Response.Write ("No resource records!") ")
End If
Rs.close
Set Rs = Nothing
End Function
' ### #记录总数
Public Property Get RecCount ()
If request.cookies ("Pageac") ("Pageacname") <> pageacname () Or request.cookies ("Pageac") ("reccount") = "" Then
Lngreccount = Conn.execute ("Select Count (" &strKeyField& ") from" &strTableStr& "&strwherestr & "", 0, 1) (0)
Response.Cookies ("Pageac") ("pageacname") = Pageacname ()
Response.Cookies ("Pageac") ("reccount") = CLng (Lngreccount)
RecCount = CLng (Lngreccount)
Else
Lngreccount = CLng (Request.Cookies ("Pageac") ("RecCount"))
RecCount = Lngreccount
End If
End Property
' ### #分页总数
Public Property Get Pagenum ()
Lngpagenum = Lngreccount/intpagesize
If lngpagenum > CLng (lngpagenum) Then
Lngpagenum = CLng (lngpagenum) + 1
Else
Lngpagenum = CLng (lngpagenum)
End If
Response.Cookies ("Pageac") ("pagenum") = CLng (Lngpagenum)
Pagenum = Lngpagenum
End Property
' ### #取得循环模板
Public Property Let listhtml (STR)
templisthtml = Str
End Property
' ### #取得当前Pages数
Public Property Let Pages (Num)
Lngpages = CLng (Num)
If Lngpages < 1 Then lngpages = 1
End Property
' ### #取得PageSize数
Public Property Let PageSize (Num)
Intpagesize = CInt (Num)
End Property
' ### #取得Table字符
Public Property Let Tablestr (STR)
Strtablestr = Str
End Property
' ### #取得field字符
Public Property Let Fieldstr (STR)
Strfieldstr = Str
' If Trim (STRFIELDSTR) = "" Then strfieldstr = "*"
End Property
' ### #取得field字符长度
Public Property Let Fieldlen (STR)
Strfieldlen = Str
End Property
' ### #取得Where条件字符
Public Property Let Wherestr (STR)
If Len (Trim (STR)) >= 3 Then
Strwherestr = "Where" &trim (STR)
Else
Strwherestr = ""
End If
End Property
' ### #取得Order方式
Public Property Let Ordermode (Num)
If CInt (Num) = 0 Then
Intordermode = "ASC"
Else
Intordermode = "Desc"
End If
End Property
' ### #取得主键字段
Public Property Let Keyfield (STR)
Strkeyfield = Trim (STR)
If Strkeyfield = "" Then Strkeyfield = "Id"
End Property
' ### #是否过滤HTML代码
Public Property Let textfromhtml (Num)
inttextfromhtml = Cint (Num)
If inttextfromhtml <> 1 Then inttextfromhtml = 0
End Property
' ### #取得加红关键字
Public Property Let Redword (STR)
Strredword = Str
End Property
' ### #取得加红关键字控制
Public Property Let Redwordcontrol (STR)
Strredwordcontrol = Str
End Property
' ### #分页辨识名称
Private Function Pageacname ()
Strpageacname = Server.URLEncode (strtablestr) & Server.URLEncode (STRWHERESTR) & Server.URLEncode ( Intordermode)
Pageacname = strpageacname & "Kangk"
End Function
' ### #截取字符指定长度
Private Function Keeplen (str,lens)
If len (str) >lens Then
Keeplen=left (str,lens) & "..."
Else
Keeplen=str
End If
End Function
Public Function gettextfromhtml (strhtml)
Dim strpatrn
Strpatrn= "<.*?>"
Dim regEx
Set regEx = New RegExp
Regex.pattern = strpatrn
Regex.ignorecase = True
Regex.global = True
gettextfromhtml = Regex.Replace (strHTML, "")
End Function
End Class
'#################################################
' Face page jump link function '
' Incoming: Class ID, current page number, total number of records, total paging, number of pages displayed
'#################################################
Function Plink (Cid,pages,pcount,pnum,shownum)
Dim tmphtml
Dim I,pagestart,pageend
Dim showp,shows
SHOWP = Shownum ' Show number of pages
Shows = CInt ((ShowP-1)/2)
tmphtml = ""
tmphtml = "Total <b>" &PCount& "</b> Strip/<b>" &PNum& "</b> page "
tmphtml = tmphtml & "Currently <b>" &Pages& "</b> page "
tmphtml = tmphtml & "<a href=" "cid=" &cId& "&pages=1" "> front page </a>"
tmphtml = tmphtml & "<a href=" "cid=" &cId& "&pages=" &Pages-1& "" > previous page </a> "
If Pages < shows Then
Pagestart = 1
Pageend = SHOWP
ElseIf Pages > Pnum-showp Then
Pagestart = PNUM-SHOWP
Pageend = Pnum
Else
Pagestart = Pages-shows
Pageend = Pages + Shows
End If
For i = Pagestart to Pageend
If i > Pnum Then Exit for
If i = Pages Then
tmphtml = tmphtml & "<a href=" "cid=" &cId& "&pages=" &i& "" ><font color= "" #FF0000 " ><b> "&i&" </b></font></a> "
Else
tmphtml = tmphtml & "<a href=" "cid=" &cId& "&pages=" &i& "" ><b> "&i&" </ B></a> "
End If
Next
tmphtml = tmphtml & "<a href=" "cid=" &cId& "&pages=" &Pages+1& "" > next page </a> "
tmphtml = tmphtml & "<a href=" "cid=" &cId& "&pages=" &PNum& "" > Last page </a> "
tmphtml = tmphtml & " go to:"
tmphtml = tmphtml & "<input name=" "Pages" "type=" "Text" "Id=" "pages" "style=" "width:18px"; height:14px; border:1px solid #cccccc; "/><input name=" "Submit" "type=" "Submit" "id=" "Submit" "value=" "Go" "style=" "width : 18px; height:18px; border:1px solid #cccccc; "onclick=" "window.location=" "cid=" &cId& "&pages=" +pages.value "/>"
Plink = tmphtml
End Function
%>