protected ActionResult GetPage(int publicationId, int pageId) { using (new Tracer(publicationId, pageId)) { try { Common.Configuration.Localization localization = SetupLocalization(publicationId); PageModel pageModel; try { pageModel = ContentProviderExt.GetPageModel(pageId, localization); } catch (DxaItemNotFoundException ex) { Log.Info(ex.Message); return(NotFound()); } PageModelWithHttpResponseData pageModelWithHttpResponseData = pageModel as PageModelWithHttpResponseData; pageModelWithHttpResponseData?.SetHttpResponseData(System.Web.HttpContext.Current.Response); SetupViewData(pageModel); PageModel model = (EnrichModel(pageModel) as PageModel) ?? pageModel; WebRequestContext.PageModel = model; return(View(model.MvcData.ViewName, model)); } catch (Exception ex) { Log.Error(ex); return(ServerError()); } } }
protected Common.Configuration.Localization SetupLocalization(int publicationId) { PublicationProvider provider = new PublicationProvider(); provider.CheckPublicationOnline(publicationId); Common.Configuration.Localization localization = WebRequestContext.Localization; localization.Id = publicationId.ToString(); return(localization); }
public SitemapItem SiteMap(Common.Configuration.Localization localization) { return(SiteConfiguration.CacheProvider.GetOrAdd( $"sitemap-{localization.Id ?? "full"}", CacheRegion.Sitemap, () => { // Workaround: Currently the content service is not returning a sitemap for Docs only content // so the workaround is for each publication get the entire subtree and merge the results. // This will cause several requests to be issued and results in quite a slow performance. IOnDemandNavigationProvider provider = SiteConfiguration.NavigationProvider as IOnDemandNavigationProvider; if (provider == null) { return null; } NavigationFilter navigationFilter = new NavigationFilter { DescendantLevels = -1, IncludeAncestors = false }; List <SitemapItem> sitemapItems = new List <SitemapItem>(); if (!string.IsNullOrEmpty(localization?.Id)) { sitemapItems.AddRange(provider.GetNavigationSubtree(null, navigationFilter, localization)); } else { var pubs = new PublicationProvider().PublicationList; foreach (var pub in pubs) { var items = provider.GetNavigationSubtree(null, navigationFilter, new DocsLocalization(int.Parse(pub.Id))); foreach (var item in items) { sitemapItems.AddRange(item.Items); } } } return new SitemapItem { Items = FixupSitemap(sitemapItems, false, false) }; })); }
public void BuildEntityModel(ref EntityModel entityModel, EntityModelData entityModelData, Type baseModelType, Common.Configuration.Localization localization) { DataModel.MvcData mvcData = entityModelData.MvcData; RemapMvcAreaName(ref mvcData); }
public void BuildPageModel(ref PageModel pageModel, PageModelData pageModelData, bool includePageRegions, Common.Configuration.Localization localization) { DataModel.MvcData mvcData = pageModelData.MvcData; RemapMvcAreaName(ref mvcData); }
public IEnumerable <SitemapItem> GetToc(Common.Configuration.Localization localization, string sitemapItemId, bool includeAncestors, int descendantLevels) { return(SiteConfiguration.CacheProvider.GetOrAdd( $"toc-{localization.Id}-{sitemapItemId}-{includeAncestors}-{WebRequestContext.CacheKeySalt}", CacheRegion.Toc, () => { new PublicationProvider().CheckPublicationOnline(int.Parse(localization.Id)); IOnDemandNavigationProvider provider = SiteConfiguration.NavigationProvider as IOnDemandNavigationProvider; NavigationFilter navigationFilter = new NavigationFilter { DescendantLevels = descendantLevels, IncludeAncestors = includeAncestors }; var sitemapItems = provider.GetNavigationSubtree(sitemapItemId, navigationFilter, localization).ToList(); if (sitemapItems.Count == 0) { throw new DxaItemNotFoundException("No sitemap items found."); } if (includeAncestors) { // if we are including ancestors we also need to get all the direct siblings for each // level in the hirarchy. SitemapItem node = FindNode(sitemapItems, sitemapItemId); // for each parent node get sibling nodes while (node.Parent != null) { var siblings = provider.GetNavigationSubtree(node.Parent.Id, new NavigationFilter { DescendantLevels = 1, IncludeAncestors = false }, localization); HashSet <string> children = new HashSet <string>(); foreach (var item in node.Parent.Items) { children.Add(item.Id); } // filter out duplicates and Page types since we don't wish to include them in TOC foreach ( var sibling in siblings.Where( sibling => sibling.Id != node.Id && sibling.Type != "Page" && !children.Contains(sibling.Id))) { node.Parent.Items.Add(sibling); } node = node.Parent; } } return FixupSitemap(sitemapItems, true, true); })); }
public IEnumerable <SitemapItem> GetToc(Common.Configuration.Localization localization, string sitemapItemId, bool includeAncestors) => GetToc(localization, sitemapItemId, includeAncestors, 1);
public IEnumerable <SitemapItem> GetToc(Common.Configuration.Localization localization, string sitemapItemId) => GetToc(localization, sitemapItemId, false, 1);
public IEnumerable <SitemapItem> GetToc(Common.Configuration.Localization localization) => GetToc(localization, null, false, 1);
public DynamicDocumentationLocalizationResolver() { _localization = new DocsLocalization(); _localization.EnsureInitialized(); }