2010-02-12 15:32:30 -08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2010-02-04 19:47:24 -08:00
|
|
|
|
using System.Web;
|
|
|
|
|
using System.Web.Routing;
|
|
|
|
|
using Autofac;
|
2010-04-28 18:21:32 -07:00
|
|
|
|
using Orchard.Commands;
|
|
|
|
|
using Orchard.Commands.Builtin;
|
2010-02-04 19:47:24 -08:00
|
|
|
|
using Orchard.ContentManagement;
|
|
|
|
|
using Orchard.ContentManagement.Handlers;
|
2010-06-08 12:05:29 -07:00
|
|
|
|
using Orchard.ContentManagement.MetaData.Builders;
|
2010-06-29 16:17:08 -07:00
|
|
|
|
using Orchard.Data.Migration.Interpreters;
|
2010-06-25 14:41:19 -07:00
|
|
|
|
using Orchard.Data.Providers;
|
2010-06-29 16:17:08 -07:00
|
|
|
|
using Orchard.Data.Migration;
|
2010-08-25 21:42:53 -07:00
|
|
|
|
using Orchard.DisplayManagement;
|
2010-08-27 17:47:27 -07:00
|
|
|
|
using Orchard.DisplayManagement.Descriptors;
|
2010-08-26 12:03:07 -07:00
|
|
|
|
using Orchard.DisplayManagement.Implementation;
|
2010-08-25 21:42:53 -07:00
|
|
|
|
using Orchard.DisplayManagement.Shapes;
|
2010-09-02 22:51:29 -07:00
|
|
|
|
using Orchard.Environment;
|
2010-04-17 16:09:53 -07:00
|
|
|
|
using Orchard.Environment.Extensions;
|
2010-02-04 19:47:24 -08:00
|
|
|
|
using Orchard.Localization;
|
|
|
|
|
using Orchard.Mvc;
|
|
|
|
|
using Orchard.Mvc.Filters;
|
|
|
|
|
using Orchard.Mvc.ModelBinders;
|
|
|
|
|
using Orchard.Mvc.Routes;
|
|
|
|
|
using Orchard.Mvc.ViewEngines;
|
2010-08-23 13:10:12 -07:00
|
|
|
|
using Orchard.Mvc.ViewEngines.Razor;
|
2010-09-03 17:41:14 -07:00
|
|
|
|
using Orchard.Mvc.ViewEngines.ThemeAwareness;
|
2010-06-30 12:38:21 -07:00
|
|
|
|
using Orchard.Mvc.ViewEngines.WebForms;
|
2010-02-04 19:47:24 -08:00
|
|
|
|
using Orchard.Settings;
|
|
|
|
|
using Orchard.Themes;
|
2010-02-05 13:36:01 -08:00
|
|
|
|
using Orchard.UI.Notify;
|
2010-02-04 19:47:24 -08:00
|
|
|
|
using Orchard.UI.PageClass;
|
|
|
|
|
using Orchard.UI.PageTitle;
|
|
|
|
|
|
2010-04-17 21:33:36 -07:00
|
|
|
|
namespace Orchard.Setup {
|
|
|
|
|
public class SetupMode : Module {
|
|
|
|
|
protected override void Load(ContainerBuilder builder) {
|
2010-02-04 19:47:24 -08:00
|
|
|
|
|
2010-04-17 21:33:36 -07:00
|
|
|
|
// standard services needed in setup mode
|
|
|
|
|
builder.RegisterModule(new MvcModule());
|
2010-04-28 18:21:32 -07:00
|
|
|
|
builder.RegisterModule(new CommandModule());
|
2010-04-02 15:17:13 -07:00
|
|
|
|
builder.RegisterType<RoutePublisher>().As<IRoutePublisher>().InstancePerLifetimeScope();
|
|
|
|
|
builder.RegisterType<ModelBinderPublisher>().As<IModelBinderPublisher>().InstancePerLifetimeScope();
|
2010-06-30 12:38:21 -07:00
|
|
|
|
builder.RegisterType<WebFormViewEngineProvider>().As<IViewEngineProvider>().InstancePerLifetimeScope();
|
2010-08-23 13:10:12 -07:00
|
|
|
|
builder.RegisterType<RazorViewEngineProvider>().As<IViewEngineProvider>().InstancePerLifetimeScope();
|
2010-09-03 18:58:24 -07:00
|
|
|
|
builder.RegisterType<ThemedViewResultFilter>().As<IFilterProvider>().InstancePerLifetimeScope();
|
2010-04-02 15:17:13 -07:00
|
|
|
|
builder.RegisterType<ThemeFilter>().As<IFilterProvider>().InstancePerLifetimeScope();
|
|
|
|
|
builder.RegisterType<PageTitleBuilder>().As<IPageTitleBuilder>().InstancePerLifetimeScope();
|
|
|
|
|
builder.RegisterType<PageClassBuilder>().As<IPageClassBuilder>().InstancePerLifetimeScope();
|
|
|
|
|
builder.RegisterType<Notifier>().As<INotifier>().InstancePerLifetimeScope();
|
|
|
|
|
builder.RegisterType<NotifyFilter>().As<IFilterProvider>().InstancePerLifetimeScope();
|
2010-06-25 14:41:19 -07:00
|
|
|
|
builder.RegisterType<DataServicesProviderFactory>().As<IDataServicesProviderFactory>().InstancePerLifetimeScope();
|
2010-04-28 18:21:32 -07:00
|
|
|
|
builder.RegisterType<DefaultCommandManager>().As<ICommandManager>().InstancePerLifetimeScope();
|
|
|
|
|
builder.RegisterType<HelpCommand>().As<ICommandHandler>().InstancePerLifetimeScope();
|
2010-09-02 22:51:29 -07:00
|
|
|
|
builder.RegisterType<DefaultWorkContextAccessor>().As<IWorkContextAccessor>();
|
2010-04-17 21:33:36 -07:00
|
|
|
|
|
|
|
|
|
// setup mode specific implementations of needed service interfaces
|
2010-04-02 15:17:13 -07:00
|
|
|
|
builder.RegisterType<SafeModeThemeService>().As<IThemeService>().InstancePerLifetimeScope();
|
|
|
|
|
builder.RegisterType<SafeModeText>().As<IText>().InstancePerLifetimeScope();
|
|
|
|
|
builder.RegisterType<SafeModeSiteService>().As<ISiteService>().InstancePerLifetimeScope();
|
2010-02-04 19:47:24 -08:00
|
|
|
|
|
2010-06-29 11:28:21 -07:00
|
|
|
|
builder.RegisterType<DefaultDataMigrationInterpreter>().As<IDataMigrationInterpreter>().InstancePerLifetimeScope();
|
|
|
|
|
builder.RegisterType<DataMigrationManager>().As<IDataMigrationManager>().InstancePerLifetimeScope();
|
|
|
|
|
|
2010-08-25 21:42:53 -07:00
|
|
|
|
// in progress - adding services for display/shape support in setup
|
|
|
|
|
builder.RegisterType<DisplayHelperFactory>().As<IDisplayHelperFactory>();
|
|
|
|
|
builder.RegisterType<DefaultDisplayManager>().As<IDisplayManager>();
|
2010-08-26 12:03:07 -07:00
|
|
|
|
builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();
|
2010-09-02 22:51:29 -07:00
|
|
|
|
builder.RegisterType<ShapeHelperFactory>().As<IShapeHelperFactory>();
|
2010-09-03 17:41:14 -07:00
|
|
|
|
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
|
|
|
|
|
|
|
|
|
|
builder.RegisterType<ThemeAwareViewEngine>().As<IThemeAwareViewEngine>();
|
2010-09-03 18:58:24 -07:00
|
|
|
|
builder.RegisterType<LayoutAwareViewEngine>().As<ILayoutAwareViewEngine>();
|
2010-09-03 21:57:01 -07:00
|
|
|
|
builder.RegisterType<ConfiguredEnginesCache>().As<IConfiguredEnginesCache>();
|
|
|
|
|
builder.RegisterType<PageWorkContextStateProvider>().As<IWorkContextStateProvider>().As<IShapeEvents>();
|
2010-02-04 19:47:24 -08:00
|
|
|
|
}
|
|
|
|
|
|
2010-04-17 21:33:36 -07:00
|
|
|
|
|
2010-02-05 12:05:26 -08:00
|
|
|
|
class SafeModeText : IText {
|
2010-02-04 19:47:24 -08:00
|
|
|
|
public LocalizedString Get(string textHint, params object[] args) {
|
|
|
|
|
if (args == null || args.Length == 0) {
|
|
|
|
|
return new LocalizedString(textHint);
|
|
|
|
|
}
|
|
|
|
|
return new LocalizedString(string.Format(textHint, args));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class SafeModeThemeService : IThemeService {
|
|
|
|
|
class SafeModeTheme : ITheme {
|
|
|
|
|
public ContentItem ContentItem { 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; }
|
2010-03-01 11:03:14 -08:00
|
|
|
|
public string Tags { get; set; }
|
2010-02-04 19:47:24 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private readonly SafeModeTheme _theme = new SafeModeTheme {
|
|
|
|
|
ThemeName = "SafeMode",
|
|
|
|
|
DisplayName = "SafeMode",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public ITheme GetThemeByName(string themeName) { return _theme; }
|
|
|
|
|
public ITheme GetSiteTheme() { return _theme; }
|
|
|
|
|
public void SetSiteTheme(string themeName) { }
|
|
|
|
|
public ITheme GetRequestTheme(RequestContext requestContext) { return _theme; }
|
|
|
|
|
public IEnumerable<ITheme> GetInstalledThemes() { return new[] { _theme }; }
|
|
|
|
|
public void InstallTheme(HttpPostedFileBase file) { }
|
|
|
|
|
public void UninstallTheme(string themeName) { }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-02-05 12:05:26 -08:00
|
|
|
|
class SafeModeSiteService : ISiteService {
|
2010-02-04 19:47:24 -08:00
|
|
|
|
public ISite GetSiteSettings() {
|
2010-06-24 16:34:10 -07:00
|
|
|
|
var siteType = new ContentTypeDefinitionBuilder().Named("Site").Build();
|
2010-06-08 12:05:29 -07:00
|
|
|
|
var site = new ContentItemBuilder(siteType)
|
2010-02-05 12:05:26 -08:00
|
|
|
|
.Weld<SafeModeSite>()
|
2010-02-04 19:47:24 -08:00
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
return site.As<ISite>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-05 12:05:26 -08:00
|
|
|
|
class SafeModeSite : ContentPart, ISite {
|
2010-02-04 19:47:24 -08:00
|
|
|
|
public string PageTitleSeparator {
|
|
|
|
|
get { return "*"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string SiteName {
|
|
|
|
|
get { return "Orchard Setup"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string SiteSalt {
|
|
|
|
|
get { return "42"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string SiteUrl {
|
|
|
|
|
get { return "/"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string SuperUser {
|
|
|
|
|
get { return ""; }
|
|
|
|
|
}
|
2010-02-12 15:32:30 -08:00
|
|
|
|
|
|
|
|
|
public string HomePage {
|
|
|
|
|
get { return ""; }
|
|
|
|
|
set { throw new NotImplementedException(); }
|
|
|
|
|
}
|
2010-06-01 15:00:28 -07:00
|
|
|
|
|
|
|
|
|
public string SiteCulture {
|
|
|
|
|
get { return ""; }
|
|
|
|
|
set { throw new NotImplementedException(); }
|
|
|
|
|
}
|
2010-02-04 19:47:24 -08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|