mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-23 12:53:33 +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());
|
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
|
#region Implementation of ITheme
|
||||||
|
|
||||||
public string ThemeName {
|
public string ThemeName { get; set; }
|
||||||
get;
|
public string DisplayName { get; set; }
|
||||||
set;
|
public string Description { get; set; }
|
||||||
}
|
public string Version { get; set; }
|
||||||
|
public string Author { get; set; }
|
||||||
public string DisplayName {
|
public string HomePage { get; set; }
|
||||||
get;
|
|
||||||
set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Description {
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Version {
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Author {
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string HomePage {
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
@@ -40,7 +40,7 @@ namespace Orchard.Core.Themes.Services {
|
|||||||
DisplayName = descriptor.DisplayName ?? String.Empty,
|
DisplayName = descriptor.DisplayName ?? String.Empty,
|
||||||
HomePage = descriptor.HomePage ?? String.Empty,
|
HomePage = descriptor.HomePage ?? String.Empty,
|
||||||
ThemeName = descriptor.Name,
|
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,
|
DisplayName = descriptor.DisplayName ?? String.Empty,
|
||||||
HomePage = descriptor.HomePage ?? String.Empty,
|
HomePage = descriptor.HomePage ?? String.Empty,
|
||||||
ThemeName = descriptor.Name,
|
ThemeName = descriptor.Name,
|
||||||
Version = descriptor.Version ?? String.Empty
|
Version = descriptor.Version ?? String.Empty,
|
||||||
};
|
};
|
||||||
themes.Add(theme);
|
themes.Add(theme);
|
||||||
}
|
}
|
||||||
@@ -65,6 +65,12 @@ namespace Orchard.Core.Themes.Services {
|
|||||||
return themes;
|
return themes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetCurrentTheme(string themeName) {
|
||||||
|
if (GetThemeByName(themeName) != null) {
|
||||||
|
CurrentSite.As<ThemeSiteSettings>().Record.CurrentThemeName = themeName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,20 +1,48 @@
|
|||||||
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<ThemesIndexViewModel>" %>
|
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<ThemesIndexViewModel>" %>
|
||||||
<%@ Import Namespace="Orchard.Core.Themes.ViewModels"%>
|
<%@ Import Namespace="Orchard.Core.Themes.ViewModels"%>
|
||||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||||
<% Html.Include("AdminHead"); %>
|
<%
|
||||||
|
Html.Include("AdminHead");%>
|
||||||
<div class="yui-u">
|
<div class="yui-u">
|
||||||
<h2 class="separator">
|
<h2 class="separator">
|
||||||
Themes</h2>
|
Manage Themes</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="yui-u">
|
<div class="yui-u">
|
||||||
<% foreach (var theme in Model.Themes) { %>
|
<ul class="templates">
|
||||||
<p>Name: <%= theme.ThemeName %></p>
|
<li>
|
||||||
<p>DisplayName: <%= theme.DisplayName %></p>
|
<div>
|
||||||
<p>Description: <%= theme.Description %></p>
|
<h3>Current Theme</h3>
|
||||||
<p>Author: <%= theme.Author %></p>
|
<% if (Model.CurrentTheme == null) { %>
|
||||||
<p>Version: <%= theme.Version %></p>
|
There is no current theme in the application. The built-in theme will be used.
|
||||||
<p>HomePage: <%= theme.HomePage %></p>
|
<% } 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>
|
</div>
|
||||||
<% Html.Include("AdminFoot"); %>
|
<% Html.Include("AdminFoot"); %>
|
@@ -5,5 +5,6 @@ namespace Orchard.Themes {
|
|||||||
ITheme GetCurrentTheme();
|
ITheme GetCurrentTheme();
|
||||||
ITheme GetThemeByName(string themeName);
|
ITheme GetThemeByName(string themeName);
|
||||||
IEnumerable<ITheme> GetInstalledThemes();
|
IEnumerable<ITheme> GetInstalledThemes();
|
||||||
|
void SetCurrentTheme(string themeName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user