2010-02-12 15:32:30 -08:00
|
|
|
|
using System;
|
2012-01-13 10:01:33 -08:00
|
|
|
|
using System.Collections.Generic;
|
2010-02-04 19:47:24 -08:00
|
|
|
|
using System.Web.Routing;
|
|
|
|
|
using Autofac;
|
2010-10-12 16:52:36 -07:00
|
|
|
|
using JetBrains.Annotations;
|
2010-12-02 16:11:47 -08:00
|
|
|
|
using Orchard.Caching;
|
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-12-09 16:39:06 -08:00
|
|
|
|
using Orchard.Core.Settings.Models;
|
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-09-09 14:29:04 -07:00
|
|
|
|
using Orchard.DisplayManagement.Descriptors.ShapeAttributeStrategy;
|
2010-09-05 04:06:18 -07:00
|
|
|
|
using Orchard.DisplayManagement.Descriptors.ShapeTemplateStrategy;
|
2010-08-26 12:03:07 -07:00
|
|
|
|
using Orchard.DisplayManagement.Implementation;
|
2010-09-02 22:51:29 -07:00
|
|
|
|
using Orchard.Environment;
|
2010-09-08 19:30:30 -07:00
|
|
|
|
using Orchard.Environment.Extensions.Models;
|
2010-02-04 19:47:24 -08:00
|
|
|
|
using Orchard.Localization;
|
|
|
|
|
using Orchard.Mvc;
|
|
|
|
|
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;
|
2011-02-12 14:57:11 -08:00
|
|
|
|
using Orchard.Recipes.Services;
|
2010-02-04 19:47:24 -08:00
|
|
|
|
using Orchard.Settings;
|
2012-02-06 14:03:21 -08:00
|
|
|
|
using Orchard.Tasks;
|
2010-02-04 19:47:24 -08:00
|
|
|
|
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-09-16 17:35:01 -07:00
|
|
|
|
using Orchard.UI.Resources;
|
2010-09-05 04:06:18 -07:00
|
|
|
|
using Orchard.UI.Zones;
|
2010-09-16 17:35:01 -07:00
|
|
|
|
using IFilterProvider = Orchard.Mvc.Filters.IFilterProvider;
|
2010-02-04 19:47:24 -08:00
|
|
|
|
|
2010-04-17 21:33:36 -07:00
|
|
|
|
namespace Orchard.Setup {
|
|
|
|
|
public class SetupMode : Module {
|
2010-09-08 19:30:30 -07:00
|
|
|
|
public Feature Feature { get; set; }
|
|
|
|
|
|
2010-04-17 21:33:36 -07:00
|
|
|
|
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-11-24 18:57:42 -08:00
|
|
|
|
builder.RegisterModule(new WorkContextModule());
|
2010-12-02 16:11:47 -08:00
|
|
|
|
builder.RegisterModule(new CacheModule());
|
2010-11-24 18:57:42 -08:00
|
|
|
|
|
2010-04-02 15:17:13 -07:00
|
|
|
|
builder.RegisterType<RoutePublisher>().As<IRoutePublisher>().InstancePerLifetimeScope();
|
|
|
|
|
builder.RegisterType<ModelBinderPublisher>().As<IModelBinderPublisher>().InstancePerLifetimeScope();
|
2011-09-12 10:46:04 -07:00
|
|
|
|
builder.RegisterType<RazorViewEngineProvider>().As<IViewEngineProvider>().As<IShapeTemplateViewEngine>().SingleInstance();
|
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();
|
2011-12-28 15:10:00 -08:00
|
|
|
|
//builder.RegisterType<WorkContextAccessor>().As<IWorkContextAccessor>().InstancePerMatchingLifetimeScope("shell");
|
2010-09-16 17:35:01 -07:00
|
|
|
|
builder.RegisterType<ResourceManager>().As<IResourceManager>().InstancePerLifetimeScope();
|
2010-09-21 00:58:56 -07:00
|
|
|
|
builder.RegisterType<ResourceFilter>().As<IFilterProvider>().InstancePerLifetimeScope();
|
2011-09-08 14:57:08 -07:00
|
|
|
|
builder.RegisterType<DefaultOrchardShell>().As<IOrchardShell>().InstancePerMatchingLifetimeScope("shell");
|
2012-02-06 14:03:21 -08:00
|
|
|
|
builder.RegisterType<SweepGenerator>().As<ISweepGenerator>().SingleInstance();
|
2015-05-31 18:15:29 +02:00
|
|
|
|
builder.RegisterType<SetupBackgroundService>().As<IBackgroundService>().InstancePerLifetimeScope();
|
2010-04-17 21:33:36 -07:00
|
|
|
|
|
|
|
|
|
// setup mode specific implementations of needed service interfaces
|
2010-11-06 20:27:45 -07:00
|
|
|
|
builder.RegisterType<SafeModeThemeService>().As<IThemeManager>().InstancePerLifetimeScope();
|
2010-04-02 15:17:13 -07:00
|
|
|
|
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();
|
|
|
|
|
|
2011-02-12 14:57:11 -08:00
|
|
|
|
builder.RegisterType<RecipeHarvester>().As<IRecipeHarvester>().InstancePerLifetimeScope();
|
|
|
|
|
builder.RegisterType<RecipeParser>().As<IRecipeParser>().InstancePerLifetimeScope();
|
|
|
|
|
|
2011-09-08 14:57:08 -07:00
|
|
|
|
builder.RegisterType<DefaultCacheHolder>().As<ICacheHolder>().SingleInstance();
|
2011-06-02 12:11:29 -07:00
|
|
|
|
|
2010-08-25 21:42:53 -07:00
|
|
|
|
// in progress - adding services for display/shape support in setup
|
2011-09-12 10:46:04 -07:00
|
|
|
|
builder.RegisterType<DisplayHelperFactory>().As<IDisplayHelperFactory>().InstancePerLifetimeScope();
|
|
|
|
|
builder.RegisterType<DefaultDisplayManager>().As<IDisplayManager>().InstancePerLifetimeScope();
|
|
|
|
|
builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>().InstancePerLifetimeScope();
|
|
|
|
|
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>().InstancePerLifetimeScope();
|
|
|
|
|
builder.RegisterType<ShapeTableLocator>().As<IShapeTableLocator>().InstancePerMatchingLifetimeScope("work");
|
|
|
|
|
|
|
|
|
|
builder.RegisterType<ThemeAwareViewEngine>().As<IThemeAwareViewEngine>().InstancePerLifetimeScope();
|
|
|
|
|
builder.RegisterType<LayoutAwareViewEngine>().As<ILayoutAwareViewEngine>().InstancePerLifetimeScope();
|
|
|
|
|
builder.RegisterType<ConfiguredEnginesCache>().As<IConfiguredEnginesCache>().SingleInstance();
|
|
|
|
|
builder.RegisterType<LayoutWorkContext>().As<IWorkContextStateProvider>().InstancePerLifetimeScope();
|
|
|
|
|
builder.RegisterType<SafeModeSiteWorkContextProvider>().As<IWorkContextStateProvider>().InstancePerLifetimeScope();
|
|
|
|
|
|
|
|
|
|
builder.RegisterType<ShapeTemplateBindingStrategy>().As<IShapeTableProvider>().InstancePerLifetimeScope();
|
|
|
|
|
builder.RegisterType<BasicShapeTemplateHarvester>().As<IShapeTemplateHarvester>().InstancePerLifetimeScope();
|
2012-01-13 11:31:34 -08:00
|
|
|
|
builder.RegisterType<ShapeAttributeBindingStrategy>().As<IShapeTableProvider>().InstancePerMatchingLifetimeScope("shell");
|
2010-09-09 14:29:04 -07:00
|
|
|
|
builder.RegisterModule(new ShapeAttributeBindingModule());
|
2010-02-04 19:47:24 -08:00
|
|
|
|
}
|
|
|
|
|
|
2010-04-17 21:33:36 -07:00
|
|
|
|
|
2015-05-31 18:15:29 +02:00
|
|
|
|
internal class SetupBackgroundService : IBackgroundService {
|
|
|
|
|
public void Sweep() {
|
|
|
|
|
// Don't run any background service in setup mode.
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-12 16:52:36 -07:00
|
|
|
|
[UsedImplicitly]
|
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));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-12 16:52:36 -07:00
|
|
|
|
[UsedImplicitly]
|
2010-11-06 20:27:45 -07:00
|
|
|
|
class SafeModeThemeService : IThemeManager {
|
2010-11-04 20:37:35 -07:00
|
|
|
|
private readonly ExtensionDescriptor _theme = new ExtensionDescriptor {
|
2010-11-18 15:37:47 -08:00
|
|
|
|
Id = "SafeMode",
|
2010-11-04 16:04:50 -07:00
|
|
|
|
Name = "SafeMode",
|
2010-11-08 11:29:22 -08:00
|
|
|
|
Location = "~/Themes",
|
2010-02-04 19:47:24 -08:00
|
|
|
|
};
|
|
|
|
|
|
2010-11-04 20:37:35 -07:00
|
|
|
|
public ExtensionDescriptor GetRequestTheme(RequestContext requestContext) { return _theme; }
|
2010-02-04 19:47:24 -08:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-12 16:52:36 -07:00
|
|
|
|
[UsedImplicitly]
|
2010-09-22 14:39:01 -07:00
|
|
|
|
class SafeModeSiteWorkContextProvider : IWorkContextStateProvider {
|
2010-11-15 18:03:38 -08:00
|
|
|
|
public Func<WorkContext, T> Get<T>(string name) {
|
2010-10-15 17:39:20 -07:00
|
|
|
|
if (name == "CurrentSite") {
|
|
|
|
|
ISite safeModeSite = new SafeModeSite();
|
2010-11-15 18:03:38 -08:00
|
|
|
|
return ctx => (T)safeModeSite;
|
2010-10-15 17:39:20 -07:00
|
|
|
|
}
|
|
|
|
|
return null;
|
2010-09-22 14:39:01 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
2010-02-04 19:47:24 -08:00
|
|
|
|
|
2010-10-12 16:52:36 -07:00
|
|
|
|
[UsedImplicitly]
|
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 {
|
2012-07-02 17:38:37 -07:00
|
|
|
|
get { return " - "; }
|
2010-02-04 19:47:24 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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-09-22 14:39:01 -07:00
|
|
|
|
|
2013-12-07 00:50:02 +01:00
|
|
|
|
public string SiteCalendar {
|
|
|
|
|
get { return ""; }
|
|
|
|
|
set { throw new NotImplementedException(); }
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-22 14:39:01 -07:00
|
|
|
|
public ResourceDebugMode ResourceDebugMode {
|
2010-11-08 11:29:22 -08:00
|
|
|
|
get { return ResourceDebugMode.FromAppSetting; }
|
2010-09-22 14:39:01 -07:00
|
|
|
|
set { throw new NotImplementedException(); }
|
|
|
|
|
}
|
2010-12-09 16:39:06 -08:00
|
|
|
|
|
2015-02-07 17:55:23 +00:00
|
|
|
|
public bool UseCdn {
|
|
|
|
|
get { return false; }
|
|
|
|
|
set { throw new NotImplementedException(); }
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-09 16:39:06 -08:00
|
|
|
|
public int PageSize {
|
2013-10-28 17:43:32 -07:00
|
|
|
|
get { return SiteSettingsPart.DefaultPageSize; }
|
2010-12-09 16:39:06 -08:00
|
|
|
|
set { throw new NotImplementedException(); }
|
|
|
|
|
}
|
2011-03-17 11:06:23 -07:00
|
|
|
|
|
2014-03-13 14:13:57 -07:00
|
|
|
|
public int MaxPageSize {
|
|
|
|
|
get { return SiteSettingsPart.DefaultPageSize; }
|
|
|
|
|
set { throw new NotImplementedException(); }
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-03 18:36:14 -07:00
|
|
|
|
public int MaxPagedCount {
|
|
|
|
|
get { return 0; }
|
|
|
|
|
set { throw new NotImplementedException(); }
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-17 11:06:23 -07:00
|
|
|
|
public string BaseUrl {
|
|
|
|
|
get { return ""; }
|
|
|
|
|
}
|
2012-01-05 14:49:10 -08:00
|
|
|
|
|
|
|
|
|
public string SiteTimeZone {
|
|
|
|
|
get { return TimeZoneInfo.Local.Id; }
|
|
|
|
|
}
|
2010-02-04 19:47:24 -08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|