public IEnumerable <string> GetAllTagsByRoot(IPublishedContent root) { var blogPosts = GetContentPages(root); if (ExistenceUtility.IsNullOrEmpty(blogPosts)) { return(Enumerable.Empty <string>()); } return(blogPosts.SelectMany(x => x.Tags).Distinct().OrderBy(x => x)); }
private IEnumerable <AccordionItemViewModel> GetTabbedContent(IndividualJobPage model) { var tabbedContent = new List <AccordionItemViewModel> { new AccordionItemViewModel("background", "Background", model.BackgroundContent), new AccordionItemViewModel("post-duties", "Post Duties", model.PostDutiesContent), new AccordionItemViewModel("competences", "Competences", model.CompetencesContent), new AccordionItemViewModel("salary-and-benefits", "Salary & Benefits", model.SalaryBenefitsContent) }; return(tabbedContent.Where(x => ExistenceUtility.IsNullOrWhiteSpace(x.Content) == false).ToArray()); }
public IEnumerable <string> GetAllByRoot(IPublishedContent root) { var articlePages = GetContentPages(root); if (ExistenceUtility.IsNullOrEmpty(articlePages)) { return(Enumerable.Empty <string>()); } return(articlePages.Select(x => x.ArticleType) .Distinct() .OrderBy(x => x)); }
private IReadOnlyDictionary <string, IHtmlString> GetTabbedContent(StaffProfilePage content) { var tabbedContent = new Dictionary <string, IHtmlString> { { "Biography", content.BiographyContent }, { "Projects", content.ProjectsContent }, { "Publications", content.PublicationsContent }, { "Research", content.ResearchContent } }; return(tabbedContent.Where(x => ExistenceUtility.IsNullOrWhiteSpace(x.Value) == false) .ToDictionary(x => x.Key, x => x.Value)); }
protected IReadOnlyDictionary <string, bool> GetFilters(IEnumerable <string> allFilters, IEnumerable <string> selectedFilters) { if (ExistenceUtility.IsNullOrEmpty(allFilters)) { return(null); } if (ExistenceUtility.IsNullOrEmpty(selectedFilters)) { return(allFilters.ToDictionary(x => x, x => false)); } return(allFilters.ToDictionary(x => x, x => selectedFilters.Contains(x, StringComparer.OrdinalIgnoreCase))); }
public bool HasPageHero(IPublishedContent currentPage) { var isPageHeroComposition = currentPage is IPageHeroComposition; var isPageHeroCarouselComposition = currentPage is IPageHeroCarouselComposition; var isArticulatePost = currentPage is ArticulatePost; var blogRoot = currentPage.AncestorOrSelf <ArticulateModel>(); var hasBlogRoot = blogRoot != null; if (isPageHeroComposition == false && isPageHeroCarouselComposition == false && isArticulatePost == false && hasBlogRoot == false) { return(false); } if (isPageHeroComposition) { return((currentPage as IPageHeroComposition).HasPageHeroImage()); } if (isArticulatePost) { var post = (currentPage as ArticulatePost); var postImage = post.PostImage; if (postImage == null) { return(false); } return(postImage.HasCrop("wide")); } else if (hasBlogRoot) { var blogBanner = blogRoot.BlogBanner; if (blogBanner == null) { return(false); } return(blogBanner.HasCrop("wide")); } if (isPageHeroCarouselComposition) { return(ExistenceUtility.IsNullOrEmpty((currentPage as IPageHeroCarouselComposition).HeroImages) == false); } return(false); }
public ActionResult RenderMainNavigation() { var viewModel = new MainNavigationViewModel { Items = mainNavigationService.GetRootMenuItems(Root, CurrentPage), HasPageHero = _pageHeroService.HasPageHero(CurrentPage) }; if (ExistenceUtility.IsNullOrEmpty(viewModel.Items)) { return(EmptyResult()); } return(PartialView("~/Views/Partials/Header/MainNavigation.cshtml", viewModel)); }
protected IReadOnlyDictionary <string, bool> GetFilters(IEnumerable <int> allFilters, IEnumerable <int> selectedFilters) { if (ExistenceUtility.IsNullOrEmpty(allFilters)) { return(null); } if (ExistenceUtility.IsNullOrEmpty(selectedFilters)) { return(allFilters.AllToString() .ToDictionary(x => x, x => false)); } return(allFilters.ToDictionary(x => x.ToString(), x => selectedFilters.Contains(x))); }
public ActionResult RenderRelatedItems() { if (CurrentPage is IRelatedItemsComposition == false) { return(EmptyResult()); } var viewModels = _relatedItemsService.GetViewModels(CurrentPage as IRelatedItemsComposition, Root); if (ExistenceUtility.IsNullOrEmpty(viewModels)) { return(EmptyResult()); } return(PartialView("~/Views/Partials/RelatedItems.cshtml", viewModels)); }
private IEnumerable <MainNavigationItemViewModel> GetCategoriesWithFeaturedPages(IEnumerable <ScienceCategoryPage> categories) { if (ExistenceUtility.IsNullOrEmpty(categories)) { return(null); } var viewModels = new List <MainNavigationItemViewModel>(); foreach (var category in categories) { var viewModel = GetCategoryWithFeaturedPages(category); viewModels.Add(viewModel); } return(viewModels); }
private IReadOnlyDictionary <char, IEnumerable <NavigationItemViewModel> > GetCategorisedPages(ScienceAtoZpage model) { var scienceLandingPage = model.Parent <ScienceLandingPage>(); if (scienceLandingPage == null) { return(null); } var categorisablePages = scienceLandingPage.Children <IScienceCategorisablePage>(); if (ExistenceUtility.IsNullOrEmpty(categorisablePages)) { return(null); } return(categorisablePages.CategorisePages()); }
private IEnumerable <string> GetNodeIdsToExcludeFromSearchResults(IRelatedItemsComposition composition) { var nodeIds = new List <string> { composition.Id.ToString() }; if (ExistenceUtility.IsNullOrEmpty(composition.RelatedItems)) { return(nodeIds); } var pickedRelatedItemIds = composition.RelatedItems.Select(x => x.Id.ToString()); nodeIds.AddRange(pickedRelatedItemIds); return(nodeIds); }
private IEnumerable <RelatedItemViewModel> GetPickedRelatedItemViewModels(IEnumerable <IPublishedContent> relatedItems, HomePage homePage) { var viewModels = new List <RelatedItemViewModel>(); if (ExistenceUtility.IsNullOrEmpty(relatedItems)) { return(viewModels); } foreach (var item in relatedItems) { var viewModel = GetViewModel(item, homePage); viewModels.Add(viewModel); } return(viewModels); }
private IEnumerable <ScienceCategorySubSectionViewModel> GetSubSectionViewModels(IEnumerable <IPublishedContent> subSections, string parentHtmlId) { var viewModels = new List <ScienceCategorySubSectionViewModel>(); if (ExistenceUtility.IsNullOrEmpty(subSections)) { return(viewModels); } foreach (var section in subSections) { ScienceCategorySubSectionViewModel viewModel = null; switch (section) { case ScienceCategorySubSectionRichTextSchema richText: viewModel = CreateRichTextSubSection(richText, parentHtmlId); break; case ScienceCategorySubSectionImageGallerySchema imageGallery: viewModel = CreateImageGallerySubSection(imageGallery, parentHtmlId); break; case ScienceCategorySubSectionImageRichTextSchema imageRichText: viewModel = CreateImageRichTextSubSection(imageRichText, parentHtmlId); break; case ScienceCategorySubSectionImageCodeSchema imageCode: viewModel = CreateImageCodeSubSection(imageCode, parentHtmlId); break; case ScienceCategorySubSectionSliderSchema slider: viewModel = CreateSliderSubSection(slider, parentHtmlId); break; } if (viewModel != null) { viewModels.Add(viewModel); } } return(viewModels); }
private IEnumerable <ScienceCategorySectionViewModel> GetSectionViewModels(IEnumerable <ScienceCategorySectionBaseSchema> mainContent) { var viewModels = new List <ScienceCategorySectionViewModel>(); if (ExistenceUtility.IsNullOrEmpty(mainContent)) { return(viewModels); } foreach (var section in mainContent) { ScienceCategorySectionViewModel viewModel = null; switch (section) { case ScienceCategorySectionRichTextSchema richText: viewModel = CreateRichTextSection(richText); break; case ScienceCategorySectionImageGallerySchema imageGallery: viewModel = CreateImageGallerySection(imageGallery); break; case ScienceCategorySectionImageTextSchema imageRichText: viewModel = CreateImageRichTextSection(imageRichText); break; case ScienceCategorySectionImageCodeSchema imageCode: viewModel = CreateImageCodeSection(imageCode); break; case ScienceCategorySectionSliderSchema slider: viewModel = CreateSliderSection(slider); break; } if (viewModel != null) { viewModels.Add(viewModel); } } return(viewModels); }
public ActionResult RenderCommentsList() { var service = new UmbracoFormsBlogCommentsService(); var formId = CurrentPage.GetPropertyValue <Guid>("commentsForm", true); if (formId == default(Guid)) { return(EmptyResult()); } var comments = service.GetComments(CurrentPage.Id, formId); if (ExistenceUtility.IsNullOrEmpty(comments)) { return(EmptyResult()); } return(PartialView("~/Views/Partials/Blog/CommentsList.cshtml", comments)); }
private IEnumerable <LatestNewsItemViewModel> GetLatestNewsItems(HomePage content) { var viewModels = new List <LatestNewsItemViewModel>(); if (content.ShowLatestNews == false) { return(viewModels); } var latestNewsItems = _umbracoHelper.TypedContentAtXPath(XPathForLatestNewsItems) .OfType <ArticlePage>() .OrderByDescending(x => x.PublishDate) .Take(NumberOfLatestNewsItems); if (ExistenceUtility.IsNullOrEmpty(latestNewsItems)) { return(viewModels); } foreach (var newsItem in latestNewsItems) { var viewModel = new LatestNewsItemViewModel { Title = string.IsNullOrWhiteSpace(newsItem.Headline) ? newsItem.Name : newsItem.Headline, PublishDate = newsItem.PublishDate, Description = newsItem.LandingPageContent, Url = newsItem.Url }; if (newsItem.HeroImage != null) { viewModel.ImageUrl = newsItem.HeroImage.GetCropUrl(ImageCropAliases.ListingThumbnail); viewModel.ImageAltText = newsItem.HeroImage.GetPropertyValue <string>("altText").IsNullOrWhiteSpace() ? newsItem.Headline : newsItem.HeroImage.GetPropertyValue <string>("altText"); viewModel.ImageTitleText = newsItem.HeroImage.GetPropertyValue <string>("titleText"); } viewModels.Add(viewModel); } return(viewModels); }
private IEnumerable <ResourcesCollectionViewModel> GetResourcesCollections(ScienceLandingPage model) { var viewModels = new List <ResourcesCollectionViewModel>(); if (ExistenceUtility.IsNullOrEmpty(model.ResourcesCollections)) { return(viewModels); } foreach (var collection in model.ResourcesCollections) { var viewModel = new ResourcesCollectionViewModel() { Title = collection.Title, Resources = _calloutCardsService.GetCalloutCards(collection.Resources), ReadMoreLink = GetViewModelReadMoreLink(collection) }; viewModels.Add(viewModel); } return(viewModels); }