mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-23 04:43:35 +08:00
Data export implementation and export/id handlers for content parts and fields.
--HG-- branch : dev
This commit is contained in:
@@ -58,6 +58,10 @@ namespace Orchard.Core.Common.Drivers {
|
|||||||
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix));
|
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Exporting(BodyPart part, ContentManagement.Handlers.ExportContentContext context) {
|
||||||
|
context.Element(part.PartDefinition.Name).SetAttributeValue("Text", part.Text);
|
||||||
|
}
|
||||||
|
|
||||||
private static BodyEditorViewModel BuildEditorViewModel(BodyPart part) {
|
private static BodyEditorViewModel BuildEditorViewModel(BodyPart part) {
|
||||||
return new BodyEditorViewModel {
|
return new BodyEditorViewModel {
|
||||||
BodyPart = part,
|
BodyPart = part,
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
using Orchard.ContentManagement.Drivers;
|
using Orchard.ContentManagement.Drivers;
|
||||||
|
using Orchard.ContentManagement.Handlers;
|
||||||
using Orchard.Core.Common.Models;
|
using Orchard.Core.Common.Models;
|
||||||
using Orchard.Core.Common.ViewModels;
|
using Orchard.Core.Common.ViewModels;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
@@ -118,5 +119,21 @@ namespace Orchard.Core.Common.Drivers {
|
|||||||
return ContentShape("Parts_Common_Container_Edit",
|
return ContentShape("Parts_Common_Container_Edit",
|
||||||
() => shapeHelper.EditorTemplate(TemplateName: "Parts.Common.Container", Model: model, Prefix: Prefix));
|
() => shapeHelper.EditorTemplate(TemplateName: "Parts.Common.Container", Model: model, Prefix: Prefix));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Exporting(CommonPart part, ExportContentContext context) {
|
||||||
|
if (part.Owner != null) {
|
||||||
|
var ownerIdentity = _contentManager.GetItemMetadata(part.Owner).Identity;
|
||||||
|
context.Element(part.PartDefinition.Name).SetAttributeValue("Owner", ownerIdentity.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (part.Container != null) {
|
||||||
|
var containerIdentity = _contentManager.GetItemMetadata(part.Container).Identity;
|
||||||
|
context.Element(part.PartDefinition.Name).SetAttributeValue("Container", containerIdentity.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
context.Element(part.PartDefinition.Name).SetAttributeValue("CreatedUtc", part.CreatedUtc);
|
||||||
|
context.Element(part.PartDefinition.Name).SetAttributeValue("PublishedUtc", part.PublishedUtc);
|
||||||
|
context.Element(part.PartDefinition.Name).SetAttributeValue("ModifiedUtc", part.ModifiedUtc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,6 +1,7 @@
|
|||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
using Orchard.ContentManagement.Drivers;
|
using Orchard.ContentManagement.Drivers;
|
||||||
|
using Orchard.ContentManagement.Handlers;
|
||||||
using Orchard.Core.Common.Fields;
|
using Orchard.Core.Common.Fields;
|
||||||
|
|
||||||
namespace Orchard.Core.Common.Drivers {
|
namespace Orchard.Core.Common.Drivers {
|
||||||
@@ -34,5 +35,9 @@ namespace Orchard.Core.Common.Drivers {
|
|||||||
updater.TryUpdateModel(field, GetPrefix(field, part), null, null);
|
updater.TryUpdateModel(field, GetPrefix(field, part), null, null);
|
||||||
return Editor(part, field, shapeHelper);
|
return Editor(part, field, shapeHelper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Exporting(ContentPart part, TextField field, ExportContentContext context) {
|
||||||
|
context.Element(part.PartDefinition.Name).SetAttributeValue("Text", field.Value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -23,5 +23,9 @@ namespace Orchard.Core.Navigation.Drivers {
|
|||||||
updater.TryUpdateModel(itemPart, Prefix, null, null);
|
updater.TryUpdateModel(itemPart, Prefix, null, null);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Exporting(MenuItemPart part, ContentManagement.Handlers.ExportContentContext context) {
|
||||||
|
context.Element(part.PartDefinition.Name).SetAttributeValue("Url", part.Url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -45,5 +45,11 @@ namespace Orchard.Core.Navigation.Drivers {
|
|||||||
|
|
||||||
return Editor(part, shapeHelper);
|
return Editor(part, shapeHelper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Exporting(MenuPart part, ContentManagement.Handlers.ExportContentContext context) {
|
||||||
|
context.Element(part.PartDefinition.Name).SetAttributeValue("MenuText", part.MenuText);
|
||||||
|
context.Element(part.PartDefinition.Name).SetAttributeValue("MenuPosition", part.MenuPosition);
|
||||||
|
context.Element(part.PartDefinition.Name).SetAttributeValue("OnMainMenu", part.OnMainMenu);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,4 +1,5 @@
|
|||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using Orchard.ContentManagement;
|
||||||
using Orchard.Core.Navigation.Models;
|
using Orchard.Core.Navigation.Models;
|
||||||
using Orchard.Data;
|
using Orchard.Data;
|
||||||
using Orchard.ContentManagement.Handlers;
|
using Orchard.ContentManagement.Handlers;
|
||||||
@@ -10,5 +11,13 @@ namespace Orchard.Core.Navigation.Handlers {
|
|||||||
Filters.Add(new ActivatingFilter<MenuItemPart>("MenuItem"));
|
Filters.Add(new ActivatingFilter<MenuItemPart>("MenuItem"));
|
||||||
Filters.Add(StorageFilter.For(repository));
|
Filters.Add(StorageFilter.For(repository));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void GetItemMetadata(GetContentItemMetadataContext context) {
|
||||||
|
var part = context.ContentItem.As<MenuItemPart>();
|
||||||
|
|
||||||
|
if (part != null) {
|
||||||
|
context.Metadata.Identity.Add("MenuItem.Url", part.Url);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,9 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Xml.Linq;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
using Orchard.ContentManagement.Aspects;
|
using Orchard.ContentManagement.Aspects;
|
||||||
using Orchard.ContentManagement.Drivers;
|
using Orchard.ContentManagement.Drivers;
|
||||||
|
using Orchard.ContentManagement.Handlers;
|
||||||
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;
|
||||||
@@ -93,5 +95,11 @@ namespace Orchard.Core.Routable.Drivers {
|
|||||||
|
|
||||||
return Editor(part, shapeHelper);
|
return Editor(part, shapeHelper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Exporting(RoutePart part, ExportContentContext context) {
|
||||||
|
context.Element(part.PartDefinition.Name).SetAttributeValue("Title", part.Title);
|
||||||
|
context.Element(part.PartDefinition.Name).SetAttributeValue("Slug", part.Slug);
|
||||||
|
context.Element(part.PartDefinition.Name).SetAttributeValue("Path", part.Path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -89,6 +89,14 @@ namespace Orchard.Core.Routable.Handlers {
|
|||||||
OnIndexing<RoutePart>((context, part) => context.DocumentIndex.Add("title", part.Record.Title).RemoveTags().Analyze());
|
OnIndexing<RoutePart>((context, part) => context.DocumentIndex.Add("title", part.Record.Title).RemoveTags().Analyze());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void GetItemMetadata(GetContentItemMetadataContext context) {
|
||||||
|
var part = context.ContentItem.As<RoutePart>();
|
||||||
|
|
||||||
|
if (part != null) {
|
||||||
|
context.Metadata.Identity.Add("Route.Slug", part.Slug);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void FinalizePath(RoutePart route, PublishContentContext context, Action<RoutePart> processSlug) {
|
private void FinalizePath(RoutePart route, PublishContentContext context, Action<RoutePart> processSlug) {
|
||||||
var path = route.Path;
|
var path = route.Path;
|
||||||
route.Path = route.GetPathWithSlug(route.Slug);
|
route.Path = route.GetPathWithSlug(route.Slug);
|
||||||
|
@@ -5,6 +5,7 @@ using Orchard.Blogs.Services;
|
|||||||
using Orchard.Blogs.ViewModels;
|
using Orchard.Blogs.ViewModels;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
using Orchard.ContentManagement.Drivers;
|
using Orchard.ContentManagement.Drivers;
|
||||||
|
using Orchard.ContentManagement.Handlers;
|
||||||
|
|
||||||
namespace Orchard.Blogs.Drivers {
|
namespace Orchard.Blogs.Drivers {
|
||||||
public class BlogArchivesPartDriver : ContentPartDriver<BlogArchivesPart> {
|
public class BlogArchivesPartDriver : ContentPartDriver<BlogArchivesPart> {
|
||||||
@@ -52,5 +53,9 @@ namespace Orchard.Blogs.Drivers {
|
|||||||
|
|
||||||
return Editor(part, shapeHelper);
|
return Editor(part, shapeHelper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Exporting(BlogArchivesPart part, ExportContentContext context) {
|
||||||
|
context.Element(part.PartDefinition.Name).SetAttributeValue("BlogSlug", part.ForBlog);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -28,5 +28,10 @@ namespace Orchard.Blogs.Drivers {
|
|||||||
updater.TryUpdateModel(blogPart, Prefix, null, null);
|
updater.TryUpdateModel(blogPart, Prefix, null, null);
|
||||||
return Editor(blogPart, shapeHelper);
|
return Editor(blogPart, shapeHelper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Exporting(BlogPart part, ContentManagement.Handlers.ExportContentContext context) {
|
||||||
|
context.Element(part.PartDefinition.Name).SetAttributeValue("Description", part.Description);
|
||||||
|
context.Element(part.PartDefinition.Name).SetAttributeValue("PostCount", part.PostCount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -26,7 +26,6 @@ namespace Orchard.ImportExport.Services {
|
|||||||
private readonly IRecipeManager _recipeManager;
|
private readonly IRecipeManager _recipeManager;
|
||||||
private readonly IShellDescriptorManager _shellDescriptorManager;
|
private readonly IShellDescriptorManager _shellDescriptorManager;
|
||||||
private const string ExportsDirectory = "Exports";
|
private const string ExportsDirectory = "Exports";
|
||||||
private static readonly List<string> _ignoredParts = new List<string> { "InfosetPart", "ContentPart`1" };
|
|
||||||
|
|
||||||
public ImportExportService(
|
public ImportExportService(
|
||||||
IOrchardServices orchardServices,
|
IOrchardServices orchardServices,
|
||||||
@@ -144,13 +143,12 @@ namespace Orchard.ImportExport.Services {
|
|||||||
var options = GetContentExportVersionOptions(versionHistoryOptions);
|
var options = GetContentExportVersionOptions(versionHistoryOptions);
|
||||||
|
|
||||||
var contentItems = _orchardServices.ContentManager.Query(options).List();
|
var contentItems = _orchardServices.ContentManager.Query(options).List();
|
||||||
var exportedContentItems = new HashSet<ContentItem>();
|
|
||||||
|
|
||||||
foreach (var contentType in contentTypes) {
|
foreach (var contentType in contentTypes) {
|
||||||
var type = contentType;
|
var type = contentType;
|
||||||
var items = contentItems.Where(i => i.ContentType == type);
|
var items = contentItems.Where(i => i.ContentType == type);
|
||||||
foreach (var contentItem in items) {
|
foreach (var contentItem in items) {
|
||||||
var contentItemElement = ExportContentItem(contentTypes, contentItem, options, exportedContentItems);
|
var contentItemElement = ExportContentItem(contentItem);
|
||||||
if (contentItemElement != null)
|
if (contentItemElement != null)
|
||||||
data.Add(contentItemElement);
|
data.Add(contentItemElement);
|
||||||
}
|
}
|
||||||
@@ -159,60 +157,9 @@ namespace Orchard.ImportExport.Services {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
private XElement ExportContentItem(IEnumerable<string> contentTypes, ContentItem contentItem, VersionOptions versionOptions, HashSet<ContentItem> exportedContentItems) {
|
private XElement ExportContentItem(ContentItem contentItem) {
|
||||||
if (exportedContentItems.Contains(contentItem)) return null;
|
|
||||||
exportedContentItems.Add(contentItem);
|
|
||||||
|
|
||||||
// Call export handler for the item.
|
// Call export handler for the item.
|
||||||
var element = new XElement(contentItem.ContentType);
|
var element = _orchardServices.ContentManager.Export(contentItem);
|
||||||
|
|
||||||
// Export Parts.
|
|
||||||
foreach (var part in contentItem.Parts) {
|
|
||||||
var partElement = ExportPart(part);
|
|
||||||
if (partElement != null) {
|
|
||||||
element.Add(partElement);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Export child content items.
|
|
||||||
var children = contentItem.ContentManager
|
|
||||||
.Query(versionOptions)
|
|
||||||
.Where<CommonPartRecord>(r => r.Container == contentItem.Record)
|
|
||||||
.List();
|
|
||||||
|
|
||||||
foreach (var child in children) {
|
|
||||||
if (contentTypes.Contains(child.ContentType)) {
|
|
||||||
var childElement = ExportContentItem(contentTypes, child, versionOptions, exportedContentItems);
|
|
||||||
if (childElement != null) {
|
|
||||||
element.Add(childElement);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
|
|
||||||
private XElement ExportPart(ContentPart part) {
|
|
||||||
if (_ignoredParts.Contains(part.PartDefinition.Name))
|
|
||||||
return null;
|
|
||||||
|
|
||||||
// Call export handler for the part.
|
|
||||||
var element = new XElement(part.PartDefinition.Name);
|
|
||||||
|
|
||||||
// Export Fields.
|
|
||||||
foreach (var field in part.Fields) {
|
|
||||||
var fieldElement = ExportField(field);
|
|
||||||
if (fieldElement != null) {
|
|
||||||
element.Add(fieldElement);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
|
|
||||||
private XElement ExportField(ContentField field) {
|
|
||||||
// Call export handler for the field.
|
|
||||||
var element = new XElement(field.FieldDefinition.Name);
|
|
||||||
|
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
using Orchard.ContentManagement.Drivers;
|
using Orchard.ContentManagement.Drivers;
|
||||||
|
using Orchard.ContentManagement.Handlers;
|
||||||
using Orchard.Core.Common.Services;
|
using Orchard.Core.Common.Services;
|
||||||
using Orchard.Mvc;
|
using Orchard.Mvc;
|
||||||
using Orchard.PublishLater.Models;
|
using Orchard.PublishLater.Models;
|
||||||
@@ -81,5 +82,9 @@ namespace Orchard.PublishLater.Drivers {
|
|||||||
return ContentShape("Parts_PublishLater_Edit",
|
return ContentShape("Parts_PublishLater_Edit",
|
||||||
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix));
|
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Exporting(PublishLaterPart part, ExportContentContext context) {
|
||||||
|
context.Element(part.PartDefinition.Name).SetAttributeValue("ScheduledPublishUtc", part.ScheduledPublishUtc.Value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,7 +1,9 @@
|
|||||||
using System.Linq;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
using Orchard.ContentManagement.Drivers;
|
using Orchard.ContentManagement.Drivers;
|
||||||
|
using Orchard.ContentManagement.Handlers;
|
||||||
using Orchard.Security;
|
using Orchard.Security;
|
||||||
using Orchard.Tags.Helpers;
|
using Orchard.Tags.Helpers;
|
||||||
using Orchard.Tags.Models;
|
using Orchard.Tags.Models;
|
||||||
@@ -56,5 +58,10 @@ namespace Orchard.Tags.Drivers {
|
|||||||
Tags = string.Join(", ", part.CurrentTags.Select((t, i) => t.TagName).ToArray())
|
Tags = string.Join(", ", part.CurrentTags.Select((t, i) => t.TagName).ToArray())
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Exporting(TagsPart part, ExportContentContext context) {
|
||||||
|
var tags = part.CurrentTags.Aggregate(String.Empty, (current, tag) => current + "," + tag.TagName);
|
||||||
|
context.Element(part.PartDefinition.Name).SetAttributeValue("Tags", tags);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,4 +1,5 @@
|
|||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using Orchard.ContentManagement;
|
||||||
using Orchard.Data;
|
using Orchard.Data;
|
||||||
using Orchard.ContentManagement.Handlers;
|
using Orchard.ContentManagement.Handlers;
|
||||||
using Orchard.Users.Models;
|
using Orchard.Users.Models;
|
||||||
@@ -10,5 +11,13 @@ namespace Orchard.Users.Handlers {
|
|||||||
Filters.Add(new ActivatingFilter<UserPart>("User"));
|
Filters.Add(new ActivatingFilter<UserPart>("User"));
|
||||||
Filters.Add(StorageFilter.For(repository));
|
Filters.Add(StorageFilter.For(repository));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void GetItemMetadata(GetContentItemMetadataContext context) {
|
||||||
|
var part = context.ContentItem.As<UserPart>();
|
||||||
|
|
||||||
|
if (part != null) {
|
||||||
|
context.Metadata.Identity.Add("User.UserName", part.UserName);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -4,6 +4,7 @@ using System.Linq;
|
|||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
using Orchard.ContentManagement.Drivers;
|
using Orchard.ContentManagement.Drivers;
|
||||||
|
using Orchard.ContentManagement.Handlers;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
using Orchard.Widgets.Models;
|
using Orchard.Widgets.Models;
|
||||||
using Orchard.Widgets.Services;
|
using Orchard.Widgets.Services;
|
||||||
@@ -63,5 +64,11 @@ namespace Orchard.Widgets.Drivers {
|
|||||||
|
|
||||||
return Editor(layerPart, shapeHelper);
|
return Editor(layerPart, shapeHelper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Exporting(LayerPart part, ExportContentContext context) {
|
||||||
|
context.Element(part.PartDefinition.Name).SetAttributeValue("Name", part.Name);
|
||||||
|
context.Element(part.PartDefinition.Name).SetAttributeValue("Description", part.Description);
|
||||||
|
context.Element(part.PartDefinition.Name).SetAttributeValue("LayerRule", part.LayerRule);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -35,5 +35,11 @@ namespace Orchard.Widgets.Drivers {
|
|||||||
updater.TryUpdateModel(widgetPart, Prefix, null, null);
|
updater.TryUpdateModel(widgetPart, Prefix, null, null);
|
||||||
return Editor(widgetPart, shapeHelper);
|
return Editor(widgetPart, shapeHelper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Exporting(WidgetPart part, ContentManagement.Handlers.ExportContentContext context) {
|
||||||
|
context.Element(part.PartDefinition.Name).SetAttributeValue("Title", part.Title);
|
||||||
|
context.Element(part.PartDefinition.Name).SetAttributeValue("Position", part.Position);
|
||||||
|
context.Element(part.PartDefinition.Name).SetAttributeValue("Zone", part.Zone);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,4 +1,5 @@
|
|||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using Orchard.ContentManagement;
|
||||||
using Orchard.ContentManagement.Handlers;
|
using Orchard.ContentManagement.Handlers;
|
||||||
using Orchard.Data;
|
using Orchard.Data;
|
||||||
using Orchard.Widgets.Models;
|
using Orchard.Widgets.Models;
|
||||||
@@ -9,5 +10,13 @@ namespace Orchard.Widgets.Handlers {
|
|||||||
public LayerPartHandler(IRepository<LayerPartRecord> layersRepository) {
|
public LayerPartHandler(IRepository<LayerPartRecord> layersRepository) {
|
||||||
Filters.Add(StorageFilter.For(layersRepository));
|
Filters.Add(StorageFilter.For(layersRepository));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void GetItemMetadata(GetContentItemMetadataContext context) {
|
||||||
|
var part = context.ContentItem.As<LayerPart>();
|
||||||
|
|
||||||
|
if (part != null) {
|
||||||
|
context.Metadata.Identity.Add("Layer.LayerName", part.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -37,6 +37,10 @@ namespace Orchard.Widgets.Handlers {
|
|||||||
{"Action", "EditWidget"},
|
{"Action", "EditWidget"},
|
||||||
{"Id", context.ContentItem.Id}
|
{"Id", context.ContentItem.Id}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
context.Metadata.Identity.Add("Widget.Title", widget.Title);
|
||||||
|
context.Metadata.Identity.Add("Widget.Position", widget.Position);
|
||||||
|
context.Metadata.Identity.Add("Widget.Zone", widget.Zone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -42,6 +42,8 @@
|
|||||||
<HintPath>..\..\..\..\lib\aspnetmvc\System.Web.Mvc.dll</HintPath>
|
<HintPath>..\..\..\..\lib\aspnetmvc\System.Web.Mvc.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Web" />
|
<Reference Include="System.Web" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="AdminMenu.cs" />
|
<Compile Include="AdminMenu.cs" />
|
||||||
|
29
src/Orchard/ContentManagement/ContentIdentity.cs
Normal file
29
src/Orchard/ContentManagement/ContentIdentity.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Orchard.ContentManagement {
|
||||||
|
public class ContentIdentity {
|
||||||
|
private readonly Dictionary<string, string> _dictionary;
|
||||||
|
|
||||||
|
public ContentIdentity() {
|
||||||
|
_dictionary = new Dictionary<string, string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Add(string name, string value) {
|
||||||
|
if (_dictionary.ContainsKey(name)) {
|
||||||
|
_dictionary[name] = value;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_dictionary.Add(name, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
var stringBuilder = new StringBuilder();
|
||||||
|
foreach (var key in _dictionary.Keys) {
|
||||||
|
stringBuilder.Append("/" + key + "=" + _dictionary[key]);
|
||||||
|
}
|
||||||
|
return stringBuilder.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -5,7 +5,11 @@ namespace Orchard.ContentManagement {
|
|||||||
public class ContentItemMetadata {
|
public class ContentItemMetadata {
|
||||||
private RouteValueDictionary _adminRouteValues;
|
private RouteValueDictionary _adminRouteValues;
|
||||||
|
|
||||||
|
public ContentItemMetadata() {
|
||||||
|
Identity = new ContentIdentity();
|
||||||
|
}
|
||||||
public string DisplayText { get; set; }
|
public string DisplayText { get; set; }
|
||||||
|
public ContentIdentity Identity { get; set; }
|
||||||
public RouteValueDictionary DisplayRouteValues { get; set; }
|
public RouteValueDictionary DisplayRouteValues { get; set; }
|
||||||
public RouteValueDictionary EditorRouteValues { get; set; }
|
public RouteValueDictionary EditorRouteValues { get; set; }
|
||||||
public RouteValueDictionary CreateRouteValues { get; set; }
|
public RouteValueDictionary CreateRouteValues { get; set; }
|
||||||
|
@@ -3,6 +3,7 @@ using System.Collections.Concurrent;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Xml.Linq;
|
||||||
using Autofac;
|
using Autofac;
|
||||||
using Orchard.ContentManagement.Handlers;
|
using Orchard.ContentManagement.Handlers;
|
||||||
using Orchard.ContentManagement.MetaData;
|
using Orchard.ContentManagement.MetaData;
|
||||||
@@ -397,6 +398,22 @@ namespace Orchard.ContentManagement {
|
|||||||
return query.ForPart<ContentItem>();
|
return query.ForPart<ContentItem>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public XElement Export(ContentItem contentItem) {
|
||||||
|
var context = new ExportContentContext(contentItem, new XElement(contentItem.ContentType));
|
||||||
|
|
||||||
|
foreach (var contentHandler in Handlers) {
|
||||||
|
contentHandler.Exporting(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var contentHandler in Handlers) {
|
||||||
|
contentHandler.Exported(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
context.Data.SetAttributeValue("Id", GetItemMetadata(contentItem).Identity.ToString());
|
||||||
|
|
||||||
|
return context.Data;
|
||||||
|
}
|
||||||
|
|
||||||
public void Flush() {
|
public void Flush() {
|
||||||
_contentItemRepository.Flush();
|
_contentItemRepository.Flush();
|
||||||
}
|
}
|
||||||
|
@@ -8,5 +8,14 @@ namespace Orchard.ContentManagement.Handlers {
|
|||||||
: base(contentItem) {
|
: base(contentItem) {
|
||||||
Data = data;
|
Data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public XElement Element(string elementName) {
|
||||||
|
var element = Data.Element(elementName);
|
||||||
|
if (element == null) {
|
||||||
|
element = new XElement(elementName);
|
||||||
|
Data.Add(element);
|
||||||
|
}
|
||||||
|
return element;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Xml.Linq;
|
||||||
using Orchard.ContentManagement.MetaData.Models;
|
using Orchard.ContentManagement.MetaData.Models;
|
||||||
using Orchard.Indexing;
|
using Orchard.Indexing;
|
||||||
|
|
||||||
@@ -20,6 +21,7 @@ namespace Orchard.ContentManagement {
|
|||||||
void Remove(ContentItem contentItem);
|
void Remove(ContentItem contentItem);
|
||||||
void Index(ContentItem contentItem, IDocumentIndex documentIndex);
|
void Index(ContentItem contentItem, IDocumentIndex documentIndex);
|
||||||
|
|
||||||
|
XElement Export(ContentItem contentItem);
|
||||||
|
|
||||||
void Flush();
|
void Flush();
|
||||||
IContentQuery<ContentItem> Query();
|
IContentQuery<ContentItem> Query();
|
||||||
|
@@ -150,6 +150,7 @@
|
|||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="ContentManagement\ContentIdentity.cs" />
|
||||||
<Compile Include="ContentManagement\ContentItemBehavior.cs" />
|
<Compile Include="ContentManagement\ContentItemBehavior.cs" />
|
||||||
<Compile Include="ContentManagement\ContentPartBehavior.cs" />
|
<Compile Include="ContentManagement\ContentPartBehavior.cs" />
|
||||||
<Compile Include="ContentManagement\DefaultContentDisplay.cs" />
|
<Compile Include="ContentManagement\DefaultContentDisplay.cs" />
|
||||||
|
Reference in New Issue
Block a user