mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Merge
--HG-- branch : dev
This commit is contained in:
@@ -61,12 +61,15 @@ namespace Orchard.Tests.Data.Builders {
|
|||||||
new Dictionary<string, object> {{"ProviderName", "SQLite"}})
|
new Dictionary<string, object> {{"ProviderName", "SQLite"}})
|
||||||
});
|
});
|
||||||
|
|
||||||
var sessionFactory = manager.BuildSessionFactory(new SessionFactoryParameters {
|
var parameters = new SessionFactoryParameters {
|
||||||
Provider = "SQLite",
|
Provider = "SQLite",
|
||||||
DataFolder = _tempDataFolder,
|
DataFolder = _tempDataFolder,
|
||||||
UpdateSchema = true,
|
UpdateSchema = true,
|
||||||
RecordDescriptors = recordDescriptors
|
RecordDescriptors = recordDescriptors
|
||||||
});
|
};
|
||||||
|
var sessionFactory = manager
|
||||||
|
.CreateProvider(parameters)
|
||||||
|
.BuildSessionFactory(parameters);
|
||||||
|
|
||||||
|
|
||||||
var session = sessionFactory.OpenSession();
|
var session = sessionFactory.OpenSession();
|
||||||
@@ -95,13 +98,16 @@ namespace Orchard.Tests.Data.Builders {
|
|||||||
(dataFolder, connectionString) => new SqlServerDataServicesProvider(dataFolder, connectionString),
|
(dataFolder, connectionString) => new SqlServerDataServicesProvider(dataFolder, connectionString),
|
||||||
new Dictionary<string, object> {{"ProviderName", "SqlServer"}})
|
new Dictionary<string, object> {{"ProviderName", "SqlServer"}})
|
||||||
});
|
});
|
||||||
var sessionFactory = manager.BuildSessionFactory(new SessionFactoryParameters {
|
var parameters = new SessionFactoryParameters {
|
||||||
Provider = "SqlServer",
|
Provider = "SqlServer",
|
||||||
DataFolder = _tempDataFolder,
|
DataFolder = _tempDataFolder,
|
||||||
ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFileName=" + databasePath + ";Integrated Security=True;User Instance=True;",
|
ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFileName=" + databasePath + ";Integrated Security=True;User Instance=True;",
|
||||||
UpdateSchema = true,
|
UpdateSchema = true,
|
||||||
RecordDescriptors = recordDescriptors,
|
RecordDescriptors = recordDescriptors,
|
||||||
});
|
};
|
||||||
|
var sessionFactory = manager
|
||||||
|
.CreateProvider(parameters)
|
||||||
|
.BuildSessionFactory(parameters);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using Orchard.ContentManagement;
|
|||||||
using Orchard.ContentManagement.Aspects;
|
using Orchard.ContentManagement.Aspects;
|
||||||
using Orchard.ContentManagement.Drivers;
|
using Orchard.ContentManagement.Drivers;
|
||||||
using Orchard.Core.Common.Models;
|
using Orchard.Core.Common.Models;
|
||||||
|
using Orchard.Core.Common.Settings;
|
||||||
using Orchard.Core.Common.ViewModels;
|
using Orchard.Core.Common.ViewModels;
|
||||||
|
|
||||||
namespace Orchard.Core.Common.Drivers {
|
namespace Orchard.Core.Common.Drivers {
|
||||||
@@ -12,6 +13,7 @@ namespace Orchard.Core.Common.Drivers {
|
|||||||
public IOrchardServices Services { get; set; }
|
public IOrchardServices Services { get; set; }
|
||||||
private const string TemplateName = "Parts/Common.Body";
|
private const string TemplateName = "Parts/Common.Body";
|
||||||
private const string DefaultTextEditorTemplate = "TinyMceTextEditor";
|
private const string DefaultTextEditorTemplate = "TinyMceTextEditor";
|
||||||
|
private const string PlainTextEditorTemplate = "PlainTextEditor";
|
||||||
|
|
||||||
public BodyDriver(IOrchardServices services) {
|
public BodyDriver(IOrchardServices services) {
|
||||||
Services = services;
|
Services = services;
|
||||||
@@ -21,7 +23,7 @@ namespace Orchard.Core.Common.Drivers {
|
|||||||
get { return "Body"; }
|
get { return "Body"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// \/\/ Haackalicious on many accounts - don't copy what has been done here for the wrapper \/\/
|
// \/\/ Hackalicious on many accounts - don't copy what has been done here for the wrapper \/\/
|
||||||
protected override DriverResult Display(BodyAspect part, string displayType) {
|
protected override DriverResult Display(BodyAspect part, string displayType) {
|
||||||
var model = new BodyDisplayViewModel { BodyAspect = part, Text = BbcodeReplace(part.Text) };
|
var model = new BodyDisplayViewModel { BodyAspect = part, Text = BbcodeReplace(part.Text) };
|
||||||
|
|
||||||
@@ -40,16 +42,29 @@ namespace Orchard.Core.Common.Drivers {
|
|||||||
protected override DriverResult Editor(BodyAspect part, IUpdateModel updater) {
|
protected override DriverResult Editor(BodyAspect part, IUpdateModel updater) {
|
||||||
var model = BuildEditorViewModel(part);
|
var model = BuildEditorViewModel(part);
|
||||||
updater.TryUpdateModel(model, Prefix, null, null);
|
updater.TryUpdateModel(model, Prefix, null, null);
|
||||||
|
|
||||||
|
// only set the format if it has not yet been set to preserve the initial format type - might want to change this later to support changing body formats but...later
|
||||||
|
if (string.IsNullOrWhiteSpace(model.Format))
|
||||||
|
model.Format = GetFlavor(part);
|
||||||
|
|
||||||
return ContentPartTemplate(model, TemplateName, Prefix).Location("primary", "5");
|
return ContentPartTemplate(model, TemplateName, Prefix).Location("primary", "5");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BodyEditorViewModel BuildEditorViewModel(BodyAspect part) {
|
private static BodyEditorViewModel BuildEditorViewModel(BodyAspect part) {
|
||||||
return new BodyEditorViewModel {
|
return new BodyEditorViewModel {
|
||||||
BodyAspect = part,
|
BodyAspect = part,
|
||||||
TextEditorTemplate = DefaultTextEditorTemplate,
|
TextEditorTemplate = GetFlavor(part) == "html" ? DefaultTextEditorTemplate : PlainTextEditorTemplate,
|
||||||
AddMediaPath= new PathBuilder(part).AddContentType().AddContainerSlug().AddSlug().ToString()
|
AddMediaPath= new PathBuilder(part).AddContentType().AddContainerSlug().AddSlug().ToString()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string GetFlavor(BodyAspect part) {
|
||||||
|
var typePartSettings = part.Settings.GetModel<BodyTypePartSettings>();
|
||||||
|
return (typePartSettings != null && !string.IsNullOrWhiteSpace(typePartSettings.Flavor))
|
||||||
|
? typePartSettings.Flavor
|
||||||
|
: part.PartDefinition.Settings.GetModel<BodyPartSettings>().FlavorDefault;
|
||||||
|
}
|
||||||
|
|
||||||
class PathBuilder {
|
class PathBuilder {
|
||||||
private readonly IContent _content;
|
private readonly IContent _content;
|
||||||
private string _path;
|
private string _path;
|
||||||
|
|||||||
67
src/Orchard.Web/Core/Common/Settings/BodySettings.cs
Normal file
67
src/Orchard.Web/Core/Common/Settings/BodySettings.cs
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Orchard.ContentManagement;
|
||||||
|
using Orchard.ContentManagement.MetaData;
|
||||||
|
using Orchard.ContentManagement.MetaData.Builders;
|
||||||
|
using Orchard.ContentManagement.MetaData.Models;
|
||||||
|
using Orchard.ContentManagement.ViewModels;
|
||||||
|
|
||||||
|
namespace Orchard.Core.Common.Settings {
|
||||||
|
public class BodyPartSettings {
|
||||||
|
public const string FlavorDefaultDefault = "html";
|
||||||
|
private string _flavorDefault;
|
||||||
|
public string FlavorDefault {
|
||||||
|
get { return !string.IsNullOrWhiteSpace(_flavorDefault)
|
||||||
|
? _flavorDefault
|
||||||
|
: FlavorDefaultDefault; }
|
||||||
|
set { _flavorDefault = value; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BodyTypePartSettings {
|
||||||
|
public string Flavor { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BodySettingsHooks : ContentDefinitionEditorEventsBase {
|
||||||
|
public override IEnumerable<TemplateViewModel> TypePartEditor(ContentTypeDefinition.Part definition) {
|
||||||
|
if (definition.PartDefinition.Name != "BodyAspect")
|
||||||
|
yield break;
|
||||||
|
|
||||||
|
var model = definition.Settings.GetModel<BodyTypePartSettings>();
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(model.Flavor)) {
|
||||||
|
var partModel = definition.PartDefinition.Settings.GetModel<BodyPartSettings>();
|
||||||
|
model.Flavor = partModel.FlavorDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
yield return DefinitionTemplate(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<TemplateViewModel> PartEditor(ContentPartDefinition definition) {
|
||||||
|
if (definition.Name != "BodyAspect")
|
||||||
|
yield break;
|
||||||
|
|
||||||
|
var model = definition.Settings.GetModel<BodyPartSettings>();
|
||||||
|
yield return DefinitionTemplate(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypeDefinitionBuilder.PartConfigurer builder, IUpdateModel updateModel) {
|
||||||
|
if (builder.Name != "BodyAspect")
|
||||||
|
yield break;
|
||||||
|
|
||||||
|
var model = new BodyTypePartSettings();
|
||||||
|
updateModel.TryUpdateModel(model, "BodyTypePartSettings", null, null);
|
||||||
|
builder.WithSetting("BodyTypePartSettings.Flavor", !string.IsNullOrWhiteSpace(model.Flavor) ? model.Flavor : null);
|
||||||
|
yield return DefinitionTemplate(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<TemplateViewModel> PartEditorUpdate(ContentPartDefinitionBuilder builder, IUpdateModel updateModel) {
|
||||||
|
if (builder.Name != "BodyAspect")
|
||||||
|
yield break;
|
||||||
|
|
||||||
|
var model = new BodyPartSettings();
|
||||||
|
updateModel.TryUpdateModel(model, "BodyPartSettings", null, null);
|
||||||
|
builder.WithSetting("BodyPartSettings.FlavorDefault", !string.IsNullOrWhiteSpace(model.FlavorDefault) ? model.FlavorDefault : null);
|
||||||
|
yield return DefinitionTemplate(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.Core.Common.Settings.BodyPartSettings>" %>
|
||||||
|
<fieldset>
|
||||||
|
<label for="<%:Html.FieldIdFor(m => m.FlavorDefault) %>"><%:T("Default flavor") %></label>
|
||||||
|
<%:Html.EditorFor(m => m.FlavorDefault)%>
|
||||||
|
<%:Html.ValidationMessageFor(m => m.FlavorDefault)%>
|
||||||
|
</fieldset>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.Core.Common.Settings.BodyTypePartSettings>" %>
|
||||||
|
<fieldset>
|
||||||
|
<label for="<%:Html.FieldIdFor(m => m.Flavor) %>"><%:T("Flavor") %></label>
|
||||||
|
<%:Html.EditorFor(m => m.Flavor) %>
|
||||||
|
<%:Html.ValidationMessageFor(m => m.Flavor) %>
|
||||||
|
</fieldset>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BodyEditorViewModel>" %>
|
||||||
|
<%@ Import Namespace="Orchard.Core.Common.ViewModels"%>
|
||||||
|
<%: Html.TextArea("Text", Model.Text, 25, 80, new { @class = Model.Format }) %>
|
||||||
@@ -69,6 +69,7 @@
|
|||||||
<Compile Include="Common\Drivers\TextFieldDriver.cs" />
|
<Compile Include="Common\Drivers\TextFieldDriver.cs" />
|
||||||
<Compile Include="Common\Fields\TextField.cs" />
|
<Compile Include="Common\Fields\TextField.cs" />
|
||||||
<Compile Include="Common\Handlers\RoutableAspectHandler.cs" />
|
<Compile Include="Common\Handlers\RoutableAspectHandler.cs" />
|
||||||
|
<Compile Include="Common\Settings\BodySettings.cs" />
|
||||||
<Compile Include="Common\ViewModels\ContainerEditorViewModel.cs" />
|
<Compile Include="Common\ViewModels\ContainerEditorViewModel.cs" />
|
||||||
<Compile Include="Common\ViewModels\TextContentFieldDisplayViewModel.cs" />
|
<Compile Include="Common\ViewModels\TextContentFieldDisplayViewModel.cs" />
|
||||||
<Compile Include="Common\ViewModels\TextContentFieldEditorViewModel.cs" />
|
<Compile Include="Common\ViewModels\TextContentFieldEditorViewModel.cs" />
|
||||||
@@ -202,11 +203,13 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Common\Module.txt" />
|
<Content Include="Common\Module.txt" />
|
||||||
|
<Content Include="Common\Views\DefinitionTemplates\BodyTypePartSettings.ascx" />
|
||||||
|
<Content Include="Common\Views\DefinitionTemplates\BodyPartSettings.ascx" />
|
||||||
<Content Include="Common\Views\DisplayTemplates\Fields\Common.TextField.ascx" />
|
<Content Include="Common\Views\DisplayTemplates\Fields\Common.TextField.ascx" />
|
||||||
<Content Include="Common\Views\EditorTemplates\Fields\Common.TextField.ascx" />
|
<Content Include="Common\Views\EditorTemplates\Fields\Common.TextField.ascx" />
|
||||||
<Content Include="Common\Views\EditorTemplates\Parts\Common.Container.ascx" />
|
<Content Include="Common\Views\EditorTemplates\Parts\Common.Container.ascx" />
|
||||||
|
<Content Include="Common\Views\EditorTemplates\PlainTextEditor.ascx" />
|
||||||
<Content Include="Contents\Module.txt" />
|
<Content Include="Contents\Module.txt" />
|
||||||
<Content Include="Contents\Styles\admin.css" />
|
|
||||||
<Content Include="Contents\Views\Admin\List.aspx" />
|
<Content Include="Contents\Views\Admin\List.aspx" />
|
||||||
<Content Include="Contents\Views\Admin\Edit.aspx" />
|
<Content Include="Contents\Views\Admin\Edit.aspx" />
|
||||||
<Content Include="Contents\Views\Admin\CreatableTypeList.aspx" />
|
<Content Include="Contents\Views\Admin\CreatableTypeList.aspx" />
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ namespace Orchard.Core.Settings.Metadata {
|
|||||||
record.Settings = _settingsWriter.Map(model.Settings).ToString();
|
record.Settings = _settingsWriter.Map(model.Settings).ToString();
|
||||||
|
|
||||||
var toRemove = record.ContentPartFieldDefinitionRecords
|
var toRemove = record.ContentPartFieldDefinitionRecords
|
||||||
.Where(partFieldDefinitionRecord => model.Fields.Any(partField => partFieldDefinitionRecord.Name == partField.Name))
|
.Where(partFieldDefinitionRecord => !model.Fields.Any(partField => partFieldDefinitionRecord.Name == partField.Name))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
foreach (var remove in toRemove) {
|
foreach (var remove in toRemove) {
|
||||||
@@ -123,7 +123,7 @@ namespace Orchard.Core.Settings.Metadata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach (var field in model.Fields) {
|
foreach (var field in model.Fields) {
|
||||||
var fieldName = field.FieldDefinition.Name;
|
var fieldName = field.Name;
|
||||||
var partFieldRecord = record.ContentPartFieldDefinitionRecords.SingleOrDefault(r => r.Name == fieldName);
|
var partFieldRecord = record.ContentPartFieldDefinitionRecords.SingleOrDefault(r => r.Name == fieldName);
|
||||||
if (partFieldRecord == null) {
|
if (partFieldRecord == null) {
|
||||||
partFieldRecord = new ContentPartFieldDefinitionRecord {
|
partFieldRecord = new ContentPartFieldDefinitionRecord {
|
||||||
|
|||||||
@@ -1,50 +1,34 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
using Orchard.ContentManagement.MetaData;
|
using Orchard.ContentManagement.MetaData;
|
||||||
using Orchard.ContentManagement.MetaData.Models;
|
using Orchard.ContentManagement.MetaData.Models;
|
||||||
using Orchard.ContentManagement.ViewModels;
|
|
||||||
using Orchard.ContentTypes.Services;
|
using Orchard.ContentTypes.Services;
|
||||||
using Orchard.ContentTypes.ViewModels;
|
using Orchard.ContentTypes.ViewModels;
|
||||||
using Orchard.Data;
|
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
using Orchard.Logging;
|
|
||||||
using Orchard.Mvc.Results;
|
using Orchard.Mvc.Results;
|
||||||
using Orchard.UI.Notify;
|
|
||||||
|
|
||||||
namespace Orchard.ContentTypes.Controllers {
|
namespace Orchard.ContentTypes.Controllers {
|
||||||
public class AdminController : Controller {
|
public class AdminController : Controller {
|
||||||
private readonly INotifier _notifier;
|
|
||||||
private readonly IContentDefinitionService _contentDefinitionService;
|
private readonly IContentDefinitionService _contentDefinitionService;
|
||||||
private readonly IContentDefinitionManager _contentDefinitionManager;
|
private readonly IContentDefinitionManager _contentDefinitionManager;
|
||||||
private readonly IContentManager _contentManager;
|
|
||||||
private readonly ITransactionManager _transactionManager;
|
|
||||||
private readonly IContentDefinitionEditorEvents _extendViewModels;
|
private readonly IContentDefinitionEditorEvents _extendViewModels;
|
||||||
|
|
||||||
public AdminController(
|
public AdminController(
|
||||||
IOrchardServices orchardServices,
|
IOrchardServices orchardServices,
|
||||||
INotifier notifier,
|
|
||||||
IContentDefinitionService contentDefinitionService,
|
IContentDefinitionService contentDefinitionService,
|
||||||
IContentDefinitionManager contentDefinitionManager,
|
IContentDefinitionManager contentDefinitionManager,
|
||||||
IContentManager contentManager,
|
|
||||||
ITransactionManager transactionManager,
|
|
||||||
IContentDefinitionEditorEvents extendViewModels) {
|
IContentDefinitionEditorEvents extendViewModels) {
|
||||||
Services = orchardServices;
|
Services = orchardServices;
|
||||||
_notifier = notifier;
|
|
||||||
_contentDefinitionService = contentDefinitionService;
|
_contentDefinitionService = contentDefinitionService;
|
||||||
_contentDefinitionManager = contentDefinitionManager;
|
_contentDefinitionManager = contentDefinitionManager;
|
||||||
_contentManager = contentManager;
|
|
||||||
_transactionManager = transactionManager;
|
|
||||||
_extendViewModels = extendViewModels;
|
_extendViewModels = extendViewModels;
|
||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
Logger = NullLogger.Instance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IOrchardServices Services { get; private set; }
|
public IOrchardServices Services { get; private set; }
|
||||||
public Localizer T { get; set; }
|
public Localizer T { get; set; }
|
||||||
public ILogger Logger { get; set; }
|
|
||||||
public ActionResult Index() {
|
public ActionResult Index() {
|
||||||
return List();
|
return List();
|
||||||
}
|
}
|
||||||
@@ -69,32 +53,14 @@ namespace Orchard.ContentTypes.Controllers {
|
|||||||
if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to create a content type.")))
|
if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to create a content type.")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
var model = new ContentTypeDefinition("");
|
if (!ModelState.IsValid)
|
||||||
TryUpdateModel(model);
|
|
||||||
|
|
||||||
if (!ModelState.IsValid) {
|
|
||||||
Services.TransactionManager.Cancel();
|
|
||||||
return View(viewModel);
|
return View(viewModel);
|
||||||
}
|
|
||||||
|
|
||||||
_contentDefinitionService.AddTypeDefinition(model);
|
_contentDefinitionService.AddTypeDefinition(viewModel.DisplayName);
|
||||||
|
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
|
|
||||||
class Updater : IUpdateModel {
|
|
||||||
public AdminController Thunk { get; set; }
|
|
||||||
public Func<string, string> _prefix = x => x;
|
|
||||||
|
|
||||||
public bool TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) where TModel : class {
|
|
||||||
return Thunk.TryUpdateModel(model, _prefix(prefix), includeProperties, excludeProperties);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddModelError(string key, LocalizedString errorMessage) {
|
|
||||||
Thunk.ModelState.AddModelError(_prefix(key), errorMessage.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ActionResult Edit(string id) {
|
public ActionResult Edit(string id) {
|
||||||
if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a content type.")))
|
if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a content type.")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
@@ -106,36 +72,56 @@ namespace Orchard.ContentTypes.Controllers {
|
|||||||
|
|
||||||
var viewModel = new EditTypeViewModel(contentTypeDefinition);
|
var viewModel = new EditTypeViewModel(contentTypeDefinition);
|
||||||
viewModel.Parts = viewModel.Parts.ToArray();
|
viewModel.Parts = viewModel.Parts.ToArray();
|
||||||
|
|
||||||
viewModel.Templates = _extendViewModels.TypeEditor(contentTypeDefinition);
|
viewModel.Templates = _extendViewModels.TypeEditor(contentTypeDefinition);
|
||||||
|
|
||||||
var entries = viewModel.Parts.Join(contentTypeDefinition.Parts,
|
var entries = viewModel.Parts.Join(contentTypeDefinition.Parts,
|
||||||
m => m.PartDefinition.Name,
|
m => m.PartDefinition.Name,
|
||||||
d => d.PartDefinition.Name,
|
d => d.PartDefinition.Name,
|
||||||
(model, definition) => new {model, definition});
|
(model, definition) => new {model, definition});
|
||||||
foreach (var entry in entries) {
|
foreach (var entry in entries) {
|
||||||
entry.model.Templates = _extendViewModels.TypePartEditor(entry.definition);
|
entry.model.Templates = _extendViewModels.TypePartEditor(entry.definition);
|
||||||
|
|
||||||
|
var fields = entry.model.PartDefinition.Fields.Join(entry.definition.PartDefinition.Fields,
|
||||||
|
m => m.FieldDefinition.Name,
|
||||||
|
d => d.FieldDefinition.Name,
|
||||||
|
(model, definition) => new { model, definition });
|
||||||
|
|
||||||
|
foreach (var field in fields) {
|
||||||
|
field.model.Templates = _extendViewModels.PartFieldEditor(field.definition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Oy, this action is getting massive :(
|
||||||
|
//todo: put this action on a diet
|
||||||
|
var contentPartDefinition = _contentDefinitionService.GetPartDefinition(id);
|
||||||
|
if (contentPartDefinition != null) {
|
||||||
|
viewModel.Fields = viewModel.Fields.ToArray();
|
||||||
|
var fields = viewModel.Fields.Join(contentPartDefinition.Fields,
|
||||||
|
m => m.FieldDefinition.Name,
|
||||||
|
d => d.FieldDefinition.Name,
|
||||||
|
(model, definition) => new { model, definition });
|
||||||
|
|
||||||
|
foreach (var field in fields) {
|
||||||
|
field.model.Templates = _extendViewModels.PartFieldEditor(field.definition);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return View(viewModel);
|
return View(viewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost, ActionName("Edit")]
|
[HttpPost, ActionName("Edit")]
|
||||||
public ActionResult EditPOST(string id) {
|
public ActionResult EditPOST(EditTypeViewModel viewModel) {
|
||||||
if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a content type.")))
|
if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a content type.")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
var contentTypeDefinition = _contentDefinitionService.GetTypeDefinition(id);
|
var contentTypeDefinition = _contentDefinitionService.GetTypeDefinition(viewModel.Name);
|
||||||
|
|
||||||
if (contentTypeDefinition == null)
|
if (contentTypeDefinition == null)
|
||||||
return new NotFoundResult();
|
return new NotFoundResult();
|
||||||
|
|
||||||
var updater = new Updater { Thunk = this };
|
var updater = new Updater(this);
|
||||||
|
_contentDefinitionManager.AlterTypeDefinition(viewModel.Name, typeBuilder => {
|
||||||
var viewModel = new EditTypeViewModel();
|
|
||||||
TryUpdateModel(viewModel);
|
|
||||||
|
|
||||||
|
|
||||||
_contentDefinitionManager.AlterTypeDefinition(id, typeBuilder => {
|
|
||||||
|
|
||||||
typeBuilder.DisplayedAs(viewModel.DisplayName);
|
typeBuilder.DisplayedAs(viewModel.DisplayName);
|
||||||
|
|
||||||
@@ -156,63 +142,14 @@ namespace Orchard.ContentTypes.Controllers {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if (!ModelState.IsValid) {
|
if (!ModelState.IsValid) {
|
||||||
_transactionManager.Cancel();
|
Services.TransactionManager.Cancel();
|
||||||
return View(viewModel);
|
return View(viewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
//var contentTypeDefinitionParts = viewModel.Parts.Select(GenerateTypePart).ToList();
|
|
||||||
//if (viewModel.Fields.Any())
|
|
||||||
// contentTypeDefinitionParts.Add(GenerateTypePart(viewModel));
|
|
||||||
|
|
||||||
////todo: apply the changes along the lines of but definately not resembling
|
|
||||||
//// for now this _might_ just get a little messy ->
|
|
||||||
//_contentDefinitionService.AlterTypeDefinition(
|
|
||||||
// new ContentTypeDefinition(
|
|
||||||
// viewModel.Name,
|
|
||||||
// viewModel.DisplayName,
|
|
||||||
// contentTypeDefinitionParts,
|
|
||||||
// viewModel.Settings
|
|
||||||
// )
|
|
||||||
// );
|
|
||||||
|
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ContentTypeDefinition.Part GenerateTypePart(EditTypePartViewModel viewModel) {
|
|
||||||
return new ContentTypeDefinition.Part(
|
|
||||||
new ContentPartDefinition(
|
|
||||||
viewModel.PartDefinition.Name,
|
|
||||||
viewModel.PartDefinition.Fields.Select(
|
|
||||||
f => new ContentPartDefinition.Field(
|
|
||||||
new ContentFieldDefinition(f.FieldDefinition.Name),
|
|
||||||
f.Name,
|
|
||||||
f.Settings
|
|
||||||
)
|
|
||||||
),
|
|
||||||
viewModel.PartDefinition.Settings
|
|
||||||
),
|
|
||||||
viewModel.Settings
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ContentTypeDefinition.Part GenerateTypePart(EditTypeViewModel viewModel) {
|
|
||||||
return new ContentTypeDefinition.Part(
|
|
||||||
new ContentPartDefinition(
|
|
||||||
viewModel.Name,
|
|
||||||
viewModel.Fields.Select(
|
|
||||||
f => new ContentPartDefinition.Field(
|
|
||||||
new ContentFieldDefinition(f.FieldDefinition.Name),
|
|
||||||
f.Name,
|
|
||||||
f.Settings
|
|
||||||
)
|
|
||||||
),
|
|
||||||
null
|
|
||||||
),
|
|
||||||
null
|
|
||||||
);
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Parts
|
#region Parts
|
||||||
@@ -226,28 +163,33 @@ namespace Orchard.ContentTypes.Controllers {
|
|||||||
if (contentPartDefinition == null)
|
if (contentPartDefinition == null)
|
||||||
return new NotFoundResult();
|
return new NotFoundResult();
|
||||||
|
|
||||||
return View(new EditPartViewModel(contentPartDefinition));
|
var viewModel = new EditPartViewModel(contentPartDefinition) {
|
||||||
|
Templates = _extendViewModels.PartEditor(contentPartDefinition)
|
||||||
|
};
|
||||||
|
|
||||||
|
return View(viewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost, ActionName("EditPart")]
|
[HttpPost, ActionName("EditPart")]
|
||||||
public ActionResult EditPartPOST(string id) {
|
public ActionResult EditPartPOST(EditPartViewModel viewModel) {
|
||||||
if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a part.")))
|
if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a part.")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
var contentPartDefinition = _contentDefinitionService.GetPartDefinition(id);
|
var contentPartDefinition = _contentDefinitionService.GetPartDefinition(viewModel.Name);
|
||||||
|
|
||||||
if (contentPartDefinition == null)
|
if (contentPartDefinition == null)
|
||||||
return new NotFoundResult();
|
return new NotFoundResult();
|
||||||
|
|
||||||
var viewModel = new EditPartViewModel();
|
var updater = new Updater(this);
|
||||||
TryUpdateModel(viewModel);
|
_contentDefinitionManager.AlterPartDefinition(viewModel.Name, partBuilder => {
|
||||||
|
// allow extensions to alter part configuration
|
||||||
|
viewModel.Templates = _extendViewModels.PartEditorUpdate(partBuilder, updater);
|
||||||
|
});
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid) {
|
||||||
return EditPart(id);
|
Services.TransactionManager.Cancel();
|
||||||
|
return View(viewModel);
|
||||||
//todo: apply the changes along the lines of but definately not resembling
|
}
|
||||||
// for now this _might_ just get a little messy ->
|
|
||||||
_contentDefinitionService.AlterPartDefinition(GeneratePart(viewModel));
|
|
||||||
|
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
@@ -319,21 +261,25 @@ namespace Orchard.ContentTypes.Controllers {
|
|||||||
return RedirectToAction("EditPart", new { id });
|
return RedirectToAction("EditPart", new { id });
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ContentPartDefinition GeneratePart(EditPartViewModel viewModel) {
|
|
||||||
return new ContentPartDefinition(
|
|
||||||
viewModel.Name,
|
|
||||||
viewModel.Fields.Select(
|
|
||||||
f => new ContentPartDefinition.Field(
|
|
||||||
new ContentFieldDefinition(f.FieldDefinition.Name),
|
|
||||||
f.Name,
|
|
||||||
f.Settings
|
|
||||||
)
|
|
||||||
),
|
|
||||||
viewModel.Settings
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
class Updater : IUpdateModel {
|
||||||
|
private readonly AdminController _thunk;
|
||||||
|
|
||||||
|
public Updater(AdminController thunk) {
|
||||||
|
_thunk = thunk;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Func<string, string> _prefix = x => x;
|
||||||
|
|
||||||
|
public bool TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) where TModel : class {
|
||||||
|
return _thunk.TryUpdateModel(model, _prefix(prefix), includeProperties, excludeProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddModelError(string key, LocalizedString errorMessage) {
|
||||||
|
_thunk.ModelState.AddModelError(_prefix(key), errorMessage.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,4 +7,4 @@ orchardversion: 0.1.2010.0312
|
|||||||
features:
|
features:
|
||||||
Orchard.ContentTypes:
|
Orchard.ContentTypes:
|
||||||
Description: ContentTypes modules enables the creation and alteration of content types not based on code.
|
Description: ContentTypes modules enables the creation and alteration of content types not based on code.
|
||||||
Category: Developer
|
Category: Content
|
||||||
@@ -83,6 +83,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Module.txt" />
|
<Content Include="Module.txt" />
|
||||||
|
<Content Include="Styles\admin.css" />
|
||||||
<Content Include="Views\Admin\AddFieldTo.ascx" />
|
<Content Include="Views\Admin\AddFieldTo.ascx" />
|
||||||
<Content Include="Views\Admin\Create.ascx" />
|
<Content Include="Views\Admin\Create.ascx" />
|
||||||
<Content Include="Views\Admin\EditPart.ascx" />
|
<Content Include="Views\Admin\EditPart.ascx" />
|
||||||
@@ -108,7 +109,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="App_Data\" />
|
<Folder Include="App_Data\" />
|
||||||
<Folder Include="Helpers\" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\..\Orchard\Orchard.Framework.csproj">
|
<ProjectReference Include="..\..\..\Orchard\Orchard.Framework.csproj">
|
||||||
@@ -136,9 +136,8 @@
|
|||||||
<IISUrl>
|
<IISUrl>
|
||||||
</IISUrl>
|
</IISUrl>
|
||||||
<NTLMAuthentication>False</NTLMAuthentication>
|
<NTLMAuthentication>False</NTLMAuthentication>
|
||||||
<UseCustomServer>False</UseCustomServer>
|
<UseCustomServer>True</UseCustomServer>
|
||||||
<CustomServerUrl>
|
<CustomServerUrl>http://orchard.codeplex.com</CustomServerUrl>
|
||||||
</CustomServerUrl>
|
|
||||||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
||||||
</WebProjectProperties>
|
</WebProjectProperties>
|
||||||
</FlavorProperties>
|
</FlavorProperties>
|
||||||
|
|||||||
@@ -31,23 +31,21 @@ namespace Orchard.ContentTypes.Services {
|
|||||||
return _contentDefinitionManager.GetTypeDefinition(name);
|
return _contentDefinitionManager.GetTypeDefinition(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddTypeDefinition(ContentTypeDefinition contentTypeDefinition) {
|
public void AddTypeDefinition(string displayName) {
|
||||||
var typeName = string.IsNullOrWhiteSpace(contentTypeDefinition.Name)
|
var name = GenerateTypeName(displayName);
|
||||||
? GenerateTypeName(contentTypeDefinition.DisplayName)
|
|
||||||
: contentTypeDefinition.Name;
|
|
||||||
|
|
||||||
while (_contentDefinitionManager.GetTypeDefinition(typeName) != null)
|
while (_contentDefinitionManager.GetTypeDefinition(name) != null)
|
||||||
typeName = VersionTypeName(typeName);
|
name = VersionTypeName(name);
|
||||||
|
|
||||||
//just giving the new type some default parts for now
|
//just giving the new type some default parts for now
|
||||||
|
_contentDefinitionManager.StoreTypeDefinition(new ContentTypeDefinition(name) {DisplayName = displayName});
|
||||||
_contentDefinitionManager.AlterTypeDefinition(
|
_contentDefinitionManager.AlterTypeDefinition(
|
||||||
typeName,
|
name,
|
||||||
cfg => cfg.DisplayedAs(contentTypeDefinition.DisplayName)
|
cfg => cfg.WithPart("CommonAspect")
|
||||||
.WithPart("CommonAspect")
|
|
||||||
//.WithPart("RoutableAspect") //need to go the new routable route
|
//.WithPart("RoutableAspect") //need to go the new routable route
|
||||||
.WithPart("BodyAspect"));
|
.WithPart("BodyAspect"));
|
||||||
|
|
||||||
Services.Notifier.Information(T("Created content type: {0}", contentTypeDefinition.DisplayName));
|
Services.Notifier.Information(T("Created content type: {0}", displayName));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AlterTypeDefinition(ContentTypeDefinition contentTypeDefinition) {
|
public void AlterTypeDefinition(ContentTypeDefinition contentTypeDefinition) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace Orchard.ContentTypes.Services {
|
|||||||
public interface IContentDefinitionService : IDependency {
|
public interface IContentDefinitionService : IDependency {
|
||||||
IEnumerable<ContentTypeDefinition> GetTypeDefinitions();
|
IEnumerable<ContentTypeDefinition> GetTypeDefinitions();
|
||||||
ContentTypeDefinition GetTypeDefinition(string name);
|
ContentTypeDefinition GetTypeDefinition(string name);
|
||||||
void AddTypeDefinition(ContentTypeDefinition contentTypeDefinition);
|
void AddTypeDefinition(string displayName);
|
||||||
void AlterTypeDefinition(ContentTypeDefinition contentTypeDefinition);
|
void AlterTypeDefinition(ContentTypeDefinition contentTypeDefinition);
|
||||||
void RemoveTypeDefinition(string name);
|
void RemoveTypeDefinition(string name);
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ namespace Orchard.ContentTypes.ViewModels {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
public IEnumerable<TemplateViewModel> Templates { get; set; }
|
||||||
public IEnumerable<EditPartFieldViewModel> Fields { get; set; }
|
public IEnumerable<EditPartFieldViewModel> Fields { get; set; }
|
||||||
public SettingsDictionary Settings { get; set; }
|
public SettingsDictionary Settings { get; set; }
|
||||||
}
|
}
|
||||||
@@ -81,6 +82,7 @@ namespace Orchard.ContentTypes.ViewModels {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
public IEnumerable<TemplateViewModel> Templates { get; set; }
|
||||||
public EditFieldViewModel FieldDefinition { get; set; }
|
public EditFieldViewModel FieldDefinition { get; set; }
|
||||||
public SettingsDictionary Settings { get; set; }
|
public SettingsDictionary Settings { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.ContentTypes.ViewModels.EditTypeViewModel>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.ContentTypes.ViewModels.EditTypeViewModel>" %>
|
||||||
<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %>
|
<% Html.RegisterStyle("admin.css"); %>
|
||||||
<%@ Import Namespace="Orchard.ContentTypes.ViewModels" %><%
|
|
||||||
Html.RegisterStyle("admin.css"); %>
|
|
||||||
<h1><%:Html.TitleForPage(T("Edit Content Type").ToString())%></h1>
|
<h1><%:Html.TitleForPage(T("Edit Content Type").ToString())%></h1>
|
||||||
<p class="breadcrumb"><%:Html.ActionLink(T("Content Types").Text, "index") %><%:T(" > ") %><%:T("Edit Content Type") %></p><%
|
<p class="breadcrumb"><%:Html.ActionLink(T("Content Types").Text, "index") %><%:T(" > ") %><%:T("Edit Content Type") %></p><%
|
||||||
using (Html.BeginFormAntiForgeryPost()) { %>
|
using (Html.BeginFormAntiForgeryPost()) { %>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ using (Html.BeginFormAntiForgeryPost()) { %>
|
|||||||
<%--// has unintended consequences (renamging the part) - changing the name creates a new part of that name--%>
|
<%--// has unintended consequences (renamging the part) - changing the name creates a new part of that name--%>
|
||||||
<%:Html.TextBoxFor(m => m.Name, new {@class = "textMedium"}) %>
|
<%:Html.TextBoxFor(m => m.Name, new {@class = "textMedium"}) %>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<%:Html.EditorFor(m => m.Settings, "Settings", "") %>
|
<% Html.RenderTemplates(Model.Templates); %>
|
||||||
<h2><%:T("Fields") %></h2>
|
<h2><%:T("Fields") %></h2>
|
||||||
<div class="manage add-to-type"><%: Html.ActionLink(T("Add").Text, "AddFieldTo", new { area = "Orchard.ContentTypes", id = Model.Name }, new { @class = "button" }) %></div>
|
<div class="manage add-to-type"><%: Html.ActionLink(T("Add").Text, "AddFieldTo", new { area = "Orchard.ContentTypes", id = Model.Name }, new { @class = "button" }) %></div>
|
||||||
<%:Html.EditorFor(m => m.Fields, "Fields", "") %>
|
<%:Html.EditorFor(m => m.Fields, "Fields", "") %>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.ContentTypes.ViewModels.EditPartFieldViewModel>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.ContentTypes.ViewModels.EditPartFieldViewModel>" %>
|
||||||
<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %>
|
|
||||||
<dt><%:Model.Name %> <span>(<%:Model.FieldDefinition.Name %>)</span></dt>
|
<dt><%:Model.Name %> <span>(<%:Model.FieldDefinition.Name %>)</span></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<%:Html.DisplayFor(m => m.Settings, "Settings", "") %>
|
<%:Html.DisplayFor(m => m.Settings, "Settings", "") %>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<IEnumerable<Orchard.ContentTypes.ViewModels.EditPartFieldViewModel>>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<IEnumerable<Orchard.ContentTypes.ViewModels.EditPartFieldViewModel>>" %>
|
||||||
<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %><%
|
<%
|
||||||
if (Model.Any()) { %>
|
if (Model.Any()) { %>
|
||||||
<dl><%
|
<dl><%
|
||||||
foreach (var field in Model) {
|
foreach (var field in Model) {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.ContentTypes.ViewModels.EditPartFieldViewModel>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.ContentTypes.ViewModels.EditPartFieldViewModel>" %>
|
||||||
<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %>
|
|
||||||
<fieldset class="manage-field">
|
<fieldset class="manage-field">
|
||||||
<h3><%:Model.Name %> <span>(<%:Model.FieldDefinition.Name %>)</span></h3>
|
<h3><%:Model.Name %> <span>(<%:Model.FieldDefinition.Name %>)</span></h3>
|
||||||
<div class="manage">
|
<div class="manage">
|
||||||
@@ -11,7 +10,7 @@
|
|||||||
<button type="submit" title="<%:T("Remove") %>"><%:T("Remove") %></button>
|
<button type="submit" title="<%:T("Remove") %>"><%:T("Remove") %></button>
|
||||||
<% } %> --%>
|
<% } %> --%>
|
||||||
</div>
|
</div>
|
||||||
<%:Html.EditorFor(m => m.Settings, "Settings", "") %>
|
<% Html.RenderTemplates(Model.Templates); %>
|
||||||
<%:Html.HiddenFor(m => m.Name) %>
|
<%:Html.HiddenFor(m => m.Name) %>
|
||||||
<%:Html.HiddenFor(m => m.FieldDefinition.Name) %>
|
<%:Html.HiddenFor(m => m.FieldDefinition.Name) %>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<IEnumerable<Orchard.ContentTypes.ViewModels.EditPartFieldViewModel>>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<IEnumerable<Orchard.ContentTypes.ViewModels.EditPartFieldViewModel>>" %>
|
||||||
<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %><%
|
<%
|
||||||
if (Model.Any()) { %>
|
if (Model.Any()) { %>
|
||||||
<fieldset><%
|
<fieldset><%
|
||||||
var fi = 0;
|
var fi = 0;
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.ContentTypes.ViewModels.EditTypePartViewModel>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.ContentTypes.ViewModels.EditTypePartViewModel>" %>
|
||||||
<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %>
|
|
||||||
<%@ Import Namespace="Orchard.ContentTypes.ViewModels" %>
|
|
||||||
<fieldset class="manage-part">
|
<fieldset class="manage-part">
|
||||||
<h3><%:Model.PartDefinition.Name %></h3>
|
<h3><%:Model.PartDefinition.Name %></h3>
|
||||||
<div class="manage">
|
<div class="manage">
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<IEnumerable<Orchard.ContentTypes.ViewModels.EditTypePartViewModel>>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<IEnumerable<Orchard.ContentTypes.ViewModels.EditTypePartViewModel>>" %>
|
||||||
<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %><%
|
<%
|
||||||
if (Model.Any()) { %>
|
if (Model.Any()) { %>
|
||||||
<fieldset><%
|
<fieldset><%
|
||||||
var pi = 0;
|
var pi = 0;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Orchard.DevTools.Settings.DevToolsSettings>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.DevTools.Settings.DevToolsSettings>" %>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<%:Html.LabelFor(m=>m.ShowDebugLinks) %>
|
|
||||||
<%:Html.EditorFor(m=>m.ShowDebugLinks) %>
|
<%:Html.EditorFor(m=>m.ShowDebugLinks) %>
|
||||||
|
<label for="<%:Html.FieldIdFor(m => m.ShowDebugLinks) %>" class="forcheckbox"><%:T("Show debug links") %></label>
|
||||||
<%:Html.ValidationMessageFor(m=>m.ShowDebugLinks) %>
|
<%:Html.ValidationMessageFor(m=>m.ShowDebugLinks) %>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|||||||
@@ -56,6 +56,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Module.txt" />
|
<Content Include="Module.txt" />
|
||||||
<Content Include="Views\Admin\Index.ascx" />
|
<Content Include="Views\Admin\Index.ascx" />
|
||||||
|
<Content Include="Views\DefinitionTemplates\IndexingSettings.ascx" />
|
||||||
<Content Include="Web.config" />
|
<Content Include="Web.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -78,6 +79,7 @@
|
|||||||
<Compile Include="Models\LuceneSearchHit.cs" />
|
<Compile Include="Models\LuceneSearchHit.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Services\IndexService.cs" />
|
<Compile Include="Services\IndexService.cs" />
|
||||||
|
<Compile Include="Settings\IndexingSettings.cs" />
|
||||||
<Compile Include="ViewModels\IndexViewModel.cs" />
|
<Compile Include="ViewModels\IndexViewModel.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Orchard.ContentManagement;
|
||||||
|
using Orchard.ContentManagement.MetaData;
|
||||||
|
using Orchard.ContentManagement.MetaData.Builders;
|
||||||
|
using Orchard.ContentManagement.MetaData.Models;
|
||||||
|
using Orchard.ContentManagement.ViewModels;
|
||||||
|
|
||||||
|
namespace Orchard.Indexing.Settings {
|
||||||
|
public class IndexingSettings {
|
||||||
|
public bool IncludeInIndex { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class IndexingSettingsHooks : ContentDefinitionEditorEventsBase {
|
||||||
|
public override IEnumerable<TemplateViewModel> PartFieldEditor(ContentPartDefinition.Field definition) {
|
||||||
|
var model = definition.Settings.GetModel<IndexingSettings>();
|
||||||
|
yield return DefinitionTemplate(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartDefinitionBuilder builder, IUpdateModel updateModel) {
|
||||||
|
var model = new IndexingSettings();
|
||||||
|
updateModel.TryUpdateModel(model, "IndexingSettings", null, null);
|
||||||
|
builder.WithSetting("IndexingSettings.IncludeInIndex", model.IncludeInIndex ? true.ToString() : null);
|
||||||
|
yield return DefinitionTemplate(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.Indexing.Settings.IndexingSettings>" %>
|
||||||
|
<%@ Import Namespace="Orchard.Mvc.Html" %>
|
||||||
|
<fieldset>
|
||||||
|
<%:Html.EditorFor(m=>m.IncludeInIndex) %>
|
||||||
|
<label for="<%:Html.FieldIdFor(m => m.IncludeInIndex) %>" class="forcheckbox"><%:T("Include in the index") %></label>
|
||||||
|
<%:Html.ValidationMessageFor(m => m.IncludeInIndex)%>
|
||||||
|
</fieldset>
|
||||||
@@ -5,6 +5,7 @@ using Orchard.Comments.Models;
|
|||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
using Orchard.ContentManagement.MetaData;
|
using Orchard.ContentManagement.MetaData;
|
||||||
using Orchard.Core.Common.Models;
|
using Orchard.Core.Common.Models;
|
||||||
|
using Orchard.Core.Common.Settings;
|
||||||
using Orchard.Core.Navigation.Models;
|
using Orchard.Core.Navigation.Models;
|
||||||
using Orchard.Core.Settings.Models;
|
using Orchard.Core.Settings.Models;
|
||||||
using Orchard.Data;
|
using Orchard.Data;
|
||||||
@@ -172,6 +173,7 @@ namespace Orchard.Setup.Services {
|
|||||||
contentDefinitionManager.AlterTypeDefinition("BlogPost", cfg => cfg.DisplayedAs("Blog Post").WithPart("HasComments").WithPart("HasTags").WithPart("Localized"));
|
contentDefinitionManager.AlterTypeDefinition("BlogPost", cfg => cfg.DisplayedAs("Blog Post").WithPart("HasComments").WithPart("HasTags").WithPart("Localized"));
|
||||||
contentDefinitionManager.AlterTypeDefinition("Page", cfg => cfg.DisplayedAs("Page").WithPart("HasComments").WithPart("HasTags").WithPart("Localized"));
|
contentDefinitionManager.AlterTypeDefinition("Page", cfg => cfg.DisplayedAs("Page").WithPart("HasComments").WithPart("HasTags").WithPart("Localized"));
|
||||||
contentDefinitionManager.AlterTypeDefinition("SandboxPage", cfg => cfg.DisplayedAs("Sandbox Page").WithPart("HasComments").WithPart("HasTags").WithPart("Localized"));
|
contentDefinitionManager.AlterTypeDefinition("SandboxPage", cfg => cfg.DisplayedAs("Sandbox Page").WithPart("HasComments").WithPart("HasTags").WithPart("Localized"));
|
||||||
|
contentDefinitionManager.AlterPartDefinition("BodyAspect", cfg => cfg.WithSetting("BodyPartSettings.FlavorDefault", BodyPartSettings.FlavorDefaultDefault));
|
||||||
|
|
||||||
// create home page as a CMS page
|
// create home page as a CMS page
|
||||||
var page = contentManager.Create("Page", VersionOptions.Draft);
|
var page = contentManager.Create("Page", VersionOptions.Draft);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ namespace Orchard.ContentManagement {
|
|||||||
public ContentTypeDefinition TypeDefinition { get { return ContentItem.TypeDefinition; } }
|
public ContentTypeDefinition TypeDefinition { get { return ContentItem.TypeDefinition; } }
|
||||||
public ContentTypeDefinition.Part TypePartDefinition { get; set; }
|
public ContentTypeDefinition.Part TypePartDefinition { get; set; }
|
||||||
public ContentPartDefinition PartDefinition { get { return TypePartDefinition.PartDefinition; } }
|
public ContentPartDefinition PartDefinition { get { return TypePartDefinition.PartDefinition; } }
|
||||||
|
public SettingsDictionary Settings { get { return TypePartDefinition.Settings; } }
|
||||||
|
|
||||||
public IEnumerable<ContentField> Fields { get { return _fields; } }
|
public IEnumerable<ContentField> Fields { get { return _fields; } }
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Orchard.ContentManagement.Handlers;
|
using Orchard.ContentManagement.Handlers;
|
||||||
using Orchard.ContentManagement.MetaData;
|
using Orchard.ContentManagement.MetaData;
|
||||||
using Orchard.ContentManagement.MetaData.Models;
|
|
||||||
|
|
||||||
namespace Orchard.ContentManagement.Drivers {
|
namespace Orchard.ContentManagement.Drivers {
|
||||||
public abstract class ContentFieldDriver<TField> : IContentFieldDriver where TField : ContentField, new() {
|
public abstract class ContentFieldDriver<TField> : IContentFieldDriver where TField : ContentField, new() {
|
||||||
@@ -15,7 +14,7 @@ namespace Orchard.ContentManagement.Drivers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DriverResult IContentFieldDriver.BuildEditorModel(BuildEditorModelContext context) {
|
DriverResult IContentFieldDriver.BuildEditorModel(BuildEditorModelContext context) {
|
||||||
return Process(context.ContentItem, (part, field) => Editor(part, field));
|
return Process(context.ContentItem, Editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
DriverResult IContentFieldDriver.UpdateEditorModel(UpdateEditorModelContext context) {
|
DriverResult IContentFieldDriver.UpdateEditorModel(UpdateEditorModelContext context) {
|
||||||
|
|||||||
@@ -26,12 +26,12 @@ namespace Orchard.ContentManagement.Handlers {
|
|||||||
typePartDefinition = new ContentTypeDefinition.Part(
|
typePartDefinition = new ContentTypeDefinition.Part(
|
||||||
new ContentPartDefinition(partName),
|
new ContentPartDefinition(partName),
|
||||||
new SettingsDictionary());
|
new SettingsDictionary());
|
||||||
}
|
|
||||||
|
|
||||||
var part = new TPart {
|
var part = new TPart {
|
||||||
TypePartDefinition = typePartDefinition
|
TypePartDefinition = typePartDefinition
|
||||||
};
|
};
|
||||||
_item.Weld(part);
|
_item.Weld(part);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ namespace Orchard.ContentManagement.MetaData.Builders {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string Name { get { return _name; } }
|
||||||
|
|
||||||
public ContentPartDefinition Build() {
|
public ContentPartDefinition Build() {
|
||||||
return new ContentPartDefinition(_name, _fields, _settings);
|
return new ContentPartDefinition(_name, _fields, _settings);
|
||||||
}
|
}
|
||||||
@@ -35,7 +37,7 @@ namespace Orchard.ContentManagement.MetaData.Builders {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ContentPartDefinitionBuilder RemoveField(string fieldName) {
|
public ContentPartDefinitionBuilder RemoveField(string fieldName) {
|
||||||
var existingField = _fields.SingleOrDefault(x => x.FieldDefinition.Name == fieldName);
|
var existingField = _fields.SingleOrDefault(x => x.Name == fieldName);
|
||||||
if (existingField != null) {
|
if (existingField != null) {
|
||||||
_fields.Remove(existingField);
|
_fields.Remove(existingField);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,9 +9,13 @@ namespace Orchard.ContentManagement.MetaData {
|
|||||||
public interface IContentDefinitionEditorEvents : IEventHandler {
|
public interface IContentDefinitionEditorEvents : IEventHandler {
|
||||||
IEnumerable<TemplateViewModel> TypeEditor(ContentTypeDefinition definition);
|
IEnumerable<TemplateViewModel> TypeEditor(ContentTypeDefinition definition);
|
||||||
IEnumerable<TemplateViewModel> TypePartEditor(ContentTypeDefinition.Part definition);
|
IEnumerable<TemplateViewModel> TypePartEditor(ContentTypeDefinition.Part definition);
|
||||||
|
IEnumerable<TemplateViewModel> PartEditor(ContentPartDefinition definition);
|
||||||
|
IEnumerable<TemplateViewModel> PartFieldEditor(ContentPartDefinition.Field definition);
|
||||||
|
|
||||||
IEnumerable<TemplateViewModel> TypeEditorUpdate(ContentTypeDefinitionBuilder builder, IUpdateModel updateModel);
|
IEnumerable<TemplateViewModel> TypeEditorUpdate(ContentTypeDefinitionBuilder builder, IUpdateModel updateModel);
|
||||||
IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypeDefinitionBuilder.PartConfigurer builder, IUpdateModel updateModel);
|
IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypeDefinitionBuilder.PartConfigurer builder, IUpdateModel updateModel);
|
||||||
|
IEnumerable<TemplateViewModel> PartEditorUpdate(ContentPartDefinitionBuilder builder, IUpdateModel updateModel);
|
||||||
|
IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartDefinitionBuilder builder, IUpdateModel updateModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class ContentDefinitionEditorEventsBase : IContentDefinitionEditorEvents {
|
public abstract class ContentDefinitionEditorEventsBase : IContentDefinitionEditorEvents {
|
||||||
@@ -23,6 +27,14 @@ namespace Orchard.ContentManagement.MetaData {
|
|||||||
return Enumerable.Empty<TemplateViewModel>();
|
return Enumerable.Empty<TemplateViewModel>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual IEnumerable<TemplateViewModel> PartEditor(ContentPartDefinition definition) {
|
||||||
|
return Enumerable.Empty<TemplateViewModel>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual IEnumerable<TemplateViewModel> PartFieldEditor(ContentPartDefinition.Field definition) {
|
||||||
|
return Enumerable.Empty<TemplateViewModel>();
|
||||||
|
}
|
||||||
|
|
||||||
public virtual IEnumerable<TemplateViewModel> TypeEditorUpdate(ContentTypeDefinitionBuilder builder, IUpdateModel updateModel) {
|
public virtual IEnumerable<TemplateViewModel> TypeEditorUpdate(ContentTypeDefinitionBuilder builder, IUpdateModel updateModel) {
|
||||||
return Enumerable.Empty<TemplateViewModel>();
|
return Enumerable.Empty<TemplateViewModel>();
|
||||||
}
|
}
|
||||||
@@ -31,6 +43,14 @@ namespace Orchard.ContentManagement.MetaData {
|
|||||||
return Enumerable.Empty<TemplateViewModel>();
|
return Enumerable.Empty<TemplateViewModel>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual IEnumerable<TemplateViewModel> PartEditorUpdate(ContentPartDefinitionBuilder builder, IUpdateModel updateModel) {
|
||||||
|
return Enumerable.Empty<TemplateViewModel>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartDefinitionBuilder builder, IUpdateModel updateModel) {
|
||||||
|
return Enumerable.Empty<TemplateViewModel>();
|
||||||
|
}
|
||||||
|
|
||||||
protected static TemplateViewModel DefinitionTemplate<TModel>(TModel model) {
|
protected static TemplateViewModel DefinitionTemplate<TModel>(TModel model) {
|
||||||
return new TemplateViewModel(model, typeof(TModel).Name) {
|
return new TemplateViewModel(model, typeof(TModel).Name) {
|
||||||
TemplateName = "DefinitionTemplates/" + typeof(TModel).Name
|
TemplateName = "DefinitionTemplates/" + typeof(TModel).Name
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Xml;
|
using System.Linq;
|
||||||
|
using System.Xml;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using Orchard.ContentManagement.MetaData.Builders;
|
using Orchard.ContentManagement.MetaData.Builders;
|
||||||
using Orchard.ContentManagement.MetaData.Models;
|
using Orchard.ContentManagement.MetaData.Models;
|
||||||
@@ -18,8 +19,16 @@ namespace Orchard.ContentManagement.MetaData.Services {
|
|||||||
}
|
}
|
||||||
foreach (var iter in source.Elements()) {
|
foreach (var iter in source.Elements()) {
|
||||||
var partElement = iter;
|
var partElement = iter;
|
||||||
|
var partName = XmlConvert.DecodeName(partElement.Name.LocalName);
|
||||||
|
if (partName == "remove") {
|
||||||
|
var nameAttribute = partElement.Attribute("name");
|
||||||
|
if (nameAttribute != null) {
|
||||||
|
builder.RemovePart(nameAttribute.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
builder.WithPart(
|
builder.WithPart(
|
||||||
XmlConvert.DecodeName(partElement.Name.LocalName),
|
partName,
|
||||||
partBuilder => {
|
partBuilder => {
|
||||||
foreach (var setting in _settingsReader.Map(partElement)) {
|
foreach (var setting in _settingsReader.Map(partElement)) {
|
||||||
partBuilder.WithSetting(setting.Key, setting.Value);
|
partBuilder.WithSetting(setting.Key, setting.Value);
|
||||||
@@ -27,6 +36,7 @@ namespace Orchard.ContentManagement.MetaData.Services {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Merge(XElement source, ContentPartDefinitionBuilder builder) {
|
public void Merge(XElement source, ContentPartDefinitionBuilder builder) {
|
||||||
builder.Named(XmlConvert.DecodeName(source.Name.LocalName));
|
builder.Named(XmlConvert.DecodeName(source.Name.LocalName));
|
||||||
@@ -36,11 +46,20 @@ namespace Orchard.ContentManagement.MetaData.Services {
|
|||||||
|
|
||||||
foreach (var iter in source.Elements()) {
|
foreach (var iter in source.Elements()) {
|
||||||
var fieldElement = iter;
|
var fieldElement = iter;
|
||||||
var fieldParameters = XmlConvert.DecodeName(fieldElement.Name.LocalName).Split('.');
|
var fieldParameters = XmlConvert.DecodeName(fieldElement.Name.LocalName).Split(new[] { '.' }, 2);
|
||||||
|
var fieldName = fieldParameters.FirstOrDefault();
|
||||||
|
var fieldType = fieldParameters.Skip(1).FirstOrDefault();
|
||||||
|
if (fieldName == "remove") {
|
||||||
|
var nameAttribute = fieldElement.Attribute("name");
|
||||||
|
if (nameAttribute != null) {
|
||||||
|
builder.RemoveField(nameAttribute.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
builder.WithField(
|
builder.WithField(
|
||||||
fieldParameters[0],
|
fieldName,
|
||||||
fieldBuilder => {
|
fieldBuilder => {
|
||||||
fieldBuilder.OfType(fieldParameters[1]);
|
fieldBuilder.OfType(fieldType);
|
||||||
foreach (var setting in _settingsReader.Map(fieldElement)) {
|
foreach (var setting in _settingsReader.Map(fieldElement)) {
|
||||||
fieldBuilder.WithSetting(setting.Key, setting.Value);
|
fieldBuilder.WithSetting(setting.Key, setting.Value);
|
||||||
}
|
}
|
||||||
@@ -49,3 +68,4 @@ namespace Orchard.ContentManagement.MetaData.Services {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@@ -1,15 +1,6 @@
|
|||||||
using NHibernate;
|
|
||||||
|
|
||||||
namespace Orchard.Data.Providers {
|
namespace Orchard.Data.Providers {
|
||||||
public interface IDataServicesProviderFactory : IDependency {
|
public interface IDataServicesProviderFactory : IDependency {
|
||||||
IDataServicesProvider CreateProvider(DataServiceParameters sessionFactoryParameters);
|
IDataServicesProvider CreateProvider(DataServiceParameters sessionFactoryParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class IDataServicesProviderSelectorExtensions {
|
|
||||||
public static ISessionFactory BuildSessionFactory(this IDataServicesProviderFactory factory, SessionFactoryParameters sessionFactoryParameters) {
|
|
||||||
var provider = factory.CreateProvider(sessionFactoryParameters);
|
|
||||||
return provider != null ? provider.BuildSessionFactory(sessionFactoryParameters) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ using Orchard.Logging;
|
|||||||
namespace Orchard.Data {
|
namespace Orchard.Data {
|
||||||
public interface ISessionFactoryHolder : ISingletonDependency {
|
public interface ISessionFactoryHolder : ISingletonDependency {
|
||||||
ISessionFactory GetSessionFactory();
|
ISessionFactory GetSessionFactory();
|
||||||
SessionFactoryParameters CreateSessionFactoryParameters(bool createDatabase, bool updateSchema);
|
|
||||||
void CreateDatabase();
|
void CreateDatabase();
|
||||||
void UpdateSchema();
|
void UpdateSchema();
|
||||||
}
|
}
|
||||||
@@ -68,7 +67,7 @@ namespace Orchard.Data {
|
|||||||
public ISessionFactory GetSessionFactory() {
|
public ISessionFactory GetSessionFactory() {
|
||||||
lock (this) {
|
lock (this) {
|
||||||
if (_sessionFactory == null) {
|
if (_sessionFactory == null) {
|
||||||
_sessionFactory = BuildSessionFactory(false /*createDatabase*/, false /*updateSchema*/);
|
_sessionFactory = BuildSessionFactory(false /*createDatabase*/, true /*updateSchema*/);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return _sessionFactory;
|
return _sessionFactory;
|
||||||
@@ -77,17 +76,12 @@ namespace Orchard.Data {
|
|||||||
private ISessionFactory BuildSessionFactory(bool createDatabase, bool updateSchema) {
|
private ISessionFactory BuildSessionFactory(bool createDatabase, bool updateSchema) {
|
||||||
Logger.Debug("Building session factory");
|
Logger.Debug("Building session factory");
|
||||||
|
|
||||||
var sessionFactory = _dataServicesProviderFactory.BuildSessionFactory(CreateSessionFactoryParameters(createDatabase, updateSchema));
|
|
||||||
return sessionFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SessionFactoryParameters CreateSessionFactoryParameters(bool createDatabase, bool updateSchema) {
|
|
||||||
var shellPath = _appDataFolder.Combine("Sites", _shellSettings.Name);
|
var shellPath = _appDataFolder.Combine("Sites", _shellSettings.Name);
|
||||||
_appDataFolder.CreateDirectory(shellPath);
|
_appDataFolder.CreateDirectory(shellPath);
|
||||||
|
|
||||||
var shellFolder = _appDataFolder.MapPath(shellPath);
|
var shellFolder = _appDataFolder.MapPath(shellPath);
|
||||||
|
|
||||||
return new SessionFactoryParameters {
|
var parameters = new SessionFactoryParameters {
|
||||||
Provider = _shellSettings.DataProvider,
|
Provider = _shellSettings.DataProvider,
|
||||||
DataFolder = shellFolder,
|
DataFolder = shellFolder,
|
||||||
ConnectionString = _shellSettings.DataConnectionString,
|
ConnectionString = _shellSettings.DataConnectionString,
|
||||||
@@ -95,6 +89,15 @@ namespace Orchard.Data {
|
|||||||
UpdateSchema = updateSchema,
|
UpdateSchema = updateSchema,
|
||||||
RecordDescriptors = _shellBlueprint.Records,
|
RecordDescriptors = _shellBlueprint.Records,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var sessionFactory = _dataServicesProviderFactory
|
||||||
|
.CreateProvider(parameters)
|
||||||
|
.BuildSessionFactory(parameters);
|
||||||
|
|
||||||
|
return sessionFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using System.Web.Mvc.Html;
|
using System.Web.Mvc.Html;
|
||||||
using Orchard.ContentManagement.ViewModels;
|
using Orchard.ContentManagement.ViewModels;
|
||||||
|
using Orchard.UI.Navigation;
|
||||||
|
|
||||||
namespace Orchard.Mvc.Html {
|
namespace Orchard.Mvc.Html {
|
||||||
public static class TemplateViewModelExtensions {
|
public static class TemplateViewModelExtensions {
|
||||||
@@ -9,7 +11,7 @@ namespace Orchard.Mvc.Html {
|
|||||||
if (templates == null)
|
if (templates == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (var template in templates) {
|
foreach (var template in templates.OrderByDescending(t => t.Position, new PositionComparer())) {
|
||||||
html.RenderTemplates(template);
|
html.RenderTemplates(template);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user