mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
#19907: Implementing Media and Media Library fields import/export
--HG-- branch : 1.x
This commit is contained in:
@@ -34,5 +34,40 @@ namespace Orchard.MediaLibrary.Drivers {
|
|||||||
protected override DriverResult Editor(MediaPart part, dynamic shapeHelper) {
|
protected override DriverResult Editor(MediaPart part, dynamic shapeHelper) {
|
||||||
return ContentShape("Parts_Media_Edit", () => shapeHelper.EditorTemplate(TemplateName: "Parts.Media.Edit", Model: part, Prefix: Prefix));
|
return ContentShape("Parts_Media_Edit", () => shapeHelper.EditorTemplate(TemplateName: "Parts.Media.Edit", Model: part, Prefix: Prefix));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Importing(MediaPart part, ContentManagement.Handlers.ImportContentContext context) {
|
||||||
|
var mimeType = context.Attribute(part.PartDefinition.Name, "MimeType");
|
||||||
|
if (mimeType != null) {
|
||||||
|
part.MimeType = mimeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
var caption = context.Attribute(part.PartDefinition.Name, "Caption");
|
||||||
|
if (caption != null) {
|
||||||
|
part.Caption = caption;
|
||||||
|
}
|
||||||
|
|
||||||
|
var alternateText = context.Attribute(part.PartDefinition.Name, "AlternateText");
|
||||||
|
if (alternateText != null) {
|
||||||
|
part.AlternateText = alternateText;
|
||||||
|
}
|
||||||
|
|
||||||
|
var folderPath = context.Attribute(part.PartDefinition.Name, "FolderPath");
|
||||||
|
if (folderPath != null) {
|
||||||
|
part.FolderPath = folderPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
var fileName = context.Attribute(part.PartDefinition.Name, "FileName");
|
||||||
|
if (fileName != null) {
|
||||||
|
part.FileName = fileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Exporting(MediaPart part, ContentManagement.Handlers.ExportContentContext context) {
|
||||||
|
context.Element(part.PartDefinition.Name).SetAttributeValue("MimeType", part.MimeType);
|
||||||
|
context.Element(part.PartDefinition.Name).SetAttributeValue("Caption", part.Caption);
|
||||||
|
context.Element(part.PartDefinition.Name).SetAttributeValue("AlternateText", part.AlternateText);
|
||||||
|
context.Element(part.PartDefinition.Name).SetAttributeValue("FolderPath", part.FolderPath);
|
||||||
|
context.Element(part.PartDefinition.Name).SetAttributeValue("FileName", part.FileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -63,5 +63,28 @@ namespace Orchard.MediaLibrary {
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int UpdateFrom2() {
|
||||||
|
ContentDefinitionManager.AlterTypeDefinition("Image", td => td
|
||||||
|
.WithPart("IdentityPart")
|
||||||
|
);
|
||||||
|
|
||||||
|
ContentDefinitionManager.AlterTypeDefinition("Video", td => td
|
||||||
|
.WithPart("IdentityPart")
|
||||||
|
);
|
||||||
|
|
||||||
|
ContentDefinitionManager.AlterTypeDefinition("Audio", td => td
|
||||||
|
.WithPart("IdentityPart")
|
||||||
|
);
|
||||||
|
|
||||||
|
ContentDefinitionManager.AlterTypeDefinition("Document", td => td
|
||||||
|
.WithPart("IdentityPart")
|
||||||
|
);
|
||||||
|
|
||||||
|
ContentDefinitionManager.AlterTypeDefinition("OEmbed", td => td
|
||||||
|
.WithPart("IdentityPart")
|
||||||
|
);
|
||||||
|
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user