Beispiel #1
0
        /// <summary>
        /// 加载主机站点信息
        /// </summary>
        /// <param name="node"></param>
        public override void Load(System.Xml.XmlElement node)
        {
            base.Load(node);

            XmlNodeList _siteNodeList = node.SelectNodes("MaSite");

            foreach (XmlElement item in _siteNodeList)
            {
                IMaSite _site = MaConfigManager.LoadConfig(item) as IMaSite;
                if (_site != null)
                {
                    #region 设置站点主机头

                    //设置站点主机头
                    XmlNodeList _hostNodeList = item.SelectNodes("host");
                    foreach (XmlElement host in _hostNodeList)
                    {
                        if (host.Attributes["value"] != null &&
                            !string.IsNullOrEmpty(host.Attributes["value"].Value))
                        {
                            _site.SetHost(host.Attributes["value"].Value);
                        }
                    }

                    #endregion
                    m_maSiteConfigList.Add(_site);
                }
                else
                {
                    throw new Exception("站点信息配置错误:" + item.Name + ":" + item.OuterXml);
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// 解析入口
 /// </summary>
 /// <param name="urlInfo"></param>
 /// <param name="site"></param>
 /// <param name="skin"></param>
 /// <param name="page"></param>
 /// <param name="pageCode"></param>
 public void Parse(MaUrl urlInfo, IMaSite site, IMaSkin skin, MaPage page, ref StringBuilder pageCode)
 {
     //处理页面临时变量
     foreach (KeyValuePair <string, string> item in Htmx.HtmxHandler.GetThisPageTempVariable())
     {
         pageCode = pageCode.Replace("{$" + item.Key + "}", item.Value);
     }
     //处理页面变量
     foreach (KeyValuePair <string, string> item in page.GetPageVariable())
     {
         pageCode = pageCode.Replace("{$" + item.Key + "}", item.Value);
     }
     //处理皮肤变量
     foreach (KeyValuePair <string, string> item in ((MaConfig)skin).Variables)
     {
         pageCode = pageCode.Replace("{$" + item.Key + "}", item.Value);
     }
     //处理站点变量
     foreach (KeyValuePair <string, string> item in ((MaConfig)site).Variables)
     {
         pageCode = pageCode.Replace("{$" + item.Key + "}", item.Value);
     }
     //处理基本变量
     pageCode = pageCode.Replace("{$_ma_this_domain}", urlInfo.Domain.Domain);
     pageCode = pageCode.Replace("{$_ma_this_root_domain}", urlInfo.Domain.MainDomain);
 }
Beispiel #3
0
        /// <summary>
        /// 页面处理工具
        /// </summary>
        /// <param name="context"></param>
        /// <param name="requestType"></param>
        /// <param name="url"></param>
        /// <param name="pathTranslated"></param>
        /// <returns></returns>
        public IHttpHandler GetHandler(HttpContext context, string requestType, string url, string pathTranslated)
        {
            if (MaWeb.Instance != null)
            {
                IMaSite _site = MaWeb.Instance.GetSite(context);
                if (_site == null)
                {
                    throw new Exception("WebApp配置错误,请检查Ma.Config配置文件[MaWeb]配置结点!");
                }
                IMaSkin _skin = _site.GetSkinConfig(context);
                MaPage  _page = _site.GetRequestConfig(context);
                if (_page == null)
                {
                    throw new Exception("WebApp配置错误,请检查Ma.Config配置文件[MaWeb]配置结点,没有设定默认页面处理类!");
                }
                IHttpHandler _handler = _page.GetHandler(context);

                context.Response.Filter = new HtmxFilter(context.Response.Filter, MaUrl.Current, _page);

                if (_handler is HtmxHandlerBase)
                {
                    HtmxHandlerBase _maHandler = (HtmxHandlerBase)_handler;
                    _maHandler.InitPage(context, MaUrl.Current, MaWeb.Instance, _site, _skin, _page);
                }
                return(_handler);
            }
            else
            {
                throw new Exception("WebApp配置错误,请检查Ma.Config配置文件[MaWeb]配置结点");
            }
        }
Beispiel #4
0
        /// <summary>
        /// 默认模板替换函数
        /// </summary>
        /// <param name="urlInfo"></param>
        /// <param name="site"></param>
        /// <param name="skin"></param>
        /// <param name="page"></param>
        /// <param name="pageCode"></param>
        /// <param name="tag"></param>
        public override void ParseTag(Page.MaUrl urlInfo, IMaSite site, IMaSkin skin, Page.MaPage page, ref StringBuilder pageCode, MaTag tag)
        {
            //模板名称
            string _tName = tag["tmp"];
            string _templateStr;

            if (!skin.TryGetTemplate(_tName, out _templateStr))
            {
                _templateStr = "<!--获取模板文件[" + _tName + "]出错-->";
                throw new Exception("获取模板文件[" + _tName + "]出错,【" + urlInfo.ToString() + "】");
            }
            pageCode = pageCode.Replace(tag.TagStr, _templateStr);
        }
Beispiel #5
0
        /// <summary>
        /// 初始化页面信息
        /// </summary>
        /// <param name="context"></param>
        /// <param name="url"></param>
        /// <param name="web"></param>
        /// <param name="site"></param>
        /// <param name="skin"></param>
        /// <param name="page"></param>
        public virtual void InitPage(HttpContext context, MaUrl url, IMaWeb web, IMaSite site, IMaSkin skin, MaPage page)
        {
            //Http对象
            Context  = context;
            Request  = context.Request;
            Response = context.Response;

            //Ma对象
            m_maUrl  = url;
            m_maweb  = web;
            m_maSite = site;
            m_maSkin = skin;
            m_maPage = page;
        }
Beispiel #6
0
        /// <summary>
        /// 标签处理虚方法
        /// </summary>
        /// <param name="urlInfo"></param>
        /// <param name="site"></param>
        /// <param name="skin"></param>
        /// <param name="page"></param>
        /// <param name="pageCode"></param>
        public virtual void Parse(MaUrl urlInfo, IMaSite site, IMaSkin skin, MaPage page, ref StringBuilder pageCode)
        {
            if (string.IsNullOrEmpty(m_tagRegexStr))
            {
                throw new Exception("解析表情出错,当前类没有标签匹配字符串串,请给[TagRegexStr]赋值");
            }

            //查询的正则表达式
            Regex           re      = new Regex(m_tagRegexStr, RegexOptions.IgnoreCase);
            MatchCollection matches = re.Matches(pageCode.ToString());

            foreach (Match var in matches)
            {
                MaTag _maTag = new MaTag(var.Value, urlInfo);
                ParseTag(urlInfo, site, skin, page, ref pageCode, _maTag);
            }
        }
Beispiel #7
0
 /// <summary>
 /// 标签处理抽象函数
 /// </summary>
 /// <param name="urlInfo"></param>
 /// <param name="site"></param>
 /// <param name="skin"></param>
 /// <param name="page"></param>
 /// <param name="pageCode"></param>
 /// <param name="tag"></param>
 public abstract void ParseTag(MaUrl urlInfo, IMaSite site, IMaSkin skin, MaPage page, ref StringBuilder pageCode, MaTag tag);
Beispiel #8
0
 /// <summary>
 /// 重写初始化页面
 /// </summary>
 /// <param name="context"></param>
 /// <param name="url"></param>
 /// <param name="web"></param>
 /// <param name="site"></param>
 /// <param name="skin"></param>
 /// <param name="page"></param>
 public override void InitPage(System.Web.HttpContext context, Page.MaUrl url, IMaWeb web, IMaSite site, IMaSkin skin, Page.MaPage page)
 {
     base.InitPage(context, url, web, site, skin, page);
 }