最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp教程-生成静态html文件实例代码
时间:2022-07-02 23:08:20 编辑:袖梨 来源:一聚教程网
asp教程-生成静态html文件实例代码
<%
'======================================================
' 文件名称 : inc/ClsTempIndex.asp
' 文件作用 : 首页类
' 最后更新 : 2008.08.10
'======================================================
Class Cls_TempIndex
Public OriginTempContent,TempContent
'****************************
'函数名: CreateIndex
'作 用: 生成首页
'参 数: 无
'返回值: 首页页面
'****************************
Function CreateIndex()
'读取模版文件内容
OriginTempContent = ClsTempMain.FetchTempContent(Server.MapPath("../template/template_Index.html"))
TempContent = OriginTempContent
'//执行静态标签
TempContent = ClsTempMain.GetMainLabel(TempContent)
'执行内部函数标签
TempContent = ProductLabel(TempContent)
TempContent = CaseLabel(TempContent)
'//替换公共标签
TempContent = ClsTempMain.GetConfigLabel(TempContent)
'生成页面
ClsMain.CreateFile Server.MapPath("../"&"index."&HtmType),TempContent
Response.Write( "
End Function
'****************************
'函数名: ProductLabel
'作 用: 产品信息
'参 数: label_templateContent -- 内容
'返回值: 标签内容
'调用格式 {$Site.IndexProduct(class=0,num=6,td=3,,)/}
'****************************
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
'取得参数
item_TempContent = Split(sp_TempContent,")/}")(0)
'返回结果
loop_Content = ProductContent(item_TempContent)
'替换模板标签
label_templateContent = Replace(label_templateContent,"{$Site.IndexProduct("&item_TempContent&")/}",loop_Content)
'处理多个相同函数标签
label_templateContent = ProductLabel(label_templateContent)
End If
End If
ProductLabel = label_templateContent
End Function
'****************************
'函数名: ProductContent
'作 用: 执行产品信息循环部分
'参 数: l_templateItem -- 参数
'返回值: 标签内容
'调用格式 {$Site.IndexProduct(class=0,num=6,td=3,,,l_LenTitle=10)/}
'循环模板 {$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
'读取循环模板
mb_TempContent = ClsTempMain.FetchTempContent(Server.MapPath("../template/Label_Index_Product.html"))
'判断是否有循环标签
If InStr(mb_TempContent,"{$Loop}") = "" Then
ProductContent = "系统找不到模板."
Exit Function
End If
'处理循环模板 tr标记
If InStr(mb_TempContent,"{$TrLoop}")>0 Then
sp_StartTr = Split(mb_TempContent,"{$TrLoop}")(1)
'取得开始标识
start_Tr = Split(sp_StartTr,"{$Loop}")(0)
'结束标识
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
'读取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&""&ClsTempMain.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 While 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_ProductProductHeight")
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
'//替换标签
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
'****************************
'函数名: CaseLabel
'作 用: 案例信息
'参 数: label_templateContent -- 内容
'返回值: 标签内容
'调用格式 {$Site.IndexCase(class=0,num=6,td=3,,)/}
'****************************
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
'取得参数
item_TempContent = Split(sp_TempContent,")/}")(0)
'返回结果
loop_Content = CaseContent(item_TempContent)
'替换模板标签
label_templateContent = Replace(label_templateContent,"{$Site.IndexCase("&item_TempContent&")/}",loop_Content)
'处理多个相同函数标签
label_templateContent = CaseLabel(label_templateContent)
End If
End If
CaseLabel = label_templateContent
End Function
'****************************
'函数名: CaseContent
'作 用: 执行案例信息循环部分
'参 数: l_templateItem -- 参数
'返回值: 标签内容
'调用格式 {$Site.IndexCase(class=0,num=6,td=3,,,l_LenTitle=10)/}
'循环模板 {$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
'读取循环模板
mb_TempContent = ClsTempMain.FetchTempContent(Server.MapPath("../template/Label_Index_Case.html"))
'判断是否有循环标签
If InStr(mb_TempContent,"{$Loop}") = "" Then
CaseContent = "系统找不到模板."
Exit Function
End If
'处理循环模板 tr标记
If InStr(mb_TempContent,"{$TrLoop}")>0 Then
sp_StartTr = Split(mb_TempContent,"{$TrLoop}")(1)
'取得开始标识
start_Tr = Split(sp_StartTr,"{$Loop}")(0)
'结束标识
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
'读取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_ProductProductHeight")
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_Product
End If
If Int(Len(l_Title))>Int(l_LenTitle) Then
l_Title = Left(l_Title,l_LenTitle)&"..."
End If
loop_tempContent = mb_LoopTemp
'//替换标签
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
%>
相关文章
- 世界之外易遇生日活动怎么玩 12-23
- 无期迷途空条徐伦什么时候复刻 12-23
- 无期迷途黛伦蝶之影怎么样 12-23
- 无期迷途空条承太郎什么时候up 12-23
- 无期迷途艾梅斯怎么样 12-23
- 阴阳师小袖之手幽篁流影怎么样 12-23