--HG--
branch : dev
This commit is contained in:
Sebastien Ros
2010-07-21 17:27:23 -07:00
33 changed files with 210 additions and 90 deletions

View File

@@ -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 add profiling data
feature disable Orchard.DevTools feature disable Orchard.DevTools

View File

@@ -17,7 +17,7 @@ namespace Orchard.Specs.Bindings {
webApp.GivenIHaveACleanSiteWith(TableData( webApp.GivenIHaveACleanSiteWith(TableData(
new { extension = "module", names = "Orchard.Setup, Orchard.Modules, Orchard.Themes, Orchard.Users, Orchard.Roles, Orchard.Comments, Orchard.Tags, TinyMce" }, 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" })); new { extension = "theme", names = "SafeMode, Classic" }));
webApp.WhenIGoTo("Setup"); webApp.WhenIGoTo("Setup");

View File

@@ -34,7 +34,7 @@ Scenario: Calling setup on a brand new install
Given I have a clean site with Given I have a clean site with
| extension | names | | extension | names |
| module | Orchard.Setup, Orchard.Users, Orchard.Roles, Orchard.Comments, Orchard.Themes, TinyMce | | 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 | | theme | SafeMode, Classic |
And I am on "/Setup" And I am on "/Setup"
When I fill in When I fill in

View File

@@ -145,8 +145,8 @@ this.ScenarioSetup(scenarioInfo);
"nyMce"}); "nyMce"});
table1.AddRow(new string[] { table1.AddRow(new string[] {
"core", "core",
"Common, Contents, Dashboard, Feeds, HomePage, Navigation, Routable, PublishLater," + "Common, Contents, ContentsLocation, Dashboard, Feeds, HomePage, Navigation, Routa" +
" Scheduling, Settings, XmlRpc"}); "ble, PublishLater, Scheduling, Settings, XmlRpc"});
table1.AddRow(new string[] { table1.AddRow(new string[] {
"theme", "theme",
"SafeMode, Classic"}); "SafeMode, Classic"});

View File

@@ -6,6 +6,7 @@ using Orchard.ContentManagement.Drivers;
using Orchard.Core.Common.Models; using Orchard.Core.Common.Models;
using Orchard.Core.Common.Settings; using Orchard.Core.Common.Settings;
using Orchard.Core.Common.ViewModels; using Orchard.Core.Common.ViewModels;
using Orchard.Core.ContentsLocation.Models;
using Orchard.Core.Routable.Models; using Orchard.Core.Routable.Models;
namespace Orchard.Core.Common.Drivers { 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 \/\/ // \/\/ 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) };
var location = part.GetLocation(displayType, "primary", "5");
return Combined( 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.ManageWrapperPre").LongestMatch(displayType, "SummaryAdmin").Location(location) : null,
Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Common.Body.Manage").LongestMatch(displayType, "SummaryAdmin").Location("primary", "5") : 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("primary", "5"), 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("primary", "5") : null); Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Common.Body.ManageWrapperPost").LongestMatch(displayType, "SummaryAdmin").Location(location) : null);
} }
protected override DriverResult Editor(BodyAspect part) { protected override DriverResult Editor(BodyAspect part) {
var model = BuildEditorViewModel(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) { protected override DriverResult Editor(BodyAspect part, IUpdateModel updater) {
@@ -48,7 +51,8 @@ namespace Orchard.Core.Common.Drivers {
if (string.IsNullOrWhiteSpace(model.Format)) if (string.IsNullOrWhiteSpace(model.Format))
model.Format = GetFlavor(part); 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) { private static BodyEditorViewModel BuildEditorViewModel(BodyAspect part) {

View File

@@ -2,6 +2,7 @@
using Orchard.ContentManagement.Drivers; using Orchard.ContentManagement.Drivers;
using Orchard.Core.Common.Models; using Orchard.Core.Common.Models;
using Orchard.Core.Common.ViewModels; using Orchard.Core.Common.ViewModels;
using Orchard.Core.ContentsLocation.Models;
using Orchard.Localization; using Orchard.Localization;
using Orchard.Security; using Orchard.Security;
using Orchard.Services; using Orchard.Services;
@@ -35,7 +36,10 @@ namespace Orchard.Core.Common.Drivers {
public IOrchardServices Services { get; set; } public IOrchardServices Services { get; set; }
protected override DriverResult Display(CommonAspect part, string displayType) { 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) { 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) { 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);
} }
} }
} }

View File

@@ -2,8 +2,7 @@
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers; using Orchard.ContentManagement.Drivers;
using Orchard.Core.Common.Fields; using Orchard.Core.Common.Fields;
using Orchard.Core.Common.Models; using Orchard.Core.ContentsLocation.Models;
using Orchard.Core.Common.Settings;
namespace Orchard.Core.Common.Drivers { namespace Orchard.Core.Common.Drivers {
[UsedImplicitly] [UsedImplicitly]
@@ -20,17 +19,17 @@ namespace Orchard.Core.Common.Drivers {
} }
protected override DriverResult Display(ContentPart part, TextField field, string displayType) { protected override DriverResult Display(ContentPart part, TextField field, string displayType) {
var locationSettings = field.PartFieldDefinition.Settings.GetModel<LocationSettings>().Get(displayType, "primary", "5"); var location = field.PartFieldDefinition.Settings.GetModel<LocationSettings>().Get(displayType, "primary", "5");
return ContentFieldTemplate(field, TemplateName, GetPrefix(field, part)) return ContentFieldTemplate(field, TemplateName, GetPrefix(field, part))
.Location(locationSettings.Zone, locationSettings.Position); .Location(location);
} }
protected override DriverResult Editor(ContentPart part, TextField field) { protected override DriverResult Editor(ContentPart part, TextField field) {
var locationSettings = field.PartFieldDefinition.Settings.GetModel<LocationSettings>().Get("Editor", "primary", "5"); var location = field.PartFieldDefinition.Settings.GetModel<LocationSettings>().Get("Editor", "primary", "5");
return ContentFieldTemplate(field, TemplateName, GetPrefix(field, part)) return ContentFieldTemplate(field, TemplateName, GetPrefix(field, part))
.Location(locationSettings.Zone, locationSettings.Position); .Location(location);
} }
protected override DriverResult Editor(ContentPart part, TextField field, IUpdateModel updater) { protected override DriverResult Editor(ContentPart part, TextField field, IUpdateModel updater) {

View File

@@ -1,23 +0,0 @@
using System.Collections.Generic;
using Orchard.ContentManagement.Drivers;
namespace Orchard.Core.Common.Models {
public class LocationSettings : Dictionary<string, ContentLocation> {
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 };
}
}
}

View File

@@ -8,4 +8,5 @@ description: The common module introduces content parts that are going to be use
features: features:
Common: Common:
Description: Core content parts. Description: Core content parts.
Dependencies: ContentsLocation
Category: Core Category: Core

View File

@@ -2,6 +2,7 @@
using Orchard.ContentManagement.Aspects; using Orchard.ContentManagement.Aspects;
using Orchard.ContentManagement.Drivers; using Orchard.ContentManagement.Drivers;
using Orchard.Core.Contents.ViewModels; using Orchard.Core.Contents.ViewModels;
using Orchard.Core.ContentsLocation.Models;
namespace Orchard.Core.Contents.Drivers { namespace Orchard.Core.Contents.Drivers {
public class ContentsDriver : ContentItemDriver<ContentPart> { public class ContentsDriver : ContentItemDriver<ContentPart> {
@@ -12,9 +13,10 @@ namespace Orchard.Core.Contents.Drivers {
} }
protected override DriverResult Display(ContentPart part, string displayType) { protected override DriverResult Display(ContentPart part, string displayType) {
var location = part.GetLocation(displayType, "secondary", null);
return Combined( return Combined(
ContentItemTemplate("Items/Contents.Item").LongestMatch(displayType, "Summary", "SummaryAdmin"), 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));
} }
} }
} }

View File

@@ -1,6 +1,6 @@
using Orchard.Localization; using Orchard.Localization;
namespace Orchard.Core.Common.Models { namespace Orchard.Core.ContentsLocation.Models {
public class LocationDefinition { public class LocationDefinition {
public string Name { get; set; } public string Name { get; set; }
public LocalizedString DisplayName { get; set; } public LocalizedString DisplayName { get; set; }

View File

@@ -0,0 +1,38 @@
using System.Collections.Generic;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
namespace Orchard.Core.ContentsLocation.Models {
public class LocationSettings : Dictionary<string, ContentLocation> {
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<TContent>(this TContent part, string locationName) where TContent : ContentPart {
return part.GetLocation(locationName, null, null);
}
public static ContentLocation GetLocation<TContent>(this TContent part, string locationName, string defaultZone, string defaultPosition) where TContent : ContentPart {
var typePartLocation = part.TypePartDefinition.Settings.GetModel<LocationSettings>().Get(locationName);
if (typePartLocation.Position == null && typePartLocation.Zone == null) {
return part.PartDefinition.Settings.GetModel<LocationSettings>().Get(locationName, defaultZone, defaultPosition);
}
return typePartLocation;
}
}
}

View File

@@ -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

View File

@@ -4,10 +4,11 @@ using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Builders; using Orchard.ContentManagement.MetaData.Builders;
using Orchard.ContentManagement.MetaData.Models; using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentManagement.ViewModels; using Orchard.ContentManagement.ViewModels;
using Orchard.Core.Common.Models; using Orchard.Core.ContentsLocation.Models;
using Orchard.Core.ContentsLocation.ViewModels;
using Orchard.Localization; using Orchard.Localization;
namespace Orchard.Core.Common.Settings { namespace Orchard.Core.ContentsLocation.Settings {
public class LocationSettingsEditorEvents : ContentDefinitionEditorEventsBase { public class LocationSettingsEditorEvents : ContentDefinitionEditorEventsBase {
public LocationSettingsEditorEvents() { public LocationSettingsEditorEvents() {

View File

@@ -1,7 +1,7 @@
using Orchard.ContentManagement.Drivers; 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 class LocationSettingsViewModel {
public LocationDefinition Definition { get; set; } public LocationDefinition Definition { get; set; }
public ContentLocation Location { get; set; } public ContentLocation Location { get; set; }

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.Core.Common.Settings.LocationSettingsViewModel>" %> <%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.Core.ContentsLocation.ViewModels.LocationSettingsViewModel>" %>
<fieldset > <fieldset >
<legend><%:T("{0}", Model.Definition.DisplayName) %></legend> <legend><%:T("{0}", Model.Definition.DisplayName) %></legend>

View File

@@ -0,0 +1,34 @@
<?xml version="1.0"?>
<configuration>
<system.web>
<httpHandlers>
<add path="*" verb="*"
type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>
<!--
Enabling request validation in view pages would cause validation to occur
after the input has already been processed by the controller. By default
MVC performs request validation before a controller processes the input.
To change this behavior apply the ValidateInputAttribute to a
controller or action.
-->
<pages
validateRequest="false"
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<controls>
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler"/>
</handlers>
</system.webServer>
</configuration>

View File

@@ -4,6 +4,7 @@ using System.Web;
using JetBrains.Annotations; using JetBrains.Annotations;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers; using Orchard.ContentManagement.Drivers;
using Orchard.Core.ContentsLocation.Models;
using Orchard.Core.Localization.Models; using Orchard.Core.Localization.Models;
using Orchard.Core.Localization.Services; using Orchard.Core.Localization.Services;
using Orchard.Core.Localization.ViewModels; using Orchard.Core.Localization.ViewModels;
@@ -26,7 +27,8 @@ namespace Orchard.Core.Localization.Drivers {
Localizations = GetDisplayLocalizations(part) 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) { protected override DriverResult Editor(Localized part) {
@@ -38,7 +40,8 @@ namespace Orchard.Core.Localization.Drivers {
ContentLocalizations = new ContentLocalizationsViewModel(part) { Localizations = localizations } 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) { protected override DriverResult Editor(Localized part, IUpdateModel updater) {

View File

@@ -2,6 +2,7 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers; using Orchard.ContentManagement.Drivers;
using Orchard.Core.ContentsLocation.Models;
using Orchard.Core.Navigation.Models; using Orchard.Core.Navigation.Models;
using Orchard.Localization; using Orchard.Localization;
using Orchard.Security; using Orchard.Security;
@@ -27,7 +28,8 @@ namespace Orchard.Core.Navigation.Drivers {
if (!_authorizationService.TryCheckAccess(Permissions.ManageMainMenu, CurrentUser, part)) if (!_authorizationService.TryCheckAccess(Permissions.ManageMainMenu, CurrentUser, part))
return null; 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) { protected override DriverResult Editor(MenuPart part, IUpdateModel updater) {
@@ -41,7 +43,8 @@ namespace Orchard.Core.Navigation.Drivers {
if (part.OnMainMenu && String.IsNullOrEmpty(part.MenuText)) { if (part.OnMainMenu && String.IsNullOrEmpty(part.MenuText)) {
updater.AddModelError("MenuText", T("The MenuText field is required")); 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);
} }
} }
} }

View File

@@ -67,13 +67,13 @@
<Compile Include="Common\Drivers\TextFieldDriver.cs" /> <Compile Include="Common\Drivers\TextFieldDriver.cs" />
<Compile Include="Common\Extensions\HtmlHelperExtensions.cs" /> <Compile Include="Common\Extensions\HtmlHelperExtensions.cs" />
<Compile Include="Common\Fields\TextField.cs" /> <Compile Include="Common\Fields\TextField.cs" />
<Compile Include="Common\Models\LocationDefinition.cs" /> <Compile Include="ContentsLocation\Models\LocationDefinition.cs" />
<Compile Include="Common\Services\ICommonService.cs" /> <Compile Include="Common\Services\ICommonService.cs" />
<Compile Include="Common\Services\CommonService.cs" /> <Compile Include="Common\Services\CommonService.cs" />
<Compile Include="Common\Settings\BodySettings.cs" /> <Compile Include="Common\Settings\BodySettings.cs" />
<Compile Include="Common\Models\LocationSettings.cs" /> <Compile Include="ContentsLocation\Models\LocationSettings.cs" />
<Compile Include="Common\Settings\LocationSettingsEditorEvents.cs" /> <Compile Include="ContentsLocation\Settings\LocationSettingsEditorEvents.cs" />
<Compile Include="Common\ViewModels\LocationSettingsViewModel.cs" /> <Compile Include="ContentsLocation\ViewModels\LocationSettingsViewModel.cs" />
<Compile Include="Common\ViewModels\CommonMetadataViewModel.cs" /> <Compile Include="Common\ViewModels\CommonMetadataViewModel.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" />
@@ -228,7 +228,6 @@
<Content Include="Common\Module.txt" /> <Content Include="Common\Module.txt" />
<Content Include="Common\Views\DefinitionTemplates\BodyTypePartSettings.ascx" /> <Content Include="Common\Views\DefinitionTemplates\BodyTypePartSettings.ascx" />
<Content Include="Common\Views\DefinitionTemplates\BodyPartSettings.ascx" /> <Content Include="Common\Views\DefinitionTemplates\BodyPartSettings.ascx" />
<Content Include="Common\Views\DefinitionTemplates\LocationSettings.ascx" />
<Content Include="Common\Views\DisplayTemplates\Fields\Common.TextField.ascx" /> <Content Include="Common\Views\DisplayTemplates\Fields\Common.TextField.ascx" />
<Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.SummaryAdmin.ascx" /> <Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.SummaryAdmin.ascx" />
<Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.Manage.SummaryAdmin.ascx" /> <Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.Manage.SummaryAdmin.ascx" />
@@ -236,6 +235,8 @@
<Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.ManageWrapperPre.SummaryAdmin.ascx" /> <Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.ManageWrapperPre.SummaryAdmin.ascx" />
<Content Include="Common\Views\DisplayTemplates\Parts\Common.Metadata.ascx" /> <Content Include="Common\Views\DisplayTemplates\Parts\Common.Metadata.ascx" />
<Content Include="Common\Views\DisplayTemplates\Parts\Common.Metadata.SummaryAdmin.ascx" /> <Content Include="Common\Views\DisplayTemplates\Parts\Common.Metadata.SummaryAdmin.ascx" />
<Content Include="ContentsLocation\Module.txt" />
<Content Include="ContentsLocation\Views\DefinitionTemplates\LocationSettings.ascx" />
<Content Include="Contents\Views\DisplayTemplates\Parts\Contents.Publish.SummaryAdmin.ascx" /> <Content Include="Contents\Views\DisplayTemplates\Parts\Contents.Publish.SummaryAdmin.ascx" />
<Content Include="Contents\Views\DisplayTemplates\Parts\Contents.Publish.ascx" /> <Content Include="Contents\Views\DisplayTemplates\Parts\Contents.Publish.ascx" />
<Content Include="Localization\Views\EditorTemplates\Parts\Localization.Translation.ascx" /> <Content Include="Localization\Views\EditorTemplates\Parts\Localization.Translation.ascx" />
@@ -352,6 +353,7 @@
<Content Include="Localization\Views\Web.config" /> <Content Include="Localization\Views\Web.config" />
<Content Include="Reports\Views\Web.config" /> <Content Include="Reports\Views\Web.config" />
<Content Include="PublishLater\Views\Web.config" /> <Content Include="PublishLater\Views\Web.config" />
<Content Include="ContentsLocation\Views\Web.config" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" /> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />

View File

@@ -2,6 +2,7 @@
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers; using Orchard.ContentManagement.Drivers;
using Orchard.Core.Common.Services; using Orchard.Core.Common.Services;
using Orchard.Core.ContentsLocation.Models;
using Orchard.Core.PublishLater.Models; using Orchard.Core.PublishLater.Models;
using Orchard.Core.PublishLater.Services; using Orchard.Core.PublishLater.Services;
using Orchard.Core.PublishLater.ViewModels; using Orchard.Core.PublishLater.ViewModels;
@@ -31,7 +32,8 @@ namespace Orchard.Core.PublishLater.Drivers {
var model = new PublishLaterViewModel(part) { var model = new PublishLaterViewModel(part) {
ScheduledPublishUtc = part.ScheduledPublishUtc.Value 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) { 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);
} }
} }
} }

View File

@@ -1,8 +1,7 @@
using Orchard.ContentManagement; 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.ContentsLocation.Models;
using Orchard.Core.Common.Settings;
using Orchard.Core.Routable.Models; using Orchard.Core.Routable.Models;
using Orchard.Core.Routable.Services; using Orchard.Core.Routable.Services;
using Orchard.Core.Routable.ViewModels; using Orchard.Core.Routable.ViewModels;
@@ -68,8 +67,8 @@ namespace Orchard.Core.Routable.Drivers {
: ""; : "";
} }
var location = part.PartDefinition.Settings.GetModel<LocationSettings>().Get("Editor"); var location = part.GetLocation("Editor");
return ContentPartTemplate(model, TemplateName, Prefix).Location(location.Zone, location.Position); return ContentPartTemplate(model, TemplateName, Prefix).Location(location);
} }
protected override DriverResult Editor(IsRoutable part, IUpdateModel updater) { protected override DriverResult Editor(IsRoutable part, IUpdateModel updater) {

View File

@@ -8,5 +8,5 @@ description: The routable module enables content items to be accessed through a
features: features:
Routable: Routable:
Description: Routable content part. Description: Routable content part.
Dependencies: Settings Dependencies: ContentsLocation
Category: Core Category: Core

View File

@@ -7,6 +7,7 @@ using Orchard.Blogs.Services;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers; using Orchard.ContentManagement.Drivers;
using Orchard.Core.Contents.ViewModels; using Orchard.Core.Contents.ViewModels;
using Orchard.Core.ContentsLocation.Models;
using Orchard.Localization; using Orchard.Localization;
using Orchard.Mvc.ViewModels; using Orchard.Mvc.ViewModels;
@@ -93,17 +94,15 @@ namespace Orchard.Blogs.Drivers {
} }
protected override DriverResult Editor(Blog blog) { protected override DriverResult Editor(Blog blog) {
var location = blog.GetLocation("Editor", "primary", "1");
return Combined( return Combined(
ContentItemTemplate("Items/Blogs.Blog"), 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) { protected override DriverResult Editor(Blog blog, IUpdateModel updater) {
updater.TryUpdateModel(blog, Prefix, null, null); updater.TryUpdateModel(blog, Prefix, null, null);
return Editor(blog);
return Combined(
ContentItemTemplate("Items/Blogs.Blog"),
ContentPartTemplate(blog, "Parts/Blogs.Blog.Fields").Location("primary", "1"));
} }
} }
} }

View File

@@ -5,16 +5,19 @@ using Orchard.Comments.ViewModels;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers; using Orchard.ContentManagement.Drivers;
using Orchard.Core.Common.Models; using Orchard.Core.Common.Models;
using Orchard.Core.ContentsLocation.Models;
namespace Orchard.Comments.Drivers { namespace Orchard.Comments.Drivers {
[UsedImplicitly] [UsedImplicitly]
public class HasCommentsContainerDriver : ContentPartDriver<HasCommentsContainer> { public class HasCommentsContainerDriver : ContentPartDriver<HasCommentsContainer> {
protected override DriverResult Display(HasCommentsContainer part, string displayType) { protected override DriverResult Display(HasCommentsContainer part, string displayType) {
if (displayType == "SummaryAdmin") { 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")) { 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; return null;

View File

@@ -3,6 +3,7 @@ using Orchard.Comments.Models;
using Orchard.Comments.ViewModels; using Orchard.Comments.ViewModels;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers; using Orchard.ContentManagement.Drivers;
using Orchard.Core.ContentsLocation.Models;
namespace Orchard.Comments.Drivers { namespace Orchard.Comments.Drivers {
[UsedImplicitly] [UsedImplicitly]
@@ -18,29 +19,35 @@ namespace Orchard.Comments.Drivers {
//return Combined( //return Combined(
// ContentPartTemplate(part, "Parts/Comments.Count").Location("body", "above.5"), // ContentPartTemplate(part, "Parts/Comments.Count").Location("body", "above.5"),
// ContentPartTemplate(part, "Parts/Comments.HasComments").Location("body", "below.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") { else if (displayType == "SummaryAdmin") {
var location = part.GetLocation("SummaryAdmin", "meta", null);
var model = new CommentCountViewModel(part); 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")) { else if (displayType.Contains("Summary")) {
var location = part.GetLocation("Summary", "meta", "5");
var model = new CommentCountViewModel(part); var model = new CommentCountViewModel(part);
return ContentPartTemplate(model, "Parts/Comments.Count").Location("meta", "5"); return ContentPartTemplate(model, "Parts/Comments.Count").Location(location);
} }
else { else {
var location = part.GetLocation(displayType, "primary", "before.5");
var model = new CommentCountViewModel(part); 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) { 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) { protected override DriverResult Editor(HasComments part, IUpdateModel updater) {
var location = part.GetLocation("Editor", "primary", "10");
updater.TryUpdateModel(part, Prefix, null, null); updater.TryUpdateModel(part, Prefix, null, null);
return ContentPartTemplate(part, "Parts/Comments.HasComments").Location("primary", "10"); return ContentPartTemplate(part, "Parts/Comments.HasComments").Location(location);
} }
} }
} }

View File

@@ -67,6 +67,7 @@ namespace Orchard.Setup.Services {
"Common", "Common",
"PublishLater", "PublishLater",
"Contents", "Contents",
"ContentsLocation",
"Dashboard", "Dashboard",
"Reports", "Reports",
"Feeds", "Feeds",

View File

@@ -2,6 +2,7 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers; using Orchard.ContentManagement.Drivers;
using Orchard.Core.ContentsLocation.Models;
using Orchard.Security; using Orchard.Security;
using Orchard.Tags.Helpers; using Orchard.Tags.Helpers;
using Orchard.Tags.Models; using Orchard.Tags.Models;
@@ -23,7 +24,8 @@ namespace Orchard.Tags.Drivers {
public virtual IUser CurrentUser { get; set; } public virtual IUser CurrentUser { get; set; }
protected override DriverResult Display(HasTags part, string displayType) { 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) { protected override DriverResult Editor(HasTags part) {
@@ -33,7 +35,8 @@ namespace Orchard.Tags.Drivers {
var model = new EditTagsViewModel { var model = new EditTagsViewModel {
Tags = string.Join(", ", part.CurrentTags.Select((t, i) => t.TagName).ToArray()) 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) { protected override DriverResult Editor(HasTags part, IUpdateModel updater) {
@@ -48,7 +51,8 @@ namespace Orchard.Tags.Drivers {
_tagService.UpdateTagsForContentItem(part.ContentItem.Id, tagNames); _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);
} }
} }
} }

View File

@@ -8,4 +8,5 @@ description: The tags module is providing basic tagging for arbitrary content ty
features: features:
Orchard.Tags: Orchard.Tags:
Description: Tag a content item. Description: Tag a content item.
Dependencies: ContentsLocation
Category: Navigation Category: Navigation

View File

@@ -106,6 +106,10 @@
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project> <Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
<Name>Orchard.Framework</Name> <Name>Orchard.Framework</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\Core\Orchard.Core.csproj">
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
<Name>Orchard.Core</Name>
</ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" /> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />

View File

@@ -26,7 +26,6 @@ namespace Orchard.ContentManagement.Drivers {
protected virtual DriverResult Editor(TContent part) { return null; } protected virtual DriverResult Editor(TContent part) { return null; }
protected virtual DriverResult Editor(TContent part, IUpdateModel updater) { return null; } protected virtual DriverResult Editor(TContent part, IUpdateModel updater) { return null; }
public ContentTemplateResult ContentPartTemplate(object model) { public ContentTemplateResult ContentPartTemplate(object model) {
return new ContentTemplateResult(model, null, Prefix).Location(Zone); return new ContentTemplateResult(model, null, Prefix).Location(Zone);
} }

View File

@@ -1,4 +1,5 @@
using System.Linq; using System;
using System.Linq;
using Orchard.ContentManagement.Handlers; using Orchard.ContentManagement.Handlers;
namespace Orchard.ContentManagement.Drivers { namespace Orchard.ContentManagement.Drivers {
@@ -36,6 +37,12 @@ namespace Orchard.ContentManagement.Drivers {
return this; 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) { public ContentTemplateResult LongestMatch(string displayType, params string[] knownDisplayTypes) {
if (string.IsNullOrEmpty(displayType)) if (string.IsNullOrEmpty(displayType))

View File

@@ -116,18 +116,28 @@ namespace Orchard.ContentManagement.MetaData.Builders {
public static class ContentPartDefinitionBuilderExtensions { public static class ContentPartDefinitionBuilderExtensions {
public static IEnumerable<KeyValuePair<string, string>> GetSettingEntries(IDictionary<string, ContentLocation> locationSettings) { public static IEnumerable<KeyValuePair<string, string>> GetSettingEntries(IDictionary<string, ContentLocation> locationSettings) {
int index = 0; int entryIndex = 0;
foreach (var entry in locationSettings) { foreach (var entry in locationSettings) {
var zone = string.IsNullOrEmpty(entry.Value.Zone) ? null : entry.Value.Zone; var zone = string.IsNullOrEmpty(entry.Value.Zone) ? null : entry.Value.Zone;
var position = string.IsNullOrEmpty(entry.Value.Position) ? null : entry.Value.Position; var position = string.IsNullOrEmpty(entry.Value.Position) ? null : entry.Value.Position;
var locationName = (zone == null && position == null) ? null : entry.Key; var locationName = (zone == null && position == null) ? null : entry.Key;
var prefix = string.Format("LocationSettings[{0}]", index); if (locationName != null) {
yield return new KeyValuePair<string, string>(string.Format("{0}.Key", prefix), locationName); var prefix = string.Format("LocationSettings[{0}]", entryIndex);
yield return new KeyValuePair<string, string>(string.Format("{0}.Value.Zone", prefix), zone); yield return new KeyValuePair<string, string>(string.Format("{0}.Key", prefix), locationName);
yield return new KeyValuePair<string, string>(string.Format("{0}.Value.Position", prefix), position); yield return new KeyValuePair<string, string>(string.Format("{0}.Value.Zone", prefix), zone);
yield return new KeyValuePair<string, string>(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, string>(string.Format("{0}.Key", prefix), null);
yield return new KeyValuePair<string, string>(string.Format("{0}.Value.Zone", prefix), null);
yield return new KeyValuePair<string, string>(string.Format("{0}.Value.Position", prefix), null);
} }
} }