ASP tutorial-Generate static HTML file instance code
<%
'======================================================
' File name: inc/clstempindex.asp
' File function: Home class
' Last Updated: 2008.08.10
'======================================================
Class Cls_tempindex
Public origintempcontent,tempcontent
'****************************
' Function name: CreateIndex
' Function: Generate Home
' Parameters: None
' Return Value: Home page
'****************************
Function CreateIndex ()
' Read template file contents
Origintempcontent = Clstempmain.fetchtempcontent (Server.MapPath ("...). /template/template_index.html "))
Tempcontent = Origintempcontent
'//execute static label
Tempcontent = Clstempmain.getmainlabel (tempcontent)
' Execute internal function tag
Tempcontent = Productlabel (tempcontent)
Tempcontent = Caselabel (tempcontent)
'//Replace public label
Tempcontent = Clstempmain.getconfiglabel (tempcontent)
' Generate page
Clsmain.createfile Server.MapPath (".. /"&" index. " &htmtype), Tempcontent
Response.Write ("<div align= ' center ' ><a href= '). /"&" index. " &HtmType& "' target= ' blank ' > First generation completed </a></div>")
End Function
'****************************
' Function name: Productlabel
' Function: Product information
' Parameters: label_templatecontent--Content
' Return value: Label content
' Call format {$Site. indexproduct (class=0,num=6,td=3,width=165,height=180)/}
'****************************
Function Productlabel (label_templatecontent)
If not Clsmain.ischar (label_templatecontent) Then
Exit Function
End If
Dim sp_tempcontent,item_tempcontent,sploop_tempcontent,loop_tempcontent,loop_content
If InStr (Label_templatecontent, "{$Site. Indexproduct (") >0 Then
Sp_tempcontent = Split (Label_templatecontent, "{$Site. Indexproduct (") (1)
If InStr (Sp_tempcontent, ")/}") >0 Then
' Get the parameters
Item_tempcontent = Split (Sp_tempcontent, ")/}") (0)
' Returns the result
Loop_content = Productcontent (item_tempcontent)
' Replace template label
Label_templatecontent = Replace (Label_templatecontent, "{$Site. Indexproduct (" &item_TempContent& ")/}", loop _content)
' Handle multiple identical function tags
Label_templatecontent = Productlabel (label_templatecontent)
End If
End If
Productlabel = Label_templatecontent
End Function
'****************************
' Function name: productcontent
' Function: Execute product Information Cycle section
' Parameters: L_templateitem--parameters
' Return value: Label content
' Call format {$Site. indexproduct (class=0,num=6,td=3,width=165,height=180,l_lentitle=10)/}
' Loop template {$TrLoop} {$Loop} {/loop} {/trloop}
'****************************
Function productcontent (L_templateitem)
If not Clsmain.ischar (L_templateitem) Then
Exit Function
End If
Dim mb_tempcontent,l_classid,l_num,l_td,l_width,l_height,arr_item,result_content
Dim sp_starttr,start_tr,sp_endtr,end_tr,l_lentitle,sp_looptempcontent,loop_tempcontent
Dim l_sql,l_rs
Arr_item = Split (L_templateitem, ",")
L_classid = Clsmain.getitem (Arr_item (0), "classid=")
L_num = Clsmain.getitem (Arr_item (1), "num=")
L_TD = Clsmain.getitem (Arr_item (2), "td=")
L_width = Clsmain.getitem (Arr_item (3), "width=")
L_height = Clsmain.getitem (Arr_item (4), "height=")
L_lentitle = Clsmain.getitem (Arr_item (5), "lentitle=")
If not Clsmain.isnumber (l_num) Then
L_num = 8
End If
' Read loop template
Mb_tempcontent = Clstempmain.fetchtempcontent (Server.MapPath ("...). /template/label_index_product.html "))
' Determine if there is a cyclic label
If InStr (Mb_tempcontent, "{$Loop}") = "" Then
Productcontent = "The system could not find the template."
Exit Function
End If
' Process loop template tr tag
If InStr (Mb_tempcontent, "{$TrLoop}") >0 Then
Sp_starttr = Split (Mb_tempcontent, "{$TrLoop}") (1)
' Get started logo
START_TR = Split (Sp_starttr, "{$Loop}") (0)
' End identification
SP_ENDTR = Split (Sp_starttr, "{$Loop}") (1)
END_TR = Split (Sp_endtr, "{/loop}") (1)
END_TR = Replace (End_tr, "{/trloop}", "")
Else
START_TR = ""
END_TR = ""
End If
' Read loop
Sp_looptempcontent = Split (Mb_tempcontent, "{$Loop}") (1)
Mb_looptemp = Split (Sp_looptempcontent, "{/loop}") (0)
If l_classid<>0 Then
L_sql = l_sql & "Select top" &l_Num& "* from [Jkms_product] Where (classid=" &l_ClassID& "" &clstemp Main.getclschild ("Jkms_productclass", L_classid)
L_sql = l_sql & ")"
Else
L_sql = "SELECT Top" &l_Num& "* from [jkms_product] Where 1=1"
End If
L_sql = L_sql & "and Flag=1"
L_sql = L_sql & "ORDER by ProductID Desc"
Set l_rs = Server.CreateObject (rsobj)
L_rs.open l_sql,conn,1,1
II_TR = L_num Mod l_td
II = 1
If start_tr <> "" Then
Result_content = Start_tr
End If
Do as not l_rs.eof
L_productid = L_rs ("ProductID")
L_productname = L_rs ("ProductName")
L_intro = L_rs ("Intro")
L_thumbfiles = L_rs ("Thumbfiles")
L_uploadfiles = L_rs ("Uploadfiles")
L_productheight = L_rs ("Productheight")
L_productprice = L_rs ("Productprice")
L_productposition = L_rs ("Productposition")
L_filename = L_rs ("FileName")
L_filenameext = L_rs ("Filenameext")
L_classid = L_rs ("ClassID")
L_classname = Clscommon.gettext ("Select ClassName from [Jkms_productclass] Where c_id=" &l_ClassID& ")
L_parentclassid = Clscommon.gettext ("Select Classparent from [Jkms_productclass] Where c_id=" &l_ClassID& ")
If l_parentclassid=0 Then
L_parentclassid = L_classid
End If
L_parentclassname = Clscommon.gettext ("Select ClassName from [Jkms_productclass] Where c_id=" &l_parentclassid& ;"")
L_url = installdir&productdir&l_filename& "." &l_filenameext
L_classurl = installdir&productdir& "List_" &l_ClassID& "_1." &htmtype
L_parenturl = installdir&productdir& "List_" &l_ParentClassID& "_1." &htmtype
If Int (Len (l_productname)) >int (L_lentitle) Then
L_productname = Left (l_productname,l_lentitle) & "..."
End If
Loop_tempcontent = Mb_looptemp
'//Replace label
Loop_tempcontent = Clsmain.replaceitem (Loop_tempcontent, "{$ProductID/}", L_productid)
Loop_tempcontent = Clsmain.replaceitem (Loop_tempcontent, "{$ClassName/}", L_classname)
Loop_tempcontent = Clsmain.replaceitem (Loop_tempcontent, "{$ProductName/}", L_productname)
Loop_tempcontent = Clsmain.replaceitem (Loop_tempcontent, "{$Intro/}", L_intro)
Loop_tempcontent = Clsmain.replaceitem (Loop_tempcontent, "{$UploadFiles/}", L_uploadfiles)
Loop_tempcontent = Clsmain.replaceitem (Loop_tempcontent, "{$ThumbFiles/}", L_thumbfiles)
Loop_tempcontent = Clsmain.replaceitem (Loop_tempcontent, "{$Url/}", L_url)
Loop_tempcontent = Clsmain.replaceitem (Loop_tempcontent, "{$ClassUrl/}", L_classurl)
Loop_tempcontent = Clsmain.replaceitem (Loop_tempcontent, "{$ParentClassUrl/}", L_parenturl)
Loop_tempcontent = Clsmain.replaceitem (Loop_tempcontent, "{$ParentClassName/}", L_parentclassname)
Loop_tempcontent = Clsmain.replaceitem (Loop_tempcontent, "{$ProductHeight/}", L_productheight)
Loop_tempcontent = Clsmain.replaceitem (Loop_tempcontent, "{$ProductPrice/}", L_productprice)
Loop_tempcontent = Clsmain.replaceitem (Loop_tempcontent, "{$ProductPosition/}", L_productposition)
Loop_tempcontent = Clsmain.replaceitem (Loop_tempcontent, "{$Width/}", L_width)
Loop_tempcontent = Clsmain.replaceitem (Loop_tempcontent, "{$Height/}", L_height)
Result_content = result_content & loop_tempcontent
If start_tr <> "" Then
If (ii Mod l_td) =0 Then
Result_content = result_content & end_tr & START_TR
End If
End If
II = II + 1
L_rs.movenext
Loop
L_rs.close
Set l_rs = Nothing
If start_tr <> "" Then
Result_content = result_content & end_tr
End If
Productcontent = Result_content
End Function
'****************************
' Function name: Caselabel
' Role: Case information
' Parameters: label_templatecontent--Content
' Return value: Label content
' Call format {$Site. Indexcase (class=0,num=6,td=3,width=165,height=180)/}
'****************************
Function Caselabel (label_templatecontent)
If not Clsmain.ischar (label_templatecontent) Then
Exit Function
End If
Dim sp_tempcontent,item_tempcontent,sploop_tempcontent,loop_tempcontent,loop_content
If InStr (Label_templatecontent, "{$Site. Indexcase (") >0 Then
Sp_tempcontent = Split (Label_templatecontent, "{$Site. Indexcase (") (1)
If InStr (Sp_tempcontent, ")/}") >0 Then
' Get the parameters
Item_tempcontent = Split (Sp_tempcontent, ")/}") (0)
' Returns the result
Loop_content = Casecontent (item_tempcontent)
' Replace template label
Label_templatecontent = Replace (Label_templatecontent, "{$Site. Indexcase (" &item_TempContent& ")/}", Loop_ Content)
' Handle multiple identical function tags
Label_templatecontent = Caselabel (label_templatecontent)
End If
End If
Caselabel = Label_templatecontent
End Function
'****************************
' Function name: casecontent
' Role: Execution case Information Cycle section
' Parameters: L_templateitem--parameters
' Return value: Label content
' Call format {$Site. Indexcase (class=0,num=6,td=3,width=165,height=180,l_lentitle=10)/}
' Loop template {$TrLoop} {$Loop} {/loop} {/trloop}
'****************************
Function casecontent (L_templateitem)
If not Clsmain.ischar (L_templateitem) Then
Exit Function
End If
dim mb_tempcontent,l_classid,l_num,l_td,l_width,l_height,arr_item,result_content
Dim sp_starttr,start_tr,sp_endtr,end_tr,l_lentitle,sp_looptempcontent,loop_tempcontent
Dim L_SQL, L_rs
arr_item = Split (L_templateitem, ",")
l_ClassID = Clsmain.getitem (Arr_item (0), "classid=")
l_Num = Clsmain.getitem (Arr_item (1), "num=")
l_Td = Clsmain.getitem (Arr_item (2), "td=")
l_Width = Clsmain.getitem (Arr_item (3), "Width=")
l_Height = Clsmain.getitem (Arr_item (4), "height=")
l_ lentitle = Clsmain.getitem (Arr_item (5), "lentitle=")
If not Clsmain.isnumber (l_num) Then
L_num = 8
End If
' Read loop template
Mb_tempcontent = Clstempmain.fetchtempcontent (Server.MapPath ("...). /template/label_index_case.html "))
' Determine if there is a cyclic label
If InStr (Mb_tempcontent, "{$Loop}") = "" Then
Casecontent = "The system could not find the template."
Exit Function
End If
' Process loop template tr tag
If InStr (Mb_tempcontent, "{$TrLoop}") >0 Then
Sp_starttr = Split (Mb_tempcontent, "{$TrLoop}") (1)
' Get started logo
START_TR = Split (Sp_starttr, "{$Loop}") (0)
' End identification
SP_ENDTR = Split (Sp_starttr, "{$Loop}") (1)
END_TR = Split (Sp_endtr, "{/loop}") (1)
END_TR = Replace (End_tr, "{/trloop}", "")
Else
START_TR = ""
END_TR = ""
End If
' Read loop
Sp_looptempcontent = Split (Mb_tempcontent, "{$Loop}") (1)
Mb_looptemp = Split (Sp_looptempcontent, "{/loop}") (0)
L_sql = "SELECT Top" &l_Num& "* from [jkms_case] Where flag=1"
If l_classid<>0 Then
L_sql = L_sql & "and classid=" &l_ClassID& ""
End If
L_sql = L_sql & "ORDER by Caseid Desc"
Set l_rs = Server.CreateObject (rsobj)
L_rs.open l_sql,conn,1,1
II_TR = L_num Mod l_td
II = 1
If start_tr <> "" Then
Result_content = Start_tr
End If
do While not l_rs.eof
l_CaseID = L_rs ("Caseid")
l_Title = L_rs ("Title")
l_ThumbFiles = l_rs ("Thumbfiles")
l_UploadFiles = L_rs ("Uploadfiles")
l_productheight = L_rs (" Productheight ")
l_ProductPosition = l_rs (" productposition ")
l_ filename = L_rs ("FileName")
l_FileNameExt = L_rs (" Filenameext ")
l_ClassID = l_rs (" ClassID ")
l_ClassName = Clscommon.gettext ("Select ClassName from [Jkms_caseclass] Where C_ Id= "&l_ClassID&")
L_parentclassid = Clscommon.gettext ("Select Classparent from [Jkms_caseclass] Where c_id=" &l_ClassID& ")
If l_parentclassid=0 Then
L_parentclassid = L_classid
End If
L_parentclassname = Clscommon.gettext ("Select ClassName from [Jkms_caseclass] Where c_id=" &l_ParentClassID& " )
L_url = installdir&casedir&l_filename& "." &l_filenameext
L_classurl = installdir&casedir& "List_" &l_ClassID& "_1." &htmtype
L_parentclassurl = installdir&casedir& "List_" &l_ClassID& "_1." &htmtype
If not Clsmain.ischar (l_productheight) Then
L_productheight = ""
End If
If Int (Len (L_title)) >int (L_lentitle) Then
L_title = Left (l_title,l_lentitle) & "..."
End If
Loop_tempcontent = Mb_looptemp
'//Replace label
Loop_tempcontent = Clsmain.replaceitem (Loop_tempcontent, "{$CaseIDID/}", L_caseid)
Loop_tempcontent = Clsmain.replaceitem (Loop_tempcontent, "{$Title/}", L_title)
Loop_tempcontent = Clsmain.replaceitem (Loop_tempcontent, "{$ClassName/}", L_classname)
Loop_tempcontent = Clsmain.replaceitem (Loop_tempcontent, "{$UploadFiles/}", L_uploadfiles)
Loop_tempcontent = Clsmain.replaceitem (Loop_tempcontent, "{$ThumbFiles/}", L_thumbfiles)
Loop_tempcontent = Clsmain.replaceitem (Loop_tempcontent, "{$Url/}", L_url)
Loop_tempcontent = Clsmain.replaceitem (Loop_tempcontent, "{$ClassUrl/}", L_classurl)
Loop_tempcontent = Clsmain.replaceitem (Loop_tempcontent, "{$ParentClassUrl/}", L_parentclassurl)
Loop_tempcontent = Clsmain.replaceitem (Loop_tempcontent, "{$ParentClassName/}", L_parentclassname)
Loop_tempcontent = Clsmain.replaceitem (Loop_tempcontent, "{$ProductHeight/}", L_productheight)
Loop_tempcontent = Clsmain.replaceitem (Loop_tempcontent, "{$ProductPosition/}", L_productposition)
Loop_tempcontent = Clsmain.replaceitem (Loop_tempcontent, "{$Width/}", L_width)
Loop_tempcontent = Clsmain.replaceitem (Loop_tempcontent, "{$Height/}", L_height)
Result_content = result_content & loop_tempcontent
If start_tr <> "" Then
If (ii Mod l_td) =0 Then
Result_content = result_content & end_tr & START_TR
End If
End If
II = II + 1
L_rs.movenext
Loop
L_rs.close
Set l_rs = Nothing
If start_tr <> "" Then
Result_content = result_content & end_tr
End If
Casecontent = Result_content
End Function
End Class
%>