当前位置:编程学习 > asp >>

aspTemplate : 类似 phpLib::Template 的分离层实现(续)

答案:这次加入了数据库模板功能 :)

<!-- METADATA TYPE="typelib" UUID="00000200-0000-0010-8000-00AA006D2EA4" NAME="ADO Type Library" -->

<%

'#######################################################################
'## NAME: aspTemplate
'## BY: BigHan
'## DATE: Nov. 28, 2003
'## SITE: http://aspTemplate.yeah.net/
'## EMAIL: aspTemplate@21cn.com
'##
'## (C) Copyright 2003-2004 bighan
'#######################################################################

'#######################################################################
'## Database Table: See db/aspTemplate.mdb
'#######################################################################


Class aspTemplate

'####
'## name of this class
'## var string
'## @access Private
'## @see property: Name
'####
Private m_strName

'####
'## version of this class
'## var string
'## @access Private
'## @see property: Version
'####
Private m_strVersion

'####
'## Determines how much debugging output Template will produce.
'## This is a bitwise mask of available debug levels:
'## 0 = no debugging
'## 1 = debug variable assignments
'## 2 = debug calls to get variable
'## 3 = debug SQL
'## 4 = debug internals (outputs all function calls with parameters).
'##
'## @var int
'## @access Private
'## @see property: Debug
'####
Private m_intDebug

'####
'## Template files data type
'##
'## "db" = Database
'## "file" = File
'##
'## @var string
'## @access private
'## @see property: Mode
'####
Private m_strMode

'####
'## The base directory from which template files are loaded.
'##
'## @var string
'## @access private
'## @see property: Root, Dir; method: SetRoot, set_root
'####
Private m_Root

'####
'## Determines how to output variable tags with no assigned value in templates.
'##
'## @var string
'## @access private
'## @see property Unknowns; method: SetUnknowns, set_unknowns
'####
Private m_strUnknowns

'####
'## Determines how Template handles error conditions.
'## "yes" = the error is reported, then execution is halted
'## "report" = the error is reported, then execution continues by returning "false"
'## "no" = errors are silently ignored, and execution resumes reporting "false"
'##
'## @var string
'## @access private
'## @see property IsHalt; method: halt
'####
Private m_strHaltError

'####
'## The last error message is retained in this variable.
'##
'## @var string
'## @access private
'## @see property LastError
'##
Private m_strLastError

'####
'## Opening delimiter (usually "{")
'##
'## @var string
'## @access private
'## @see property BeginTag
'####
Private m_strBeginTag

'####
'## Closing delimiter (usually "}")
'##
'## @var string
'## @access private
'## @see private EndTag
'####
Private m_strEndTag

'####
'## A hash of strings forming a translation table which translates variable names
'## into names of files containing the variable content.
'## m_oFile.Item(varname) = "filename";
'##
'## @var object
'## @access private
'## @see method: SetFile, SetFiles, set_file
'####
Private m_oFile

'####
'## Regular Expression Object
'##
'## @var object
'## @access private
'####
Private m_oRegExp

'####
'## A hash of strings forming a translation table which translates variable names
'## into regular expressions for themselves.
'## m_oVarKeys.Item(varname) = "{varname}"
'##
'## @var object
'## @access private
'## @see method: SetVar, SetVars, SetAppendVar, SetAppendVars, set_var
'####
Private m_oVarKeys

'####
'## A hash of strings forming a translation table which translates variable names
'## into values for their respective varkeys.
'## m_oVarVals.Item(varname) = "value"
'##
'## @var object
'## @access private
'## @see method: SetVar, SetVars, SetAppendVar, SetAppendVars, set_var
'####
Private m_oVarVals

'####
'## Connection Object, if this Mode = "db" the Connection Object need.
'##
'## @var object
'## @access private
'## @see property: ActiveConnection, method: OpenTemplateDatabase, CloseTemplateDatabase
'####
Private m_oConn

'####
'## Is native connection object.
'##
'## @var object
'## @access private
'## @see property: ActiveConnection, method: OpenTemplateDatabase, CloseTemplateDatabase
'####
Private m_blnNativeConnection

'####
'## Is Open connection object.
'##
'## @var object
'## @access private
'## @see property: ActiveConnection, method: OpenTemplateDatabase, CloseTemplateDatabase
'####
Private m_blnConnectionState

'####
'## Template database set table name.
'##
'## @var string
'## @access private
'## @see property: CatTable
'####
Private m_strCatTable

'####
'## Template database data table name.
'##
'## @var string
'## @access private
'## @see property: DataTable
'####
Private m_strDataTable

'####
'## get class name attribute.
'##
'## usage: oTemplate.Name
'## access public
'##


Public Property Get Name()
'############################################################
Name = m_strName
End Property

'####
'## get class version property.
'##
'## usage: oTemplate.Version
'## access public
'##
Public Property Get Version()
'############################################################
Version = m_strVersion
End Property

'####
'## get/set m_strMode property.
'##
'## usage: oTemplate.Mode = string A_strType
'## access public
'##
Public Property Let Mode(ByVal A_strType)
'############################################################
If Debug = 4 Then Response.Write "<p><b>Mode:</b> A_strType = " & A_strType & "</p>" & VbCrLf
A_strType = LCase(A_strType)
Select Case A_strType
Case "file"
m_strMode = "file"
Case "db"
m_strMode = "db"
End Select
End Property

Public Property Get Mode()
Mode = m_strMode
End Property

'####
'## set m_oConn property.
'##
'## usage: oTemplate.ActiveConnection = object A_oConn
'## access public
'##
Public Property Let ActiveConnection(ByRef A_oConn)
'############################################################
If Debug = 3 Then Response.Write "<p><b>ActiveConnection:</b> Use ActiveConnection</p>" & VbCrLf
if IsObject(A_oConn) Then
If A_oConn.State <> AdStateClosed Then
Set m_oConn = A_oConn
m_blnConnectionState = True
m_blnNativeConnection = False
End If
End If
End Property

'####
'## set/get m_strCatTable property.
'##
'## usage: oTemplate.CatTable = string A_strCatTable
'## access public
'##
Public Property Let CatTable(ByVal A_strCatTable)
'#######################################

上一个:控制用户登陆到网站和显示在线用户列表
下一个:aspTemplate : 类似 phpLib::Template 的分离层实现

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,