Represents an IPage instance in a sitemap.
Inheritance: System.Web.SiteMapNode
示例#1
0
        /// <exclude />
        public override SiteMapNode GetParentNode(SiteMapNode node)
        {
            Verify.ArgumentNotNull(node, "node");

            var pageSiteMapNode = (CmsPageSiteMapNode)node;

            IPage parentPage = null;

            using (new DataScope(pageSiteMapNode.Culture))
            {
                Guid parentPageId = PageManager.GetParentId(pageSiteMapNode.Page.Id);
                if (parentPageId != Guid.Empty)
                {
                    parentPage = PageManager.GetPageById(parentPageId);
                }
            }

            SiteMapNode parentNode;

            if (parentPage != null)
            {
                parentNode = new CmsPageSiteMapNode(this, parentPage);
            }
            else
            {
                parentNode = ParentProvider?.GetParentNode(node);
            }

            return(parentNode != null && parentNode.IsAccessibleToUser(HttpContext.Current) ? parentNode : null);
        }
示例#2
0
        /// <exclude />
        protected override SiteMapNode GetRootNodeCore()
        {
            var context = SiteMapContext.Current;

            var rootPage = context?.RootPage;

            if (rootPage == null)
            {
                Guid homePageId = SitemapNavigator.CurrentHomePageId;
                if (homePageId == Guid.Empty)
                {
                    homePageId = PageManager.GetChildrenIDs(Guid.Empty).FirstOrDefault();
                }

                if (homePageId != Guid.Empty)
                {
                    rootPage = PageManager.GetPageById(homePageId);
                }
            }

            if (rootPage == null)
            {
                return(null);
            }

            var node = new CmsPageSiteMapNode(this, rootPage);

            return(node.IsAccessibleToUser(HttpContext.Current) ? node : null);
        }
        /// <inheritdoc />
        protected override SiteMapNode GetRootNodeCore()
        {
            var siteMapContext = SiteMapContext.Current;

            var rootPage = siteMapContext?.RootPage;

            if (rootPage == null)
            {
                var homePageId = SitemapNavigator.CurrentHomePageId;
                if (homePageId == Guid.Empty)
                {
                    var context = HttpContext.Current;
                    if (context == null)
                    {
                        homePageId = PageManager.GetChildrenIDs(Guid.Empty).FirstOrDefault();
                    }
                    else
                    {
                        using (var data = new DataConnection())
                        {
                            var pageNode = data.SitemapNavigator.GetPageNodeByHostname(context.Request.Url.Host);

                            homePageId = pageNode?.Id ?? Guid.Empty;
                        }
                    }
                }

                if (homePageId != Guid.Empty)
                {
                    rootPage = PageManager.GetPageById(homePageId);
                }
            }

            if (rootPage == null)
            {
                return(null);
            }

            var node = new CmsPageSiteMapNode(this, rootPage);

            return(SecurityTrimNode(node));
        }
示例#4
0
        private IHostnameBinding FindMatchingBinding(CmsPageSiteMapNode sitemapNode, List <IHostnameBinding> bindings)
        {
            Guid   homePageId  = Guid.Parse(sitemapNode.Key);
            string cultureName = sitemapNode.Culture.Name;

            var bestMatch = bindings.SingleOrDefault(h => h.HomePageId == homePageId && h.Culture == cultureName);

            if (bestMatch != null)
            {
                return(bestMatch);
            }

            string defaultCulture  = DataLocalizationFacade.DefaultLocalizationCulture.Name;
            var    secondBestMatch = bindings.SingleOrDefault(h => h.HomePageId == homePageId && h.Culture == defaultCulture);

            if (secondBestMatch != null)
            {
                return(secondBestMatch);
            }

            return(bindings.OrderBy(b => b.Hostname).FirstOrDefault(h => h.HomePageId == homePageId));
        }
示例#5
0
        private IHostnameBinding FindMatchingBinding(CmsPageSiteMapNode sitemapNode, List<IHostnameBinding> bindings)
        {
            Guid homePageId = Guid.Parse(sitemapNode.Key);
            string cultureName = sitemapNode.Culture.Name;

            var bestMatch = bindings.SingleOrDefault(h => h.HomePageId == homePageId && h.Culture == cultureName);
            if (bestMatch != null)
            {
                return bestMatch;
            }

            string defaultCulture = DataLocalizationFacade.DefaultLocalizationCulture.Name;
            var secondBestMatch = bindings.SingleOrDefault(h => h.HomePageId == homePageId && h.Culture == defaultCulture);
            if (secondBestMatch != null)
            {
                return secondBestMatch;
            }

            return  bindings.OrderBy(b => b.Hostname).FirstOrDefault(h => h.HomePageId == homePageId);
        }
示例#6
0
 /// <exclude />
 public bool Equals(CmsPageSiteMapNode obj)
 {
     return(Key == obj.Key && Culture.Equals(obj.Culture));
 }
        /// <exclude />
        protected override SiteMapNode GetRootNodeCore()
        {
            var context = SiteMapContext.Current;

            var rootPage = context?.RootPage;

            if (rootPage == null)
            {
                Guid homePageId = SitemapNavigator.CurrentHomePageId;
                if (homePageId == Guid.Empty)
                {
                    homePageId = PageManager.GetChildrenIDs(Guid.Empty).FirstOrDefault();
                }

                if (homePageId != Guid.Empty)
                {
                    rootPage = PageManager.GetPageById(homePageId);
                }
            }

            if (rootPage == null)
            {
                return null;
            }

            var node = new CmsPageSiteMapNode(this, rootPage);

            return node.IsAccessibleToUser(HttpContext.Current) ? node : null;
        }
        /// <exclude />
        public override SiteMapNode GetParentNode(SiteMapNode node)
        {
            Verify.ArgumentNotNull(node, "node");

            var pageSiteMapNode = (CmsPageSiteMapNode)node;

            IPage parentPage = null;
            using (new DataScope(pageSiteMapNode.Culture))
            {
                Guid parentPageId = PageManager.GetParentId(pageSiteMapNode.Page.Id);
                if (parentPageId != Guid.Empty)
                {
                    parentPage = PageManager.GetPageById(parentPageId);
                }
            }

            SiteMapNode parentNode;
            if (parentPage != null)
            {
                parentNode = new CmsPageSiteMapNode(this, parentPage);
            }
            else
            {
                parentNode = ParentProvider?.GetParentNode(node);
            }

            return parentNode != null && parentNode.IsAccessibleToUser(HttpContext.Current) ? parentNode : null;
        }
示例#9
0
 /// <exclude />
 public bool Equals(CmsPageSiteMapNode obj)
 {
     return Key == obj.Key && Culture.Equals(obj.Culture);
 }