mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-04-05 21:01:35 +08:00
Move LocationSettings to a separate module
Also go through all existing parts and use the new LocationSettings API to retrieve the location according to the display types. --HG-- branch : dev rename : src/Orchard.Web/Core/Common/Settings/LocationSettingsEditorEvents.cs => src/Orchard.Web/Core/ContentsLocation/Settings/LocationSettingsEditorEvents.cs
This commit is contained in:
parent
5dea6c7b73
commit
a7ade53495
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -19,17 +19,17 @@ namespace Orchard.Core.Common.Drivers {
|
||||
}
|
||||
|
||||
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))
|
||||
.Location(locationSettings.Zone, locationSettings.Position);
|
||||
.Location(location);
|
||||
}
|
||||
|
||||
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))
|
||||
.Location(locationSettings.Zone, locationSettings.Position);
|
||||
.Location(location);
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(ContentPart part, TextField field, IUpdateModel updater) {
|
||||
|
@ -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<ContentPart> {
|
||||
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
|
||||
namespace Orchard.Core.ContentsLocation.Models {
|
||||
@ -20,4 +21,18 @@ namespace Orchard.Core.ContentsLocation.Models {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -4,12 +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() {
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -72,7 +72,7 @@
|
||||
<Compile Include="Common\Services\CommonService.cs" />
|
||||
<Compile Include="Common\Settings\BodySettings.cs" />
|
||||
<Compile Include="ContentsLocation\Models\LocationSettings.cs" />
|
||||
<Compile Include="Common\Settings\LocationSettingsEditorEvents.cs" />
|
||||
<Compile Include="ContentsLocation\Settings\LocationSettingsEditorEvents.cs" />
|
||||
<Compile Include="ContentsLocation\ViewModels\LocationSettingsViewModel.cs" />
|
||||
<Compile Include="Common\ViewModels\CommonMetadataViewModel.cs" />
|
||||
<Compile Include="Common\ViewModels\ContainerEditorViewModel.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);
|
||||
}
|
||||
}
|
||||
}
|
@ -67,8 +67,8 @@ namespace Orchard.Core.Routable.Drivers {
|
||||
: "";
|
||||
}
|
||||
|
||||
var location = part.PartDefinition.Settings.GetModel<LocationSettings>().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) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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<HasCommentsContainer> {
|
||||
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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
|
@ -106,6 +106,10 @@
|
||||
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
|
||||
<Name>Orchard.Framework</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Core\Orchard.Core.csproj">
|
||||
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
|
||||
<Name>Orchard.Core</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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))
|
||||
|
@ -116,18 +116,28 @@ namespace Orchard.ContentManagement.MetaData.Builders {
|
||||
|
||||
public static class ContentPartDefinitionBuilderExtensions {
|
||||
public static IEnumerable<KeyValuePair<string, string>> GetSettingEntries(IDictionary<string, ContentLocation> 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, string>(string.Format("{0}.Key", prefix), locationName);
|
||||
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);
|
||||
if (locationName != null) {
|
||||
var prefix = string.Format("LocationSettings[{0}]", entryIndex);
|
||||
yield return new KeyValuePair<string, string>(string.Format("{0}.Key", prefix), locationName);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user