diff --git a/src/Orchard.Web/Core/Themes/Controllers/AdminController.cs b/src/Orchard.Web/Core/Themes/Controllers/AdminController.cs index 3e46c69e1..1f55c745f 100644 --- a/src/Orchard.Web/Core/Themes/Controllers/AdminController.cs +++ b/src/Orchard.Web/Core/Themes/Controllers/AdminController.cs @@ -31,5 +31,16 @@ namespace Orchard.Core.Themes.Controllers { return View(new ThemesIndexViewModel()); } } + + public ActionResult Activate(string themeName) { + try { + _themeService.SetCurrentTheme(themeName); + return RedirectToAction("Index"); + } + catch (Exception exception) { + _notifier.Error(T("Activating theme failed: " + exception.Message)); + return RedirectToAction("Index"); + } + } } } diff --git a/src/Orchard.Web/Core/Themes/Models/Theme.cs b/src/Orchard.Web/Core/Themes/Models/Theme.cs index 52cb9f831..820c54924 100644 --- a/src/Orchard.Web/Core/Themes/Models/Theme.cs +++ b/src/Orchard.Web/Core/Themes/Models/Theme.cs @@ -8,35 +8,12 @@ namespace Orchard.Core.Themes.Models { #region Implementation of ITheme - public string ThemeName { - get; - set; - } - - public string DisplayName { - get; - set; - } - - public string Description { - get; - set; - } - - public string Version { - get; - set; - } - - public string Author { - get; - set; - } - - public string HomePage { - get; - set; - } + public string ThemeName { get; set; } + public string DisplayName { get; set; } + public string Description { get; set; } + public string Version { get; set; } + public string Author { get; set; } + public string HomePage { get; set; } #endregion } diff --git a/src/Orchard.Web/Core/Themes/Services/ThemeService.cs b/src/Orchard.Web/Core/Themes/Services/ThemeService.cs index 9edae441b..123da53f8 100644 --- a/src/Orchard.Web/Core/Themes/Services/ThemeService.cs +++ b/src/Orchard.Web/Core/Themes/Services/ThemeService.cs @@ -40,7 +40,7 @@ namespace Orchard.Core.Themes.Services { DisplayName = descriptor.DisplayName ?? String.Empty, HomePage = descriptor.HomePage ?? String.Empty, ThemeName = descriptor.Name, - Version = descriptor.Version ?? String.Empty + Version = descriptor.Version ?? String.Empty, }; } } @@ -57,7 +57,7 @@ namespace Orchard.Core.Themes.Services { DisplayName = descriptor.DisplayName ?? String.Empty, HomePage = descriptor.HomePage ?? String.Empty, ThemeName = descriptor.Name, - Version = descriptor.Version ?? String.Empty + Version = descriptor.Version ?? String.Empty, }; themes.Add(theme); } @@ -65,6 +65,12 @@ namespace Orchard.Core.Themes.Services { return themes; } + public void SetCurrentTheme(string themeName) { + if (GetThemeByName(themeName) != null) { + CurrentSite.As().Record.CurrentThemeName = themeName; + } + } + #endregion } } diff --git a/src/Orchard.Web/Core/Themes/Views/Admin/Index.aspx b/src/Orchard.Web/Core/Themes/Views/Admin/Index.aspx index 3329a69ed..e53bd2684 100644 --- a/src/Orchard.Web/Core/Themes/Views/Admin/Index.aspx +++ b/src/Orchard.Web/Core/Themes/Views/Admin/Index.aspx @@ -1,20 +1,48 @@ <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %> <%@ Import Namespace="Orchard.Core.Themes.ViewModels"%> <%@ Import Namespace="Orchard.Mvc.Html"%> -<% Html.Include("AdminHead"); %> +<% + Html.Include("AdminHead");%>

- Themes

+ Manage Themes
- <% foreach (var theme in Model.Themes) { %> -

Name: <%= theme.ThemeName %>

-

DisplayName: <%= theme.DisplayName %>

-

Description: <%= theme.Description %>

-

Author: <%= theme.Author %>

-

Version: <%= theme.Version %>

-

HomePage: <%= theme.HomePage %>

+
    +
  • +
    +

    Current Theme

    + <% if (Model.CurrentTheme == null) { %> + There is no current theme in the application. The built-in theme will be used. + <% } else { %> +

    <%= Model.CurrentTheme.DisplayName %>

    +

    " alt="<%= Model.CurrentTheme.DisplayName %>" />
    + By <%= Model.CurrentTheme.Author %>
    + <%= Model.CurrentTheme.Version %>
    + <%= Model.CurrentTheme.Description %>
    + <%= Model.CurrentTheme.HomePage %>
    +

    <% } %> - Current Theme: <%= Model.CurrentTheme != null ? Model.CurrentTheme.ThemeName : "None" %> +
    +
  • +
  • + +
    +

    Available Themes

    + <% foreach (var theme in Model.Themes) { + if (Model.CurrentTheme == null || theme.ThemeName != Model.CurrentTheme.ThemeName) {%> +

    <%= theme.DisplayName %>

    +

    " alt="<%= theme.DisplayName %>" />
    + By <%= theme.Author %>
    + <%= theme.Version %>
    + <%= theme.Description %>
    + <%= theme.HomePage %>
    + <%=Html.ActionLink("Activate", "Activate", new {themeName = theme.ThemeName}) %> +

    + <% } + } %> +
    +
  • +
<% Html.Include("AdminFoot"); %> \ No newline at end of file diff --git a/src/Orchard/Themes/IThemeService.cs b/src/Orchard/Themes/IThemeService.cs index c9abc5958..08c9f5418 100644 --- a/src/Orchard/Themes/IThemeService.cs +++ b/src/Orchard/Themes/IThemeService.cs @@ -5,5 +5,6 @@ namespace Orchard.Themes { ITheme GetCurrentTheme(); ITheme GetThemeByName(string themeName); IEnumerable GetInstalledThemes(); + void SetCurrentTheme(string themeName); } }