" %>
+<%@ Import Namespace="Orchard.Core.Themes.ViewModels"%>
+<%@ Import Namespace="Orchard.Mvc.Html"%>
+<% Html.Include("AdminHead"); %>
+
+
+ Themes
+
+
+ List of Orchard Themes
+
+<% Html.Include("AdminFoot"); %>
\ No newline at end of file
diff --git a/src/Orchard.Web/Core/Themes/Views/Models/EditorTemplates/ThemeSiteSettingsRecord.ascx b/src/Orchard.Web/Core/Themes/Views/Models/EditorTemplates/ThemeSiteSettingsRecord.ascx
new file mode 100644
index 000000000..19029941a
--- /dev/null
+++ b/src/Orchard.Web/Core/Themes/Views/Models/EditorTemplates/ThemeSiteSettingsRecord.ascx
@@ -0,0 +1,10 @@
+<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
+<%@ Import Namespace="Orchard.Core.Themes.Records"%>
+Themes
+
+ -
+ <%= Html.LabelFor(x=>x.CurrentThemeName) %>
+ <%= Html.EditorFor(x=>x.CurrentThemeName) %>
+ <%= Html.ValidationMessage("CurrentThemeName", "*")%>
+
+
diff --git a/src/Orchard.Web/Core/Themes/Views/Web.config b/src/Orchard.Web/Core/Themes/Views/Web.config
new file mode 100644
index 000000000..7022197d4
--- /dev/null
+++ b/src/Orchard.Web/Core/Themes/Views/Web.config
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Orchard/Data/HackSessionLocator.cs b/src/Orchard/Data/HackSessionLocator.cs
index 6db6b116e..dad642adf 100644
--- a/src/Orchard/Data/HackSessionLocator.cs
+++ b/src/Orchard/Data/HackSessionLocator.cs
@@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Reflection;
using System.Threading;
-using System.Web;
using System.Web.Hosting;
using FluentNHibernate.Automapping;
using FluentNHibernate.Automapping.Alterations;
@@ -12,7 +10,6 @@ using FluentNHibernate.Cfg.Db;
using NHibernate;
using NHibernate.Tool.hbm2ddl;
using Orchard.Environment;
-using Orchard.Models;
using Orchard.Models.Records;
namespace Orchard.Data {
diff --git a/src/Orchard/Environment/DefaultCompositionStrategy.cs b/src/Orchard/Environment/DefaultCompositionStrategy.cs
index 92880674d..19ba083b4 100644
--- a/src/Orchard/Environment/DefaultCompositionStrategy.cs
+++ b/src/Orchard/Environment/DefaultCompositionStrategy.cs
@@ -2,8 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
-using System.Text;
-using System.Web.Compilation;
using Autofac;
using Orchard.Models;
using Orchard.Models.Records;
diff --git a/src/Orchard/Orchard.csproj b/src/Orchard/Orchard.csproj
index 603421b57..a8fbe8e62 100644
--- a/src/Orchard/Orchard.csproj
+++ b/src/Orchard/Orchard.csproj
@@ -214,6 +214,9 @@
+
+
+
diff --git a/src/Orchard/Packages/PackageManager.cs b/src/Orchard/Packages/PackageManager.cs
index 56a6a9c2e..29d4f76a3 100644
--- a/src/Orchard/Packages/PackageManager.cs
+++ b/src/Orchard/Packages/PackageManager.cs
@@ -1,8 +1,5 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
-using System.Reflection;
-using System.Text;
using Orchard.Packages.Loaders;
using Yaml.Grammar;
diff --git a/src/Orchard/Themes/ITheme.cs b/src/Orchard/Themes/ITheme.cs
new file mode 100644
index 000000000..5f2174931
--- /dev/null
+++ b/src/Orchard/Themes/ITheme.cs
@@ -0,0 +1,10 @@
+using Orchard.Models;
+
+namespace Orchard.Themes {
+ ///
+ /// Interface provided by the "themes" model.
+ ///
+ public interface ITheme : IContent {
+ string ThemeName { get; set; }
+ }
+}
diff --git a/src/Orchard/Themes/IThemeService.cs b/src/Orchard/Themes/IThemeService.cs
new file mode 100644
index 000000000..c9abc5958
--- /dev/null
+++ b/src/Orchard/Themes/IThemeService.cs
@@ -0,0 +1,9 @@
+using System.Collections.Generic;
+
+namespace Orchard.Themes {
+ public interface IThemeService : IDependency {
+ ITheme GetCurrentTheme();
+ ITheme GetThemeByName(string themeName);
+ IEnumerable GetInstalledThemes();
+ }
+}
diff --git a/src/Orchard/Themes/ThemesModule.cs b/src/Orchard/Themes/ThemesModule.cs
new file mode 100644
index 000000000..30af82ba1
--- /dev/null
+++ b/src/Orchard/Themes/ThemesModule.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Reflection;
+using Module = Autofac.Builder.Module;
+
+namespace Orchard.Themes {
+ public class ThemesModule : Module {
+ protected override void AttachToComponentRegistration(Autofac.IContainer container, Autofac.IComponentRegistration registration) {
+
+ var themeProperty = FindThemeProperty(registration.Descriptor.BestKnownImplementationType);
+
+ if (themeProperty != null) {
+ registration.Activated += (sender, e) => {
+ var themeService = e.Context.Resolve();
+ var currentTheme = themeService.GetCurrentTheme();
+ themeProperty.SetValue(e.Instance, currentTheme, null);
+ };
+ }
+ }
+
+ private static PropertyInfo FindThemeProperty(Type type) {
+ return type.GetProperty("CurrentTheme", typeof(ITheme));
+ }
+ }
+}