private void CreateChildNodes(
            mojoSiteMapNode node,
            PageSettings page,
            int depth)
        {
            foreach (PageSettings p in menuPages)
            {
                if (p.ParentId == page.PageId)
                {
                    SiteMapNode childNode = CreateSiteMapNode(p, depth);
                    try
                    {
                        AddNode(childNode, node);
                    }
                    catch (InvalidOperationException ex)
                    {
                        log.Error("failed to add node to sitemap", ex);
                    }
                    catch (HttpException ex)
                    {
                        log.Error("failed to add node to sitemap", ex);
                    }

                    if ((p.UseUrl) && (p.Url.StartsWith("http")))
                    {
                        childNode.Url = p.Url;
                    }
                }
            }
        }
Example #2
0
        //http://msdn.microsoft.com/en-us/library/system.web.sitemapnodecollection.aspx

        //http://stackoverflow.com/questions/1960364/asp-net-enumerate-through-sitemapnode-childnodes

        //foreach (var childNode in node.ChildNodes.OrderBy(x => x.Key))

        //public static IEnumerable<SiteMapNode> OrderBy(this SiteMapNodeCollection smnc, Func<SiteMapNode, TKey> expression)
        //{
        //    return smnc.Cast<SiteMapNode>().OrderBy(expression);
        //}

        //http://stackoverflow.com/questions/703130/linq-query-loses-order

        public static SiteMapNode FindNodeAllowedForParentPage(SiteMapNode rootNode, string pageName)
        {
            //SiteMapNode node = rootNode.GetAllNodes().Cast().FirstOrDefault(n => n.Key.Equals(pagekey));
            //return node != null ? node.Url : String.Empty;

            SiteMapNode foundNode = (
                from SiteMapNode cr in rootNode.GetAllNodes()
                where cr.Title.StartsWith(pageName)
                orderby cr.Title
                select cr
                ).First();

            mojoSiteMapNode mojoNode = foundNode as mojoSiteMapNode;

            if (mojoNode != null)
            {
                if ((WebUser.IsInRoles(mojoNode.CreateChildPageRoles)) || (WebUser.IsInRoles(mojoNode.CreateChildDraftPageRoles)))
                {
                    return(foundNode);
                }
            }


            return(null);
        }
 public ModuleDecoratedSiteMapNode(mojoSiteMapNode siteNode)
 {
     if (siteNode == null)
     {
         throw new ArgumentException("siteNode can't be null");
     }
     this.siteMapNode = siteNode;
 }
Example #4
0
        private mojoSiteMapNode CreateRootNode()
        {
            string[] rolelist = new string[0];

            mojoSiteMapNode node = new mojoSiteMapNode(
                this,
                "-1");

            node.IsRootNode = true;

            nodes.Add(-1, node);

            return(node);
        }
Example #5
0
        public static void PopulateArrayList(
            ArrayList arrayList,
            SiteMapNode siteMapNode)
        {
            mojoSiteMapNode mojoNode = (mojoSiteMapNode)siteMapNode;

            if (!mojoNode.IsRootNode)
            {
                mojoNode.DepthIndicator = GetDepthIndicatorString(mojoNode.Depth);
                arrayList.Add(mojoNode);
            }

            foreach (SiteMapNode childNode in mojoNode.ChildNodes)
            {
                //recurse to populate children
                PopulateArrayList(arrayList, childNode);
            }
        }
Example #6
0
        //public static mojoSiteMapNode GetSiteMapNodeForPage(SiteMapNode rootNode, PageSettings pageSettings)
        //{
        //    if (rootNode == null) { return null; }
        //    if (pageSettings == null) { return null; }
        //    if (!(rootNode is mojoSiteMapNode)) { return null; }

        //    foreach (SiteMapNode childNode in rootNode.ChildNodes)
        //    {
        //        if (!(childNode is mojoSiteMapNode)) { return null; }

        //        mojoSiteMapNode node = childNode as mojoSiteMapNode;
        //        if (node.PageId == pageSettings.PageId) { return node; }

        //        mojoSiteMapNode foundNode = GetSiteMapNodeForPage(node, pageSettings);
        //        if (foundNode != null) { return foundNode; }


        //    }

        //    return null;

        //}

        public static mojoSiteMapNode GetSiteMapNodeForPage(SiteMapNode rootNode, string currentUrl)
        {
            if (rootNode == null)
            {
                return(null);
            }
            if (string.IsNullOrEmpty(currentUrl))
            {
                return(null);
            }
            if (!(rootNode is mojoSiteMapNode))
            {
                return(null);
            }

            foreach (SiteMapNode childNode in rootNode.ChildNodes)
            {
                if (!(childNode is mojoSiteMapNode))
                {
                    return(null);
                }

                mojoSiteMapNode node = childNode as mojoSiteMapNode;
                if (string.Equals(node.Url.Replace("~", string.Empty), currentUrl, StringComparison.InvariantCultureIgnoreCase))
                {
                    return(node);
                }

                mojoSiteMapNode foundNode = GetSiteMapNodeForPage(node, currentUrl);
                if (foundNode != null)
                {
                    return(foundNode);
                }
            }

            return(null);
        }
Example #7
0
        public static mojoSiteMapNode GetSiteMapNodeForPage(SiteMapNode rootNode, PageSettings pageSettings)
        {
            if (rootNode == null)
            {
                return(null);
            }
            if (pageSettings == null)
            {
                return(null);
            }
            if (!(rootNode is mojoSiteMapNode))
            {
                return(null);
            }

            foreach (SiteMapNode childNode in rootNode.ChildNodes)
            {
                if (!(childNode is mojoSiteMapNode))
                {
                    return(null);
                }

                mojoSiteMapNode node = childNode as mojoSiteMapNode;
                if (node.PageId == pageSettings.PageId)
                {
                    return(node);
                }

                mojoSiteMapNode foundNode = GetSiteMapNodeForPage(node, pageSettings);
                if (foundNode != null)
                {
                    return(foundNode);
                }
            }

            return(null);
        }
Example #8
0
        private static bool CanCreatePages(SiteMapNode siteMapNode)
        {
            mojoSiteMapNode mojoNode = (mojoSiteMapNode)siteMapNode;

            if (!mojoNode.IsRootNode)
            {
                if (WebUser.IsInRoles(mojoNode.CreateChildPageRoles))
                {
                    return(true);
                }
            }


            foreach (SiteMapNode childNode in mojoNode.ChildNodes)
            {
                //recurse to populate children
                if (CanCreatePages(childNode))
                {
                    return(true);
                }
            }

            return(false);
        }
Example #9
0
        public bool HasVisibleChildren()
        {
            if (this.ChildNodes == null)
            {
                return(false);
            }
            if (this.ChildNodes.Count == 0)
            {
                return(false);
            }
            foreach (SiteMapNode child in ChildNodes)
            {
                if (child is mojoSiteMapNode)
                {
                    mojoSiteMapNode mchild = child as mojoSiteMapNode;
                    if ((mchild.IncludeInMenu) && (WebUser.IsInRoles(mchild.ViewRoles)))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Example #10
0
        public static bool NodeHasVisibleChildrenAtDepth(mojoSiteMapNode node, int depth, bool recurse)
        {
            foreach (SiteMapNode cNode in node.ChildNodes)
            {
                if (!(cNode is mojoSiteMapNode)) { return false; }

                mojoSiteMapNode childNode = cNode as mojoSiteMapNode;
                if (childNode.Depth >= depth)
                {
                    if (
                        (childNode.IncludeInMenu)
                        &&(!(childNode.PublishMode == (int)ContentPublishMode.MobileOnly))
                        &&(WebUser.IsInRoles(childNode.ViewRoles))
                        )
                    { return true; }
                }
                else
                {
                    if (recurse)
                    {
                        if (NodeHasVisibleChildrenAtDepth(childNode, depth, recurse))
                        { return true; }
                    }
                }

            }

            return false;
        }
Example #11
0
        private string BuildUlClass(mojoSiteMapNode mojoNode)
        {
            string result = string.Empty;
            string spacer = string.Empty;

            //added 2013-11-08 https://www.mojoportal.com/Forums/Thread.aspx?pageid=5&t=12214~1#post50717
            if (childUlCssClass.Length > 0)
            {
                result += spacer + childUlCssClass;
                spacer = " ";
            }

            if ((ulChildSelectedCssClass.Length > 0) && (currentNode != null)
                && (currentNode.IsDescendantOf(mojoNode))
                )
            {
                result += spacer + ulChildSelectedCssClass;
                spacer = " ";
            }

            if ((ulSelectedCssClass.Length > 0) && (currentNode != null)
                && (currentNode.PageGuid == mojoNode.PageGuid)
                )
            {
                result += spacer + ulSelectedCssClass;
                spacer = " ";
            }

            if (result.Length > 0)
            {
                return " class='" + result + "'";
            }

            return result;
        }
        private SiteMapNode CreateSiteMapNode(
            PageSettings page,
            int depth)
        {
            //string[] rolelist = null;
            List<string> roleList = null;
            if (!String.IsNullOrEmpty(page.AuthorizedRoles))
            {
                //rolelist = page.AuthorizedRoles.Split(new char[] { ',', ';' }, 512);
                roleList = page.AuthorizedRoles.SplitOnChar(';');
            }

            string pageUrl;
            if (
                (page.UseUrl)
                &&(!page.Url.StartsWith("http"))
                &&(page.Url.Length > 0)
                &&(useUrlRewriter)
                )
            {

                pageUrl = page.Url ;
            }
            else
            {
               pageUrl = "~/Default.aspx?pageid=" + page.PageId.ToString();
            }

            // this was making a title (tooltip) on the link with the same text as the link text
            // not a good idea, adds no value and actually can make the page obnoxious for a screen reader user as it
            // would read the link text and the title
            //mojoSiteMapNode node = new mojoSiteMapNode(
            //    this,
            //    page.PageId.ToString(),
            //    pageUrl,
            //    HttpContext.Current.Server.HtmlEncode(page.PageName),
            //    HttpContext.Current.Server.HtmlEncode(page.PageName),
            //    rolelist,
            //    null,
            //    null,
            //    null);

            mojoSiteMapNode node = new mojoSiteMapNode(
                this,
                page.PageId.ToString(),
                pageUrl,
                HttpContext.Current.Server.HtmlEncode(page.PageName),
                string.Empty,
                roleList,
                null,
                null,
                null);

            if((page.MenuImage.Length > 0)&&(page.MenuImage.ToLower().IndexOf("blank") == -1))
            {
                node.MenuImage = this.iconBaseUrl + page.MenuImage;
            }

            node.PageGuid = page.PageGuid;
            node.PageId = page.PageId;
            node.ParentId = page.ParentId;
            node.Depth = depth;
            node.ViewRoles = page.AuthorizedRoles;
            node.EditRoles = page.EditRoles;
            node.DraftEditRoles = page.DraftEditOnlyRoles;
            node.CreateChildPageRoles = page.CreateChildPageRoles;
            node.CreateChildDraftPageRoles = page.CreateChildDraftRoles;
            node.IncludeInMenu = page.IncludeInMenu;
            node.IncludeInSiteMap = page.IncludeInSiteMap;
            node.ExpandOnSiteMap = page.ExpandOnSiteMap;
            node.IncludeInChildSiteMap = page.IncludeInChildSiteMap;
            node.IncludeInSearchMap = page.IncludeInSearchMap;
            node.LastModifiedUtc = page.LastModifiedUtc;
            node.ChangeFrequency = page.ChangeFrequency;
            node.SiteMapPriority = page.SiteMapPriority;
            node.OpenInNewWindow = page.OpenInNewWindow;
            node.HideAfterLogin = page.HideAfterLogin;
            node.UseSsl = (page.RequireSsl && sslIsAvailable);
            node.IsPending = page.IsPending;
            node.IsClickable = page.IsClickable;
            node.MenuCssClass = page.MenuCssClass;
            node.PublishMode = page.PublishMode;
            node.MenuDescription = page.MenuDescription;
            node.LinkRel = page.LinkRel;
            node.PubDateUtc = page.PubDateUtc;

            if(!this.nodes.ContainsKey(page.PageId))
            {
                nodes.Add(page.PageId, node);
            }

            //this.CreateChildNodes(node, page, pageIndex);
            this.CreateChildNodes(node, page, depth + 1);

            return node;
        }
Example #13
0
 public static bool NodeHasVisibleChildrenAtDepth(mojoSiteMapNode node, int depth)
 {
     bool recurse = true;
     return NodeHasVisibleChildrenAtDepth(node, depth, recurse);
 }
Example #14
0
        private void RenderNode(HtmlTextWriter writer, mojoSiteMapNode mojoNode, bool renderDivider)
        {
            if (!ShouldRender(mojoNode)) { return; }

            writer.Write("<li");

            writer.Write(BuildLiClass(mojoNode));

            writer.Write(">");

            writer.Write("<a");
            writer.Write(BuildAnchorClass(mojoNode));
            if(mojoNode.OpenInNewWindow)
            {
                writer.Write(" target='_blank'");
            }
            if(mojoNode.LinkRel.Length > 0)
            {
                writer.Write(" rel='" + mojoNode.LinkRel + "'");
            }

            if (mojoNode.IsClickable || (renderHrefWhenUnclickable && !mojoNode.IsClickable))
            {
                writer.Write(" href='" + FormatUrl(mojoNode) + "'>");
            }
            else
            {
                writer.Write(">");
            }

            if ((anchorInnerHtmlTop.Length > 0) && (anchorInnerHtmlBottom.Length > 0))
            {
                writer.Write(anchorInnerHtmlTop);
            }

            writer.Write(mojoNode.Title);

            if ((anchorInnerHtmlTop.Length > 0) && (anchorInnerHtmlBottom.Length > 0))
            {
                writer.Write(anchorInnerHtmlBottom);
            }

            writer.Write("</a>");

            if ((renderDescription)&&(mojoNode.MenuDescription.Length > 0))
            {
                writer.Write("<span");
                if (descriptionCssClass.Length > 0)
                {
                    writer.Write(" class='" + descriptionCssClass + "'");
                }
                writer.Write(">");
                writer.Write(mojoNode.MenuDescription);
                writer.Write("</span>");
            }

            //if (mojoNode.ChildNodes.Count > 0)
            if(HasVisibleChildNodes(mojoNode))
            {
                if (childContainerElement.Length > 0)
                {
                    writer.Write("<" + childContainerElement);
                    if (childContainerCssClass.Length > 0)
                    {
                        writer.Write(" class='" + childContainerCssClass + "'");
                    }
                    writer.Write(">");
                }

                RenderChildNodes(writer, mojoNode);

                if (childContainerElement.Length > 0)
                {
                    writer.Write("</" + childContainerElement + ">");
                }
            }

            writer.Write("</li>");

            if (renderDivider)
            {
                writer.Write("<" + dividerElement);
                if (!String.IsNullOrEmpty(dividerCssClass))
                {
                    writer.Write(" class='" + dividerCssClass + "'");
                }
                writer.Write("></" + dividerElement + ">");
            }
        }
Example #15
0
        private bool ShouldRender(mojoSiteMapNode mapNode)
        {
            if (mapNode == null) { return false; }

            bool remove = false;

            if (mapNode.Roles == null)
            {
                if ((!isAdmin) && (!isContentAdmin) && (!isSiteEditor)) { remove = true; }
            }
            else
            {
                if ((!isAdmin) && (mapNode.Roles.Count == 1) && (mapNode.Roles[0].ToString() == "Admins")) { remove = true; }

                if ((!isAdmin) && (!isContentAdmin) && (!isSiteEditor) && (!WebUser.IsInRoles(mapNode.Roles))) { remove = true; }
            }

            if ((!isAdmin) && (!isContentAdmin) && (!isSiteEditor) && (!WebUser.IsInRoles(mapNode.ViewRoles))) { remove = true; }

            if (!mapNode.IncludeInMenu) { remove = true; }

            if (mapNode.IsPending && !WebUser.IsAdminOrContentAdminOrContentPublisherOrContentAuthor) { remove = true; }

            if ((mapNode.HideAfterLogin) && (Page.Request.IsAuthenticated)) { remove = true; }

            if ((!isMobileSkin)&&(mapNode.PublishMode == mobileOnly)) { remove = true; }

            if ((isMobileSkin) && (mapNode.PublishMode == webOnly)) { remove = true; }

            if ((maxDataRenderDepth > -1) && (mapNode.Depth > maxDataRenderDepth)) { remove = true; }

            { return !remove; }
        }
Example #16
0
        private void LoadSettings()
        {
            siteSettings = CacheHelper.GetCurrentSiteSettings();

            isAdmin = WebUser.IsAdmin;
            if (!isAdmin) { isContentAdmin = WebUser.IsContentAdmin; }
            if ((!isAdmin) && (!isContentAdmin)) { isSiteEditor = SiteUtils.UserIsSiteEditor(); }

            resolveFullUrlsForMenuItemProtocolDifferences = WebConfigSettings.ResolveFullUrlsForMenuItemProtocolDifferences;
            if (resolveFullUrlsForMenuItemProtocolDifferences)
            {
                secureSiteRoot = WebUtils.GetSecureSiteRoot();
                insecureSiteRoot = WebUtils.GetInSecureSiteRoot();
            }

            isSecureRequest = SiteUtils.IsSecureRequest();

            siteMapDataSource = new SiteMapDataSource();
            siteMapDataSource.SiteMapProvider = "mojosite" + siteSettings.SiteId.ToInvariantString();

            rootNode = siteMapDataSource.Provider.RootNode;
            currentNode = SiteUtils.GetCurrentPageSiteMapNode(rootNode);
            startingNode = rootNode;

            if (startingNodePageId > -1)
            {
                startingNode = SiteUtils.GetSiteMapNodeForPage(rootNode, startingNodePageId);
            }
            else if (startingNodeOffset > -1)
            {
                startingNode = SiteUtils.GetOffsetNode(currentNode, startingNodeOffset);
            }
            //else if (isSubMenu)
            //{
            //    startingNode = SiteUtils.GetTopLevelParentNode(currentNode);
            //}
        }
        private mojoSiteMapNode CreateRootNode()
        {
            string[] rolelist = new string[0];

            mojoSiteMapNode node = new mojoSiteMapNode(
                this,
                "-1");
            node.IsRootNode = true;

            nodes.Add(-1, node);

            return node;
        }
Example #18
0
        private string BuildAnchorClass(mojoSiteMapNode mojoNode)
        {
            string result = string.Empty;
            string spacer = string.Empty;

            if (anchorCssClass.Length > 0)
            {
                result += anchorCssClass;
                spacer = " ";
            }

            if ((anchorChildSelectedCssClass.Length > 0) && (currentNode != null)
                && (currentNode.IsDescendantOf(mojoNode))
                )
            {
                result += spacer + anchorChildSelectedCssClass;
                spacer = " ";
            }

            if ((anchorSelectedCssClass.Length > 0) && (currentNode != null)
                && (currentNode.PageGuid == mojoNode.PageGuid)
                )
            {
                result += spacer + anchorSelectedCssClass;
                spacer = " ";
            }

            if ((renderCustomClassOnAnchor) && (mojoNode.MenuCssClass.Length > 0))
            {
                result += spacer + mojoNode.MenuCssClass;
                spacer = " ";
            }

            if (!mojoNode.IsClickable)
            {
                result += spacer + "unclickable";
            }

            if (result.Length > 0)
            {
                return " class='" + result + "'";
            }

            return result;
        }
Example #19
0
        private SiteMapNode CreateSiteMapNode(
            PageSettings page,
            int depth)
        {
            //string[] rolelist = null;
            List <string> roleList = null;

            if (!String.IsNullOrEmpty(page.AuthorizedRoles))
            {
                //rolelist = page.AuthorizedRoles.Split(new char[] { ',', ';' }, 512);
                roleList = page.AuthorizedRoles.SplitOnChar(';');
            }

            string pageUrl;

            if (
                (page.UseUrl) &&
                (!page.Url.StartsWith("http")) &&
                (page.Url.Length > 0) &&
                (useUrlRewriter)
                )
            {
                pageUrl = page.Url;
            }
            else
            {
                pageUrl = "~/Default.aspx?pageid=" + page.PageId.ToString();
            }

            // this was making a title (tooltip) on the link with the same text as the link text
            // not a good idea, adds no value and actually can make the page obnoxious for a screen reader user as it
            // would read the link text and the title
            //mojoSiteMapNode node = new mojoSiteMapNode(
            //    this,
            //    page.PageId.ToString(),
            //    pageUrl,
            //    HttpContext.Current.Server.HtmlEncode(page.PageName),
            //    HttpContext.Current.Server.HtmlEncode(page.PageName),
            //    rolelist,
            //    null,
            //    null,
            //    null);

            mojoSiteMapNode node = new mojoSiteMapNode(
                this,
                page.PageId.ToString(),
                pageUrl,
                HttpContext.Current.Server.HtmlEncode(page.PageName),
                string.Empty,
                roleList,
                null,
                null,
                null);

            if ((page.MenuImage.Length > 0) && (page.MenuImage.ToLower().IndexOf("blank") == -1))
            {
                node.MenuImage = this.iconBaseUrl + page.MenuImage;
            }

            node.PageGuid                  = page.PageGuid;
            node.PageId                    = page.PageId;
            node.ParentId                  = page.ParentId;
            node.Depth                     = depth;
            node.ViewRoles                 = page.AuthorizedRoles;
            node.EditRoles                 = page.EditRoles;
            node.DraftEditRoles            = page.DraftEditOnlyRoles;
            node.CreateChildPageRoles      = page.CreateChildPageRoles;
            node.CreateChildDraftPageRoles = page.CreateChildDraftRoles;
            node.IncludeInMenu             = page.IncludeInMenu;
            node.IncludeInSiteMap          = page.IncludeInSiteMap;
            node.ExpandOnSiteMap           = page.ExpandOnSiteMap;
            node.IncludeInChildSiteMap     = page.IncludeInChildSiteMap;
            node.IncludeInSearchMap        = page.IncludeInSearchMap;
            node.LastModifiedUtc           = page.LastModifiedUtc;
            node.ChangeFrequency           = page.ChangeFrequency;
            node.SiteMapPriority           = page.SiteMapPriority;
            node.OpenInNewWindow           = page.OpenInNewWindow;
            node.HideAfterLogin            = page.HideAfterLogin;
            node.UseSsl                    = (page.RequireSsl && sslIsAvailable);
            node.IsPending                 = page.IsPending;
            node.IsClickable               = page.IsClickable;
            node.MenuCssClass              = page.MenuCssClass;
            node.PublishMode               = page.PublishMode;
            node.MenuDescription           = page.MenuDescription;
            node.LinkRel                   = page.LinkRel;
            node.PubDateUtc                = page.PubDateUtc;

            if (!this.nodes.ContainsKey(page.PageId))
            {
                nodes.Add(page.PageId, node);
            }

            //this.CreateChildNodes(node, page, pageIndex);
            this.CreateChildNodes(node, page, depth + 1);

            return(node);
        }
Example #20
0
        private string BuildLiClass(mojoSiteMapNode mojoNode)
        {
            string result = string.Empty;
            string spacer = string.Empty;

            if (((mojoNode.Depth == 0)
                || (mojoNode.Depth == startingNodeOffset)
                //|| ((startingNodeOffset > 0) &&(isSubMenu) &&(mojoNode.Depth == startingNodeOffset + 1)))
                || ((startingNodeOffset > -1) && (mojoNode.Depth == startingNodeOffset + 1)))
                && (rootLevelLiCssClass.Length > 0))
            {
                result = rootLevelLiCssClass;
                spacer = " ";
            }
            else if(liCssClass.Length > 0)
            {
                result = liCssClass;
                spacer = " ";
            }

            if (itemDepthCssPrefix.Length > 0)
            {
                result += spacer + itemDepthCssPrefix + mojoNode.Depth.ToInvariantString();
                spacer = " ";
            }

            //if ((parentLiCssClass.Length > 0) && (mojoNode.ChildNodes.Count > 0))
            if ((parentLiCssClass.Length > 0) && (mojoNode.HasVisibleChildren()))
            {
                result += spacer + parentLiCssClass;
                spacer = " ";
            }

            if ((liChildSelectedCssClass.Length > 0) && (currentNode != null)
                && (currentNode.IsDescendantOf(mojoNode))
                )
            {
                result += spacer + liChildSelectedCssClass;
                spacer = " ";
            }

            if ((liSelectedCssClass.Length > 0) && (currentNode != null)
                && (currentNode.PageGuid == mojoNode.PageGuid)
                )
            {
                result += spacer + liSelectedCssClass;
                spacer = " ";
            }

            if ((renderCustomClassOnLi) && (mojoNode.MenuCssClass.Length > 0))
            {
                result += spacer + mojoNode.MenuCssClass;
            }

            if (result.Length > 0)
            {
                return " class='" + result + "'";
            }

            return result;
        }
Example #21
0
        private string FormatUrl(mojoSiteMapNode mapNode)
        {
            string itemUrl = Page.ResolveUrl(mapNode.Url);
            if (resolveFullUrlsForMenuItemProtocolDifferences)
            {
                if (isSecureRequest)
                {
                    if (
                        (!mapNode.UseSsl)
                        && (!siteSettings.UseSslOnAllPages)
                        && (mapNode.Url.StartsWith("~/"))
                        )
                    {
                        itemUrl = insecureSiteRoot + mapNode.Url.Replace("~/", "/");
                    }
                }
                else
                {
                    if ((mapNode.UseSsl) || (siteSettings.UseSslOnAllPages))
                    {
                        if (mapNode.Url.StartsWith("~/"))
                        {
                            itemUrl = secureSiteRoot + mapNode.Url.Replace("~/", "/");
                        }
                    }
                }
            }

            return itemUrl;
        }
Example #22
0
        private bool HasVisibleChildNodes(mojoSiteMapNode mapNode)
        {
            foreach (SiteMapNode childNode in mapNode.ChildNodes)
            {
                mojoSiteMapNode mojoNode = childNode as mojoSiteMapNode;
                if (mojoNode == null) { return false; }

                if (ShouldRender(mojoNode)) { return true; }
            }

            return false;
        }
 public ModuleDecoratedSiteMapNode(mojoSiteMapNode siteNode)
 {
     if (siteNode == null) throw new ArgumentException("siteNode can't be null");
     this.siteMapNode = siteNode;
 }
        private void CreateChildNodes(
            mojoSiteMapNode node, 
            PageSettings page,
            int depth)
        {
            foreach (PageSettings p in menuPages)
            {
                if (p.ParentId == page.PageId)
                {
                    SiteMapNode childNode = CreateSiteMapNode(p, depth);
                    try
                    {
                        AddNode(childNode, node);
                    }
                    catch (InvalidOperationException ex)
                    {
                        log.Error("failed to add node to sitemap", ex);

                    }
                    catch (HttpException ex)
                    {
                        log.Error("failed to add node to sitemap", ex);

                    }

                    if ((p.UseUrl) && (p.Url.StartsWith("http")))
                    {
                        childNode.Url = p.Url;
                    }
                }
            }
        }