Exemple #1
0
        /// <summary>
        /// 根据当前节点的特性来设置该节点
        /// </summary>
        protected virtual void MarkXhtmlElement(PageSection pageSection)
        {
            switch (pageSection)
            {
            case PageSection.MainPage:
            {
                _XhtmlElement = new XhtmlSection();
                string       tmpltFullFile = this.ToHtmlHelper.TmpltRelativeUrl;
                XhtmlElement tag           = _XhtmlElement.CreateXhtmlCommentShtml
                                                 (tmpltFullFile + this.SdsiteElement.TmpltId + Utility.Const.ShtmlFileExt);
                _XhtmlElement.AppendChild(tag);
                this._isAlreadyToMainPageHtml = true;
                break;
            }

            case PageSection.Head:
            {
                _HeadXhtmlElement = new XhtmlSection();

                #region Title

                XhtmlTagElement title = _HeadXhtmlElement.CreateXhtmlTitle();
                title.InnerText = this.Title;
                _HeadXhtmlElement.AppendChild(title);

                #endregion

                #region keywords

                XhtmlAtts.Name    name;
                StringBuilder     sb;
                XhtmlAtts.Content content;

                if (!(this.PageKeywords == null))
                {
                    name = new XhtmlAtts.Name("keywords");
                    sb   = new StringBuilder();
                    foreach (string str in this.PageKeywords)
                    {
                        sb.Append(str).Append(',');
                    }
                    content = new XhtmlAtts.Content(sb.ToString().TrimEnd(','));
                    XhtmlTagElement keyword = _HeadXhtmlElement.CreateXhtmlMeta(name, content);
                    _HeadXhtmlElement.AppendChild(keyword);
                }

                #endregion

                #region description

                name    = new XhtmlAtts.Name("description");
                content = new XhtmlAtts.Content(this.PageSummary);
                XhtmlTagElement description = _HeadXhtmlElement.CreateXhtmlMeta(name, content);
                _HeadXhtmlElement.AppendChild(description);

                #endregion

                this._isAlreadyToHeadHtml = true;
                break;
            }

            case PageSection.Content:
            {
                SdsiteXmlDocument doc = (SdsiteXmlDocument)this.SdsiteElement.OwnerAnyDocument;

                string           tmpltId = this.SdsiteElement.TmpltId;
                TmpltXmlDocument tmplt   = doc.GetTmpltDocumentById(this.SdsiteElement.TmpltId);
                XhtmlSection     ele     = (XhtmlSection)tmplt.GetContentSnipEle().XhtmlElement;
                if (ele == null)
                {
                    SnipXmlElement snip = tmplt.GetContentSnipEle();
                    snip.MarkXhtmlElement(this);
                    ele = (XhtmlSection)tmplt.GetContentSnipEle().XhtmlElement;
                }
                _ContentXhtmlElement = ele;

                this._isAlreadyToContentHtml = true;
                break;
            }

            case PageSection.None:
            default:
                break;
            }
        }
Exemple #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的标记
        }