Tsys V2_0_beta1标签说明

新闻标题
 TSYS:data(title)
 
新闻数据
 TSYS:data(short_content)
 
新闻作者
 TSYS:data(author)
 
显示相关新闻
 TSYS:relate_list(数量)
 
显示前5条相关新闻
 TSYS:relate_list(5)
 
Url编码的新闻
 TSYS:urlencode(TSYS:data(title))
 
取新闻标题前10个字
 TSYS:left(TSYS:data(title),10)
 
过滤新闻标题内Html标签
 TSYS:filter_html(TSYS:data(title))
 





/tsys/manage/inc/TagParser.class.asp中,是2.0的标签类文件,我全部拷贝出来了!具体 的使用方法,目前还没有很详细的说明,请各位高手加以详细说明!


    '####### 系统预设标签库-开始 ############################################################ #################

    '方法:资源字段读取标签处理 TSYS:data(字段名)
    '参数:Tsys标签
    '返回:资源字段数据
    Private Function TSYSTAG_Data_Field(myFlag)

        TSYSTAG_Data_Field = ""
        If Trim(myFlag.Value) <> "" Or Not IsNull(myFlag.Value) Then
             TSYSTAG_Data_Field = RsInfo(Trim(myFlag.Value))
        End If

    End Function
    
    '方法:相关资源列表 TSYS:relate_list(数目, "相关列表样式模板")
    '参数:Tsys标签
    '返回:分页列表Html字符串
    '说明:
    '   相关列表样式模板:便用用户定义个性化的相关列表效果
    '样式模板内部可用的动态变量有:
    '   $id$              资源id
    '   $title$         资源标题
    '   $url$         & nbsp; 资源访问地址
    '   $author$        作者
    '   $addtime$       添加时间
    '   $class_title$   频道名称
    '   $class_id$      频道id
    '   $class_url$     频道地址
    Private Function TSYSTAG_Relate_List(myFlag)

        Dim Relate_IdList
        Relate_IdList = RsInfo("relate_list")
        If IsNull(Relate_IdList) Or Relate_IdList = "" Then
             TSYSTAG_Relate_List = ""
             Exit Function
        End If

        Dim regEx, Matches
        Set regEx = New RegExp
        regEx.IgnoreCase = False
        regEx.Global = False
        regEx.MultiLine = False
        regEx.Pattern = "[/s]{0,}([/d]+)[/s]{0,},[/s]{0,}'([^']{0,})'"
        Set Matches = regEx.Execute(myFlag.value)

        TSYSTAG_Relate_List = ""

        Dim strTemplate, strTemplate2, TopNum
        strTemplate2 = ""
        If Matches.Count = 0 Then
             strTemplate = ""
             TopNum = 10
        Else
             strTemplate = Trim(Matches(0).SubMatches(1))
             TopNum = FLib.SafeSql(Matches(0).SubMatches(0))
        End If

        If strTemplate = "" Then
             strTemplate = "·<a href=""$url___FCKpd___0quot;" target=""_blank"">$title___FCKpd___0lt;/a>&nbsp;<font color=""#808080"">[$addtime$]</font>$br___FCKpd___0quot;
        End If

        Dim Sql, Rs, strHtml
        strHtml = ""
        Sql = "SELECT TOP " & TopNum & " id, title, author, visit_url,  addtime, class_title, class_id, home_url FROM view_resource WHERE id IN (" & Relate_IdList & ")"
        Set Rs = Db.ExeCute(Sql)
        While Not Rs.Eof
             strTemplate2 = Replace(strTemplate, "$id___FCKpd___0quot;, Rs("id"))
             strTemplate2 = Replace(strTemplate2, "$title___FCKpd___0quot;, Rs("title"))
             strTemplate2 = Replace(strTemplate2, "$url___FCKpd___0quot;, Rs("visit_url"))
             strTemplate2 = Replace(strTemplate2, "$author___FCKpd___0quot;, Rs("author"))
             strTemplate2 = Replace(strTemplate2, "$addtime___FCKpd___0quot;, FLib.FormatMyDate(Rs("addtime"), "{y}-{m}-{d}"))
             strTemplate2 = Replace(strTemplate2, "$class_title___FCKpd___0quot;, Rs("class_title"))
             strTemplate2 = Replace(strTemplate2, "$class_id___FCKpd___0quot;, Rs("class_id"))
             strTemplate2 = Replace(strTemplate2, "$class_url___FCKpd___0quot;, Rs("home_url"))
             strTemplate2 = Replace(strTemplate2, "$br___FCKpd___0quot;, "<br>")
             strHtml = strHtml & strTemplate2 & vbCrLf
             Rs.MoveNext()
        Wend
        Rs.Close()
        Set Rs = Nothing

        Set regEx = Nothing
        Set Matches = Nothing
        TSYSTAG_Relate_List = strHtml
        Set strHtml = Nothing

    End Function

    '方法:分页列表 TSYS:pages_list(分页类型,'分页样式模板','当前页时的分页样式模板')
    '参数:Tsys标签
    '返回:分页列表Html字符串
    '说明:
    '   分页列表样式模板:便用用户定义个性化的分页列表效果
    '样式模板内部可用的动态变量有:
    '   $id$        资源id
    '   $title$     资源标题
    '   $title2$    资源标题2, 经过Html标签清除处理
    '   $title3$    资源标题3, 经过url编码、Html标签清除处理
    '   $url$       资源访问地址
    '   $page$      当前页号
    '   $addtime$   添加时间, {y}-{m}-{d}
    '   $addtime2$  添加时间2, {d}/{m}
    Private Function TSYSTAG_Pages_List(myFlag)

        Dim regEx, Matches
        Set regEx = New RegExp
        regEx.IgnoreCase = False
        regEx.Global = False
        regEx.MultiLine = False
        regEx.Pattern = "([/d]+)[/s]{0,},[/s]{0,}'([^']{0,})'[/s]{0,},[/s]{0,}'([^']{0,})'"
        Set Matches = regEx.Execute(myFlag.value)

        TSYSTAG_Pages_List = ""

        Dim strTemplate, strTemplate_CurrPage, ListType
        If Matches.Count = 0 Then
             strTemplate = ""
             strTemplate_CurrPage = ""
        Else
             strTemplate = Trim(Matches(0).SubMatches(1))
             strTemplate_CurrPage = Trim(Matches(0).SubMatches(2))
             ListType = Matches(0).SubMatches(0)
        End If

        If strTemplate = "" Then
             strTemplate = "<a href=""$url___FCKpd___0quot;" title=""$title2___FCKpd___0quot;">[$page$]</a>&nbsp;"
        End If
        If strTemplate_CurrPage = "" Then
             strTemplate_CurrPage = "<a href=""$url___FCKpd___0quot;" title=""$title2___FCKpd___0quot;"><b>[$page$]</b></a>&nbsp;"
        End If

        If RsInfo("pages_count") = 0 Then
             Set regEx = Nothing
             Set Matches = Nothing
             Exit Function
        End If

        Dim Sql, Rs, I, strHtml, tmpTitle, tmpTemplate, VisitUrl
        I = 1
        If RsInfo("pages_head") = -1 Then
             Sql = "SELECT TOP " & RsInfo("pages_count") & " id, title, visit_url, addtime FROM resource_list WHERE id=" & RsInfo("id") & " Or pages_head=" & RsInfo("id") & " ORDER BY pages_position"
        Else
             Sql = "SELECT TOP " & RsInfo("pages_count") & " id, title, visit_url, addtime FROM resource_list WHERE id=" & RsInfo("pages_head") & " Or pages_head=" & RsInfo("pages_head") & " ORDER BY pages_position"
        End If
        Set Rs = Db.ExeCute(Sql)
        While Not Rs.Eof

             'If IsNull(Rs("visit_url")) Or Rs("visit_url") = "" Then
                ' VisitUrl = ""
             'Else
                 VisitUrl = Rs("visit_url")
           ' End If

             If Rs("id") = RsInfo("id") Then
                 tmpTemplate = strTemplate_CurrPage
             Else
                 tmpTemplate = strTemplate
             End If

             tmpTemplate = Replace(tmpTemplate, "$id___FCKpd___0quot;, Rs("id"))
             tmpTitle = Rs("title")
             tmpTemplate = Replace(tmpTemplate, "$title___FCKpd___0quot;, tmpTitle)
             tmpTitle = RegReplace("<.*?>", tmpTitle, "")
             tmpTemplate = Replace(tmpTemplate, "$title2___FCKpd___0quot;, tmpTitle)
             tmpTemplate = Replace(tmpTemplate, "$title3___FCKpd___0quot;, Server.UrlEncode(tmpTitle))
             tmpTemplate = Replace(tmpTemplate, "$url___FCKpd___0quot;, VisitUrl)
             tmpTemplate = Replace(tmpTemplate, "$page___FCKpd___0quot;, I)
             tmpTemplate = Replace(tmpTemplate, "$addtime___FCKpd___0quot;, FLib.FormatMyDate(Rs("addtime"), "{y}-{m}-{d}"))
             tmpTemplate = Replace(tmpTemplate, "$br___FCKpd___0quot;, "<br>")
             strHtml = strHtml & tmpTemplate
             I = I + 1
             Rs.MoveNext()
        Wend
        Rs.Close()
        Set Rs = Nothing

        If strHtml <> "" Then
             If ListType = "1" Then
                 TSYSTAG_Pages_List = "<select οnchange=""location=this.options[this.options.selectedIndex].value"">" & strHtml & "</option>"
             Else
                 TSYSTAG_Pages_List = strHtml
             End If
        Else
             TSYSTAG_Pages_List = strHtml
        End If

        Set regEx = Nothing
        Set Matches = Nothing
        Set strHtml = Nothing

    End Function

    '方法:字符url编码 TSYS:urlencode(字符串)
    '参数:Tsys标签
    '返回:url编码后数据
    Private Function TSYSTAG_UrlEncode(myFlag)

        TSYSTAG_UrlEncode = ""
        If myFlag.Value = "" Or IsNull(myFlag.Value) Then
             Exit Function
        End If
        TSYSTAG_UrlEncode = Server.UrlEncode(myFlag.Value)

    End Function

    '方法:字符串截取函数 TSYS:left(字符串, 截取长度, '补给串')
    '参数:Tsys标签
    '返回:截取后字符串
    Private Function TSYSTAG_Left(myFlag)
        Dim regEx, Matches
        Set regEx = New RegExp
        regEx.IgnoreCase = False
        regEx.Global = False
        regEx.MultiLine = False
        regEx.Pattern = "([^/,]{0,}),[/s]{0,}([/d]+)[/s]{0,},[/s]{0,}'([^']{0,})'"
        Set Matches = regEx.Execute(myFlag.Value)

        TSYSTAG_Left = ""

        If Matches.Count > 0 Then
           ' If Len(Matches(0).SubMatches(0))<=CInt(Matches(0).SubMatches (1)) Then
                 'TSYSTAG_Left = Matches(0).SubMatches(0)
           ' Else
                 'TSYSTAG_Left = Left(Matches(0).SubMatches(0), Matches(0).SubMatches(1)) & Matches(0).SubMatches(2)
             'End If
             l=len(Matches(0).SubMatches(0))
             t=0
             For m_i = 1 To l
              c = Abs(Asc(Mid(Matches(0).SubMatches(0),m_i,1)))
              If c > 255 Then
                 t = t+2
                 Else
                 t = t+1
              End If

             If t>= 2*CInt(Matches(0).SubMatches(1)) Then
                TSYSTAG_Left = left(Matches(0).SubMatches(0),m_i)& Matches(0).SubMatches(2)
             exit for
           Else
              TSYSTAG_Left = Matches(0).SubMatches(0)
           End if
       Next

        End If

        Set regEx = Nothing
        Set Matches = Nothing
    End Function

    '方法:格式化时间格式 TSYS:format_date(时间, '时间格式串')
    '参数:Tsys标签
    '返回:截取后字符串
    Private Function TSYSTAG_Format_Date(myFlag)
        Dim regEx, Matches
        Set regEx = New RegExp
        regEx.IgnoreCase = true
        regEx.Global = True
        regEx.MultiLine = True
        regEx.Pattern = "([^/,]{0,})[/s]{0,},[/s]{0,}'([^']{0,})'"
        Set Matches = regEx.Execute(myFlag.value)
        Dim DateTemplate
             DateTemplate = "{Y}-{m}-{d}"
        TSYSTAG_Format_Date = ""
        If Matches.Count > 0 Then
             If Matches(0).SubMatches(1) <> "" Then
                 DateTemplate = Matches(0).SubMatches(1)
             End If
             TSYSTAG_Format_Date = FLib.FormatMyDate(Matches(0).SubMatches(0), DateTemplate)
        Else
             TSYSTAG_Format_Date = myFlag.Value
        End If

        Set regEx = Nothing
        Set Matches = Nothing
    End Function

    '方法:清除html标签 TSYS:filter_html(字符串)
    '参数:Tsys标签
    '返回:清除后字符串
    Private Function TSYSTAG_FilterHtml(myFlag)

        TSYSTAG_FilterHtml = ""
        If myFlag.Value <> "" Or Not IsNull(myFlag.Value) Then
             TSYSTAG_FilterHtml = RegReplace("<.*?>", myFlag.Value, "")
        End If

    End Function

    '####### 系统预设标签库-结束 ############################################################ #################

 

    '####### 用户扩展标签库-开始 ############################################################ #################

    '方法:清除所有空格 TSYS:trim(字符串)
    '参数:Tsys标签
    '返回:清除后字符串
    Private Function USERTAG_TRIM(myFlag)
        USERTAG_TRIM = Trim(myFlag.Value)
    End Function

    '####### 用户扩展标签库-结束 ############################################################ #################
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值