Ejemplo n.º 1
0
        public HttpResponseMessage GetThemeFiles(string themeName)
        {
            const ThemeLevel level = ThemeLevel.Global | ThemeLevel.Site;
            var themeLayout        = _themesController.GetLayouts(PortalSettings, level).FirstOrDefault(t => t.PackageName.Equals(themeName, StringComparison.InvariantCultureIgnoreCase));
            var themeContainer     = _themesController.GetContainers(PortalSettings, level).FirstOrDefault(t => t.PackageName.Equals(themeName, StringComparison.InvariantCultureIgnoreCase));

            return(Request.CreateResponse(HttpStatusCode.OK, new {
                layouts = themeLayout == null ? new List <ThemeFileInfo>() : _themesController.GetThemeFiles(PortalSettings, themeLayout),
                containers = themeContainer == null ? new List <ThemeFileInfo>() : _themesController.GetThemeFiles(PortalSettings, themeContainer)
            }));
        }
Ejemplo n.º 2
0
 public HttpResponseMessage GetThemes(ThemeLevel level)
 {
     try
     {
         return(this.Request.CreateResponse(HttpStatusCode.OK, new
         {
             Layouts = this._controller.GetLayouts(this.PortalSettings, level),
             Containers = this._controller.GetContainers(this.PortalSettings, level),
         }));
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         return(this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Get Containers.
        /// </summary>
        /// <param name="portalSettings"></param>
        /// <param name="level">portal level or host level.</param>
        /// <returns></returns>
        public IList <ThemeInfo> GetContainers(PortalSettings portalSettings, ThemeLevel level)
        {
            var themes = new List <ThemeInfo>();

            if ((level & ThemeLevel.Site) == ThemeLevel.Site)
            {
                themes.AddRange(GetThemes(ThemeType.Container, Path.Combine(portalSettings.HomeSystemDirectoryMapPath, SkinController.RootContainer)));
            }

            if ((level & ThemeLevel.Global) == ThemeLevel.Global)
            {
                themes.AddRange(GetThemes(ThemeType.Container, Path.Combine(Globals.HostMapPath, SkinController.RootContainer)));
            }

            return(themes);
        }
Ejemplo n.º 4
0
        public HttpResponseMessage GetThemeFiles(string themeName, ThemeType type, ThemeLevel level)
        {
            try
            {
                var theme = (type == ThemeType.Skin ? this._controller.GetLayouts(this.PortalSettings, level)
                                                    : this._controller.GetContainers(this.PortalSettings, level))
                            .FirstOrDefault(t => t.PackageName.Equals(themeName, StringComparison.OrdinalIgnoreCase));

                if (theme == null)
                {
                    return(this.Request.CreateErrorResponse(HttpStatusCode.NotFound, "ThemeNotFound"));
                }

                return(this.Request.CreateResponse(HttpStatusCode.OK, this._controller.GetThemeFiles(this.PortalSettings, theme)));
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                return(this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// update portal skin.
        /// </summary>
        /// <param name="portalSettings">portal settings.</param>
        /// <param name="themeName"></param>
        /// <param name="level"></param>
        public void ApplyDefaultTheme(PortalSettings portalSettings, string themeName, ThemeLevel level)
        {
            var skin = GetLayouts(portalSettings, ThemeLevel.All)
                       .FirstOrDefault(t => t.PackageName.Equals(themeName, StringComparison.InvariantCultureIgnoreCase) && t.Level == level);

            if (skin != null)
            {
                var skinFile = GetThemeFiles(portalSettings, skin).FirstOrDefault(t => t.Path == skin.DefaultThemeFile);
                if (skinFile != null)
                {
                    ApplyTheme(portalSettings.PortalId, skinFile, ApplyThemeScope.Site | ApplyThemeScope.Edit);
                }
            }

            var container = GetContainers(portalSettings, ThemeLevel.All)
                            .FirstOrDefault(t => t.PackageName.Equals(themeName, StringComparison.InvariantCultureIgnoreCase) && t.Level == level);

            if (container != null)
            {
                var containerFile = GetThemeFiles(portalSettings, container).FirstOrDefault(t => t.Path == container.DefaultThemeFile);
                if (containerFile != null)
                {
                    ApplyTheme(portalSettings.PortalId, containerFile, ApplyThemeScope.Site | ApplyThemeScope.Edit);
                }
            }
        }