public override SiteMapNodeCollection GetChildNodes(SiteMapNode node) { TraceInfo("GetChildNodes({0})", node.Key); var children = new List <SiteMapNode>(); var portal = PortalContext; var context = portal.ServiceContext; var website = portal.Website; var page = UrlMapping.LookupPageByUrlPath(context, website, node.Url); // If the node URL is that of a web page... if (page != null) { var childEntities = context.GetChildPages(page).Union(context.GetChildFiles(page)); // Add the (valid) child pages and files of that page to the children we will return. foreach (var entity in childEntities) { var childNode = GetNode(context, entity); if (ChildNodeValidator.Validate(context, childNode)) { children.Add(childNode); } } } // Append values from other site map providers. foreach (SiteMapProvider subProvider in SiteMap.Providers) { // Skip this provider if it is the same as this one. if (subProvider.Name == Name) { continue; } var subProviderChildNodes = subProvider.GetChildNodes(node); if (subProviderChildNodes == null) { continue; } foreach (SiteMapNode childNode in subProviderChildNodes) { children.Add(childNode); } } children.Sort(new SiteMapNodeDisplayOrderComparer()); return(new SiteMapNodeCollection(children.ToArray())); }
public override SiteMapNode GetParentNode(SiteMapNode node) { TraceInfo("GetParentNode({0})", node.Key); var portal = PortalContext; var context = portal.ServiceContext; var website = portal.Website; var page = UrlMapping.LookupPageByUrlPath(context, website, node.Url); if (page == null) { return(null); } var parentPage = page.GetRelatedEntity(context, "adx_webpage_webpage", EntityRole.Referencing); if (parentPage == null) { return(null); } return(GetAccessibleNodeOrAccessDeniedNode(context, parentPage)); }
public override SiteMapNode FindSiteMapNode(string rawUrl) { var clientUrl = ExtractClientUrlFromRawUrl(rawUrl); // For the case when we're relying on the redirect-404-to-dummy-Default.aspx trick for // URL routing, normalize this path to '/'. if (clientUrl.Path.Equals("/Default.aspx", StringComparison.OrdinalIgnoreCase)) { clientUrl.Path = "/"; } TraceInfo("FindSiteMapNode({0})", clientUrl.PathWithQueryString); var portal = PortalContext; var context = portal.ServiceContext; var website = portal.Website; // If the URL matches a web page, try to look up that page and return a node. var page = UrlMapping.LookupPageByUrlPath(context, website, clientUrl.Path); if (page != null) { return(GetAccessibleNodeOrAccessDeniedNode(context, page)); } // If the URL matches a web file, try to look up that file and return a node. var file = UrlMapping.LookupFileByUrlPath(context, website, clientUrl.Path); if (file != null) { return(GetAccessibleNodeOrAccessDeniedNode(context, file)); } // If there is a pageid Guid on the querystring, try to look up a web page by // that ID and return a node. Guid pageid; if (TryParseGuid(clientUrl.QueryString["pageid"], out pageid)) { var webPagesInCurrentWebsite = website.GetRelatedEntities(context, "adx_website_webpage"); page = webPagesInCurrentWebsite.Where(wp => wp.GetAttributeValue <Guid>("adx_webpageid") == pageid).FirstOrDefault(); if (page != null) { return(GetAccessibleNodeOrAccessDeniedNode(context, page)); } } // If the above lookups failed, try find a node in any other site map providers. foreach (SiteMapProvider subProvider in SiteMap.Providers) { // Skip this provider if it is the same as this one. if (subProvider.Name == Name) { continue; } var node = subProvider.FindSiteMapNode(clientUrl.PathWithQueryString); if (node != null) { return(node); } } return(GetNotFoundNode()); }