private void CreateChildNodes(
            CSiteMapNode 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;
                    }
                }
            }
        }
示例#2
0
 public ModuleDecoratedSiteMapNode(CSiteMapNode siteNode)
 {
     if (siteNode == null)
     {
         throw new ArgumentException("siteNode can't be null");
     }
     this.siteMapNode = siteNode;
 }
        private CSiteMapNode CreateRootNode()
        {
            string[] rolelist = new string[0];

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

            node.IsRootNode = true;

            nodes.Add(-1, node);

            return(node);
        }
        public static void PopulateArrayList(
            ArrayList arrayList,
            SiteMapNode siteMapNode)
        {
            CSiteMapNode CNode = (CSiteMapNode)siteMapNode;

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

            foreach (SiteMapNode childNode in CNode.ChildNodes)
            {
                //recurse to populate children
                PopulateArrayList(arrayList, childNode);
            }
        }
        public bool HasVisibleChildren()
        {
            if (this.ChildNodes == null)
            {
                return(false);
            }
            if (this.ChildNodes.Count == 0)
            {
                return(false);
            }
            foreach (SiteMapNode child in ChildNodes)
            {
                if (child is CSiteMapNode)
                {
                    CSiteMapNode mchild = child as CSiteMapNode;
                    if ((mchild.IncludeInMenu) && (WebUser.IsInRoles(mchild.ViewRoles)))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
        private SiteMapNode CreateSiteMapNode(
            PageSettings page,
            int depth)
        {
            string[] rolelist = null;
            if (!String.IsNullOrEmpty(page.AuthorizedRoles))
            {
                rolelist = page.AuthorizedRoles.Split(new char[] { ',', ';' }, 512);
            }

            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
            //CSiteMapNode node = new CSiteMapNode(
            //    this,
            //    page.PageId.ToString(),
            //    pageUrl,
            //    HttpContext.Current.Server.HtmlEncode(page.PageName),
            //    HttpContext.Current.Server.HtmlEncode(page.PageName),
            //    rolelist,
            //    null,
            //    null,
            //    null);

            CSiteMapNode node = new CSiteMapNode(
                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.Settings = page;

            node.PageGuid             = page.PageGuid;
            node.PageId               = page.PageId;
            node.ParentId             = page.ParentId;
            node.Depth                = depth;
            node.ViewRoles            = page.AuthorizedRoles;
            node.EditRoles            = page.EditRoles;
            node.CreateChildPageRoles = page.CreateChildPageRoles;
            node.IncludeInMenu        = page.IncludeInMenu;
            node.IncludeInSiteMap     = page.IncludeInSiteMap;
            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.PageID = page.PageID;
            //node.ParentID = page.ParentID;
            //node.ViewRoles = page.AuthorizedRoles;
            //node.EditRoles = page.EditRoles;
            //node.CreateChildPageRoles = page.CreateChildPageRoles;

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

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

            return(node);
        }