Exemplo n.º 1
0
		protected override void OnPreInit(EventArgs e)
		{
			base.OnPreInit(e);

			// handle the infamous umbDebugShowTrace, etc
			Page.Trace.IsEnabled &= GlobalSettings.DebugMode && !String.IsNullOrWhiteSpace(Request["umbDebugShowTrace"]);

			// get the document request and the page
			_docRequest = UmbracoContext.Current.PublishedContentRequest;
			_upage = _docRequest.UmbracoPage;

			//we need to check this for backwards compatibility in case people still arent' using master pages
			if (UmbracoSettings.UseAspNetMasterPages)
			{
				var args = new RequestInitEventArgs()
				{
					Page = _upage,
					PageId = _upage.PageID,
					Context = Context
				};
				FireBeforeRequestInit(args);

				//if we are cancelling then return and don't proceed
				if (args.Cancel) return;

				this.MasterPageFile = template.GetMasterPageName(_upage.Template);

				// reset the friendly path so it's used by forms, etc.			
				Context.RewritePath(UmbracoContext.Current.OriginalRequestUrl.PathAndQuery);

				//fire the init finished event
				FireAfterRequestInit(args);	
			}
			
		}
Exemplo n.º 2
0
        protected override void OnPreInit(EventArgs e)
        {
            base.OnPreInit(e);

            // get the document request and the page
            _docRequest = UmbracoContext.Current.PublishedContentRequest;
            _upage      = _docRequest.UmbracoPage;

            //we need to check this for backwards compatibility in case people still arent' using master pages
            if (UmbracoSettings.UseAspNetMasterPages)
            {
                var args = new RequestInitEventArgs()
                {
                    Page    = _upage,
                    PageId  = _upage.PageID,
                    Context = Context
                };
                FireBeforeRequestInit(args);

                //if we are cancelling then return and don't proceed
                if (args.Cancel)
                {
                    return;
                }

                this.MasterPageFile = template.GetMasterPageName(_upage.Template);

                // reset the friendly path so it's used by forms, etc.
                Context.RewritePath(UmbracoContext.Current.OriginalRequestUrl.PathAndQuery);

                //fire the init finished event
                FireAfterRequestInit(args);
            }
        }
Exemplo n.º 3
0
        public static bool TryGetImageUrl(string specifiedSrc, string field, string provider, string parameters, int? nodeId, out string url)
        {
            var imageUrlProvider = GetProvider(provider);

            var parsedParameters = string.IsNullOrEmpty(parameters) ? new NameValueCollection() : HttpUtility.ParseQueryString(parameters);

            var queryValues = parsedParameters.Keys.Cast<string>().ToDictionary(key => key, key => parsedParameters[key]);

            if (string.IsNullOrEmpty(field))
            {
                url = imageUrlProvider.GetImageUrlFromFileName(specifiedSrc, queryValues);
                return true;
            }
            else
            {
                var fieldValue = string.Empty;
                if (nodeId.HasValue)
                {
                    var contentFromCache = GetContentFromCache(nodeId.GetValueOrDefault(), field);
                    if (contentFromCache != null)
                    {
                        fieldValue = contentFromCache.ToString();
                    }
                    else
                    {
                        var itemPage = new page(content.Instance.XmlContent.GetElementById(nodeId.GetValueOrDefault().ToString(CultureInfo.InvariantCulture)));
                        var value = itemPage.Elements[field];
                        fieldValue = value != null ? value.ToString() : string.Empty;
                    }
                }
                else
                {
                    var context = HttpContext.Current;
                    if (context != null)
                    {
                        var elements = context.Items["pageElements"] as Hashtable;
                        if (elements != null)
                        {
                            var value = elements[field];
                            fieldValue = value != null ? value.ToString() : string.Empty;
                        }
                    }
                }

                if (!string.IsNullOrWhiteSpace(fieldValue))
                {
                    int mediaId;
                    url = int.TryParse(fieldValue, out mediaId)
                              ? imageUrlProvider.GetImageUrlFromMedia(mediaId, queryValues)
                              : imageUrlProvider.GetImageUrlFromFileName(fieldValue, queryValues);
                    return true;
                }
            }

            url = string.Empty;
            return false;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Parses the content of the templateOutput stringbuilder, and matches any tags given in the
        /// XML-file /umbraco/config/umbracoTemplateTags.xml.
        /// Replaces the found tags in the StringBuilder object, with "real content"
        /// </summary>
        /// <param name="umbPage"></param>
        public void Parse(page umbPage)
        {
            System.Web.HttpContext.Current.Trace.Write("umbracoTemplate", "Start parsing");

            // First parse for known umbraco tags
            // <?UMBRACO_MACRO/> - macros
            // <?UMBRACO_GETITEM/> - print item from page, level, or recursive
            MatchCollection tags = Regex.Matches(_templateOutput.ToString(), "<\\?UMBRACO_MACRO[^>]*/>|<\\?UMBRACO_GETITEM[^>]*/>|<\\?(?<tagName>[\\S]*)[^>]*/>", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);

            foreach (Match tag in tags)
            {
                Hashtable attributes = helper.ReturnAttributes(tag.Value.ToString());


                if (tag.ToString().ToLower().IndexOf("umbraco_macro") > -1)
                {
                    String macroID = helper.FindAttribute(attributes, "macroid");
                    if (macroID != "")
                    {
                        macro tempMacro = getMacro(macroID);
                        _templateOutput.Replace(tag.Value.ToString(), tempMacro.MacroContent.ToString());
                    }
                }
                else
                {
                    if (tag.ToString().ToLower().IndexOf("umbraco_getitem") > -1)
                    {
                        try
                        {
                            String          tempElementContent = umbPage.Elements[helper.FindAttribute(attributes, "field")].ToString();
                            MatchCollection tempMacros         = Regex.Matches(tempElementContent, "<\\?UMBRACO_MACRO(?<attributes>[^>]*)><img[^>]*><\\/\\?UMBRACO_MACRO>", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
                            foreach (Match tempMacro in tempMacros)
                            {
                                Hashtable tempAttributes = helper.ReturnAttributes(tempMacro.Groups["attributes"].Value.ToString());
                                String    macroID        = helper.FindAttribute(tempAttributes, "macroid");
                                if (Convert.ToInt32(macroID) > 0)
                                {
                                    macro tempContentMacro = getMacro(macroID);
                                    _templateOutput.Replace(tag.Value.ToString(), tempContentMacro.MacroContent.ToString());
                                }
                            }

                            _templateOutput.Replace(tag.Value.ToString(), tempElementContent);
                        }
                        catch (Exception e)
                        {
                            System.Web.HttpContext.Current.Trace.Warn("umbracoTemplate", "Error reading element (" + helper.FindAttribute(attributes, "field") + ")", e);
                        }
                    }
                }
            }

            System.Web.HttpContext.Current.Trace.Write("umbracoTemplate", "Done parsing");
        }
Exemplo n.º 5
0
        protected override void OnPreInit(EventArgs e)
        {
            base.OnPreInit(e);
            using (Current.ProfilingLogger.DebugDuration <UmbracoDefault>("PreInit"))
            {
                // handle the infamous umbDebugShowTrace, etc
                Page.Trace.IsEnabled &= GlobalSettings.DebugMode && string.IsNullOrWhiteSpace(Request["umbDebugShowTrace"]) == false;

                // get the document request and the page
                _frequest = UmbracoContext.Current.PublishedRequest;
                _upage    = _frequest.UmbracoPage;

                var args = new RequestInitEventArgs()
                {
                    Page    = _upage,
                    PageId  = _upage.PageID,
                    Context = Context
                };
                FireBeforeRequestInit(args);

                //if we are cancelling then return and don't proceed
                if (args.Cancel)
                {
                    return;
                }

                var template = Current.Services.FileService.GetTemplate(_upage.Template);
                if (template != null)
                {
                    var alias = template.MasterTemplateAlias;
                    var file  = alias.Replace(" ", "") + ".master";
                    var path  = SystemDirectories.Masterpages + "/" + file;


                    if (File.Exists(IOHelper.MapPath(VirtualPathUtility.ToAbsolute(path))))
                    {
                        this.MasterPageFile = path;
                    }
                    else
                    {
                        this.MasterPageFile = SystemDirectories.Umbraco + "/masterPages/default.master";
                    }
                }

                // reset the friendly path so it's used by forms, etc.
                Context.RewritePath(UmbracoContext.Current.OriginalRequestUrl.PathAndQuery);

                //fire the init finished event
                FireAfterRequestInit(args);
            }
        }
Exemplo n.º 6
0
        protected override void OnPreInit(EventArgs e)
        {
            base.OnPreInit(e);
            using (DisposableTimer.DebugDuration <UmbracoDefault>("PreInit"))
            {
                // handle the infamous umbDebugShowTrace, etc
                Page.Trace.IsEnabled &= GlobalSettings.DebugMode && string.IsNullOrWhiteSpace(Request["umbDebugShowTrace"]) == false;

                // get the document request and the page
                _docRequest = UmbracoContext.Current.PublishedContentRequest;
                _upage      = _docRequest.UmbracoPage;

                //we need to check this for backwards compatibility in case people still arent' using master pages
                if (UmbracoSettings.UseAspNetMasterPages)
                {
                    var args = new RequestInitEventArgs()
                    {
                        Page    = _upage,
                        PageId  = _upage.PageID,
                        Context = Context
                    };
                    FireBeforeRequestInit(args);

                    //if we are cancelling then return and don't proceed
                    if (args.Cancel)
                    {
                        return;
                    }

                    this.MasterPageFile = template.GetMasterPageName(_upage.Template);

                    // reset the friendly path so it's used by forms, etc.
                    Context.RewritePath(UmbracoContext.Current.OriginalRequestUrl.PathAndQuery);

                    //fire the init finished event
                    FireAfterRequestInit(args);
                }
            }
        }
Exemplo n.º 7
0
        public Control ParseWithControls(page umbPage)
        {
            System.Web.HttpContext.Current.Trace.Write("umbracoTemplate", "Start parsing");

            if (System.Web.HttpContext.Current.Items["macrosAdded"] == null)
                System.Web.HttpContext.Current.Items.Add("macrosAdded", 0);

            StringBuilder tempOutput = _templateOutput;

            Control pageLayout = new Control();
            Control pageHeader = new Control();
            Control pageFooter = new Control();
            Control pageContent = new Control();
            System.Web.UI.HtmlControls.HtmlForm pageForm = new System.Web.UI.HtmlControls.HtmlForm();
            System.Web.UI.HtmlControls.HtmlHead pageAspNetHead = new System.Web.UI.HtmlControls.HtmlHead();

            // Find header and footer of page if there is an aspnet-form on page
            if (_templateOutput.ToString().ToLower().IndexOf("<?aspnet_form>") > 0 ||
                _templateOutput.ToString().ToLower().IndexOf("<?aspnet_form disablescriptmanager=\"true\">") > 0)
            {
                pageForm.Attributes.Add("method", "post");
                pageForm.Attributes.Add("action", Convert.ToString(System.Web.HttpContext.Current.Items["VirtualUrl"]));

                // Find header and footer from tempOutput
                int aspnetFormTagBegin = tempOutput.ToString().ToLower().IndexOf("<?aspnet_form>");
                int aspnetFormTagLength = 14;
                int aspnetFormTagEnd = tempOutput.ToString().ToLower().IndexOf("</?aspnet_form>") + 15;

                // check if we should disable the script manager
                if (aspnetFormTagBegin == -1)
                {
                    aspnetFormTagBegin =
                        _templateOutput.ToString().ToLower().IndexOf("<?aspnet_form disablescriptmanager=\"true\">");
                    aspnetFormTagLength = 42;
                }
                else
                {
                    ScriptManager sm = new ScriptManager();
                    sm.ID = "umbracoScriptManager";
                    pageForm.Controls.Add(sm);
                }


                StringBuilder header = new StringBuilder(tempOutput.ToString().Substring(0, aspnetFormTagBegin));

                // Check if there's an asp.net head element in the header
                if (header.ToString().ToLower().Contains("<?aspnet_head>"))
                {
                    StringBuilder beforeHeader = new StringBuilder(header.ToString().Substring(0, header.ToString().ToLower().IndexOf("<?aspnet_head>")));
                    header.Remove(0, header.ToString().ToLower().IndexOf("<?aspnet_head>") + 14);
                    StringBuilder afterHeader = new StringBuilder(header.ToString().Substring(header.ToString().ToLower().IndexOf("</?aspnet_head>") + 15, header.Length - header.ToString().ToLower().IndexOf("</?aspnet_head>") - 15));
                    header.Remove(header.ToString().ToLower().IndexOf("</?aspnet_head>"), header.Length - header.ToString().ToLower().IndexOf("</?aspnet_head>"));

                    // Find the title from head
                    MatchCollection matches = Regex.Matches(header.ToString(), @"<title>(.*?)</title>", RegexOptions.IgnoreCase | RegexOptions.Multiline);
                    if (matches.Count > 0)
                    {
                        StringBuilder titleText = new StringBuilder();
                        HtmlTextWriter titleTextTw = new HtmlTextWriter(new System.IO.StringWriter(titleText));
                        parseStringBuilder(new StringBuilder(matches[0].Groups[1].Value), umbPage).RenderControl(titleTextTw);
                        pageAspNetHead.Title = titleText.ToString();
                        header = new StringBuilder(header.ToString().Replace(matches[0].Value, ""));
                    }

                    pageAspNetHead.Controls.Add(parseStringBuilder(header, umbPage));
                    pageAspNetHead.ID = "head1";

                    // build the whole header part
                    pageHeader.Controls.Add(parseStringBuilder(beforeHeader, umbPage));
                    pageHeader.Controls.Add(pageAspNetHead);
                    pageHeader.Controls.Add(parseStringBuilder(afterHeader, umbPage));

                }
                else
                    pageHeader.Controls.Add(parseStringBuilder(header, umbPage));


                pageFooter.Controls.Add(parseStringBuilder(new StringBuilder(tempOutput.ToString().Substring(aspnetFormTagEnd, tempOutput.Length - aspnetFormTagEnd)), umbPage));
                tempOutput.Remove(0, aspnetFormTagBegin + aspnetFormTagLength);
                aspnetFormTagEnd = tempOutput.ToString().ToLower().IndexOf("</?aspnet_form>");
                tempOutput.Remove(aspnetFormTagEnd, tempOutput.Length - aspnetFormTagEnd);


                //throw new ArgumentException(tempOutput.ToString());
                pageForm.Controls.Add(parseStringBuilder(tempOutput, umbPage));

                pageContent.Controls.Add(pageHeader);
                pageContent.Controls.Add(pageForm);
                pageContent.Controls.Add(pageFooter);
                return pageContent;

            }
            else
                return parseStringBuilder(tempOutput, umbPage);

        }
Exemplo n.º 8
0
        public Control parseStringBuilder(StringBuilder tempOutput, page umbPage)
        {
            Control pageContent = new Control();

            bool stop      = false;
            bool debugMode = umbraco.presentation.UmbracoContext.Current.Request.IsDebug;

            while (!stop)
            {
                System.Web.HttpContext.Current.Trace.Write("template", "Begining of parsing rutine...");
                int tagIndex = tempOutput.ToString().ToLower().IndexOf("<?umbraco");
                if (tagIndex > -1)
                {
                    String tempElementContent = "";
                    pageContent.Controls.Add(new LiteralControl(tempOutput.ToString().Substring(0, tagIndex)));

                    tempOutput.Remove(0, tagIndex);

                    String    tag        = tempOutput.ToString().Substring(0, tempOutput.ToString().IndexOf(">") + 1);
                    Hashtable attributes = helper.ReturnAttributes(tag);

                    // Check whether it's a single tag (<?.../>) or a tag with children (<?..>...</?...>)
                    if (tag.Substring(tag.Length - 2, 1) != "/" && tag.IndexOf(" ") > -1)
                    {
                        String closingTag = "</" + (tag.Substring(1, tag.IndexOf(" ") - 1)) + ">";
                        // Tag with children are only used when a macro is inserted by the umbraco-editor, in the
                        // following format: "<?UMBRACO_MACRO ...><IMG SRC="..."..></?UMBRACO_MACRO>", so we
                        // need to delete extra information inserted which is the image-tag and the closing
                        // umbraco_macro tag
                        if (tempOutput.ToString().IndexOf(closingTag) > -1)
                        {
                            tempOutput.Remove(0, tempOutput.ToString().IndexOf(closingTag));
                        }
                    }



                    System.Web.HttpContext.Current.Trace.Write("umbTemplate", "Outputting item: " + tag);

                    // Handle umbraco macro tags
                    if (tag.ToString().ToLower().IndexOf("umbraco_macro") > -1)
                    {
                        if (debugMode)
                        {
                            pageContent.Controls.Add(new LiteralControl("<div title=\"Macro Tag: '" + System.Web.HttpContext.Current.Server.HtmlEncode(tag) + "'\" style=\"border: 1px solid #009;\">"));
                        }

                        // NH: Switching to custom controls for macros
                        if (UmbracoConfig.For.UmbracoSettings().Templates.UseAspNetMasterPages)
                        {
                            umbraco.presentation.templateControls.Macro macroControl = new umbraco.presentation.templateControls.Macro();
                            macroControl.Alias = helper.FindAttribute(attributes, "macroalias");
                            IDictionaryEnumerator ide = attributes.GetEnumerator();
                            while (ide.MoveNext())
                            {
                                if (macroControl.Attributes[ide.Key.ToString()] == null)
                                {
                                    macroControl.Attributes.Add(ide.Key.ToString(), ide.Value.ToString());
                                }
                            }
                            pageContent.Controls.Add(macroControl);
                        }
                        else
                        {
                            macro  tempMacro;
                            String macroID = helper.FindAttribute(attributes, "macroid");
                            if (macroID != String.Empty)
                            {
                                tempMacro = getMacro(macroID);
                            }
                            else
                            {
                                tempMacro = macro.GetMacro(helper.FindAttribute(attributes, "macroalias"));
                            }

                            if (tempMacro != null)
                            {
                                try
                                {
                                    Control c = tempMacro.renderMacro(attributes, umbPage.Elements, umbPage.PageID);
                                    if (c != null)
                                    {
                                        pageContent.Controls.Add(c);
                                    }
                                    else
                                    {
                                        System.Web.HttpContext.Current.Trace.Warn("Template", "Result of macro " + tempMacro.Name + " is null");
                                    }
                                }
                                catch (Exception e)
                                {
                                    System.Web.HttpContext.Current.Trace.Warn("Template", "Error adding macro " + tempMacro.Name, e);
                                }
                            }
                        }
                        if (debugMode)
                        {
                            pageContent.Controls.Add(new LiteralControl("</div>"));
                        }
                    }
                    else
                    {
                        if (tag.ToLower().IndexOf("umbraco_getitem") > -1)
                        {
                            // NH: Switching to custom controls for items
                            if (UmbracoConfig.For.UmbracoSettings().Templates.UseAspNetMasterPages)
                            {
                                umbraco.presentation.templateControls.Item itemControl = new umbraco.presentation.templateControls.Item();
                                itemControl.Field = helper.FindAttribute(attributes, "field");
                                IDictionaryEnumerator ide = attributes.GetEnumerator();
                                while (ide.MoveNext())
                                {
                                    if (itemControl.Attributes[ide.Key.ToString()] == null)
                                    {
                                        itemControl.Attributes.Add(ide.Key.ToString(), ide.Value.ToString());
                                    }
                                }
                                pageContent.Controls.Add(itemControl);
                            }
                            else
                            {
                                try
                                {
                                    if (helper.FindAttribute(attributes, "nodeId") != "" && int.Parse(helper.FindAttribute(attributes, "nodeId")) != 0)
                                    {
                                        cms.businesslogic.Content c = new umbraco.cms.businesslogic.Content(int.Parse(helper.FindAttribute(attributes, "nodeId")));
                                        item umbItem = new item(c.getProperty(helper.FindAttribute(attributes, "field")).Value.ToString(), attributes);
                                        tempElementContent = umbItem.FieldContent;

                                        // Check if the content is published
                                        if (c.nodeObjectType == cms.businesslogic.web.Document._objectType)
                                        {
                                            try
                                            {
                                                cms.businesslogic.web.Document d = (cms.businesslogic.web.Document)c;
                                                if (!d.Published)
                                                {
                                                    tempElementContent = "";
                                                }
                                            }
                                            catch { }
                                        }
                                    }
                                    else
                                    {
                                        // NH adds Live Editing test stuff
                                        item umbItem = new item(umbPage.Elements, attributes);
                                        //								item umbItem = new item(umbPage.PageElements[helper.FindAttribute(attributes, "field")].ToString(), attributes);
                                        tempElementContent = umbItem.FieldContent;
                                    }

                                    if (debugMode)
                                    {
                                        tempElementContent =
                                            "<div title=\"Field Tag: '" + System.Web.HttpContext.Current.Server.HtmlEncode(tag) + "'\" style=\"border: 1px solid #fc6;\">" + tempElementContent + "</div>";
                                    }
                                }
                                catch (Exception e)
                                {
                                    System.Web.HttpContext.Current.Trace.Warn("umbracoTemplate", "Error reading element (" + helper.FindAttribute(attributes, "field") + ")", e);
                                }
                            }
                        }
                    }
                    tempOutput.Remove(0, tempOutput.ToString().IndexOf(">") + 1);
                    tempOutput.Insert(0, tempElementContent);
                }
                else
                {
                    pageContent.Controls.Add(new LiteralControl(tempOutput.ToString()));
                    break;
                }
            }

            return(pageContent);
        }
Exemplo n.º 9
0
        public Control ParseWithControls(page umbPage)
        {
            System.Web.HttpContext.Current.Trace.Write("umbracoTemplate", "Start parsing");

            if (System.Web.HttpContext.Current.Items["macrosAdded"] == null)
            {
                System.Web.HttpContext.Current.Items.Add("macrosAdded", 0);
            }

            StringBuilder tempOutput = _templateOutput;

            Control pageLayout  = new Control();
            Control pageHeader  = new Control();
            Control pageFooter  = new Control();
            Control pageContent = new Control();

            System.Web.UI.HtmlControls.HtmlForm pageForm       = new System.Web.UI.HtmlControls.HtmlForm();
            System.Web.UI.HtmlControls.HtmlHead pageAspNetHead = new System.Web.UI.HtmlControls.HtmlHead();

            // Find header and footer of page if there is an aspnet-form on page
            if (_templateOutput.ToString().ToLower().IndexOf("<?aspnet_form>") > 0 ||
                _templateOutput.ToString().ToLower().IndexOf("<?aspnet_form disablescriptmanager=\"true\">") > 0)
            {
                pageForm.Attributes.Add("method", "post");
                pageForm.Attributes.Add("action", Convert.ToString(System.Web.HttpContext.Current.Items["VirtualUrl"]));

                // Find header and footer from tempOutput
                int aspnetFormTagBegin  = tempOutput.ToString().ToLower().IndexOf("<?aspnet_form>");
                int aspnetFormTagLength = 14;
                int aspnetFormTagEnd    = tempOutput.ToString().ToLower().IndexOf("</?aspnet_form>") + 15;

                // check if we should disable the script manager
                if (aspnetFormTagBegin == -1)
                {
                    aspnetFormTagBegin =
                        _templateOutput.ToString().ToLower().IndexOf("<?aspnet_form disablescriptmanager=\"true\">");
                    aspnetFormTagLength = 42;
                }
                else
                {
                    ScriptManager sm = new ScriptManager();
                    sm.ID = "umbracoScriptManager";
                    pageForm.Controls.Add(sm);
                }


                StringBuilder header = new StringBuilder(tempOutput.ToString().Substring(0, aspnetFormTagBegin));

                // Check if there's an asp.net head element in the header
                if (header.ToString().ToLower().Contains("<?aspnet_head>"))
                {
                    StringBuilder beforeHeader = new StringBuilder(header.ToString().Substring(0, header.ToString().ToLower().IndexOf("<?aspnet_head>")));
                    header.Remove(0, header.ToString().ToLower().IndexOf("<?aspnet_head>") + 14);
                    StringBuilder afterHeader = new StringBuilder(header.ToString().Substring(header.ToString().ToLower().IndexOf("</?aspnet_head>") + 15, header.Length - header.ToString().ToLower().IndexOf("</?aspnet_head>") - 15));
                    header.Remove(header.ToString().ToLower().IndexOf("</?aspnet_head>"), header.Length - header.ToString().ToLower().IndexOf("</?aspnet_head>"));

                    // Find the title from head
                    MatchCollection matches = Regex.Matches(header.ToString(), @"<title>(.*?)</title>", RegexOptions.IgnoreCase | RegexOptions.Multiline);
                    if (matches.Count > 0)
                    {
                        StringBuilder  titleText   = new StringBuilder();
                        HtmlTextWriter titleTextTw = new HtmlTextWriter(new System.IO.StringWriter(titleText));
                        parseStringBuilder(new StringBuilder(matches[0].Groups[1].Value), umbPage).RenderControl(titleTextTw);
                        pageAspNetHead.Title = titleText.ToString();
                        header = new StringBuilder(header.ToString().Replace(matches[0].Value, ""));
                    }

                    pageAspNetHead.Controls.Add(parseStringBuilder(header, umbPage));
                    pageAspNetHead.ID = "head1";

                    // build the whole header part
                    pageHeader.Controls.Add(parseStringBuilder(beforeHeader, umbPage));
                    pageHeader.Controls.Add(pageAspNetHead);
                    pageHeader.Controls.Add(parseStringBuilder(afterHeader, umbPage));
                }
                else
                {
                    pageHeader.Controls.Add(parseStringBuilder(header, umbPage));
                }


                pageFooter.Controls.Add(parseStringBuilder(new StringBuilder(tempOutput.ToString().Substring(aspnetFormTagEnd, tempOutput.Length - aspnetFormTagEnd)), umbPage));
                tempOutput.Remove(0, aspnetFormTagBegin + aspnetFormTagLength);
                aspnetFormTagEnd = tempOutput.ToString().ToLower().IndexOf("</?aspnet_form>");
                tempOutput.Remove(aspnetFormTagEnd, tempOutput.Length - aspnetFormTagEnd);


                //throw new ArgumentException(tempOutput.ToString());
                pageForm.Controls.Add(parseStringBuilder(tempOutput, umbPage));

                pageContent.Controls.Add(pageHeader);
                pageContent.Controls.Add(pageForm);
                pageContent.Controls.Add(pageFooter);
                return(pageContent);
            }
            else
            {
                return(parseStringBuilder(tempOutput, umbPage));
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Renders the content of a macro. Uses the normal template umbraco macro markup as input.
        /// This only works properly with xslt macros. 
        /// Python and .ascx based macros will not render properly, as viewstate is not included.
        /// </summary>
        /// <param name="Text">The macro markup to be rendered.</param>
        /// <param name="PageId">The page id.</param>
        /// <returns>The rendered macro as a string</returns>
        public static string RenderMacroContent(string Text, int PageId)
        {
            try
            {
                page p = new page(((IHasXmlNode)GetXmlNodeById(PageId.ToString()).Current).GetNode());
                template t = new template(p.Template);
                Control c = t.parseStringBuilder(new StringBuilder(Text), p);

                StringWriter sw = new StringWriter();
                HtmlTextWriter hw = new HtmlTextWriter(sw);
                c.RenderControl(hw);

                return sw.ToString();
            }
            catch (Exception ee)
            {
                return string.Format("<!-- Error generating macroContent: '{0}' -->", ee);
            }
        }
Exemplo n.º 11
0
 public library(int id)
 {
     _page = new page(((System.Xml.IHasXmlNode)GetXmlNodeById(id.ToString()).Current).GetNode());
 }
Exemplo n.º 12
0
        /// <summary>
        /// Renders a template.
        /// </summary>
        /// <param name="PageId">The page id.</param>
        /// <param name="TemplateId">The template id.</param>
        /// <returns>The rendered template as a string</returns>
        public static string RenderTemplate(int PageId, int TemplateId)
        {
            if (UmbracoConfig.For.UmbracoSettings().Templates.UseAspNetMasterPages)
            {
                using (var sw = new StringWriter())
                {
                    try
                    {
                        var altTemplate = TemplateId == -1 ? null : (int?)TemplateId;
                        var templateRenderer = new TemplateRenderer(Umbraco.Web.UmbracoContext.Current, PageId, altTemplate);
                        templateRenderer.Render(sw);
                    }
                    catch (Exception ee)
                    {
                        sw.Write("<!-- Error rendering template with id {0}: '{1}' -->", PageId, ee);
                    }

                    return sw.ToString();
                }
            }
            else
            {

                var p = new page(((IHasXmlNode)GetXmlNodeById(PageId.ToString()).Current).GetNode());
                p.RenderPage(TemplateId);
                var c = p.PageContentControl;
                
				using (var sw = new StringWriter())
                using(var hw = new HtmlTextWriter(sw))
                {
					c.RenderControl(hw);
					return sw.ToString();    
                }
                
            }
        }
Exemplo n.º 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="library"/> class.
 /// </summary>
 /// <param name="Page">The page.</param>
 public library(page page)
 {
     _page = page;
 }
Exemplo n.º 14
0
        /// <summary>
        /// Parses the content of the templateOutput stringbuilder, and matches any tags given in the
        /// XML-file /umbraco/config/umbracoTemplateTags.xml. 
        /// Replaces the found tags in the StringBuilder object, with "real content"
        /// </summary>
        /// <param name="umbPage"></param>
        public void Parse(page umbPage)
        {
            System.Web.HttpContext.Current.Trace.Write("umbracoTemplate", "Start parsing");

            // First parse for known umbraco tags
            // <?UMBRACO_MACRO/> - macros
            // <?UMBRACO_GETITEM/> - print item from page, level, or recursive
            MatchCollection tags = Regex.Matches(_templateOutput.ToString(), "<\\?UMBRACO_MACRO[^>]*/>|<\\?UMBRACO_GETITEM[^>]*/>|<\\?(?<tagName>[\\S]*)[^>]*/>", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);

            foreach (Match tag in tags)
            {
                Hashtable attributes = helper.ReturnAttributes(tag.Value.ToString());


                if (tag.ToString().ToLower().IndexOf("umbraco_macro") > -1)
                {
                    String macroID = helper.FindAttribute(attributes, "macroid");
                    if (macroID != "")
                    {
                        macro tempMacro = getMacro(macroID);
                        _templateOutput.Replace(tag.Value.ToString(), tempMacro.MacroContent.ToString());
                    }
                }
                else
                {
                    if (tag.ToString().ToLower().IndexOf("umbraco_getitem") > -1)
                    {
                        try
                        {
                            String tempElementContent = umbPage.Elements[helper.FindAttribute(attributes, "field")].ToString();
                            MatchCollection tempMacros = Regex.Matches(tempElementContent, "<\\?UMBRACO_MACRO(?<attributes>[^>]*)><img[^>]*><\\/\\?UMBRACO_MACRO>", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
                            foreach (Match tempMacro in tempMacros)
                            {
                                Hashtable tempAttributes = helper.ReturnAttributes(tempMacro.Groups["attributes"].Value.ToString());
                                String macroID = helper.FindAttribute(tempAttributes, "macroid");
                                if (Convert.ToInt32(macroID) > 0)
                                {
                                    macro tempContentMacro = getMacro(macroID);
                                    _templateOutput.Replace(tag.Value.ToString(), tempContentMacro.MacroContent.ToString());
                                }

                            }

                            _templateOutput.Replace(tag.Value.ToString(), tempElementContent);
                        }
                        catch (Exception e)
                        {
                            System.Web.HttpContext.Current.Trace.Warn("umbracoTemplate", "Error reading element (" + helper.FindAttribute(attributes, "field") + ")", e);
                        }
                    }
                }
            }

            System.Web.HttpContext.Current.Trace.Write("umbracoTemplate", "Done parsing");
        }
Exemplo n.º 15
0
        public Control parseStringBuilder(StringBuilder tempOutput, page umbPage)
        {

            Control pageContent = new Control();

            bool stop = false;
            bool debugMode = umbraco.presentation.UmbracoContext.Current.Request.IsDebug;

            while (!stop)
            {
                System.Web.HttpContext.Current.Trace.Write("template", "Begining of parsing rutine...");
                int tagIndex = tempOutput.ToString().ToLower().IndexOf("<?umbraco");
                if (tagIndex > -1)
                {
                    String tempElementContent = "";
                    pageContent.Controls.Add(new LiteralControl(tempOutput.ToString().Substring(0, tagIndex)));

                    tempOutput.Remove(0, tagIndex);

                    String tag = tempOutput.ToString().Substring(0, tempOutput.ToString().IndexOf(">") + 1);
                    Hashtable attributes = helper.ReturnAttributes(tag);

                    // Check whether it's a single tag (<?.../>) or a tag with children (<?..>...</?...>)
                    if (tag.Substring(tag.Length - 2, 1) != "/" && tag.IndexOf(" ") > -1)
                    {
                        String closingTag = "</" + (tag.Substring(1, tag.IndexOf(" ") - 1)) + ">";
                        // Tag with children are only used when a macro is inserted by the umbraco-editor, in the
                        // following format: "<?UMBRACO_MACRO ...><IMG SRC="..."..></?UMBRACO_MACRO>", so we
                        // need to delete extra information inserted which is the image-tag and the closing
                        // umbraco_macro tag
                        if (tempOutput.ToString().IndexOf(closingTag) > -1)
                        {
                            tempOutput.Remove(0, tempOutput.ToString().IndexOf(closingTag));
                        }
                    }



                    System.Web.HttpContext.Current.Trace.Write("umbTemplate", "Outputting item: " + tag);

                    // Handle umbraco macro tags
                    if (tag.ToString().ToLower().IndexOf("umbraco_macro") > -1)
                    {
                        if (debugMode)
                            pageContent.Controls.Add(new LiteralControl("<div title=\"Macro Tag: '" + System.Web.HttpContext.Current.Server.HtmlEncode(tag) + "'\" style=\"border: 1px solid #009;\">"));

                        // NH: Switching to custom controls for macros
                        if (UmbracoSettings.UseAspNetMasterPages)
                        {
                            umbraco.presentation.templateControls.Macro macroControl = new umbraco.presentation.templateControls.Macro();
                            macroControl.Alias = helper.FindAttribute(attributes, "macroalias");
                            IDictionaryEnumerator ide = attributes.GetEnumerator();
                            while (ide.MoveNext())
                                if (macroControl.Attributes[ide.Key.ToString()] == null)
                                    macroControl.Attributes.Add(ide.Key.ToString(), ide.Value.ToString());
                            pageContent.Controls.Add(macroControl);
                        }
                        else
                        {
                            macro tempMacro;
                            String macroID = helper.FindAttribute(attributes, "macroid");
                            if (macroID != String.Empty)
                                tempMacro = getMacro(macroID);
                            else
                                tempMacro = macro.GetMacro(helper.FindAttribute(attributes, "macroalias"));

                            if (tempMacro != null)
                            {

                                try
                                {
                                    Control c = tempMacro.renderMacro(attributes, umbPage.Elements, umbPage.PageID);
                                    if (c != null)
                                        pageContent.Controls.Add(c);
                                    else
                                        System.Web.HttpContext.Current.Trace.Warn("Template", "Result of macro " + tempMacro.Name + " is null");

                                }
                                catch (Exception e)
                                {
                                    System.Web.HttpContext.Current.Trace.Warn("Template", "Error adding macro " + tempMacro.Name, e);
                                }
                            }
                        }
                        if (debugMode)
                            pageContent.Controls.Add(new LiteralControl("</div>"));
                    }
                    else
                    {
                        if (tag.ToLower().IndexOf("umbraco_getitem") > -1)
                        {

                            // NH: Switching to custom controls for items
                            if (UmbracoSettings.UseAspNetMasterPages)
                            {
                                umbraco.presentation.templateControls.Item itemControl = new umbraco.presentation.templateControls.Item();
                                itemControl.Field = helper.FindAttribute(attributes, "field");
                                IDictionaryEnumerator ide = attributes.GetEnumerator();
                                while (ide.MoveNext())
                                    if (itemControl.Attributes[ide.Key.ToString()] == null)
                                        itemControl.Attributes.Add(ide.Key.ToString(), ide.Value.ToString());
                                pageContent.Controls.Add(itemControl);
                            }
                            else
                            {
                                try
                                {
                                    if (helper.FindAttribute(attributes, "nodeId") != "" && int.Parse(helper.FindAttribute(attributes, "nodeId")) != 0)
                                    {
                                        cms.businesslogic.Content c = new umbraco.cms.businesslogic.Content(int.Parse(helper.FindAttribute(attributes, "nodeId")));
                                        item umbItem = new item(c.getProperty(helper.FindAttribute(attributes, "field")).Value.ToString(), attributes);
                                        tempElementContent = umbItem.FieldContent;

                                        // Check if the content is published
                                        if (c.nodeObjectType == cms.businesslogic.web.Document._objectType)
                                        {
                                            try
                                            {
                                                cms.businesslogic.web.Document d = (cms.businesslogic.web.Document)c;
                                                if (!d.Published)
                                                    tempElementContent = "";
                                            }
                                            catch { }
                                        }

                                    }
                                    else
                                    {
                                        // NH adds Live Editing test stuff
                                        item umbItem = new item(umbPage.Elements, attributes);
                                        //								item umbItem = new item(umbPage.PageElements[helper.FindAttribute(attributes, "field")].ToString(), attributes);
                                        tempElementContent = umbItem.FieldContent;
                                    }

                                    if (debugMode)
                                        tempElementContent =
                                            "<div title=\"Field Tag: '" + System.Web.HttpContext.Current.Server.HtmlEncode(tag) + "'\" style=\"border: 1px solid #fc6;\">" + tempElementContent + "</div>";
                                }
                                catch (Exception e)
                                {
                                    System.Web.HttpContext.Current.Trace.Warn("umbracoTemplate", "Error reading element (" + helper.FindAttribute(attributes, "field") + ")", e);
                                }
                            }
                        }
                    }
                    tempOutput.Remove(0, tempOutput.ToString().IndexOf(">") + 1);
                    tempOutput.Insert(0, tempElementContent);
                }
                else
                {
                    pageContent.Controls.Add(new LiteralControl(tempOutput.ToString()));
                    break;
                }

            }

            return pageContent;

        }
Exemplo n.º 16
0
        void Page_PreInit(Object sender, EventArgs e)
        {
            Trace.Write("umbracoInit", "handling request");

            if (UmbracoContext.Current == null)
                UmbracoContext.Current = new UmbracoContext(HttpContext.Current);

            bool editMode = UmbracoContext.Current.LiveEditingContext.Enabled;

            if (editMode)
                ValidateRequest = false;

            if (m_tmp != "" && Request["umbPageID"] == null)
            {
                // Check numeric
                string tryIntParse = m_tmp.Replace("/", "").Replace(".aspx", string.Empty);
                int result;
                if (int.TryParse(tryIntParse, out result))
                {
                    m_tmp = m_tmp.Replace(".aspx", string.Empty);

                    // Check for request
                    if (!string.IsNullOrEmpty(Request["umbVersion"]))
                    {
                        // Security check
                        BasePages.UmbracoEnsuredPage bp = new BasePages.UmbracoEnsuredPage();
                        bp.ensureContext();
                        m_version = new Guid(Request["umbVersion"]);
                    }
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(Request["umbPageID"]))
                {
                    int result;
                    if (int.TryParse(Request["umbPageID"], out result))
                    {
                        m_tmp = Request["umbPageID"];
                    }
                }
            }

            if (m_version != Guid.Empty)
            {
                HttpContext.Current.Items["pageID"] = m_tmp.Replace("/", "");
                m_umbPage = new page(int.Parse(m_tmp.Replace("/", "")), m_version);
            }
            else
            {
                m_umbRequest = new requestHandler(UmbracoContext.Current.GetXml(), m_tmp);
                Trace.Write("umbracoInit", "Done handling request");
                if (m_umbRequest.currentPage != null)
                {
                    HttpContext.Current.Items["pageID"] = m_umbRequest.currentPage.Attributes.GetNamedItem("id").Value;

                    // Handle edit
                    if (editMode)
                    {
                        Document d = new Document(int.Parse(m_umbRequest.currentPage.Attributes.GetNamedItem("id").Value));
                        m_umbPage = new page(d.Id, d.Version);
                    }
                    else
                        m_umbPage = new page(m_umbRequest.currentPage);
                }
            }

            // set the friendly path so it's used by forms
            HttpContext.Current.RewritePath(HttpContext.Current.Items[requestModule.ORIGINAL_URL_CXT_KEY].ToString());

            if (UmbracoSettings.UseAspNetMasterPages)
            {
                HttpContext.Current.Trace.Write("umbracoPage", "Looking up skin information");

                if (m_umbPage != null)
                {
                    if (m_umbPage.Template == 0)
                    {
                        string custom404 = umbraco.library.GetCurrentNotFoundPageId();
                        if (!String.IsNullOrEmpty(custom404))
                        {
                            XmlNode xmlNodeNotFound = content.Instance.XmlContent.GetElementById(custom404);
                            if (xmlNodeNotFound != null)
                            {
                                m_umbPage = new page(xmlNodeNotFound);
                            }
                        }
                    }

                    if (m_umbPage.Template != 0)
                    {
                        this.MasterPageFile = template.GetMasterPageName(m_umbPage.Template);
                    }
                    else
                    {
                        GenerateNotFoundContent();
                        Response.End();
                    }
                }

                initUmbracoPage();
            }
        }
Exemplo n.º 17
0
        public static string GetRenderedMacro(int MacroId, page umbPage, Hashtable attributes, int pageId)
        {
            macro m = GetMacro(MacroId);
            Control c = m.renderMacro(attributes, umbPage.Elements, pageId);
            TextWriter writer = new StringWriter();
            var ht = new HtmlTextWriter(writer);
            c.RenderControl(ht);
            string result = writer.ToString();

            // remove hrefs
            string pattern = "href=\"([^\"]*)\"";
            MatchCollection hrefs =
                Regex.Matches(result, pattern, RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
            foreach (Match href in hrefs)
                result = result.Replace(href.Value, "href=\"javascript:void(0)\"");

            return result;
        }
Exemplo n.º 18
0
        /// <summary>
        /// Renders a template.
        /// </summary>
        /// <param name="PageId">The page id.</param>
        /// <param name="TemplateId">The template id.</param>
        /// <returns>The rendered template as a string</returns>
        public static string RenderTemplate(int PageId, int TemplateId)
        {
            if (UmbracoSettings.UseAspNetMasterPages)
            {
                if (!umbraco.presentation.UmbracoContext.Current.LiveEditingContext.Enabled)
                {
                    System.Collections.Generic.Dictionary<object, object> items = getCurrentContextItems();
                    HttpContext.Current.Items["altTemplate"] = null;

                    HttpContext Context = HttpContext.Current;
                    StringBuilder queryString = new StringBuilder();
                    const string ONE_QS_PARAM = "&{0}={1}";
                    foreach (object key in Context.Request.QueryString.Keys)
                    {
                        if (!key.ToString().ToLower().Equals("umbpageid") && !key.ToString().ToLower().Equals("alttemplate"))
                            queryString.Append(string.Format(ONE_QS_PARAM, key, Context.Request.QueryString[key.ToString()]));
                    }
                    StringWriter sw = new StringWriter();

                    try
                    {
                        Context.Server.Execute(
                            string.Format("~/default.aspx?umbPageID={0}&alttemplate={1}{2}",
                            PageId, new template(TemplateId).TemplateAlias, queryString), sw);

                    }
                    catch (Exception ee)
                    {
                        sw.Write("<!-- Error generating macroContent: '{0}' -->", ee);
                    }

                    // update the local page items again
                    updateLocalContextItems(items, Context);

                    return sw.ToString();

                }
                else
                {
                    return "RenderTemplate not supported in Canvas";
                }
            }
            else
            {
                page p = new page(((IHasXmlNode)GetXmlNodeById(PageId.ToString()).Current).GetNode());
                p.RenderPage(TemplateId);
                Control c = p.PageContentControl;
                StringWriter sw = new StringWriter();
                HtmlTextWriter hw = new HtmlTextWriter(sw);
                c.RenderControl(hw);

                return sw.ToString();
            }
        }
        void Page_PreInit(Object sender, EventArgs e)
        {
            Trace.Write("umbracoInit", "handling request");

            if (UmbracoContext.Current == null)
            {
                UmbracoContext.Current = new UmbracoContext(HttpContext.Current);
            }

            bool editMode = UmbracoContext.Current.LiveEditingContext.Enabled;

            if (editMode)
            {
                ValidateRequest = false;
            }

            if (m_tmp != "" && Request["umbPageID"] == null)
            {
                // Check numeric
                string tryIntParse = m_tmp.Replace("/", "").Replace(".aspx", string.Empty);
                int    result;
                if (int.TryParse(tryIntParse, out result))
                {
                    m_tmp = m_tmp.Replace(".aspx", string.Empty);

                    // Check for request
                    if (!string.IsNullOrEmpty(Request["umbVersion"]))
                    {
                        // Security check
                        BasePages.UmbracoEnsuredPage bp = new BasePages.UmbracoEnsuredPage();
                        bp.ensureContext();
                        m_version = new Guid(Request["umbVersion"]);
                    }
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(Request["umbPageID"]))
                {
                    int result;
                    if (int.TryParse(Request["umbPageID"], out result))
                    {
                        m_tmp = Request["umbPageID"];
                    }
                }
            }

            if (m_version != Guid.Empty)
            {
                HttpContext.Current.Items["pageID"] = m_tmp.Replace("/", "");
                m_umbPage = new page(int.Parse(m_tmp.Replace("/", "")), m_version);
            }
            else
            {
                m_umbRequest = new requestHandler(UmbracoContext.Current.GetXml(), m_tmp);
                Trace.Write("umbracoInit", "Done handling request");
                if (m_umbRequest.currentPage != null)
                {
                    HttpContext.Current.Items["pageID"] = m_umbRequest.currentPage.Attributes.GetNamedItem("id").Value;

                    // Handle edit
                    if (editMode)
                    {
                        Document d = new Document(int.Parse(m_umbRequest.currentPage.Attributes.GetNamedItem("id").Value));
                        m_umbPage = new page(d.Id, d.Version);
                    }
                    else
                    {
                        m_umbPage = new page(m_umbRequest.currentPage);
                    }
                }
            }

            // set the friendly path so it's used by forms
            HttpContext.Current.RewritePath(HttpContext.Current.Items[requestModule.ORIGINAL_URL_CXT_KEY].ToString());

            if (UmbracoSettings.UseAspNetMasterPages)
            {
                HttpContext.Current.Trace.Write("umbracoPage", "Looking up skin information");

                if (m_umbPage != null)
                {
                    if (m_umbPage.Template == 0)
                    {
                        string custom404 = umbraco.library.GetCurrentNotFoundPageId();
                        if (!String.IsNullOrEmpty(custom404))
                        {
                            XmlNode xmlNodeNotFound = content.Instance.XmlContent.GetElementById(custom404);
                            if (xmlNodeNotFound != null)
                            {
                                m_umbPage = new page(xmlNodeNotFound);
                            }
                        }
                    }

                    if (m_umbPage.Template != 0)
                    {
                        this.MasterPageFile = template.GetMasterPageName(m_umbPage.Template);
                    }
                    else
                    {
                        GenerateNotFoundContent();
                        Response.End();
                    }
                }

                initUmbracoPage();
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init"/> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            // check if a macro (tag) is specified
            if (!string.IsNullOrEmpty(this.Options.MacroTag))
            {
                // get the node for the current page
                var node = uQuery.GetCurrentNode();

                // if the node is null (either document is unpublished, or rendering from outside the content section)
                if (node == null)
                {
                    // then get the first child node from the XML content root
                    var nodes = uQuery.GetNodesByXPath(string.Concat("descendant::*[@parentID = ", uQuery.RootNodeId, "]")).ToList();
                    if (nodes != null && nodes.Count > 0)
                    {
                        node = nodes[0];
                    }
                }

                if (node != null)
                {
                    // load the page reference
                    var umbPage = new page(node.Id, node.Version);
                    HttpContext.Current.Items["pageID"] = node.Id;
                    HttpContext.Current.Items["pageElements"] = umbPage.Elements;

                    var attr = XmlHelper.GetAttributesFromElement(this.Options.MacroTag);

                    if (attr.ContainsKey("macroalias"))
                    {
                        var macro = new Macro() { Alias = attr["macroalias"].ToString() };

                        foreach (var item in attr)
                        {
                            macro.Attributes.Add(item.Key.ToString(), item.Value.ToString());
                        }

                        this.Controls.Add(macro);
                    }
                }
                else
                {
                    this.Controls.Add(new Literal() { Text = "<em>There are no published content nodes (yet), therefore the macro can not be rendered.</em>" });
                }
            }

            base.OnInit(e);
        }