Esempio n. 1
0
        /// <summary>
        /// 获取父级对象
        /// </summary>
        /// <param name="AllList">总集合</param>
        /// <param name="_HeaderBaseClass">当前对象</param>
        /// <returns>返回所有的父级对象</returns>
        private List <HeaderBaseClass> P_HeaderBaseClass(List <HeaderBaseClass> AllList, HeaderBaseClass _HeaderBaseClass)
        {
            List <HeaderBaseClass> L      = new List <HeaderBaseClass>();
            HeaderBaseClass        parent = null;

            foreach (HeaderBaseClass HBC in AllList)
            {
                if (HBC == null)
                {
                    continue;
                }
                if (HBC.ID == _HeaderBaseClass.TopID)
                {
                    parent = HBC; break;
                }
            }
            if (parent == null)
            {
                return(L);
                //throw new Exception("HeaderHelper Or [TitleMap.config]    Error !");
            }
            L.Insert(0, parent);
            if (parent.ID != "Top")
            {
                L.InsertRange(0, P_HeaderBaseClass(AllList, parent));
            }
            return(L);
        }
Esempio n. 2
0
        /// <summary>
        /// 复制
        /// </summary>
        /// <returns></returns>
        public HeaderBaseClass Clone()
        {
            HeaderBaseClass _HeaderBaseClass = new HeaderBaseClass();

            _HeaderBaseClass.c     = c;
            _HeaderBaseClass.a     = a;
            _HeaderBaseClass.title = title;
            _HeaderBaseClass.url   = url;
            _HeaderBaseClass.ID    = ID;
            _HeaderBaseClass.TopID = TopID;
            return(_HeaderBaseClass);
        }
Esempio n. 3
0
        protected override void Render(HtmlTextWriter writer)
        {
            writer.WriteLine(string.Empty);
            string controller = _ViewContext.RouteData.Values["controller"].ToString();
            string action     = _ViewContext.RouteData.Values["action"].ToString();

            HeaderBaseClass _HeaderBaseClass = TitltMap.GetNowHeaderBaseClass(controller, action);//当前对象
            ArrayList       _Title           = new ArrayList();

            if (_HeaderBaseClass != null)
            {
                List <HeaderBaseClass> ParentsAndMeList = _HeaderBaseClass.ParentsAndMeList(TitltMap.ReadTitleMapXMLToHeaderBaseClassList());//父级和当前对象list
                ParentsAndMeList = DealHeaderBaseClassList(ParentsAndMeList, _ViewContext);
                _Title           = GetTitle(ParentsAndMeList);
            }
            else
            {
                if (HttpContext.Current.Items[Key] != null)
                {
                    _Title.InsertRange(0, (ArrayList)HttpContext.Current.Items[Key]);
                }
            }
            Model.SiteInfo m_site       = WebCacheHelper.GetSiteInfo();
            ArrayList      _KeyWord     = (ArrayList)_Title.Clone();
            ArrayList      _Description = (ArrayList)_Title.Clone();

            if (string.Join(BrowserTitleSeparator, (string[])_Title.ToArray(typeof(string))).IndexOf(m_site.WebTitle) < 0)
            {
                _Title.Add(m_site.WebTitle);
            }
            //_Title.Add(Common.Config.ConfigInfo<Common.Config.SiteInfo>.Instance().HomeUrl);
            writer.WriteLine("<title>{0}</title>", string.Join(BrowserTitleSeparator, (string[])_Title.ToArray(typeof(string))));

            if (HttpContext.Current.Items[Key2] != null)
            {
                _KeyWord.InsertRange(0, (ArrayList)HttpContext.Current.Items[Key2]);
            }
            _KeyWord.Add(m_site.WebKeyword);
            writer.WriteLine("<meta name=\"keywords\" content=\"{0}\" />", string.Join(BrowserTitleSeparator, (string[])_KeyWord.ToArray(typeof(string))));

            if (HttpContext.Current.Items[Key3] != null)
            {
                _Description.InsertRange(0, (ArrayList)HttpContext.Current.Items[Key3]);
            }
            writer.WriteLine("<meta name=\"description\" content=\"{0}\" />", string.Join(BrowserTitleSeparator, (string[])_Description.ToArray(typeof(string))));

            writer.WriteLine("<meta name=\"copyright\" content=\"{0}\" />", m_site.WebCopyright);

            writer.WriteLine("<meta name=\"author\" content=\"{0}\" />", "成都雷驰科技有限公司");

            base.Render(writer);
        }
Esempio n. 4
0
        protected override void Render(HtmlTextWriter writer)
        {
            _nowtitle = _ViewContext.ViewData["___Now_SiteMap_Title"] == null ? "" : _ViewContext.ViewData["___Now_SiteMap_Title"].ToString();
            UrlHelper Url = new UrlHelper(_ViewContext.RequestContext);

            writer.WriteLine(string.Empty);
            string controller = _ViewContext.RouteData.Values["controller"].ToString();
            string action     = _ViewContext.RouteData.Values["action"].ToString();

            HeaderBaseClass _HeaderBaseClass = TitltMap.GetNowHeaderBaseClass(controller, action);//当前对象

            if (_HeaderBaseClass == null)
            {
                if (_HeaderBaseClass == null)
                {
                    base.Render(writer); return;
                }
            }
            List <HeaderBaseClass> ParentsAndMeList = _HeaderBaseClass.ParentsAndMeList(TitltMap.ReadTitleMapXMLToHeaderBaseClassList());//父级和当前对象list

            ParentsAndMeList = HeaderHelper.DealHeaderBaseClassList(ParentsAndMeList, _ViewContext);

            string    Str    = "<a " + (_isblank ? " target=\"_blank\" " : "") + " href=\"{0}\">{1}</a>";
            ArrayList output = new ArrayList();

            for (int i = 0; i < ParentsAndMeList.Count; i++)
            {
                HeaderBaseClass __HeaderBaseClass = ParentsAndMeList[i];
                if (i == ParentsAndMeList.Count - 1)
                {
                    output.Add(string.IsNullOrEmpty(_nowtitle) ? __HeaderBaseClass.title : _nowtitle);
                }
                else
                {
                    output.Add(string.Format(Str, string.IsNullOrEmpty(__HeaderBaseClass.url) ? Url.Action(__HeaderBaseClass.a, __HeaderBaseClass.c) : __HeaderBaseClass.url, __HeaderBaseClass.title));
                }
            }
            writer.Write(string.Join(_sign, (string[])output.ToArray(typeof(string))));
            base.Render(writer);
        }
Esempio n. 5
0
        /// <summary>
        /// 遍历XML
        /// </summary>
        /// <param name="_XmlElement"></param>
        /// <returns></returns>
        protected static List <HeaderBaseClass> ForeachXML(string TopID, XmlNode _XmlElement)
        {
            List <HeaderBaseClass> _L           = new List <HeaderBaseClass>();
            XmlNodeList            _XmlNodeList = _XmlElement.SelectNodes("item");

            foreach (XmlNode _XmlNode in _XmlNodeList)
            {
                string          c                = _XmlNode.Attributes["c"] == null ? "" : _XmlNode.Attributes["c"].Value.ToString();
                string          a                = _XmlNode.Attributes["a"] == null ? "" : _XmlNode.Attributes["a"].Value.ToString();
                string          title            = _XmlNode.Attributes["title"] == null ? "" : _XmlNode.Attributes["title"].Value.ToString();
                HeaderBaseClass _HeaderBaseClass = new HeaderBaseClass();
                _HeaderBaseClass.c     = c;
                _HeaderBaseClass.a     = a;
                _HeaderBaseClass.title = title;
                _HeaderBaseClass.ID    = "Top" + sign.ToString2();
                _HeaderBaseClass.TopID = TopID;
                _L.Add(_HeaderBaseClass);
                sign = sign ?? 0;
                sign++;
                _L.AddRange(ForeachXML(_HeaderBaseClass.ID, _XmlNode));
            }
            return(_L);
        }