2014-10-15 07:07:00 +08:00
|
|
|
using System;
|
|
|
|
using System.Linq;
|
|
|
|
using Orchard.Layouts.Framework.Display;
|
|
|
|
using Orchard.Layouts.Framework.Elements;
|
|
|
|
|
|
|
|
namespace Orchard.Layouts.Framework.Drivers {
|
2015-02-20 05:14:55 +08:00
|
|
|
public abstract class ElementDriver<TElement> : Component, IElementDriver where TElement: Element {
|
2014-10-15 07:07:00 +08:00
|
|
|
public virtual int Priority {
|
|
|
|
get { return 0; }
|
|
|
|
}
|
|
|
|
|
|
|
|
public EditorResult BuildEditor(ElementEditorContext context) {
|
|
|
|
return OnBuildEditor((TElement) context.Element, context);
|
|
|
|
}
|
|
|
|
|
|
|
|
public EditorResult UpdateEditor(ElementEditorContext context) {
|
|
|
|
return OnUpdateEditor((TElement)context.Element, context);
|
|
|
|
}
|
|
|
|
|
2015-04-20 00:43:05 +08:00
|
|
|
public void CreatingDisplay(ElementCreatingDisplayShapeContext context) {
|
|
|
|
OnCreatingDisplay((TElement)context.Element, context);
|
|
|
|
}
|
|
|
|
|
2015-04-04 23:22:17 +08:00
|
|
|
public void Displaying(ElementDisplayingContext context) {
|
2014-10-15 07:07:00 +08:00
|
|
|
OnDisplaying((TElement) context.Element, context);
|
|
|
|
}
|
|
|
|
|
2015-04-04 23:22:17 +08:00
|
|
|
public void Displayed(ElementDisplayedContext context) {
|
|
|
|
OnDisplayed((TElement)context.Element, context);
|
|
|
|
}
|
|
|
|
|
2014-10-15 07:07:00 +08:00
|
|
|
public void LayoutSaving(ElementSavingContext context) {
|
|
|
|
OnLayoutSaving((TElement) context.Element, context);
|
|
|
|
}
|
|
|
|
|
2014-11-14 07:13:39 +08:00
|
|
|
public void Removing(ElementRemovingContext context) {
|
|
|
|
OnRemoving((TElement) context.Element, context);
|
|
|
|
}
|
|
|
|
|
2014-11-14 10:25:05 +08:00
|
|
|
public void Exporting(ExportElementContext context) {
|
|
|
|
OnExporting((TElement)context.Element, context);
|
|
|
|
}
|
|
|
|
|
2015-09-29 21:20:12 +08:00
|
|
|
public void Exported(ExportElementContext context) {
|
|
|
|
OnExported((TElement)context.Element, context);
|
|
|
|
}
|
|
|
|
|
2014-11-14 10:25:05 +08:00
|
|
|
public void Importing(ImportElementContext context) {
|
|
|
|
OnImporting((TElement)context.Element, context);
|
|
|
|
}
|
|
|
|
|
2015-09-29 21:20:12 +08:00
|
|
|
public void Imported(ImportElementContext context) {
|
|
|
|
OnImported((TElement)context.Element, context);
|
|
|
|
}
|
|
|
|
|
2015-10-10 05:52:35 +08:00
|
|
|
public void ImportCompleted(ImportElementContext context) {
|
|
|
|
OnImportCompleted((TElement)context.Element, context);
|
|
|
|
}
|
|
|
|
|
2014-10-15 07:07:00 +08:00
|
|
|
protected virtual EditorResult OnBuildEditor(TElement element, ElementEditorContext context) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected virtual EditorResult OnUpdateEditor(TElement element, ElementEditorContext context) {
|
|
|
|
return OnBuildEditor(element, context);
|
|
|
|
}
|
|
|
|
|
2015-04-20 00:43:05 +08:00
|
|
|
protected virtual void OnCreatingDisplay(TElement element, ElementCreatingDisplayShapeContext context) {
|
|
|
|
}
|
|
|
|
|
2015-04-04 23:22:17 +08:00
|
|
|
protected virtual void OnDisplaying(TElement element, ElementDisplayingContext context) {
|
|
|
|
}
|
|
|
|
|
|
|
|
protected virtual void OnDisplayed(TElement element, ElementDisplayedContext context) {
|
2014-10-15 07:07:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected virtual void OnLayoutSaving(TElement element, ElementSavingContext context) {
|
|
|
|
}
|
|
|
|
|
2014-11-14 07:13:39 +08:00
|
|
|
protected virtual void OnRemoving(TElement element, ElementRemovingContext context) {
|
|
|
|
}
|
|
|
|
|
2014-11-14 10:25:05 +08:00
|
|
|
protected virtual void OnExporting(TElement element, ExportElementContext context) {
|
|
|
|
}
|
|
|
|
|
2015-09-29 21:20:12 +08:00
|
|
|
protected virtual void OnExported(TElement element, ExportElementContext context) {
|
|
|
|
}
|
|
|
|
|
2014-11-14 10:25:05 +08:00
|
|
|
protected virtual void OnImporting(TElement element, ImportElementContext context) {
|
|
|
|
}
|
|
|
|
|
2015-09-29 21:20:12 +08:00
|
|
|
protected virtual void OnImported(TElement element, ImportElementContext context) {
|
|
|
|
}
|
|
|
|
|
2015-10-10 05:52:35 +08:00
|
|
|
protected virtual void OnImportCompleted(TElement element, ImportElementContext context) {
|
|
|
|
}
|
|
|
|
|
2014-10-15 07:07:00 +08:00
|
|
|
protected EditorResult Editor(ElementEditorContext context, params dynamic[] editorShapes) {
|
|
|
|
foreach (var editorShape in editorShapes) {
|
|
|
|
if (String.IsNullOrWhiteSpace(editorShape.Metadata.Position)) {
|
|
|
|
editorShape.Metadata.Position = "Properties:0";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var result = new EditorResult {
|
|
|
|
Editors = editorShapes.ToList()
|
|
|
|
};
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|