mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-23 04:43:35 +08:00
- Themes: Admin to show the theme metadata and preview as well as the ability to switch themes.
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4043757
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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<ThemeSiteSettings>().Record.CurrentThemeName = themeName;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@@ -1,20 +1,48 @@
|
||||
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<ThemesIndexViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Core.Themes.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||
<% Html.Include("AdminHead"); %>
|
||||
<%
|
||||
Html.Include("AdminHead");%>
|
||||
<div class="yui-u">
|
||||
<h2 class="separator">
|
||||
Themes</h2>
|
||||
Manage Themes</h2>
|
||||
</div>
|
||||
<div class="yui-u">
|
||||
<% foreach (var theme in Model.Themes) { %>
|
||||
<p>Name: <%= theme.ThemeName %></p>
|
||||
<p>DisplayName: <%= theme.DisplayName %></p>
|
||||
<p>Description: <%= theme.Description %></p>
|
||||
<p>Author: <%= theme.Author %></p>
|
||||
<p>Version: <%= theme.Version %></p>
|
||||
<p>HomePage: <%= theme.HomePage %></p>
|
||||
<ul class="templates">
|
||||
<li>
|
||||
<div>
|
||||
<h3>Current Theme</h3>
|
||||
<% if (Model.CurrentTheme == null) { %>
|
||||
There is no current theme in the application. The built-in theme will be used.
|
||||
<% } else { %>
|
||||
<h4><%= Model.CurrentTheme.DisplayName %> </h4>
|
||||
<p><img src="<%= ResolveUrl("~/Themes/" + Model.CurrentTheme.ThemeName + "/Theme.gif")%>" alt="<%= Model.CurrentTheme.DisplayName %>" /><br />
|
||||
By <%= Model.CurrentTheme.Author %><br />
|
||||
<%= Model.CurrentTheme.Version %><br />
|
||||
<%= Model.CurrentTheme.Description %><br />
|
||||
<%= Model.CurrentTheme.HomePage %><br />
|
||||
</p>
|
||||
<% } %>
|
||||
Current Theme: <%= Model.CurrentTheme != null ? Model.CurrentTheme.ThemeName : "None" %>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
|
||||
<div>
|
||||
<h3>Available Themes</h3>
|
||||
<% foreach (var theme in Model.Themes) {
|
||||
if (Model.CurrentTheme == null || theme.ThemeName != Model.CurrentTheme.ThemeName) {%>
|
||||
<h4><%= theme.DisplayName %> </h4>
|
||||
<p><img src="<%= ResolveUrl("~/Themes/" + theme.ThemeName + "/Theme.gif") %>" alt="<%= theme.DisplayName %>" /><br />
|
||||
By <%= theme.Author %><br />
|
||||
<%= theme.Version %><br />
|
||||
<%= theme.Description %><br />
|
||||
<%= theme.HomePage %><br />
|
||||
<%=Html.ActionLink("Activate", "Activate", new {themeName = theme.ThemeName}) %>
|
||||
</p>
|
||||
<% }
|
||||
} %>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<% Html.Include("AdminFoot"); %>
|
@@ -5,5 +5,6 @@ namespace Orchard.Themes {
|
||||
ITheme GetCurrentTheme();
|
||||
ITheme GetThemeByName(string themeName);
|
||||
IEnumerable<ITheme> GetInstalledThemes();
|
||||
void SetCurrentTheme(string themeName);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user