public IEnumerable <CountryPage> All()
        {
            using (_profileLogger.TraceDuration <CountryPageService>("All"))
            {
                var countries = _umbracoHelper
                                .TypedContentAtXPath($"/root/{CountryPage.ModelTypeAlias}")
                                .Select(c => c as CountryPage)
                                .Where(c => c != null)
                                .OrderBy(c => c.CountryName)
                                .ToList();

                var currentCountry = Current();

                foreach (var country in countries)
                {
                    if (country.Id == currentCountry.Id)
                    {
                        country.Selected = true;
                        break;
                    }
                }

                return(countries);
            }
        }
예제 #2
0
 public IPublishedContent Current()
 {
     using (_profileLogger.TraceDuration <PageService>("Current"))
     {
         return(_umbracoContext.Current.PublishedContentRequest.PublishedContent);
     }
 }
예제 #3
0
        public IEnumerable <LanguagePage> All()
        {
            using (_profileLogger.TraceDuration <LanguagePageService>("All"))
            {
                var country = _countryPageService.Current();

                var languages = country?.Children <LanguagePage>().OrderBy(l => l.LanguageName).ToList();
                if (languages == null)
                {
                    return(null);
                }

                var currentLanguage = Current();

                foreach (var language in languages)
                {
                    language.HomePageUrl = language.FirstChild <HomePage>().Url;

                    if (language.Id == currentLanguage.Id)
                    {
                        language.Selected = true;
                    }
                }

                return(languages);
            }
        }
예제 #4
0
        private IPublishedContent FindConfigPage(string docTypeAlias)
        {
            using (_profileLogger.TraceDuration <ConfigPageService>("FindConfigPage"))
            {
                var currentLanguage = _languagePageService.Current();
                if (currentLanguage != null)
                {
                    var languageSiteContentPage =
                        _umbracoHelper.TypedContentSingleAtXPath(
                            $"//*[@id={currentLanguage.Id}]//{docTypeAlias}");

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

                var currentCountry = _countryPageService.Current();
                if (currentCountry == null)
                {
                    return(null);
                }

                var countrySiteConfigPage =
                    _umbracoHelper.TypedContentSingleAtXPath(
                        $"//*[@id={currentCountry.Id}]//{docTypeAlias}");

                return(countrySiteConfigPage);
            }
        }
예제 #5
0
        public IEnumerable <Theme> All()
        {
            using (_profileLogger.TraceDuration <ThemeService>("All"))
            {
                var retval = new List <Theme>();

                var themesPath = _httpServerUtility.MapPath("~/css/");
                var themes     = _fileSystem.Directory.GetDirectories(themesPath);

                foreach (var theme in themes)
                {
                    var id = theme.TrimEnd('\\');
                    id = id.Substring(id.LastIndexOf("\\", StringComparison.Ordinal) + 1);

                    var name = _cultureInfo.CurrentCulture.TextInfo
                               .ToTitleCase(id.Replace("-", " "))
                               .Replace("Agebase", "AgeBase");

                    retval.Add(new Theme
                    {
                        Id   = id,
                        Name = name
                    });
                }

                return(retval);
            }
        }
예제 #6
0
 public string CurrentTrackingId()
 {
     using (_profileLogger.TraceDuration <GoogleAnalyticsService>("CurrentTrackingId"))
     {
         return(_httpContext.IsDebuggingEnabled
             ? null
             : _configPageService.CurrentAnalyticsPage()?.GoogleAnalytics);
     }
 }
        public HomePage Current()
        {
            using (_profileLogger.TraceDuration <HomePageService>("Current"))
            {
                var currentPage = _pageService.Current();

                var retval = currentPage.AncestorOrSelf <HomePage>();
                if (retval != null)
                {
                    return(retval);
                }

                return(_umbracoHelper.TypedContentSingleAtXPath($"//*[@id={currentPage.Id}]//{HomePage.ModelTypeAlias}") as HomePage);
            }
        }
        MasterPage <T> IMasterPageService.Create <T>(IPublishedContent content)
        {
            using (_profileLogger.TraceDuration <MasterPageService>("Create"))
            {
                var contentType = content.GetType();
                var masterType  = typeof(MasterPage <>);

                var modelType = masterType.MakeGenericType(contentType);

                if (!(Activator.CreateInstance(modelType, content) is MasterPage <T> retval))
                {
                    return(null);
                }

                retval.Theme = _configPageService.CurrentSiteContentPage()?.SiteTheme;
                return(retval);
            }
        }