%
class FaqToc
public mComponentId
public mComponentName
public mXmlPropFile
public mLangFile
private mIsDebugMode
private mRankStar
private mPrefix
private mNextPage
private mShowDetailes
private mSitePath
private mScriptsDirName
private mRelPathToRoot
private mConstraint
private mErrorMessage
private mFaqFilePath
private mCategoryFilePath
private mRankFilePath
private mCategoryRs
private mFaqTableHead
private mRankTableHead
private mCategoryTableHead
'request variables
private mReqAct
private sub Class_Initialize
on error resume next
set mErrorObject = Server.CreateObject("Scripting.Dictionary")
mErrorObject.Add "Code", 0
mErrorObject.Add "Source", ""
mErrorObject.Add "Description", ""
set mCategoryRs = Server.CreateObject("ADODB.RecordSet")
if err.number <> 0 then
call err.Raise(910,"faq_toc.Class_Initialize", "Could not create the RecordSet object.")
exit sub
end if
mIsDebugMode = false
mRankStar = "
"
mNextPage = ""
mShowDetailes = false
mReqAct = ""
mSitePath = ""
mScriptsDirName = "scripts"
mRelPathToRoot = "./"
mCategoryTableHead = "Id,Name,Description"
mConstraint = ""
if Request.Form("toc_question").Item <> "" then
mConstraint = Request.Form("toc_question").Item
elseif Request.QueryString("question").Item <> "" then
mConstraint = Request.QueryString("question").Item
end if
mErrorMessage = ""
end sub
private sub Class_Terminate
if mErrorMessage <> "" then Response.Write mErrorMessage
end sub
public function Initialize(ByVal sitePath, ByVal scriptDir, ByVal rootDir, ByVal debugMode)
on error resume next
Initialize = false
mSitePath = sitePath
mScriptsDirName = scriptDir
mRelPathToRoot = rootDir
mIsDebugMode = debugMode
mRankStar = Replace(mRankStar, "[[path]]", mRelPathToRoot & mScriptsDirName)
Dim xmlDoc
set xmlDoc = faqOpenXMLFile(mSitePath & mScriptsDirName & "\" & mXmlPropFile)
if xmlDoc is nothing then
if err.number = 0 then
call err.Raise ( 601, "faq_search.Initialize", faqGetLocaleString("Error.601", Array(mSitePath & mScriptsDirName & "\" & mXmlPropFile)) )
end if
call SetError(err)
exit function
end if
Dim ComponentNode
set ComponentNode = faqGetNode(xmlDoc,,"Component", Array("name","id"), Array(mComponentName, mComponentId), -1)
If ComponentNode Is Nothing Then
if err.number = 0 then
call err.Raise ( 400, "faq_search.Initialize", faqGetLocaleString("Error.400", Array(mComponentId)) )
end if
call SetError(err)
exit function
end if
mPrefix = faqGetProperty(ComponentNode, "dbPath")
if not inStr(1, mPrefix, "\", 1) > 0 then
Dim absPath, relPath
set relPath = nothing
set relPath = faqReFind(mPrefix, "\.\./")
absPath = mSitePath & mScriptsDirName
if not relPath is nothing then
if relPath.count > 0 then
for i=1 to relPath.count
absPath = Left(absPath, inStrRev(absPath,"\") - 1)
mPrefix = Replace(mPrefix, "../", "", 1, 1)
next
else
if inStr(1, mPrefix, "./") > 0 then
mPrefix = Replace(mPrefix, "./", "", 1, 1)
end if
end if
set relPath = nothing
end if
mPrefix = absPath & "\" & Replace(mPrefix, "/", "\")
end if
mNextPage = faqGetProperty(ComponentNode, "nextpage")
mShowDetailes = faqGetProperty(ComponentNode, "showdetailes")
if mShowDetailes <> "" then mShowDetailes = CBool(mShowDetailes)
set ComponentNode = nothing
set xmlDoc = nothing
mFaqFilePath = mPrefix & "FAQ.csv"
mCategoryFilePath = mPrefix & "category.csv"
mRankFilePath = mPrefix & "rank.csv"
if not faqFileExist(mCategoryFilePath) then
if not faqCreateDB(mCategoryFilePath, mCategoryTableHead) then
call SetError(err)
exit function
end if
end if
set mCategoryRs = faqRSFileContent(mCategoryFilePath, "")
if mCategoryRs is nothing then
call SetError(err)
exit function
end if
if err.number = 0 then Initialize = true
end function
public sub ShowToc()
Dim i
on error resume next
Response.Write "" & vbCrLf
Response.Write "
| " & vbCrLf & _ "" & faqGetLocaleString("faq.TOC.Label", null) & " (" & _ FaqCount(0) & ")" & vbCrLf & _ " |
| " & vbCrLf & _ "" & Trim(mCategoryRs.Fields("Name").Value) & _ " (" & FaqCount(Trim(mCategoryRs.Fields("Id").Value)) & ")" & vbCrLf & _ " |
| " & _ DecodeStr(Trim(mCategoryRs.Fields("Description").Value)) & " |
" & faqGetLocaleString("Error.Text.Generic", null) & "
" & _ "" & faqGetLocaleString("Error.Text.Code", null) & " " & errNumber & "
" end if errObj.Clear end sub private function FaqCount(ByVal DomainId) Dim cond, lRs on error resume next if DomainId <> "" and DomainId <> "0" then cond = "DomainId=" & DomainId set lRs = faqRSFileContent(mFaqFilePath, cond) FaqCount = lRs.RecordCount set lRs = nothing end function private function DecodeStr(ByVal str) dim s s = str s = Replace(s, "<", "<") s = Replace(s, ">", ">") s = Replace(s, """, """") s = Replace(s, "vbCrLf", "