mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Hooking up {import|export}{ing|ed} events for part/field handler/drivers.
--HG-- branch : dev
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Routing;
|
||||
using ClaySharp.Implementation;
|
||||
|
@@ -23,6 +23,22 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
return Process(context.ContentItem, (part, field) => Editor(part, field, context.Updater, context.New));
|
||||
}
|
||||
|
||||
void IContentFieldDriver.Importing(ImportContentContext context) {
|
||||
Process(context.ContentItem, (part, field) => Importing(part, field, context));
|
||||
}
|
||||
|
||||
void IContentFieldDriver.Imported(ImportContentContext context) {
|
||||
Process(context.ContentItem, (part, field) => Imported(part, field, context));
|
||||
}
|
||||
|
||||
void IContentFieldDriver.Exporting(ExportContentContext context) {
|
||||
Process(context.ContentItem, (part, field) => Exporting(part, field, context));
|
||||
}
|
||||
|
||||
void IContentFieldDriver.Exported(ExportContentContext context) {
|
||||
Process(context.ContentItem, (part, field) => Exported(part, field, context));
|
||||
}
|
||||
|
||||
DriverResult Process(ContentItem item, Func<ContentPart, TField, DriverResult> effort) {
|
||||
var results = item.Parts
|
||||
.SelectMany(part => part.Fields.OfType<TField>().Select(field => new { part, field }))
|
||||
@@ -47,6 +63,10 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
protected virtual DriverResult Display(ContentPart part, TField field, string displayType, dynamic shapeHelper) { return null; }
|
||||
protected virtual DriverResult Editor(ContentPart part, TField field, dynamic shapeHelper) { return null; }
|
||||
protected virtual DriverResult Editor(ContentPart part, TField field, IUpdateModel updater, dynamic shapeHelper) { return null; }
|
||||
protected virtual DriverResult Importing(ContentPart part, TField field, ImportContentContext context) { return null; }
|
||||
protected virtual DriverResult Imported(ContentPart part, TField field, ImportContentContext context) { return null; }
|
||||
protected virtual DriverResult Exporting(ContentPart part, TField field, ExportContentContext context) { return null; }
|
||||
protected virtual DriverResult Exported(ContentPart part, TField field, ExportContentContext context) { return null; }
|
||||
|
||||
public ContentShapeResult ContentShape(string shapeType, Func<dynamic> factory) {
|
||||
return ContentShapeImplementation(shapeType, null, ctx => factory());
|
||||
|
@@ -28,11 +28,39 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
: !string.IsNullOrWhiteSpace(context.GroupInfoId) ? Editor(part, context.Updater, context.GroupInfoId, context.New) : Editor(part, context.Updater, context.New);
|
||||
}
|
||||
|
||||
void IContentPartDriver.Importing(ImportContentContext context) {
|
||||
var part = context.ContentItem.As<TContent>();
|
||||
if (part != null)
|
||||
Importing(part, context);
|
||||
}
|
||||
|
||||
void IContentPartDriver.Imported(ImportContentContext context) {
|
||||
var part = context.ContentItem.As<TContent>();
|
||||
if (part != null)
|
||||
Imported(part, context);
|
||||
}
|
||||
|
||||
void IContentPartDriver.Exporting(ExportContentContext context) {
|
||||
var part = context.ContentItem.As<TContent>();
|
||||
if (part != null)
|
||||
Exporting(part, context);
|
||||
}
|
||||
|
||||
void IContentPartDriver.Exported(ExportContentContext context) {
|
||||
var part = context.ContentItem.As<TContent>();
|
||||
if (part != null)
|
||||
Exported(part, context);
|
||||
}
|
||||
|
||||
protected virtual DriverResult Display(TContent part, string displayType, dynamic shapeHelper) { return null; }
|
||||
protected virtual DriverResult Editor(TContent part, dynamic shapeHelper) { return null; }
|
||||
protected virtual DriverResult Editor(TContent part, string groupInfoId, dynamic shapeHelper) { return null; }
|
||||
protected virtual DriverResult Editor(TContent part, IUpdateModel updater, dynamic shapeHelper) { return null; }
|
||||
protected virtual DriverResult Editor(TContent part, IUpdateModel updater, string groupInfoId, dynamic shapeHelper) { return null; }
|
||||
protected virtual void Importing(TContent part, ImportContentContext context) { return; }
|
||||
protected virtual void Imported(TContent part, ImportContentContext context) { return; }
|
||||
protected virtual void Exporting(TContent part, ExportContentContext context) { return; }
|
||||
protected virtual void Exported(TContent part, ExportContentContext context) { return; }
|
||||
|
||||
[Obsolete("Provided while transitioning to factory variations")]
|
||||
public ContentShapeResult ContentShape(IShape shape) {
|
||||
|
@@ -62,5 +62,29 @@ namespace Orchard.ContentManagement.Drivers.Coordinators {
|
||||
result.Apply(context);
|
||||
}, Logger);
|
||||
}
|
||||
|
||||
public override void Importing(ImportContentContext context) {
|
||||
foreach (var contentFieldDriver in _drivers) {
|
||||
contentFieldDriver.Importing(context);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Imported(ImportContentContext context) {
|
||||
foreach (var contentFieldDriver in _drivers) {
|
||||
contentFieldDriver.Imported(context);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Exporting(ExportContentContext context) {
|
||||
foreach (var contentFieldDriver in _drivers) {
|
||||
contentFieldDriver.Exporting(context);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Exported(ExportContentContext context) {
|
||||
foreach (var contentFieldDriver in _drivers) {
|
||||
contentFieldDriver.Exported(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -59,5 +59,29 @@ namespace Orchard.ContentManagement.Drivers.Coordinators {
|
||||
result.Apply(context);
|
||||
}, Logger);
|
||||
}
|
||||
|
||||
public override void Importing(ImportContentContext context) {
|
||||
foreach (var contentPartDriver in _drivers) {
|
||||
contentPartDriver.Importing(context);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Imported(ImportContentContext context) {
|
||||
foreach (var contentPartDriver in _drivers) {
|
||||
contentPartDriver.Imported(context);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Exporting(ExportContentContext context) {
|
||||
foreach (var contentPartDriver in _drivers) {
|
||||
contentPartDriver.Exporting(context);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Exported(ExportContentContext context) {
|
||||
foreach (var contentPartDriver in _drivers) {
|
||||
contentPartDriver.Exported(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -7,7 +7,10 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
DriverResult BuildDisplayShape(BuildDisplayContext context);
|
||||
DriverResult BuildEditorShape(BuildEditorContext context);
|
||||
DriverResult UpdateEditorShape(UpdateEditorContext context);
|
||||
|
||||
void Importing(ImportContentContext context);
|
||||
void Imported(ImportContentContext context);
|
||||
void Exporting(ExportContentContext context);
|
||||
void Exported(ExportContentContext context);
|
||||
IEnumerable<ContentFieldInfo> GetFieldInfo();
|
||||
}
|
||||
}
|
@@ -7,7 +7,10 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
DriverResult BuildDisplay(BuildDisplayContext context);
|
||||
DriverResult BuildEditor(BuildEditorContext context);
|
||||
DriverResult UpdateEditor(UpdateEditorContext context);
|
||||
|
||||
void Importing(ImportContentContext context);
|
||||
void Imported(ImportContentContext context);
|
||||
void Exporting(ExportContentContext context);
|
||||
void Exported(ExportContentContext context);
|
||||
IEnumerable<ContentPartInfo> GetPartInfo();
|
||||
}
|
||||
}
|
@@ -283,6 +283,22 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
Indexed(context);
|
||||
}
|
||||
|
||||
void IContentHandler.Importing(ImportContentContext context) {
|
||||
Importing(context);
|
||||
}
|
||||
|
||||
void IContentHandler.Imported(ImportContentContext context) {
|
||||
Imported(context);
|
||||
}
|
||||
|
||||
void IContentHandler.Exporting(ExportContentContext context) {
|
||||
Exporting(context);
|
||||
}
|
||||
|
||||
void IContentHandler.Exported(ExportContentContext context) {
|
||||
Exported(context);
|
||||
}
|
||||
|
||||
void IContentHandler.GetContentItemMetadata(GetContentItemMetadataContext context) {
|
||||
foreach (var filter in Filters.OfType<IContentTemplateFilter>())
|
||||
filter.GetContentItemMetadata(context);
|
||||
@@ -330,6 +346,11 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
protected virtual void Indexing(IndexContentContext context) { }
|
||||
protected virtual void Indexed(IndexContentContext context) { }
|
||||
|
||||
protected virtual void Importing(ImportContentContext context) { }
|
||||
protected virtual void Imported(ImportContentContext context) { }
|
||||
protected virtual void Exporting(ExportContentContext context) { }
|
||||
protected virtual void Exported(ExportContentContext context) { }
|
||||
|
||||
protected virtual void GetItemMetadata(GetContentItemMetadataContext context) { }
|
||||
protected virtual void BuildDisplayShape(BuildDisplayContext context) { }
|
||||
protected virtual void BuildEditorShape(BuildEditorContext context) { }
|
||||
|
@@ -11,12 +11,16 @@
|
||||
public virtual void Versioned(VersionContentContext context) {}
|
||||
public virtual void Publishing(PublishContentContext context) {}
|
||||
public virtual void Published(PublishContentContext context) {}
|
||||
public virtual void Unpublishing(PublishContentContext context) { }
|
||||
public virtual void Unpublished(PublishContentContext context) { }
|
||||
public virtual void Removing(RemoveContentContext context) { }
|
||||
public virtual void Unpublishing(PublishContentContext context) {}
|
||||
public virtual void Unpublished(PublishContentContext context) {}
|
||||
public virtual void Removing(RemoveContentContext context) {}
|
||||
public virtual void Removed(RemoveContentContext context) {}
|
||||
public virtual void Indexing(IndexContentContext context) {}
|
||||
public virtual void Indexed(IndexContentContext context) {}
|
||||
public virtual void Importing(ImportContentContext context) {}
|
||||
public virtual void Imported(ImportContentContext context) {}
|
||||
public virtual void Exporting(ExportContentContext context) {}
|
||||
public virtual void Exported(ExportContentContext context) {}
|
||||
|
||||
public virtual void GetContentItemMetadata(GetContentItemMetadataContext context) {}
|
||||
public virtual void BuildDisplay(BuildDisplayContext context) {}
|
||||
|
@@ -0,0 +1,13 @@
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Orchard.ContentManagement.Handlers {
|
||||
public class ExportContentContext : ContentContextBase {
|
||||
|
||||
public XElement Data { get; set; }
|
||||
|
||||
public ExportContentContext(ContentItem contentItem, XElement data)
|
||||
: base(contentItem) {
|
||||
Data = data;
|
||||
}
|
||||
}
|
||||
}
|
@@ -17,6 +17,10 @@
|
||||
void Removed(RemoveContentContext context);
|
||||
void Indexing(IndexContentContext context);
|
||||
void Indexed(IndexContentContext context);
|
||||
void Importing(ImportContentContext context);
|
||||
void Imported(ImportContentContext context);
|
||||
void Exporting(ExportContentContext context);
|
||||
void Exported(ExportContentContext context);
|
||||
|
||||
void GetContentItemMetadata(GetContentItemMetadataContext context);
|
||||
void BuildDisplay(BuildDisplayContext context);
|
||||
|
@@ -0,0 +1,13 @@
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Orchard.ContentManagement.Handlers {
|
||||
public class ImportContentContext : ContentContextBase {
|
||||
|
||||
public XElement Data { get; set; }
|
||||
|
||||
public ImportContentContext(ContentItem contentItem, XElement data)
|
||||
: base(contentItem) {
|
||||
Data = data;
|
||||
}
|
||||
}
|
||||
}
|
@@ -156,6 +156,8 @@
|
||||
<Compile Include="ContentManagement\Drivers\ContentShapeResult.cs" />
|
||||
<Compile Include="ContentManagement\GroupInfo.cs" />
|
||||
<Compile Include="ContentManagement\Handlers\BuildShapeContext.cs" />
|
||||
<Compile Include="ContentManagement\Handlers\ExportContentContext.cs" />
|
||||
<Compile Include="ContentManagement\Handlers\ImportContentContext.cs" />
|
||||
<Compile Include="ContentManagement\IContentBehavior.cs" />
|
||||
<Compile Include="ContentManagement\Utilities\ComputedField.cs" />
|
||||
<Compile Include="DisplayManagement\Descriptors\PlacementInfo.cs" />
|
||||
|
Reference in New Issue
Block a user