⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 label.cs

📁 最好用的站点内容管理系统 全部源代码都有
💻 CS
字号:
//======================================================
//==     (c)2008 aspxcms inc by NeTCMS v1.0              ==
//==          Forum:bbs.aspxcms.com                   ==
//==         Website:www.aspxcms.com                  ==
//======================================================
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Data;
using NetCMS.Config;

namespace NetCMS.Publish
{
    /// <summary>
    /// 标签参数
    /// </summary>
    public struct LabelParameter
    {
        /// <summary>
        /// 参数名称
        /// </summary>
        public string LPName;
        /// <summary>
        /// 参数值
        /// </summary>
        public string LPValue;
    }
    /// <summary>
    /// 标签分类
    /// </summary>
    public enum LabelType { Free, Custom, Class, Channel }
    /// <summary>
    /// 标签类
    /// </summary>
    public class Label
    {
        /// <summary>
        /// 标签名称
        /// </summary>
        protected string _LabelName = string.Empty;
        /// <summary>
        /// 标签种类
        /// </summary>
        protected LabelType _LabelType;
        /// <summary>
        /// 最终的HTML代码
        /// </summary>
        protected string _FinalHtmlCode = string.Empty;
        /// <summary>
        /// 当前的模板类型
        /// </summary>
        protected TempType _TemplateType;
        /// <summary>
        /// 当前的栏目ID
        /// </summary>
        protected string _CurrentClassID = null;
        /// <summary>
        /// 当前的专题ID
        /// </summary>
        protected string _CurrentSpecialID = null;
        /// <summary>
        /// 当前新闻ID
        /// </summary>
        protected string _CurrentNewsID = null;


        /// <summary>
        /// 当前的频道栏目ID
        /// </summary>
        protected int _CurrentCHClassID;
        /// <summary>
        /// 当前的频道专题ID
        /// </summary>
        protected int _CurrentCHSpecialID;
        /// <summary>
        /// 当前频道新闻ID
        /// </summary>
        protected int _CurrentCHNewsID;

        protected int _CurrentChID;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="labelname">标签名称</param>
        public Label(string labelname,LabelType labeltype)
        {
            _LabelName = labelname;
            _LabelType = labeltype;
        }
        /// <summary>
        /// 标签名称
        /// </summary>
        public string LabelName
        {
            get { return _LabelName; }
        }
        /// <summary>
        /// 解析标签种类并返回标签实例
        /// </summary>
        /// <returns>跟距标签类型返回标签实例</returns>
        public static Label GetLabel(string labelname)
        {
            string _labelname = labelname.ToUpper();
            if (Regex.Match( _labelname,@"\{NT_FREE_[^\}]+\}", RegexOptions.Compiled).Success)
            {
                return new FreeLabel(labelname, LabelType.Free);
            }
            else if (Regex.Match(_labelname, @"\{NT_DYN[^\}]+\}", RegexOptions.Compiled).Success)
            {
                return new DynamicLabel(labelname, LabelType.Class);
            }
            else if (Regex.Match(_labelname, @"\{NT_CH\$\d+_[^\}]+\}", RegexOptions.Compiled).Success)
            {
                string getReplaceStr = _labelname.Replace("{NT_CH$", "");
                int pLnamee = getReplaceStr.IndexOf("_");
                string FileChHTML = getReplaceStr.Substring(0, pLnamee);
                ChannelLabel chlbl = new ChannelLabel(labelname, LabelType.Channel);
                chlbl.CHID = int.Parse(FileChHTML);
                return chlbl;
            }
            else if (Regex.Match(_labelname, @"\{NT_[^\}]+\}", RegexOptions.Compiled).Success)
            {
                return new CustomLabel(labelname, LabelType.Custom);
            }
            else
            {
                throw new Exception("标签名称非法");
            }
        }
        /// <summary>
        /// 当前标签的种类
        /// </summary>
        public LabelType MyType
        {
            get { return _LabelType; }
        }
        /// <summary>
        /// 从数据库取得标签的内容
        /// </summary>
        /// <param name="cn"></param>
        public virtual void GetContentFromDB()
        {
        }
        /// <summary>
        /// 生成最终的HTML代码
        /// </summary>
        /// <param name="cn"></param>
        public virtual void MakeHtmlCode()
        {
        }
        /// <summary>
        /// 最终的标签HTML代码
        /// </summary>
        public string FinalHtmlCode
        {
            get { return _FinalHtmlCode; }
        }
        /// <summary>
        /// 设置或获取当前的模板类型
        /// </summary>
        public TempType TemplateType
        {
            set { _TemplateType = value; }
            get { return _TemplateType; }
        }
        /// <summary>
        /// 当前的栏目ID
        /// </summary>
        public string CurrentClassID
        {
            set { _CurrentClassID = value; }
        }
        /// <summary>
        /// 当前的专题ID
        /// </summary>
        public string CurrentSpecialID
        {
            set { _CurrentSpecialID = value; }
        }
        /// <summary>
        /// 当前新闻ID
        /// </summary>
        public string CurrentNewsID
        {
            set { _CurrentNewsID = value; }
        }


        /// <summary>
        /// 当前的频道栏目ID
        /// </summary>
        public int CurrentChClassID
        {
            set { _CurrentCHClassID = value; }
        }
        /// <summary>
        /// 当前的频道专题ID
        /// </summary>
        public int CurrentCHSpecialID
        {
            set { _CurrentCHSpecialID = value; }
        }
        /// <summary>
        /// 当前频道新闻ID
        /// </summary>
        public int CurrentCHNewsID
        {
            set { _CurrentCHNewsID = value; }
        }
        /// <summary>
        /// 当前频道ID
        /// </summary>
        public int CurrentChID
        {
            set { _CurrentChID = value; }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -