解答|問題 1.'功能: 過慮HTML字元
'輸入:字串
'輸出:經格式化後的字串
function HTMLEncode(fString)
if not isnull(fString) then
fString = replace(fString, ">", ">")
fString = replace(fString, "<", "<")
fString = Replace(fString, CHR(32)&CHR(32), " ")
fString = Replace(fString, CHR(9), " ")
fString = Replace(fString, CHR(34), """)
fString = Replace(fString, CHR(39), "'")
fString = Replace(fString, CHR(13), "")
fString = Replace(fString, CHR(10) & CHR(10), "</P><P> ")
fString = Replace(fString, CHR(10), "<BR> ")
HTMLEncode = fString
end if
end function
2.分頁類
'參數:系統(如:product,article),條件(如果是數值,則預設為categoryID的值),排序,
'每頁顯示記錄數,模式(more:顯示更多字樣,page:顯示翻頁導航),
'翻頁導航模式(number:顯示數字,page:顯示上一頁,下一頁),記錄顯示模版名(顯示記錄的過程名)
class List
dim p_system'系統資料表,如tblProduct,tblArticle
dim p_where'條件
dim p_orderBy'排序
dim p_recordCount'每頁顯示記錄數
dim p_horizontal'每行顯示記錄數
dim p_mode'列表模式,參數:more(更多模式,顯示更多字樣),page(列表模式,顯示翻頁導航)
dim p_moreURL'更多模式時的URL
dim p_paginationMode'翻頁導航模式,參數:number(數字導航,顯示如:1,2,3,4),page(翻頁導航,顯示如:上一頁,下一頁)
dim p_models'列表模版過程
dim p_table'列表的table標籤
dim p_page'頁碼
dim p_member'是否顯示會員產品
dim p_groupWhere
Private Sub Class_Initialize
p_system=""
p_where=""
p_orderBy=" order by categoryID,orderBy,postdate"
p_recordCount=15
p_horizontal=4
p_mode=""
p_moreURL=""
p_paginationMode="page"
p_models=""
p_table="<table width=100% border=0 align=center cellpadding=0 cellspacing=0 bordercolor=#CCCCCC style='border-collapse: collapse'>"
p_page=1
p_member=false
p_groupWhere="groupID=0"
End Sub
Property Let system(value)
p_system=value
end property
Property Let where(value)
if isInt(value) then
p_where=" where categoryID="&value
else
p_where=" where ("&value&")"
end if
end property
Property Let orderBy(value)
p_orderBy=" order by "&value
end property
Property Let recordCount(value)
p_recordCount=value
end property
Property Let horizontal(value)
p_horizontal=value
end property
Property Let mode(value)
p_mode=value
end property
Property Let moreURL(value)
p_moreURL=value
end property
Property Let paginationMode(value)
p_paginationMode=value
end property
Property Let models(value)
p_models=value
end property
Property Let table(value)
p_table=value
end property
Property Let page(value)
if getNumeric(value)<1 then
p_page=1
else
p_page=int(value)
end if
end property
Property Let member(value)
p_member=value
if p_member then
authorizationID=getValue("tblMember","authorizationID","memberID="&session("memberID"))
if authorizationID="" or authorizationID=0 then
authorizationID=getValue("tblGroup","authorizationID","groupID="&session("groupID"))
end if
virtual=getValue("tblAuthorization","virtual","authorizationID="&authorizationID)
authArr=split(virtual,",")
for i=0 to ubound(authArr)
if i=0 then
p_groupWhere="groupID="&getValue("tblGroup","groupID","authorizationID="&authArr(i))
else
p_groupWhere=p_groupWhere&" or groupID="&getValue("tblGroup","groupID","authorizationID="&authArr(i))
end if
next
else
p_groupWhere="groupID=0"
end if
end property
'列表過程
public sub List()
dim rs
dim where
if p_where="" then
where=" where "&p_groupWhere&" and publish=1"
else
where=p_where&" and ("&p_groupWhere&") and publish=1"
end