diff --git a/src/Orchard.Profile/profiling-setup-commands.txt b/src/Orchard.Profile/profiling-setup-commands.txt index 45ef0ae5c..312f31de7 100644 --- a/src/Orchard.Profile/profiling-setup-commands.txt +++ b/src/Orchard.Profile/profiling-setup-commands.txt @@ -1,3 +1,3 @@ -setup /SiteName:Profiling /AdminUsername:admin /AdminPassword:profiling-secret /DatabaseProvider:SqlCe /EnabledFeatures:Profiling,Orchard.Framework,Routable,Common,Dashboard,Feeds,PublishLater,HomePage,Contents,Navigation,Reports,Scheduling,Indexing,Settings,Localization,XmlRpc,Orchard.Users,Orchard.Roles,TinyMce,Orchard.Themes,Orchard.MultiTenancy,Orchard.Blogs,Orchard.Comments,Orchard.Modules,Futures.Widgets,Orchard.Media,Orchard.Tags,Orchard.DevTools +setup /SiteName:Profiling /AdminUsername:admin /AdminPassword:profiling-secret /DatabaseProvider:SqlCe /EnabledFeatures:Profiling,Orchard.Framework,Routable,Common,Dashboard,Feeds,PublishLater,HomePage,Contents,ContentsLocation,Navigation,Reports,Scheduling,Indexing,Settings,Localization,XmlRpc,Orchard.Users,Orchard.Roles,TinyMce,Orchard.Themes,Orchard.MultiTenancy,Orchard.Blogs,Orchard.Comments,Orchard.Modules,Futures.Widgets,Orchard.Media,Orchard.Tags,Orchard.DevTools add profiling data feature disable Orchard.DevTools diff --git a/src/Orchard.Specs/Bindings/OrchardSiteFactory.cs b/src/Orchard.Specs/Bindings/OrchardSiteFactory.cs index e7e8a1a56..3014f0eee 100644 --- a/src/Orchard.Specs/Bindings/OrchardSiteFactory.cs +++ b/src/Orchard.Specs/Bindings/OrchardSiteFactory.cs @@ -17,7 +17,7 @@ namespace Orchard.Specs.Bindings { webApp.GivenIHaveACleanSiteWith(TableData( new { extension = "module", names = "Orchard.Setup, Orchard.Modules, Orchard.Themes, Orchard.Users, Orchard.Roles, Orchard.Comments, Orchard.Tags, TinyMce" }, - new { extension = "core", names = "Common, Dashboard, Feeds, HomePage, Navigation, Contents, PublishLater, Routable, Scheduling, Settings, XmlRpc" }, + new { extension = "core", names = "Common, Dashboard, Feeds, HomePage, Navigation, Contents, ContentsLocation, PublishLater, Routable, Scheduling, Settings, XmlRpc" }, new { extension = "theme", names = "SafeMode, Classic" })); webApp.WhenIGoTo("Setup"); diff --git a/src/Orchard.Specs/Setup.feature b/src/Orchard.Specs/Setup.feature index d6b83f363..09bbad8c8 100644 --- a/src/Orchard.Specs/Setup.feature +++ b/src/Orchard.Specs/Setup.feature @@ -34,7 +34,7 @@ Scenario: Calling setup on a brand new install Given I have a clean site with | extension | names | | module | Orchard.Setup, Orchard.Users, Orchard.Roles, Orchard.Comments, Orchard.Themes, TinyMce | - | core | Common, Contents, Dashboard, Feeds, HomePage, Navigation, Routable, PublishLater, Scheduling, Settings, XmlRpc | + | core | Common, Contents, ContentsLocation, Dashboard, Feeds, HomePage, Navigation, Routable, PublishLater, Scheduling, Settings, XmlRpc | | theme | SafeMode, Classic | And I am on "/Setup" When I fill in diff --git a/src/Orchard.Specs/Setup.feature.cs b/src/Orchard.Specs/Setup.feature.cs index 3f9536ee2..143c807fb 100644 --- a/src/Orchard.Specs/Setup.feature.cs +++ b/src/Orchard.Specs/Setup.feature.cs @@ -145,8 +145,8 @@ this.ScenarioSetup(scenarioInfo); "nyMce"}); table1.AddRow(new string[] { "core", - "Common, Contents, Dashboard, Feeds, HomePage, Navigation, Routable, PublishLater," + - " Scheduling, Settings, XmlRpc"}); + "Common, Contents, ContentsLocation, Dashboard, Feeds, HomePage, Navigation, Routa" + + "ble, PublishLater, Scheduling, Settings, XmlRpc"}); table1.AddRow(new string[] { "theme", "SafeMode, Classic"}); diff --git a/src/Orchard.Web/Core/Common/Drivers/BodyDriver.cs b/src/Orchard.Web/Core/Common/Drivers/BodyDriver.cs index 1c5ef6284..6210d40d0 100644 --- a/src/Orchard.Web/Core/Common/Drivers/BodyDriver.cs +++ b/src/Orchard.Web/Core/Common/Drivers/BodyDriver.cs @@ -6,6 +6,7 @@ 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; namespace Orchard.Core.Common.Drivers { @@ -27,17 +28,19 @@ namespace Orchard.Core.Common.Drivers { // \/\/ Hackalicious on many accounts - don't copy what has been done here for the wrapper \/\/ protected override DriverResult Display(BodyAspect part, string displayType) { var model = new BodyDisplayViewModel { BodyAspect = part, Text = BbcodeReplace(part.Text) }; + var location = part.GetLocation(displayType, "primary", "5"); return Combined( - Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Common.Body.ManageWrapperPre").LongestMatch(displayType, "SummaryAdmin").Location("primary", "5") : null, - Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Common.Body.Manage").LongestMatch(displayType, "SummaryAdmin").Location("primary", "5") : null, - ContentPartTemplate(model, TemplateName, Prefix).LongestMatch(displayType, "Summary", "SummaryAdmin").Location("primary", "5"), - Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Common.Body.ManageWrapperPost").LongestMatch(displayType, "SummaryAdmin").Location("primary", "5") : null); + Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Common.Body.ManageWrapperPre").LongestMatch(displayType, "SummaryAdmin").Location(location) : null, + Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Common.Body.Manage").LongestMatch(displayType, "SummaryAdmin").Location(location) : null, + ContentPartTemplate(model, TemplateName, Prefix).LongestMatch(displayType, "Summary", "SummaryAdmin").Location(location), + Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Common.Body.ManageWrapperPost").LongestMatch(displayType, "SummaryAdmin").Location(location) : null); } protected override DriverResult Editor(BodyAspect part) { var model = BuildEditorViewModel(part); - return ContentPartTemplate(model, TemplateName, Prefix).Location("primary", "5"); + var location = part.GetLocation("Editor", "primary", "5"); + return ContentPartTemplate(model, TemplateName, Prefix).Location(location); } protected override DriverResult Editor(BodyAspect part, IUpdateModel updater) { @@ -48,7 +51,8 @@ namespace Orchard.Core.Common.Drivers { if (string.IsNullOrWhiteSpace(model.Format)) model.Format = GetFlavor(part); - return ContentPartTemplate(model, TemplateName, Prefix).Location("primary", "5"); + var location = part.GetLocation("Editor", "primary", "5"); + return ContentPartTemplate(model, TemplateName, Prefix).Location(location); } private static BodyEditorViewModel BuildEditorViewModel(BodyAspect part) { diff --git a/src/Orchard.Web/Core/Common/Drivers/CommonDriver.cs b/src/Orchard.Web/Core/Common/Drivers/CommonDriver.cs index 89dbb5b5b..3e46c5b2b 100644 --- a/src/Orchard.Web/Core/Common/Drivers/CommonDriver.cs +++ b/src/Orchard.Web/Core/Common/Drivers/CommonDriver.cs @@ -2,6 +2,7 @@ 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; @@ -35,7 +36,10 @@ namespace Orchard.Core.Common.Drivers { public IOrchardServices Services { get; set; } protected override DriverResult Display(CommonAspect part, string displayType) { - return ContentPartTemplate(new CommonMetadataViewModel(part), "Parts/Common.Metadata").LongestMatch(displayType, "Summary", "SummaryAdmin").Location("metadata", "5"); + var location = part.GetLocation(displayType, "metadata", "5"); + return ContentPartTemplate(new CommonMetadataViewModel(part), "Parts/Common.Metadata") + .LongestMatch(displayType, "Summary", "SummaryAdmin") + .Location(location); } protected override DriverResult Editor(CommonAspect part) { @@ -79,7 +83,8 @@ namespace Orchard.Core.Common.Drivers { } } - return ContentPartTemplate(model, "Parts/Common.Owner", TemplatePrefix).Location("primary", "20"); + var location = part.GetLocation("Editor", "primary", "20"); + return ContentPartTemplate(model, "Parts/Common.Owner", TemplatePrefix).Location(location); } DriverResult ContainerEditor(CommonAspect part, IUpdateModel updater) { @@ -106,7 +111,9 @@ namespace Orchard.Core.Common.Drivers { } } } - return ContentPartTemplate(model, "Parts/Common.Container", TemplatePrefix).Location("primary", "20.1"); + + var location = part.GetLocation("Editor", "primary", "20.1"); + return ContentPartTemplate(model, "Parts/Common.Container", TemplatePrefix).Location(location); } } } \ 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 77dd7e36e..8f3a64ba3 100644 --- a/src/Orchard.Web/Core/Common/Drivers/TextFieldDriver.cs +++ b/src/Orchard.Web/Core/Common/Drivers/TextFieldDriver.cs @@ -2,8 +2,7 @@ using Orchard.ContentManagement; using Orchard.ContentManagement.Drivers; using Orchard.Core.Common.Fields; -using Orchard.Core.Common.Models; -using Orchard.Core.Common.Settings; +using Orchard.Core.ContentsLocation.Models; namespace Orchard.Core.Common.Drivers { [UsedImplicitly] @@ -20,17 +19,17 @@ namespace Orchard.Core.Common.Drivers { } protected override DriverResult Display(ContentPart part, TextField field, string displayType) { - var locationSettings = field.PartFieldDefinition.Settings.GetModel().Get(displayType, "primary", "5"); + var location = field.PartFieldDefinition.Settings.GetModel().Get(displayType, "primary", "5"); return ContentFieldTemplate(field, TemplateName, GetPrefix(field, part)) - .Location(locationSettings.Zone, locationSettings.Position); + .Location(location); } protected override DriverResult Editor(ContentPart part, TextField field) { - var locationSettings = field.PartFieldDefinition.Settings.GetModel().Get("Editor", "primary", "5"); + var location = field.PartFieldDefinition.Settings.GetModel().Get("Editor", "primary", "5"); return ContentFieldTemplate(field, TemplateName, GetPrefix(field, part)) - .Location(locationSettings.Zone, locationSettings.Position); + .Location(location); } protected override DriverResult Editor(ContentPart part, TextField field, IUpdateModel updater) { diff --git a/src/Orchard.Web/Core/Common/Models/LocationSettings.cs b/src/Orchard.Web/Core/Common/Models/LocationSettings.cs deleted file mode 100644 index 1e3058c0c..000000000 --- a/src/Orchard.Web/Core/Common/Models/LocationSettings.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Collections.Generic; -using Orchard.ContentManagement.Drivers; - -namespace Orchard.Core.Common.Models { - public class LocationSettings : Dictionary { - public LocationSettings() { } - public LocationSettings(LocationSettings value) - : base(value) { - } - - public ContentLocation Get(string location) { - return Get(location, null, null); - } - - public ContentLocation Get(string location, string defaultZone, string defaultPosition) { - ContentLocation result; - if (this.TryGetValue(location, out result)) { - return result; - } - return new ContentLocation { Zone = defaultZone, Position = defaultPosition }; - } - } -} \ No newline at end of file diff --git a/src/Orchard.Web/Core/Common/Module.txt b/src/Orchard.Web/Core/Common/Module.txt index 9669d53a4..4f52a20b8 100644 --- a/src/Orchard.Web/Core/Common/Module.txt +++ b/src/Orchard.Web/Core/Common/Module.txt @@ -8,4 +8,5 @@ description: The common module introduces content parts that are going to be use features: Common: Description: Core content parts. + Dependencies: ContentsLocation Category: Core diff --git a/src/Orchard.Web/Core/Contents/Drivers/ContentsDriver.cs b/src/Orchard.Web/Core/Contents/Drivers/ContentsDriver.cs index afffea50e..7e5225f60 100644 --- a/src/Orchard.Web/Core/Contents/Drivers/ContentsDriver.cs +++ b/src/Orchard.Web/Core/Contents/Drivers/ContentsDriver.cs @@ -2,6 +2,7 @@ using Orchard.ContentManagement.Aspects; using Orchard.ContentManagement.Drivers; using Orchard.Core.Contents.ViewModels; +using Orchard.Core.ContentsLocation.Models; namespace Orchard.Core.Contents.Drivers { public class ContentsDriver : ContentItemDriver { @@ -12,9 +13,10 @@ namespace Orchard.Core.Contents.Drivers { } protected override DriverResult Display(ContentPart part, string displayType) { + var location = part.GetLocation(displayType, "secondary", null); return Combined( ContentItemTemplate("Items/Contents.Item").LongestMatch(displayType, "Summary", "SummaryAdmin"), - ContentPartTemplate(new PublishContentViewModel(part.ContentItem), "Parts/Contents.Publish").LongestMatch(displayType, "Summary", "SummaryAdmin").Location("secondary")); + ContentPartTemplate(new PublishContentViewModel(part.ContentItem), "Parts/Contents.Publish").LongestMatch(displayType, "Summary", "SummaryAdmin").Location(location)); } } } \ No newline at end of file diff --git a/src/Orchard.Web/Core/Common/Models/LocationDefinition.cs b/src/Orchard.Web/Core/ContentsLocation/Models/LocationDefinition.cs similarity index 75% rename from src/Orchard.Web/Core/Common/Models/LocationDefinition.cs rename to src/Orchard.Web/Core/ContentsLocation/Models/LocationDefinition.cs index 7d5274924..524413aaa 100644 --- a/src/Orchard.Web/Core/Common/Models/LocationDefinition.cs +++ b/src/Orchard.Web/Core/ContentsLocation/Models/LocationDefinition.cs @@ -1,6 +1,6 @@ using Orchard.Localization; -namespace Orchard.Core.Common.Models { +namespace Orchard.Core.ContentsLocation.Models { public class LocationDefinition { public string Name { get; set; } public LocalizedString DisplayName { get; set; } diff --git a/src/Orchard.Web/Core/ContentsLocation/Models/LocationSettings.cs b/src/Orchard.Web/Core/ContentsLocation/Models/LocationSettings.cs new file mode 100644 index 000000000..6403b227b --- /dev/null +++ b/src/Orchard.Web/Core/ContentsLocation/Models/LocationSettings.cs @@ -0,0 +1,38 @@ +using System.Collections.Generic; +using Orchard.ContentManagement; +using Orchard.ContentManagement.Drivers; + +namespace Orchard.Core.ContentsLocation.Models { + public class LocationSettings : Dictionary { + public LocationSettings() { } + public LocationSettings(LocationSettings value) + : base(value) { + } + + public ContentLocation Get(string location) { + return Get(location, null, null); + } + + public ContentLocation Get(string location, string defaultZone, string defaultPosition) { + ContentLocation result; + if (this.TryGetValue(location, out result)) { + return result; + } + return new ContentLocation { Zone = defaultZone, Position = defaultPosition }; + } + } + + public static class LocationSettingsExtensions { + public static ContentLocation GetLocation(this TContent part, string locationName) where TContent : ContentPart { + return part.GetLocation(locationName, null, null); + } + + public static ContentLocation GetLocation(this TContent part, string locationName, string defaultZone, string defaultPosition) where TContent : ContentPart { + var typePartLocation = part.TypePartDefinition.Settings.GetModel().Get(locationName); + if (typePartLocation.Position == null && typePartLocation.Zone == null) { + return part.PartDefinition.Settings.GetModel().Get(locationName, defaultZone, defaultPosition); + } + return typePartLocation; + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Core/ContentsLocation/Module.txt b/src/Orchard.Web/Core/ContentsLocation/Module.txt new file mode 100644 index 000000000..f2947182d --- /dev/null +++ b/src/Orchard.Web/Core/ContentsLocation/Module.txt @@ -0,0 +1,12 @@ +Name: ContentsLocation +antiforgery: enabled +author: The Orchard Team +website: http://orchardproject.net +version: 0.5.0 +orchardversion: 0.5.0 +description: The "Contents Location" module introduces settings for part and field to fine tune the location of contents. +features: + ContentsLocation: + Description: Contents location settings management + Dependencies: Settings + Category: Core diff --git a/src/Orchard.Web/Core/Common/Settings/LocationSettingsEditorEvents.cs b/src/Orchard.Web/Core/ContentsLocation/Settings/LocationSettingsEditorEvents.cs similarity index 95% rename from src/Orchard.Web/Core/Common/Settings/LocationSettingsEditorEvents.cs rename to src/Orchard.Web/Core/ContentsLocation/Settings/LocationSettingsEditorEvents.cs index 325b3855b..e11343591 100644 --- a/src/Orchard.Web/Core/Common/Settings/LocationSettingsEditorEvents.cs +++ b/src/Orchard.Web/Core/ContentsLocation/Settings/LocationSettingsEditorEvents.cs @@ -4,10 +4,11 @@ using Orchard.ContentManagement.MetaData; using Orchard.ContentManagement.MetaData.Builders; using Orchard.ContentManagement.MetaData.Models; using Orchard.ContentManagement.ViewModels; -using Orchard.Core.Common.Models; +using Orchard.Core.ContentsLocation.Models; +using Orchard.Core.ContentsLocation.ViewModels; using Orchard.Localization; -namespace Orchard.Core.Common.Settings { +namespace Orchard.Core.ContentsLocation.Settings { public class LocationSettingsEditorEvents : ContentDefinitionEditorEventsBase { public LocationSettingsEditorEvents() { diff --git a/src/Orchard.Web/Core/Common/ViewModels/LocationSettingsViewModel.cs b/src/Orchard.Web/Core/ContentsLocation/ViewModels/LocationSettingsViewModel.cs similarity index 66% rename from src/Orchard.Web/Core/Common/ViewModels/LocationSettingsViewModel.cs rename to src/Orchard.Web/Core/ContentsLocation/ViewModels/LocationSettingsViewModel.cs index 11dc57e13..7387113b3 100644 --- a/src/Orchard.Web/Core/Common/ViewModels/LocationSettingsViewModel.cs +++ b/src/Orchard.Web/Core/ContentsLocation/ViewModels/LocationSettingsViewModel.cs @@ -1,7 +1,7 @@ using Orchard.ContentManagement.Drivers; -using Orchard.Core.Common.Models; +using Orchard.Core.ContentsLocation.Models; -namespace Orchard.Core.Common.Settings { +namespace Orchard.Core.ContentsLocation.ViewModels { public class LocationSettingsViewModel { public LocationDefinition Definition { get; set; } public ContentLocation Location { get; set; } diff --git a/src/Orchard.Web/Core/Common/Views/DefinitionTemplates/LocationSettings.ascx b/src/Orchard.Web/Core/ContentsLocation/Views/DefinitionTemplates/LocationSettings.ascx similarity index 88% rename from src/Orchard.Web/Core/Common/Views/DefinitionTemplates/LocationSettings.ascx rename to src/Orchard.Web/Core/ContentsLocation/Views/DefinitionTemplates/LocationSettings.ascx index bcda2b218..e04003a51 100644 --- a/src/Orchard.Web/Core/Common/Views/DefinitionTemplates/LocationSettings.ascx +++ b/src/Orchard.Web/Core/ContentsLocation/Views/DefinitionTemplates/LocationSettings.ascx @@ -1,4 +1,4 @@ -<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> +<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %>
<%:T("{0}", Model.Definition.DisplayName) %> diff --git a/src/Orchard.Web/Core/ContentsLocation/Views/Web.config b/src/Orchard.Web/Core/ContentsLocation/Views/Web.config new file mode 100644 index 000000000..e065d8735 --- /dev/null +++ b/src/Orchard.Web/Core/ContentsLocation/Views/Web.config @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web/Core/Localization/Drivers/LocalizationDriver.cs b/src/Orchard.Web/Core/Localization/Drivers/LocalizationDriver.cs index 1b269b850..a49bca5bb 100644 --- a/src/Orchard.Web/Core/Localization/Drivers/LocalizationDriver.cs +++ b/src/Orchard.Web/Core/Localization/Drivers/LocalizationDriver.cs @@ -4,6 +4,7 @@ using System.Web; using JetBrains.Annotations; using Orchard.ContentManagement; using Orchard.ContentManagement.Drivers; +using Orchard.Core.ContentsLocation.Models; using Orchard.Core.Localization.Models; using Orchard.Core.Localization.Services; using Orchard.Core.Localization.ViewModels; @@ -26,7 +27,8 @@ namespace Orchard.Core.Localization.Drivers { Localizations = GetDisplayLocalizations(part) }; - return ContentPartTemplate(model, "Parts/Localization.ContentTranslations", TemplatePrefix).LongestMatch(displayType, "Summary", "SummaryAdmin").Location("primary", "5"); + var location = part.GetLocation(displayType, "primary", "5"); + return ContentPartTemplate(model, "Parts/Localization.ContentTranslations", TemplatePrefix).LongestMatch(displayType, "Summary", "SummaryAdmin").Location(location); } protected override DriverResult Editor(Localized part) { @@ -38,7 +40,8 @@ namespace Orchard.Core.Localization.Drivers { ContentLocalizations = new ContentLocalizationsViewModel(part) { Localizations = localizations } }; - return ContentPartTemplate(model, "Parts/Localization.Translation", TemplatePrefix).Location("primary", "1"); + var location = part.GetLocation("Editor", "primary", "1"); + return ContentPartTemplate(model, "Parts/Localization.Translation", TemplatePrefix).Location(location); } protected override DriverResult Editor(Localized part, IUpdateModel updater) { diff --git a/src/Orchard.Web/Core/Navigation/Drivers/MenuPartDriver.cs b/src/Orchard.Web/Core/Navigation/Drivers/MenuPartDriver.cs index b0df9aa82..43c1e15af 100644 --- a/src/Orchard.Web/Core/Navigation/Drivers/MenuPartDriver.cs +++ b/src/Orchard.Web/Core/Navigation/Drivers/MenuPartDriver.cs @@ -2,6 +2,7 @@ using JetBrains.Annotations; using Orchard.ContentManagement; using Orchard.ContentManagement.Drivers; +using Orchard.Core.ContentsLocation.Models; using Orchard.Core.Navigation.Models; using Orchard.Localization; using Orchard.Security; @@ -27,7 +28,8 @@ namespace Orchard.Core.Navigation.Drivers { if (!_authorizationService.TryCheckAccess(Permissions.ManageMainMenu, CurrentUser, part)) return null; - return ContentPartTemplate(part, "Parts/Navigation.EditMenuPart").Location("primary", "9"); + var location = part.GetLocation("Editor", "primary", "9"); + return ContentPartTemplate(part, "Parts/Navigation.EditMenuPart").Location(location); } protected override DriverResult Editor(MenuPart part, IUpdateModel updater) { @@ -41,7 +43,8 @@ namespace Orchard.Core.Navigation.Drivers { if (part.OnMainMenu && String.IsNullOrEmpty(part.MenuText)) { updater.AddModelError("MenuText", T("The MenuText field is required")); } - return ContentPartTemplate(part, "Parts/Navigation.EditMenuPart").Location("primary", "9"); + var location = part.GetLocation("Editor", "primary", "9"); + return ContentPartTemplate(part, "Parts/Navigation.EditMenuPart").Location(location); } } } \ 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 bbf80b552..6e8e7c584 100644 --- a/src/Orchard.Web/Core/Orchard.Core.csproj +++ b/src/Orchard.Web/Core/Orchard.Core.csproj @@ -67,13 +67,13 @@ - + - - - + + + @@ -228,7 +228,6 @@ - @@ -236,6 +235,8 @@ + + @@ -352,6 +353,7 @@ + diff --git a/src/Orchard.Web/Core/PublishLater/Drivers/PublishLaterPartDriver.cs b/src/Orchard.Web/Core/PublishLater/Drivers/PublishLaterPartDriver.cs index feb42f6ba..ad805e931 100644 --- a/src/Orchard.Web/Core/PublishLater/Drivers/PublishLaterPartDriver.cs +++ b/src/Orchard.Web/Core/PublishLater/Drivers/PublishLaterPartDriver.cs @@ -2,6 +2,7 @@ using Orchard.ContentManagement; using Orchard.ContentManagement.Drivers; using Orchard.Core.Common.Services; +using Orchard.Core.ContentsLocation.Models; using Orchard.Core.PublishLater.Models; using Orchard.Core.PublishLater.Services; using Orchard.Core.PublishLater.ViewModels; @@ -31,7 +32,8 @@ namespace Orchard.Core.PublishLater.Drivers { var model = new PublishLaterViewModel(part) { ScheduledPublishUtc = part.ScheduledPublishUtc.Value }; - return ContentPartTemplate(model, "Parts/PublishLater.Metadata").LongestMatch(displayType, "Summary", "SummaryAdmin").Location("metadata", "1"); + var location = part.GetLocation(displayType, "metadata", "1"); + return ContentPartTemplate(model, "Parts/PublishLater.Metadata").LongestMatch(displayType, "Summary", "SummaryAdmin").Location(location); } protected override DriverResult Editor(PublishLaterPart part) { @@ -65,7 +67,8 @@ namespace Orchard.Core.PublishLater.Drivers { } } - return ContentPartTemplate(model, "Parts/PublishLater", TemplatePrefix).Location("secondary", "1"); + var location = part.GetLocation("Editor", "secondary", "1"); + return ContentPartTemplate(model, "Parts/PublishLater", TemplatePrefix).Location(location); } } } \ No newline at end of file diff --git a/src/Orchard.Web/Core/Routable/Drivers/RoutableDriver.cs b/src/Orchard.Web/Core/Routable/Drivers/RoutableDriver.cs index 612ef2af0..70c8cb828 100644 --- a/src/Orchard.Web/Core/Routable/Drivers/RoutableDriver.cs +++ b/src/Orchard.Web/Core/Routable/Drivers/RoutableDriver.cs @@ -1,8 +1,7 @@ using Orchard.ContentManagement; using Orchard.ContentManagement.Aspects; using Orchard.ContentManagement.Drivers; -using Orchard.Core.Common.Models; -using Orchard.Core.Common.Settings; +using Orchard.Core.ContentsLocation.Models; using Orchard.Core.Routable.Models; using Orchard.Core.Routable.Services; using Orchard.Core.Routable.ViewModels; @@ -68,8 +67,8 @@ namespace Orchard.Core.Routable.Drivers { : ""; } - var location = part.PartDefinition.Settings.GetModel().Get("Editor"); - return ContentPartTemplate(model, TemplateName, Prefix).Location(location.Zone, location.Position); + var location = part.GetLocation("Editor"); + return ContentPartTemplate(model, TemplateName, Prefix).Location(location); } protected override DriverResult Editor(IsRoutable part, IUpdateModel updater) { diff --git a/src/Orchard.Web/Core/Routable/Module.txt b/src/Orchard.Web/Core/Routable/Module.txt index 7ee9065be..0ac49def9 100644 --- a/src/Orchard.Web/Core/Routable/Module.txt +++ b/src/Orchard.Web/Core/Routable/Module.txt @@ -8,5 +8,5 @@ description: The routable module enables content items to be accessed through a features: Routable: Description: Routable content part. - Dependencies: Settings + Dependencies: ContentsLocation Category: Core diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Drivers/BlogDriver.cs b/src/Orchard.Web/Modules/Orchard.Blogs/Drivers/BlogDriver.cs index eeb6d0f71..73245830d 100644 --- a/src/Orchard.Web/Modules/Orchard.Blogs/Drivers/BlogDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Blogs/Drivers/BlogDriver.cs @@ -7,6 +7,7 @@ using Orchard.Blogs.Services; using Orchard.ContentManagement; using Orchard.ContentManagement.Drivers; using Orchard.Core.Contents.ViewModels; +using Orchard.Core.ContentsLocation.Models; using Orchard.Localization; using Orchard.Mvc.ViewModels; @@ -93,17 +94,15 @@ namespace Orchard.Blogs.Drivers { } protected override DriverResult Editor(Blog blog) { + var location = blog.GetLocation("Editor", "primary", "1"); return Combined( ContentItemTemplate("Items/Blogs.Blog"), - ContentPartTemplate(blog, "Parts/Blogs.Blog.Fields").Location("primary", "1")); + ContentPartTemplate(blog, "Parts/Blogs.Blog.Fields").Location(location)); } protected override DriverResult Editor(Blog blog, IUpdateModel updater) { updater.TryUpdateModel(blog, Prefix, null, null); - - return Combined( - ContentItemTemplate("Items/Blogs.Blog"), - ContentPartTemplate(blog, "Parts/Blogs.Blog.Fields").Location("primary", "1")); + return Editor(blog); } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Comments/Drivers/HasCommentsContainerDriver.cs b/src/Orchard.Web/Modules/Orchard.Comments/Drivers/HasCommentsContainerDriver.cs index 09005a51d..70da63156 100644 --- a/src/Orchard.Web/Modules/Orchard.Comments/Drivers/HasCommentsContainerDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Comments/Drivers/HasCommentsContainerDriver.cs @@ -5,16 +5,19 @@ using Orchard.Comments.ViewModels; using Orchard.ContentManagement; using Orchard.ContentManagement.Drivers; using Orchard.Core.Common.Models; +using Orchard.Core.ContentsLocation.Models; namespace Orchard.Comments.Drivers { [UsedImplicitly] public class HasCommentsContainerDriver : ContentPartDriver { protected override DriverResult Display(HasCommentsContainer part, string displayType) { if (displayType == "SummaryAdmin") { - return ContentPartTemplate(CreateViewModel(part.ContentItem), "Parts/Comments.CountAdmin").Location("meta"); + var location = part.GetLocation("SummaryAdmin", "meta", null); + return ContentPartTemplate(CreateViewModel(part.ContentItem), "Parts/Comments.CountAdmin").Location(location); } else if (displayType.Contains("Summary")) { - return ContentPartTemplate(CreateViewModel(part.ContentItem), "Parts/Comments.Count").Location("meta"); + var location = part.GetLocation("Summary", "meta", null); + return ContentPartTemplate(CreateViewModel(part.ContentItem), "Parts/Comments.Count").Location(location); } return null; diff --git a/src/Orchard.Web/Modules/Orchard.Comments/Drivers/HasCommentsDriver.cs b/src/Orchard.Web/Modules/Orchard.Comments/Drivers/HasCommentsDriver.cs index ac4ceb686..91af8fd3c 100644 --- a/src/Orchard.Web/Modules/Orchard.Comments/Drivers/HasCommentsDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Comments/Drivers/HasCommentsDriver.cs @@ -3,6 +3,7 @@ using Orchard.Comments.Models; using Orchard.Comments.ViewModels; using Orchard.ContentManagement; using Orchard.ContentManagement.Drivers; +using Orchard.Core.ContentsLocation.Models; namespace Orchard.Comments.Drivers { [UsedImplicitly] @@ -18,29 +19,35 @@ namespace Orchard.Comments.Drivers { //return Combined( // ContentPartTemplate(part, "Parts/Comments.Count").Location("body", "above.5"), // ContentPartTemplate(part, "Parts/Comments.HasComments").Location("body", "below.5")); - return ContentPartTemplate(part, "Parts/Comments.HasComments").Location("primary", "after.5"); + var location = part.GetLocation("Detail", "primary", "after.5"); + return ContentPartTemplate(part, "Parts/Comments.HasComments").Location(location); } else if (displayType == "SummaryAdmin") { + var location = part.GetLocation("SummaryAdmin", "meta", null); var model = new CommentCountViewModel(part); - return ContentPartTemplate(model, "Parts/Comments.CountAdmin").Location("meta"); + return ContentPartTemplate(model, "Parts/Comments.CountAdmin").Location(location); } else if (displayType.Contains("Summary")) { + var location = part.GetLocation("Summary", "meta", "5"); var model = new CommentCountViewModel(part); - return ContentPartTemplate(model, "Parts/Comments.Count").Location("meta", "5"); + return ContentPartTemplate(model, "Parts/Comments.Count").Location(location); } else { + var location = part.GetLocation(displayType, "primary", "before.5"); var model = new CommentCountViewModel(part); - return ContentPartTemplate(model, "Parts/Comments.Count").Location("primary", "before.5"); + return ContentPartTemplate(model, "Parts/Comments.Count").Location(location); } } protected override DriverResult Editor(HasComments part) { - return ContentPartTemplate(part, "Parts/Comments.HasComments").Location("primary", "10"); + var location = part.GetLocation("Editor", "primary", "10"); + return ContentPartTemplate(part, "Parts/Comments.HasComments").Location(location); } protected override DriverResult Editor(HasComments part, IUpdateModel updater) { + var location = part.GetLocation("Editor", "primary", "10"); updater.TryUpdateModel(part, Prefix, null, null); - return ContentPartTemplate(part, "Parts/Comments.HasComments").Location("primary", "10"); + return ContentPartTemplate(part, "Parts/Comments.HasComments").Location(location); } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs b/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs index 135e441fb..e5cbced2a 100644 --- a/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs +++ b/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs @@ -67,6 +67,7 @@ namespace Orchard.Setup.Services { "Common", "PublishLater", "Contents", + "ContentsLocation", "Dashboard", "Reports", "Feeds", diff --git a/src/Orchard.Web/Modules/Orchard.Tags/Drivers/HasTagsDriver.cs b/src/Orchard.Web/Modules/Orchard.Tags/Drivers/HasTagsDriver.cs index a0629914e..eea7a3471 100644 --- a/src/Orchard.Web/Modules/Orchard.Tags/Drivers/HasTagsDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Tags/Drivers/HasTagsDriver.cs @@ -2,6 +2,7 @@ using JetBrains.Annotations; using Orchard.ContentManagement; using Orchard.ContentManagement.Drivers; +using Orchard.Core.ContentsLocation.Models; using Orchard.Security; using Orchard.Tags.Helpers; using Orchard.Tags.Models; @@ -23,7 +24,8 @@ namespace Orchard.Tags.Drivers { public virtual IUser CurrentUser { get; set; } protected override DriverResult Display(HasTags part, string displayType) { - return ContentPartTemplate(part, "Parts/Tags.ShowTags").Location("primary", "49"); + var location = part.GetLocation(displayType, "primary", "49"); + return ContentPartTemplate(part, "Parts/Tags.ShowTags").Location(location); } protected override DriverResult Editor(HasTags part) { @@ -33,7 +35,8 @@ namespace Orchard.Tags.Drivers { var model = new EditTagsViewModel { Tags = string.Join(", ", part.CurrentTags.Select((t, i) => t.TagName).ToArray()) }; - return ContentPartTemplate(model, "Parts/Tags.EditTags").Location("primary", "9"); + var location = part.GetLocation("Editor", "primary", "9"); + return ContentPartTemplate(model, "Parts/Tags.EditTags").Location(location); } protected override DriverResult Editor(HasTags part, IUpdateModel updater) { @@ -48,7 +51,8 @@ namespace Orchard.Tags.Drivers { _tagService.UpdateTagsForContentItem(part.ContentItem.Id, tagNames); } - return ContentPartTemplate(model, "Parts/Tags.EditTags").Location("primary", "9"); + var location = part.GetLocation("Editor", "primary", "9"); + return ContentPartTemplate(model, "Parts/Tags.EditTags").Location(location); } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Tags/Module.txt b/src/Orchard.Web/Modules/Orchard.Tags/Module.txt index 49c67767b..bfef09925 100644 --- a/src/Orchard.Web/Modules/Orchard.Tags/Module.txt +++ b/src/Orchard.Web/Modules/Orchard.Tags/Module.txt @@ -8,4 +8,5 @@ description: The tags module is providing basic tagging for arbitrary content ty features: Orchard.Tags: Description: Tag a content item. + Dependencies: ContentsLocation Category: Navigation diff --git a/src/Orchard.Web/Modules/Orchard.Tags/Orchard.Tags.csproj b/src/Orchard.Web/Modules/Orchard.Tags/Orchard.Tags.csproj index a698e74a8..4fba11da8 100644 --- a/src/Orchard.Web/Modules/Orchard.Tags/Orchard.Tags.csproj +++ b/src/Orchard.Web/Modules/Orchard.Tags/Orchard.Tags.csproj @@ -106,6 +106,10 @@ {2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6} Orchard.Framework + + {9916839C-39FC-4CEB-A5AF-89CA7E87119F} + Orchard.Core + diff --git a/src/Orchard/ContentManagement/Drivers/ContentPartDriver.cs b/src/Orchard/ContentManagement/Drivers/ContentPartDriver.cs index 5cac8419d..7cb49de85 100644 --- a/src/Orchard/ContentManagement/Drivers/ContentPartDriver.cs +++ b/src/Orchard/ContentManagement/Drivers/ContentPartDriver.cs @@ -26,7 +26,6 @@ namespace Orchard.ContentManagement.Drivers { protected virtual DriverResult Editor(TContent part) { return null; } protected virtual DriverResult Editor(TContent part, IUpdateModel updater) { return null; } - public ContentTemplateResult ContentPartTemplate(object model) { return new ContentTemplateResult(model, null, Prefix).Location(Zone); } diff --git a/src/Orchard/ContentManagement/Drivers/ContentTemplateResult.cs b/src/Orchard/ContentManagement/Drivers/ContentTemplateResult.cs index 08735137e..04b7fd1ce 100644 --- a/src/Orchard/ContentManagement/Drivers/ContentTemplateResult.cs +++ b/src/Orchard/ContentManagement/Drivers/ContentTemplateResult.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System; +using System.Linq; using Orchard.ContentManagement.Handlers; namespace Orchard.ContentManagement.Drivers { @@ -36,6 +37,12 @@ namespace Orchard.ContentManagement.Drivers { return this; } + public ContentTemplateResult Location(ContentLocation location) { + if (location.Position == null) + return Location(location.Zone); + return Location(location.Zone, location.Position); + } + public ContentTemplateResult LongestMatch(string displayType, params string[] knownDisplayTypes) { if (string.IsNullOrEmpty(displayType)) diff --git a/src/Orchard/ContentManagement/MetaData/Builders/ContentPartDefinitionBuilder.cs b/src/Orchard/ContentManagement/MetaData/Builders/ContentPartDefinitionBuilder.cs index f8419c98d..1680355ce 100644 --- a/src/Orchard/ContentManagement/MetaData/Builders/ContentPartDefinitionBuilder.cs +++ b/src/Orchard/ContentManagement/MetaData/Builders/ContentPartDefinitionBuilder.cs @@ -116,18 +116,28 @@ namespace Orchard.ContentManagement.MetaData.Builders { public static class ContentPartDefinitionBuilderExtensions { public static IEnumerable> GetSettingEntries(IDictionary locationSettings) { - int index = 0; + int entryIndex = 0; foreach (var entry in locationSettings) { var zone = string.IsNullOrEmpty(entry.Value.Zone) ? null : entry.Value.Zone; var position = string.IsNullOrEmpty(entry.Value.Position) ? null : entry.Value.Position; var locationName = (zone == null && position == null) ? null : entry.Key; - var prefix = string.Format("LocationSettings[{0}]", index); - yield return new KeyValuePair(string.Format("{0}.Key", prefix), locationName); - yield return new KeyValuePair(string.Format("{0}.Value.Zone", prefix), zone); - yield return new KeyValuePair(string.Format("{0}.Value.Position", prefix), position); + if (locationName != null) { + var prefix = string.Format("LocationSettings[{0}]", entryIndex); + yield return new KeyValuePair(string.Format("{0}.Key", prefix), locationName); + yield return new KeyValuePair(string.Format("{0}.Value.Zone", prefix), zone); + yield return new KeyValuePair(string.Format("{0}.Value.Position", prefix), position); - index++; + entryIndex++; + } + } + + // Clear the remaining entries from [index -> end of collection] + for (int i = entryIndex; i < locationSettings.Count; i++) { + var prefix = string.Format("LocationSettings[{0}]", i); + yield return new KeyValuePair(string.Format("{0}.Key", prefix), null); + yield return new KeyValuePair(string.Format("{0}.Value.Zone", prefix), null); + yield return new KeyValuePair(string.Format("{0}.Value.Position", prefix), null); } }