- Themes: Adding core themes package, CurrentTheme property injection, base theme/theme service interface/implementations...

--HG--
extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4043641
This commit is contained in:
suhacan
2009-12-10 00:15:58 +00:00
parent 01245485e8
commit 85f8b1d03b
20 changed files with 238 additions and 10 deletions

View File

@@ -83,6 +83,13 @@
<Compile Include="Settings\Records\SiteSettingsRecord.cs" />
<Compile Include="Settings\Services\SiteService.cs" />
<Compile Include="Settings\ViewModels\SettingsIndexViewModel.cs" />
<Compile Include="Themes\AdminMenu.cs" />
<Compile Include="Themes\Controllers\AdminController.cs" />
<Compile Include="Themes\Models\ThemeSiteSettings.cs" />
<Compile Include="Themes\Models\ThemeSiteSettingsHandler.cs" />
<Compile Include="Themes\Records\ThemeSiteSettingsRecord.cs" />
<Compile Include="Themes\Services\ThemeService.cs" />
<Compile Include="Themes\ViewModels\ThemesIndexViewModel.cs" />
<Compile Include="XmlRpc\Controllers\HomeController.cs" />
<Compile Include="XmlRpc\Controllers\LiveWriterController.cs" />
<Compile Include="XmlRpc\IXmlRpcHandler.cs" />
@@ -122,6 +129,12 @@
<ItemGroup>
<Content Include="Common\Views\Models\EditorTemplates\OwnerEditorViewModel.ascx" />
<Content Include="Common\Views\Web.config" />
<Content Include="Themes\Package.txt" />
<Content Include="Themes\Views\Admin\Index.aspx" />
<Content Include="Themes\Views\Models\EditorTemplates\ThemeSiteSettingsRecord.ascx" />
</ItemGroup>
<ItemGroup>
<Content Include="Themes\Views\Web.config" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />

View File

@@ -1,4 +1,5 @@
using Orchard.Core.Settings.Records;
using System;
using Orchard.Core.Settings.Records;
using Orchard.Models;
using Orchard.Settings;

View File

@@ -0,0 +1,14 @@
using Orchard.UI.Navigation;
namespace Orchard.Core.Themes {
public class AdminMenu : INavigationProvider {
public string MenuName { get { return "admin"; } }
public void GetNavigation(NavigationBuilder builder) {
builder.Add("Themes", "11",
menu => menu
.Add("Manage Themes", "2.0", item => item.Action("Index", "Admin", new { area = "Themes" }))
.Add("Upload a Theme", "2.1", item => item.Action("Index", "Admin",new { area = "Themes" })));
}
}
}

View File

@@ -0,0 +1,25 @@
using System.Web.Mvc;
using Orchard.Core.Themes.ViewModels;
using Orchard.Localization;
using Orchard.Themes;
using Orchard.UI.Notify;
namespace Orchard.Core.Themes.Controllers {
[ValidateInput(false)]
public class AdminController : Controller {
private readonly IThemeService _themeService;
private readonly INotifier _notifier;
public AdminController(IThemeService themeService, INotifier notifier) {
_themeService = themeService;
_notifier = notifier;
T = NullLocalizer.Instance;
}
public Localizer T { get; set; }
public ActionResult Index() {
return View(new ThemesIndexViewModel());
}
}
}

View File

@@ -0,0 +1,11 @@
using Orchard.Core.Themes.Records;
using Orchard.Models;
namespace Orchard.Core.Themes.Models {
public class ThemeSiteSettings : ContentPart<ThemeSiteSettingsRecord> {
public string CurrentThemeName {
get { return Record.CurrentThemeName; }
set { Record.CurrentThemeName = value; }
}
}
}

View File

@@ -0,0 +1,16 @@
using Orchard.Core.Themes.Records;
using Orchard.Data;
using Orchard.Models.Driver;
namespace Orchard.Core.Themes.Models {
public class ThemeSiteSettingsHandler : ContentHandler {
private readonly IRepository<ThemeSiteSettingsRecord> _themeSiteSettingsRepository;
public ThemeSiteSettingsHandler(IRepository<ThemeSiteSettingsRecord> repository) {
_themeSiteSettingsRepository = repository;
Filters.Add(new ActivatingFilter<ThemeSiteSettings>("site"));
Filters.Add(new StorageFilter<ThemeSiteSettingsRecord>(_themeSiteSettingsRepository) { AutomaticallyCreateMissingRecord = true });
Filters.Add(new TemplateFilterForRecord<ThemeSiteSettingsRecord>("ThemeSiteSettings"));
}
}
}

View File

@@ -0,0 +1 @@
name: Themes

View File

@@ -0,0 +1,7 @@
using Orchard.Models.Records;
namespace Orchard.Core.Themes.Records {
public class ThemeSiteSettingsRecord : ContentPartRecord {
public virtual string CurrentThemeName { get; set; }
}
}

View File

@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using Orchard.Logging;
using Orchard.Models;
using Orchard.Settings;
using Orchard.Themes;
using Orchard.Core.Themes.Models;
namespace Orchard.Core.Themes.Services {
public class ThemeService : IThemeService {
public ThemeService() {
Logger = NullLogger.Instance;
}
public ILogger Logger { get; set; }
public ISite CurrentSite { get; set; }
#region Implementation of IThemeService
public ITheme GetCurrentTheme() {
string currentThemeName = CurrentSite.As<ThemeSiteSettings>().Record.CurrentThemeName;
if (String.IsNullOrEmpty(currentThemeName)) {
return null;
}
return GetThemeByName(currentThemeName);
}
public ITheme GetThemeByName(string name) {
throw new NotImplementedException();
}
public IEnumerable<ITheme> GetInstalledThemes() {
throw new NotImplementedException();
}
#endregion
}
}

View File

@@ -0,0 +1,6 @@
using Orchard.Mvc.ViewModels;
namespace Orchard.Core.Themes.ViewModels {
public class ThemesIndexViewModel : AdminViewModel {
}
}

View File

@@ -0,0 +1,12 @@
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<ThemesIndexViewModel>" %>
<%@ Import Namespace="Orchard.Core.Themes.ViewModels"%>
<%@ Import Namespace="Orchard.Mvc.Html"%>
<% Html.Include("AdminHead"); %>
<div class="yui-u">
<h2 class="separator">
Themes</h2>
</div>
<div class="yui-u">
List of Orchard Themes
</div>
<% Html.Include("AdminFoot"); %>

View File

@@ -0,0 +1,10 @@
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ThemeSiteSettingsRecord>" %>
<%@ Import Namespace="Orchard.Core.Themes.Records"%>
<h3>Themes</h3>
<ol>
<li>
<%= Html.LabelFor(x=>x.CurrentThemeName) %>
<%= Html.EditorFor(x=>x.CurrentThemeName) %>
<%= Html.ValidationMessage("CurrentThemeName", "*")%>
</li>
</ol>

View File

@@ -0,0 +1,34 @@
<?xml version="1.0"?>
<configuration>
<system.web>
<httpHandlers>
<add path="*" verb="*"
type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>
<!--
Enabling request validation in view pages would cause validation to occur
after the input has already been processed by the controller. By default
MVC performs request validation before a controller processes the input.
To change this behavior apply the ValidateInputAttribute to a
controller or action.
-->
<pages
validateRequest="false"
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<controls>
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler"/>
</handlers>
</system.webServer>
</configuration>