コード例 #1
0
        public string CalculatedVirtualPath()
        {
            var parents = MediaDetailsMapper.GetAllParentMediaDetails(this, LanguagesMapper.GetByID(this.LanguageID)).Reverse();

            var virtualPath = "";

            foreach (var parent in parents)
            {
                if (parent is RootPage || parent is Website)
                {
                    continue;
                }

                virtualPath = StringHelper.CreateSlug(parent.LinkTitle) + "/" + virtualPath;
            }

            if (virtualPath == "")
            {
                virtualPath = "~/";
            }

            virtualPath = URIHelper.ConvertAbsUrlToTilda(virtualPath);

            return(virtualPath);
        }
コード例 #2
0
        public void RemoveFromCache()
        {
            var htmlCacheKey   = GetCacheKey(RenderVersion.HTML);
            var mobileCacheKey = GetCacheKey(RenderVersion.Mobile);

            FileCacheHelper.RemoveFromCache(htmlCacheKey);
            RedisCacheHelper.RemoveFromCache(htmlCacheKey);
            ContextHelper.RemoveFromCache(htmlCacheKey);

            RedisCacheHelper.RemoveFromCache(mobileCacheKey);
            FileCacheHelper.RemoveFromCache(mobileCacheKey);
            ContextHelper.RemoveFromCache(mobileCacheKey);

            var language = this.Language;

            if (language == null && this.LanguageID > 0)
            {
                language = LanguagesMapper.GetByID(this.LanguageID);
            }

            var parents = MediaDetailsMapper.GetAllParentMediaDetails(this, language).Where(i => i.ID != this.ID);

            foreach (var item in parents)
            {
                item.RemoveFromCache();
            }
        }
コード例 #3
0
        public static Settings GetSettings()
        {
            /*var settings = (Settings)ContextHelper.GetFromRequestContext("SettingsMapper_GetSettings");
             *
             * if (settings != null)
             * return settings;*/

            /*if (CanConnectToDB is null || !(bool)CanConnectToDB)
             *      return null;*/

            var settings = GetDataModel().AllSettings.FirstOrDefault();

            if (settings != null && settings.DefaultLanguage == null && settings.DefaultLanguageID > 0)
            {
                settings.DefaultLanguage = LanguagesMapper.GetByID(settings.DefaultLanguageID);
            }

            //ContextHelper.SetToRequestContext("SettingsMapper_GetSettings", settings);

            return(settings);
        }
コード例 #4
0
        public static Language GetDefaultLanguage()
        {
            var language = ContextHelper.GetFromRequestContext("GetDefaultLanguage");

            if (language != null)
            {
                return((Language)language);
            }

            var settings = SettingsMapper.GetSettings();

            language = settings.DefaultLanguage;

            if (language == null && settings.DefaultLanguageID > 0)
            {
                language = LanguagesMapper.GetByID(settings.DefaultLanguageID);
            }

            ContextHelper.SetToRequestContext("GetDefaultLanguage", language);

            return((Language)language);
        }