예제 #1
0
        /// <summary>
        /// Loads the theme.
        /// </summary>
        /// <param name="currentWebPath">
        /// The current web path.
        /// </param>
        /// <returns>
        /// A bool value...
        /// </returns>
        private bool LoadTheme(string currentWebPath)
        {
            this.currentTheme.WebPath = currentWebPath;

            // if (!Appleseed.Framework.Settings.Cache.CurrentCache.Exists (Appleseed.Framework.Settings.Cache.Key.CurrentTheme(CurrentWebPath)))
            if (!CurrentCache.Exists(Key.CurrentTheme(this.currentTheme.Path)))
            {
                if (File.Exists(this.currentTheme.ThemeFileName))
                {
                    if (this.LoadXml(this.currentTheme.ThemeFileName))
                    {
                        // Appleseed.Framework.Settings.Cache.CurrentCache.Insert(Appleseed.Framework.Settings.Cache.Key.CurrentTheme(CurrentWebPath), CurrentTheme, new CacheDependency(CurrentTheme.ThemeFileName));
                        CurrentCache.Insert(
                            Key.CurrentTheme(this.currentTheme.Path),
                            this.currentTheme,
                            new CacheDependency(this.currentTheme.Path));
                    }
                    else
                    {
                        // failed
                        return false;
                    }
                }
                else
                {
                    // Return fail
                    return false;
                }
            }
            else
            {
                // CurrentTheme = (Theme) Appleseed.Framework.Settings.Cache.CurrentCache.Get (Appleseed.Framework.Settings.Cache.Key.CurrentTheme(CurrentWebPath));
                this.currentTheme = (Theme)CurrentCache.Get(Key.CurrentTheme(this.currentTheme.Path));
            }

            this.currentTheme.WebPath = currentWebPath;
            return true;
        }
예제 #2
0
        /// <summary>
        /// Loads the specified theme name.
        /// </summary>
        /// <param name="themeName">
        /// Name of the theme.
        /// </param>
        public void Load(string themeName)
        {
            this.currentTheme = new Theme { Name = themeName };

            // Try loading private theme first
            if (this.LoadTheme(Settings.Path.WebPathCombine(this.PortalWebPath, themeName)))
            {
                return;
            }

            // Try loading public theme
            if (this.LoadTheme(Settings.Path.WebPathCombine(WebPath, themeName)))
            {
                return;
            }

            // Try default
            this.currentTheme.Name = "default";
            if (this.LoadTheme(Settings.Path.WebPathCombine(WebPath, "default")))
            {
                return;
            }

            var errormsg = General.GetString("LOAD_THEME_ERROR");
            throw new FileNotFoundException(
                errormsg.Replace("%1%", string.Format("'{0}'", themeName)), string.Format("{0}/{1}", WebPath, themeName));
        }