📄 cls_asptemplate.asp
字号:
<%
'==============================================================================
'软件名称:拓网文件上传提取系统
'当前版本:拓网文件上传提取系统1.0(TopWang Upload V1.0)
'Copyright (C) 2003-2006 TopWang.Com All rights reserved.
'产品咨询QQ:36355735
'程序开发:拓网产品开发组
'Email:Service@TopWang.Com
'官方网站:www.TopWang.com
'论坛支持:拓网在线论坛(http://bbs.TopWang.com)
'免费版本请在程序首页保留版权信息,并做上本站LOGO友情连接
'==============================================================================
'==============================================================================
'文件名:Cls_AspTemplate.asp
'摘 要:系统模板类
'作 者:Valerio Santinelli
'更 新:2006-2-10
'==============================================================================
' ASP Template 1.2.1
' Copyright (C) 2001-2004 Valerio Santinelli
'
' This library is free software; you can redistribute it and/or
' modify it under the terms of the GNU Lesser General Public
' License as published by the Free Software Foundation; either
' version 2.1 of the License, or (at your option) any later version.
'
' This library is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
' Lesser General Public License for more details.
'
' You should have received a copy of the GNU Lesser General Public
' License along with this library; if not, write to the Free Software
' Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
'
' ---------------------------------------------------------------------------
'
' ASP Template main class file
'
' Author: Valerio Santinelli <tanis@altralogica.it>
' $Id: asptemplate.asp,v 1.18 2004/11/10 23:23:31 tanis Exp $
'
'===============================================================================
' Name: ASPTemplate Class
' Purpose: HTML separation class
' Functions:
' <functions' list in alphabetical order>
' Properties:
' <properties' list in alphabetical order>
' Methods:
' <Methods' list in alphabetical order>
' Author: Valerio Santinelli <tanis@mediacom.it>
' Start: 2001/01/01
' Modified: 2001/12/19
'===============================================================================
class Cls_ASPTemplate
' Contains the error objects
private p_error
' Print error messages?
private p_print_errors
' What to do with unknown tags (keep, remove or comment)?
private p_unknowns
' Opening delimiter (usually "{{")
private p_var_tag_o
' Closing delimiter (usually "}}")
private p_var_tag_c
'private p_start_block_delimiter_o
'private p_start_block_delimiter_c
'private p_end_block_delimiter_o
'private p_end_block_delimiter_c
'private p_int_block_delimiter
private p_template
private p_variables_list
private p_blocks_list
private p_blocks_name_list
private p_regexp
private p_parsed_blocks_list
private p_boolSubMatchesAllowed
' Directory containing HTML templates
private p_templates_dir
'===============================================================================
' Name: class_Initialize
' Purpose: Constructor
' Remarks: None
'===============================================================================
private sub class_Initialize
p_print_errors = FALSE
p_unknowns = "keep"
' Remember that opening and closing tags are being used in regular expressions
' and must be explicitly escaped
p_var_tag_o = "\{\{"
p_var_tag_c = "\}\}"
' Block delimiters are actually disabled and no longer available. Maybe they'll be again
' in the future.
'p_start_block_delimiter_o = "<!-- BEGIN "
'p_start_block_delimiter_c = " -->"
'p_end_block_delimiter_o = "<!-- END "
'p_end_block_delimiter_c = " -->"
'p_int_block_delimiter = "__"
p_templates_dir = ""
set p_variables_list = createobject(ServerObject_004)
set p_blocks_list = createobject(ServerObject_004)
set p_blocks_name_list = createobject(ServerObject_004)
set p_parsed_blocks_list = createobject(ServerObject_004)
p_template = ""
p_boolSubMatchesAllowed = not (ScriptEngineMajorVersion & "." & ScriptEngineMinorVersion & "." & ScriptEngineBuildVersion < "5.5")
Set p_regexp = New RegExp
end sub
'===============================================================================
' Name: SetTemplatesDir
' Input:
' dir as Variant Directory
' Output:
' Purpose: Sets the directory containing html templates
' Remarks: None
'===============================================================================
public sub SetTemplatesDir(dir)
p_templates_dir = dir
end sub
'===============================================================================
' Name: SetTemplate
' Input:
' template as Variant String containing the template
' Output:
' Purpose: Sets a template passed through a string argument
' Remarks: None
'===============================================================================
public sub SetTemplate(template)
p_template = template
end sub
'===============================================================================
' Name: GetTemplate
' Input:
' Output:
' template as Variant String
' Purpose: returns template as a string
' Remarks: None
'===============================================================================
public function GetTemplate
GetTemplate = p_template
end function
'===============================================================================
' Name: SetUnknowns
' Input:
' action as String containing the action to perform with unrecognized
' tags in the template
' Output:
' Purpose: Sets a variable passed through a string argument
' Remarks: The action can be one of the following:
' - 'keep': leave the tags untouched
' - 'remove': remove the tags from the output
' - 'comment': mark the tags as HTML comment
'===============================================================================
public sub SetUnknowns(action)
if (action <> "keep") and (action <> "remove") and (action <> "comment") then
p_unknowns = "keep"
else
p_unknowns = action
end if
end sub
'===============================================================================
' Name: SetTemplateFile
' Input:
' inFileName as Variant Name of the file to read the template from
' Output:
' Purpose: Sets a template given the filename to load the template from
' Remarks: None
'===============================================================================
private Stream
public sub SetTemplateFile(inFileName)
Err.Clear
On Error Resume Next
Set Stream = Server.CreateObject(ServerObject_003)
With Stream
.Mode = 3
.Type = 2
.Open
.LoadFromFile(Server.Mappath(p_templates_dir & inFileName))
p_template = Bytes2bStr(.ReadText)
.Close
End With
Set Stream = Nothing
If Err Then
SysMsg=inFileName&": 模板加载出错<br>"&Err.Description
Call ClsPub.ShowMsg("Back","")
End If
end sub
Private Function Bytes2bStr(ByVal vin)
'二进制转换为字符串
if lenb(vin) =0 then
Bytes2bStr = ""
exit function
end if
Dim BytesStream,StringReturn
Set BytesStream = Server.CreateObject(ServerObject_003)
BytesStream.Type = 2
BytesStream.Open
BytesStream.WriteText vin
BytesStream.Position = 0
BytesStream.Charset = "gb2312"
BytesStream.Position = 2
StringReturn = BytesStream.ReadText
BytesStream.close
Set BytesStream = Nothing
Bytes2bStr = StringReturn
End Function
Public Function IsTagExists(s)
Dim Temp
if p_variables_list.Exists(s) then
Temp=True
else
Temp=False
end if
IsTagExists
End Function
'===============================================================================
' Name: SetVariable
' Input:
' s as Variant - Variable name
' v as Variant - Value
' Output:
' Purpose: Sets a variable given it's name and value
' Remarks: None
'===============================================================================
public sub SetVariable(s, v)
if p_variables_list.Exists(s) then
p_variables_list.Remove s
p_variables_list.Add s, v
else
p_variables_list.Add s, v
end if
end sub
'===============================================================================
' Name: Append
' Input:
' s as Variant - Variable name
' v as Variant - Value
' Output:
' Purpose: Sets a variable appending the new value to the existing one
' Remarks: None
'===============================================================================
public sub Append(s, v)
Dim tmp
if p_variables_list.Exists(s) then
tmp = p_variables_list.Item(s) & v
p_variables_list.Remove s
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -