diff --git a/src/Orchard.Web/Core/Common/Drivers/BodyPartDriver.cs b/src/Orchard.Web/Core/Common/Drivers/BodyPartDriver.cs index 4f52efb0a..fd0726094 100644 --- a/src/Orchard.Web/Core/Common/Drivers/BodyPartDriver.cs +++ b/src/Orchard.Web/Core/Common/Drivers/BodyPartDriver.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Web; using JetBrains.Annotations; @@ -9,7 +8,6 @@ using Orchard.ContentManagement.Drivers; using Orchard.Core.Common.Models; using Orchard.Core.Common.Settings; using Orchard.Core.Common.ViewModels; -using Orchard.Core.ContentsLocation.Models; using Orchard.Core.Routable.Models; using Orchard.Services; @@ -49,10 +47,6 @@ namespace Orchard.Core.Common.Drivers { ); } - private string IfThen(bool predicate, string value) { - return predicate ? value : null; - } - protected override DriverResult Editor(BodyPart part, dynamic shapeHelper) { var model = BuildEditorViewModel(part); return ContentShape("Parts_Common_Body_Edit", diff --git a/src/Orchard.Web/Core/Common/Drivers/CommonPartDriver.cs b/src/Orchard.Web/Core/Common/Drivers/CommonPartDriver.cs index ceb9377e9..cf735b2bd 100644 --- a/src/Orchard.Web/Core/Common/Drivers/CommonPartDriver.cs +++ b/src/Orchard.Web/Core/Common/Drivers/CommonPartDriver.cs @@ -2,7 +2,6 @@ using Orchard.ContentManagement.Drivers; using Orchard.Core.Common.Models; using Orchard.Core.Common.ViewModels; -using Orchard.Core.ContentsLocation.Models; using Orchard.Localization; using Orchard.Security; using Orchard.Services; @@ -48,8 +47,8 @@ namespace Orchard.Core.Common.Drivers { protected override DriverResult Editor(CommonPart part, dynamic shapeHelper) { return Combined( - OwnerEditor(part, null), - ContainerEditor(part, null)); + OwnerEditor(part, null, shapeHelper), + ContainerEditor(part, null, shapeHelper)); } protected override DriverResult Editor(CommonPart instance, IUpdateModel updater, dynamic shapeHelper) { @@ -58,11 +57,11 @@ namespace Orchard.Core.Common.Drivers { instance.VersionModifiedUtc = _clock.UtcNow; return Combined( - OwnerEditor(instance, updater), - ContainerEditor(instance, updater)); + OwnerEditor(instance, updater, shapeHelper), + ContainerEditor(instance, updater, shapeHelper)); } - DriverResult OwnerEditor(CommonPart part, IUpdateModel updater) { + DriverResult OwnerEditor(CommonPart part, IUpdateModel updater, dynamic shapeHelper) { var currentUser = _authenticationService.GetAuthenticatedUser(); if (!_authorizationService.TryCheckAccess(Permissions.ChangeOwner, currentUser, part)) { return null; @@ -87,10 +86,11 @@ namespace Orchard.Core.Common.Drivers { } } - return ContentPartTemplate(model, "Parts/Common.Owner", TemplatePrefix).Location(part.GetLocation("Editor")); + return ContentShape("Parts_Common_Owner_Edit", + () => shapeHelper.EditorTemplate(TemplateName: "Parts/Common.Owner", Model: model, Prefix: Prefix)); } - DriverResult ContainerEditor(CommonPart part, IUpdateModel updater) { + DriverResult ContainerEditor(CommonPart part, IUpdateModel updater, dynamic shapeHelper) { var currentUser = _authenticationService.GetAuthenticatedUser(); if (!_authorizationService.TryCheckAccess(Permissions.ChangeOwner, currentUser, part)) { return null; @@ -115,7 +115,8 @@ namespace Orchard.Core.Common.Drivers { } } - return ContentPartTemplate(model, "Parts/Common.Container", TemplatePrefix).Location(part.GetLocation("Editor")); + return ContentShape("Parts_Common_Container_Edit", + () => shapeHelper.EditorTemplate(TemplateName: "Parts/Common.Container", Model: model, Prefix: Prefix)); } } } \ No newline at end of file diff --git a/src/Orchard.Web/Core/Common/Drivers/TextFieldDriver.cs b/src/Orchard.Web/Core/Common/Drivers/TextFieldDriver.cs index 128379d55..d697728f5 100644 --- a/src/Orchard.Web/Core/Common/Drivers/TextFieldDriver.cs +++ b/src/Orchard.Web/Core/Common/Drivers/TextFieldDriver.cs @@ -2,39 +2,32 @@ using Orchard.ContentManagement; using Orchard.ContentManagement.Drivers; using Orchard.Core.Common.Fields; -using Orchard.Core.ContentsLocation.Models; namespace Orchard.Core.Common.Drivers { [UsedImplicitly] public class TextFieldDriver : ContentFieldDriver { - public IOrchardServices Services { get; set; } - private const string TemplateName = "Fields/Common.TextField"; - public TextFieldDriver(IOrchardServices services) { Services = services; } + public IOrchardServices Services { get; set; } + private static string GetPrefix(TextField field, ContentPart part) { return part.PartDefinition.Name + "." + field.Name; } - protected override DriverResult Display(ContentPart part, TextField field, string displayType) { - var location = field.GetLocation(displayType, "Primary", "1"); - - return ContentFieldTemplate(field, TemplateName, GetPrefix(field, part)) - .Location(location); + protected override DriverResult Display(ContentPart part, TextField field, string displayType, dynamic shapeHelper) { + return ContentShape("Fields_Common_Text", () => shapeHelper.Fields_Common_Text(ContentField: field, Name: field.Name, Value: field.Value)); } - protected override DriverResult Editor(ContentPart part, TextField field) { - var location = field.GetLocation("Editor", "Primary", "1"); - - return ContentFieldTemplate(field, TemplateName, GetPrefix(field, part)) - .Location(location); + protected override DriverResult Editor(ContentPart part, TextField field, dynamic shapeHelper) { + return ContentShape("Fields_Common_Text_Edit", + () => shapeHelper.EditorTemplate(TemplateName: "Fields/Common.Text.Edit", Model: field, Prefix: GetPrefix(field, part))); } - protected override DriverResult Editor(ContentPart part, TextField field, IUpdateModel updater) { + protected override DriverResult Editor(ContentPart part, TextField field, IUpdateModel updater, dynamic shapeHelper) { updater.TryUpdateModel(field, GetPrefix(field, part), null, null); - return Editor(part, field); + return Editor(part, field, shapeHelper); } } -} +} \ No newline at end of file diff --git a/src/Orchard.Web/Core/Common/Placement.info b/src/Orchard.Web/Core/Common/Placement.info index fa102159f..c9796ff46 100644 --- a/src/Orchard.Web/Core/Common/Placement.info +++ b/src/Orchard.Web/Core/Common/Placement.info @@ -1,16 +1,24 @@  - + + + + + + @Model.Name.CamelFriendly(): @Model.Value

\ No newline at end of file diff --git a/src/Orchard.Web/Core/Common/Views/DisplayTemplates/Parts/Common.Body.Manage.SummaryAdmin.cshtml b/src/Orchard.Web/Core/Common/Views/DisplayTemplates/Parts/Common.Body.Manage.SummaryAdmin.cshtml deleted file mode 100644 index 55250529b..000000000 --- a/src/Orchard.Web/Core/Common/Views/DisplayTemplates/Parts/Common.Body.Manage.SummaryAdmin.cshtml +++ /dev/null @@ -1 +0,0 @@ -@model Orchard.Core.Common.ViewModels.BodyDisplayViewModel \ No newline at end of file diff --git a/src/Orchard.Web/Core/Common/Views/DisplayTemplates/Parts/Common.Body.Manage.cshtml b/src/Orchard.Web/Core/Common/Views/DisplayTemplates/Parts/Common.Body.Manage.cshtml deleted file mode 100644 index 7340291dc..000000000 --- a/src/Orchard.Web/Core/Common/Views/DisplayTemplates/Parts/Common.Body.Manage.cshtml +++ /dev/null @@ -1,5 +0,0 @@ -@model BodyDisplayViewModel -@using Orchard.Core.Common.ViewModels; -
- @Html.ItemEditLinkWithReturnUrl(T("Edit").ToString(), Model.BodyPart.ContentItem) -
\ No newline at end of file diff --git a/src/Orchard.Web/Core/Common/Views/DisplayTemplates/Parts/Common.Body.ManageWrapperPost.SummaryAdmin.cshtml b/src/Orchard.Web/Core/Common/Views/DisplayTemplates/Parts/Common.Body.ManageWrapperPost.SummaryAdmin.cshtml deleted file mode 100644 index 55250529b..000000000 --- a/src/Orchard.Web/Core/Common/Views/DisplayTemplates/Parts/Common.Body.ManageWrapperPost.SummaryAdmin.cshtml +++ /dev/null @@ -1 +0,0 @@ -@model Orchard.Core.Common.ViewModels.BodyDisplayViewModel \ No newline at end of file diff --git a/src/Orchard.Web/Core/Common/Views/DisplayTemplates/Parts/Common.Body.ManageWrapperPost.cshtml b/src/Orchard.Web/Core/Common/Views/DisplayTemplates/Parts/Common.Body.ManageWrapperPost.cshtml deleted file mode 100644 index a24a87b20..000000000 --- a/src/Orchard.Web/Core/Common/Views/DisplayTemplates/Parts/Common.Body.ManageWrapperPost.cshtml +++ /dev/null @@ -1,7 +0,0 @@ -@model BodyDisplayViewModel -@using Orchard.Core.Common.ViewModels; -@* begin: knowingly broken HTML (hence the ManageWrapperPre and ManageWrapperPost templates) -we need "wrapper templates" (among other functionality) in the future of UI composition -please do not delete or the front end will be broken when the user is authenticated. *@ - -@* begin: knowingly broken HTML *@ \ No newline at end of file diff --git a/src/Orchard.Web/Core/Common/Views/DisplayTemplates/Parts/Common.Body.ManageWrapperPre.SummaryAdmin.cshtml b/src/Orchard.Web/Core/Common/Views/DisplayTemplates/Parts/Common.Body.ManageWrapperPre.SummaryAdmin.cshtml deleted file mode 100644 index 55250529b..000000000 --- a/src/Orchard.Web/Core/Common/Views/DisplayTemplates/Parts/Common.Body.ManageWrapperPre.SummaryAdmin.cshtml +++ /dev/null @@ -1 +0,0 @@ -@model Orchard.Core.Common.ViewModels.BodyDisplayViewModel \ No newline at end of file diff --git a/src/Orchard.Web/Core/Common/Views/DisplayTemplates/Parts/Common.Body.ManageWrapperPre.cshtml b/src/Orchard.Web/Core/Common/Views/DisplayTemplates/Parts/Common.Body.ManageWrapperPre.cshtml deleted file mode 100644 index 930523ad4..000000000 --- a/src/Orchard.Web/Core/Common/Views/DisplayTemplates/Parts/Common.Body.ManageWrapperPre.cshtml +++ /dev/null @@ -1,3 +0,0 @@ -@model BodyDisplayViewModel -@using Orchard.Core.Common.ViewModels; -
\ No newline at end of file diff --git a/src/Orchard.Web/Core/Common/Views/EditorTemplates/Fields/Common.TextField.cshtml b/src/Orchard.Web/Core/Common/Views/EditorTemplates/Fields/Common.Text.Edit.cshtml similarity index 100% rename from src/Orchard.Web/Core/Common/Views/EditorTemplates/Fields/Common.TextField.cshtml rename to src/Orchard.Web/Core/Common/Views/EditorTemplates/Fields/Common.Text.Edit.cshtml diff --git a/src/Orchard.Web/Core/Common/Views/Fields/Common.Text.cshtml b/src/Orchard.Web/Core/Common/Views/Fields/Common.Text.cshtml new file mode 100644 index 000000000..4cf10f9d6 --- /dev/null +++ b/src/Orchard.Web/Core/Common/Views/Fields/Common.Text.cshtml @@ -0,0 +1,8 @@ +@using Orchard.Utility.Extensions; +@{ + string name = Model.Name; + string value = Model.Value; +} +@if (HasText(name) && HasText(value)) { +

@name.CamelFriendly(): @value

+} \ No newline at end of file diff --git a/src/Orchard.Web/Core/Orchard.Core.csproj b/src/Orchard.Web/Core/Orchard.Core.csproj index e26fd93c7..a6827f9b7 100644 --- a/src/Orchard.Web/Core/Orchard.Core.csproj +++ b/src/Orchard.Web/Core/Orchard.Core.csproj @@ -82,7 +82,6 @@ - @@ -148,7 +147,6 @@ - @@ -255,11 +253,8 @@ - + - - - @@ -281,7 +276,7 @@ - + @@ -359,9 +354,6 @@ - - - diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Drivers/RecentBlogPostsPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Blogs/Drivers/RecentBlogPostsPartDriver.cs index 319ccde9e..082bf4019 100644 --- a/src/Orchard.Web/Modules/Orchard.Blogs/Drivers/RecentBlogPostsPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Blogs/Drivers/RecentBlogPostsPartDriver.cs @@ -47,7 +47,7 @@ namespace Orchard.Blogs.Drivers { } protected override DriverResult Editor(RecentBlogPostsPart part, dynamic shapeHelper) { - return ContentShape("Parts_Blogs_RecentBlogPosts_Editor", + return ContentShape("Parts_Blogs_RecentBlogPosts_Edit", () => shapeHelper.EditorTemplate(TemplateName: "Parts/Blogs.RecentBlogPosts", Model: part, Prefix: Prefix)); } diff --git a/src/Orchard.Web/Modules/Orchard.Email/Drivers/SmtpSettingsPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Email/Drivers/SmtpSettingsPartDriver.cs index e8847e280..7706e6d2b 100644 --- a/src/Orchard.Web/Modules/Orchard.Email/Drivers/SmtpSettingsPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Email/Drivers/SmtpSettingsPartDriver.cs @@ -20,13 +20,13 @@ namespace Orchard.Email.Drivers { protected override string Prefix { get { return "SmtpSettings"; } } protected override DriverResult Editor(SmtpSettingsPart part, dynamic shapeHelper) { - return ContentShape("Parts_SmtpSettings_Editor", + return ContentShape("Parts_SmtpSettings_Edit", () => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: part, Prefix: Prefix)); } protected override DriverResult Editor(SmtpSettingsPart part, IUpdateModel updater, dynamic shapeHelper) { updater.TryUpdateModel(part, Prefix, null, null); - return ContentShape("Parts_SmtpSettings_Editor", + return ContentShape("Parts_SmtpSettings_Edit", () => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: part, Prefix: Prefix)); } } diff --git a/src/Orchard.Web/Modules/Orchard.Tags/Drivers/TagsPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Tags/Drivers/TagsPartDriver.cs index 2989a258a..b517e940e 100644 --- a/src/Orchard.Web/Modules/Orchard.Tags/Drivers/TagsPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Tags/Drivers/TagsPartDriver.cs @@ -36,7 +36,7 @@ namespace Orchard.Tags.Drivers { if (!_authorizationService.TryCheckAccess(Permissions.ApplyTag, CurrentUser, part)) return null; - return ContentShape("Parts_Tags_Editor", + return ContentShape("Parts_Tags_Edit", () => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: BuildEditorViewModel(part), Prefix: Prefix)); } @@ -52,7 +52,7 @@ namespace Orchard.Tags.Drivers { _tagService.UpdateTagsForContentItem(part.ContentItem.Id, tagNames); } - return ContentShape("Parts_Tags_Editor", + return ContentShape("Parts_Tags_Edit", () => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix)); } diff --git a/src/Orchard/ContentManagement/Drivers/ContentFieldDriver.cs b/src/Orchard/ContentManagement/Drivers/ContentFieldDriver.cs index 9ec26a243..17cbcded1 100644 --- a/src/Orchard/ContentManagement/Drivers/ContentFieldDriver.cs +++ b/src/Orchard/ContentManagement/Drivers/ContentFieldDriver.cs @@ -3,22 +3,23 @@ using System.Collections.Generic; using System.Linq; using Orchard.ContentManagement.Handlers; using Orchard.ContentManagement.MetaData; +using Orchard.DisplayManagement; namespace Orchard.ContentManagement.Drivers { public abstract class ContentFieldDriver : IContentFieldDriver where TField : ContentField, new() { protected virtual string Prefix { get { return ""; } } - protected virtual string Zone { get { return "body"; } } + protected virtual string Zone { get { return "Content"; } } DriverResult IContentFieldDriver.BuildDisplayShape(BuildDisplayContext context) { - return Process(context.ContentItem, (part, field) => Display(part, field, context.DisplayType)); + return Process(context.ContentItem, (part, field) => Display(part, field, context.DisplayType, context.New)); } DriverResult IContentFieldDriver.BuildEditorShape(BuildEditorContext context) { - return Process(context.ContentItem, Editor); + return Process(context.ContentItem, (part, field) => Editor(part, field, context.New)); } DriverResult IContentFieldDriver.UpdateEditorShape(UpdateEditorContext context) { - return Process(context.ContentItem, (part, field) => Editor(part, field, context.Updater)); + return Process(context.ContentItem, (part, field) => Editor(part, field, context.Updater, context.New)); } DriverResult Process(ContentItem item, Func effort) { @@ -43,19 +44,44 @@ namespace Orchard.ContentManagement.Drivers { } - protected virtual DriverResult Display(ContentPart part, TField field, string displayType) { return null; } - protected virtual DriverResult Editor(ContentPart part, TField field) { return null; } - protected virtual DriverResult Editor(ContentPart part, TField field, IUpdateModel updater) { return null; } + protected virtual DriverResult Display(ContentPart part, TField field, string displayType, dynamic shapeHelper) { return null; } + protected virtual DriverResult Editor(ContentPart part, TField field, dynamic shapeHelper) { return null; } + protected virtual DriverResult Editor(ContentPart part, TField field, IUpdateModel updater, dynamic shapeHelper) { return null; } + public ContentShapeResult ContentShape(string shapeType, Func factory) { + return ContentShapeImplementation(shapeType, null, ctx => factory()); + } + public ContentShapeResult ContentShape(string shapeType, string defaultLocation, Func factory) { + return ContentShapeImplementation(shapeType, defaultLocation, ctx => factory()); + } + + public ContentShapeResult ContentShape(string shapeType, Func factory) { + return ContentShapeImplementation(shapeType, null, ctx=>factory(CreateShape(ctx, shapeType))); + } + + public ContentShapeResult ContentShape(string shapeType, string defaultLocation, Func factory) { + return ContentShapeImplementation(shapeType, defaultLocation, factory); + } + + private ContentShapeResult ContentShapeImplementation(string shapeType, string defaultLocation, Func shapeBuilder) { + return new ContentShapeResult(shapeType, Prefix, shapeBuilder).Location(defaultLocation); + } + + private object CreateShape(BuildShapeContext context, string shapeType) { + IShapeFactory shapeFactory = context.New; + return shapeFactory.Create(shapeType); + } + + [Obsolete] public ContentTemplateResult ContentFieldTemplate(object model) { return new ContentTemplateResult(model, null, Prefix).Location(Zone); } - + [Obsolete] public ContentTemplateResult ContentFieldTemplate(object model, string template) { return new ContentTemplateResult(model, template, Prefix).Location(Zone); } - + [Obsolete] public ContentTemplateResult ContentFieldTemplate(object model, string template, string prefix) { return new ContentTemplateResult(model, template, prefix).Location(Zone); } @@ -64,4 +90,4 @@ namespace Orchard.ContentManagement.Drivers { return new CombinedResult(results); } } -} \ No newline at end of file +} \ No newline at end of file diff --git a/src/Orchard/ContentManagement/Drivers/ContentPartDriver.cs b/src/Orchard/ContentManagement/Drivers/ContentPartDriver.cs index c362864d9..146fce428 100644 --- a/src/Orchard/ContentManagement/Drivers/ContentPartDriver.cs +++ b/src/Orchard/ContentManagement/Drivers/ContentPartDriver.cs @@ -7,7 +7,7 @@ using Orchard.DisplayManagement; namespace Orchard.ContentManagement.Drivers { public abstract class ContentPartDriver : IContentPartDriver where TContent : ContentPart, new() { protected virtual string Prefix { get { return ""; } } - protected virtual string Zone { get { return "Primary"; } } + protected virtual string Zone { get { return "Content"; } } DriverResult IContentPartDriver.BuildDisplay(BuildDisplayContext context) { var part = context.ContentItem.As(); @@ -45,7 +45,6 @@ namespace Orchard.ContentManagement.Drivers { return ContentShapeImplementation(shapeType, null, ctx=>factory(CreateShape(ctx, shapeType))); } - public ContentShapeResult ContentShape(string shapeType, string defaultLocation, Func factory) { return ContentShapeImplementation(shapeType, defaultLocation, factory); }