コード例 #1
0
        ///// <summary>
        ///// 判断是否含有列表或导航型part,用于发布时判断snip是否需要重新生成Html
        ///// </summary>
        //public bool ContainNavigationOrList()
        //{
        //    XmlNode xmlNavigationOrListNode = this.SelectSingleNode("//part[@type='Navigation']|//part[@type='List']");
        //    if (xmlNavigationOrListNode != null)
        //    {
        //        return true;
        //    }
        //    else
        //    {
        //        return false;
        //    }
        //}

        #endregion

        #region 重写Tohtml相关的方法

        /// <summary>
        /// 重写,考虑Snip节点下应该是一个SSI的包含语句,被包含的是一个“.inc”文件。
        /// </summary>
        protected override void TagCreator()
        {
            XhtmlElement tag;

            if (this._ParentXhtmlElement != null)
            {
                if (this.SnipType == PageSnipType.Content)//当是Content型的Snip时,不再生成,而是置入一条CGI语句
                {
                    SdCgiObject cgi = new SdCgiObject(CgiPlace.Content);
                    tag = this._ParentXhtmlElement.OwnerPage.CreateXhtmlCommentShtml(cgi);
                }
                else
                {
                    string path = ((TmpltXmlDocument)this.OwnerAnyDocument).TmpltToHtmlUrl;
                    string file = Path.GetFileName(this.HtmlFile);
                    tag = this._ParentXhtmlElement.OwnerPage.CreateXhtmlCommentShtml(path + file);
                }

                this._ParentXhtmlElement.AppendChild(tag);
            }
            this._XhtmlElement = new XhtmlSection("div");
        }
コード例 #2
0
        /// <summary>
        /// 根据当前模板的特性来设置该节点
        /// </summary>
        protected virtual void MarkXhtmlElement()
        {
            XhtmlPage ownerPage = (XhtmlPage)this._ParentXhtmlElement.OwnerPage;

            //<meta http-equiv="Expires" content="Fri, 26 Mar 1999 23:59:59 GMT">
            //<meta http-equiv="pragma" content="no-cache">
            //<meta name="Author" content="Apple Inc.">
            //<meta name="Keywords" content="Apple">

            //<link rel="home" href="http://www.apple.com/">
            //<link rel="alternate" type="application/rss+xml" title="RSS" href="http://images.apple.com/main/rss/hotnews/hotnews.rss">
            //<link rel="index" href="http://www.apple.com/find/sitemap.html">


            #region Meta: Content-Type

            XhtmlAtts.Http_equiv httpEquiv   = new XhtmlAtts.Http_equiv(Xhtml.Http_equiv.content_type);
            XhtmlAtts.Content    content     = new XhtmlAtts.Content("text/html; charset=utf-8");
            XhtmlTagElement      contentType = ownerPage.CreateXhtmlMeta(httpEquiv, content);
            ownerPage.Head.AppendChild(contentType);

            #endregion

            //<!--#include virtual="http://ssi.jeelu.com/GetHtml.cgi?domain=$SERVER_ADDR&dir=$DOCUMENT_URI&filename=asdfads"-->
            SdCgiObject cgi = new SdCgiObject(CgiPlace.Head);
            ownerPage.Head.AppendChild(ownerPage.CreateXhtmlCommentShtml(cgi));

            #region Meta: Power
#if !DEBUG
            string         version = Application.ProductVersion;
            XhtmlAtts.Name name    = new XhtmlAtts.Name("Generator");
            content = new XhtmlAtts.Content("网站360°: v" + version + ",http://www.SimplusD.com");
            XhtmlTagElement power = ownerPage.CreateXhtmlMeta(name, content);
            ownerPage.Head.AppendChild(power);
#endif
            #endregion

            XhtmlElement mainElement = ownerPage.CreateXhtmlDiv();
            this._XhtmlElement.AppendChild(mainElement);

            #region 辩别生成效果
#if DEBUG
            mainElement.SetAttribute("name", "tmplt");
#endif
            #endregion

            /// this.GetRectsElement().ChildNodes[0]是指的rects节点下的第一个节点,一般是rect
            /// 按照SimplusD的规则,这个节点有仅有一个rect节点
            XmlNode firstNode = null;
            if (this.GetRectsElement().ChildNodes[0] is SnipXmlElement)
            {
                firstNode = this.GetRectsElement();///当一个模板里只有一个页面片时的特殊情况处理
            }
            else
            {
                firstNode = this.GetRectsElement().ChildNodes[0];
            }

            foreach (XmlNode node in firstNode.ChildNodes)///遍历子节点,通过Element的继承关系递归
            {
                if (node.NodeType != XmlNodeType.Element)
                {
                    continue;
                }
                if (node is ToHtmlXmlElement)///当节点是继承自ToHtmlXmlElement,即可以生成页面
                {
                    ToHtmlXmlElement htmlNode = (ToHtmlXmlElement)node;
                    htmlNode.ParentXhtmlElement = mainElement; ///下一级节点的父节点即为本节点
                    htmlNode.ToHtml();                         ///调用下一级节点的ToHtml
                }
            }
            this._isAlreadyToHtml = true;///已经ToHtml的标记
        }