mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 19:04:51 +08:00
Creating helpers for settings based metadata scenarios to be used in migrations, fixes #4693
This commit is contained in:
@@ -68,9 +68,7 @@ namespace Orchard.Blogs {
|
|||||||
ContentDefinitionManager.AlterTypeDefinition("RecentBlogPosts",
|
ContentDefinitionManager.AlterTypeDefinition("RecentBlogPosts",
|
||||||
cfg => cfg
|
cfg => cfg
|
||||||
.WithPart("RecentBlogPostsPart")
|
.WithPart("RecentBlogPostsPart")
|
||||||
.WithPart("CommonPart")
|
.AsWidgetWithIdentity()
|
||||||
.WithPart("WidgetPart")
|
|
||||||
.WithSetting("Stereotype", "Widget")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
ContentDefinitionManager.AlterPartDefinition("BlogArchivesPart", part => part
|
ContentDefinitionManager.AlterPartDefinition("BlogArchivesPart", part => part
|
||||||
@@ -134,6 +132,11 @@ namespace Orchard.Blogs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int UpdateFrom6() {
|
public int UpdateFrom6() {
|
||||||
|
ContentDefinitionManager.AlterTypeDefinition("RecentBlogPosts",
|
||||||
|
cfg => cfg
|
||||||
|
.WithPart("IdentityPart")
|
||||||
|
);
|
||||||
|
|
||||||
ContentDefinitionManager.AlterTypeDefinition("BlogArchives",
|
ContentDefinitionManager.AlterTypeDefinition("BlogArchives",
|
||||||
cfg => cfg
|
cfg => cfg
|
||||||
.WithPart("IdentityPart")
|
.WithPart("IdentityPart")
|
||||||
|
@@ -167,6 +167,10 @@
|
|||||||
<Project>{f301ef7d-f19c-4d83-aa94-cb64f29c037d}</Project>
|
<Project>{f301ef7d-f19c-4d83-aa94-cb64f29c037d}</Project>
|
||||||
<Name>Orchard.ContentPicker</Name>
|
<Name>Orchard.ContentPicker</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\Orchard.Widgets\Orchard.Widgets.csproj">
|
||||||
|
<Project>{194d3ccc-1153-474d-8176-fde8d7d0d0bd}</Project>
|
||||||
|
<Name>Orchard.Widgets</Name>
|
||||||
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Placement.info">
|
<Content Include="Placement.info">
|
||||||
|
@@ -56,15 +56,14 @@ namespace Orchard.DynamicForms {
|
|||||||
.Draftable());
|
.Draftable());
|
||||||
|
|
||||||
ContentDefinitionManager.AlterTypeDefinition("FormWidget", type => type
|
ContentDefinitionManager.AlterTypeDefinition("FormWidget", type => type
|
||||||
|
.AsWidgetWithIdentity()
|
||||||
|
.WithPart("LayoutPart", p => p
|
||||||
|
.WithSetting("LayoutTypePartSettings.DefaultLayoutData", DefaultFormLayoutData))
|
||||||
.WithPart("CommonPart", p => p
|
.WithPart("CommonPart", p => p
|
||||||
.WithSetting("OwnerEditorSettings.ShowOwnerEditor", "false")
|
.WithSetting("OwnerEditorSettings.ShowOwnerEditor", "false")
|
||||||
.WithSetting("DateEditorSettings.ShowDateEditor", "false"))
|
.WithSetting("DateEditorSettings.ShowDateEditor", "false"))
|
||||||
.WithPart("WidgetPart")
|
|
||||||
.WithPart("LayoutPart", p => p
|
|
||||||
.WithSetting("LayoutTypePartSettings.DefaultLayoutData", DefaultFormLayoutData))
|
|
||||||
.WithSetting("Stereotype", "Widget")
|
|
||||||
.DisplayedAs("Form Widget"));
|
.DisplayedAs("Form Widget"));
|
||||||
return 2;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int UpdateFrom1() {
|
public int UpdateFrom1() {
|
||||||
@@ -107,6 +106,13 @@ namespace Orchard.DynamicForms {
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int UpdateFrom2() {
|
||||||
|
ContentDefinitionManager.AlterTypeDefinition("FormWidget", type => type
|
||||||
|
.WithPart("IdentityPart"));
|
||||||
|
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
private byte[] GetMD5(string text) {
|
private byte[] GetMD5(string text) {
|
||||||
byte[] encodedText = System.Text.Encoding.UTF8.GetBytes(text);
|
byte[] encodedText = System.Text.Encoding.UTF8.GetBytes(text);
|
||||||
return ((HashAlgorithm)CryptoConfig.CreateFromName("MD5")).ComputeHash(encodedText);
|
return ((HashAlgorithm)CryptoConfig.CreateFromName("MD5")).ComputeHash(encodedText);
|
||||||
|
@@ -154,6 +154,10 @@
|
|||||||
<Project>{79aed36e-abd0-4747-93d3-8722b042454b}</Project>
|
<Project>{79aed36e-abd0-4747-93d3-8722b042454b}</Project>
|
||||||
<Name>Orchard.Users</Name>
|
<Name>Orchard.Users</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\Orchard.Widgets\Orchard.Widgets.csproj">
|
||||||
|
<Project>{194d3ccc-1153-474d-8176-fde8d7d0d0bd}</Project>
|
||||||
|
<Name>Orchard.Widgets</Name>
|
||||||
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\Orchard.Workflows\Orchard.Workflows.csproj">
|
<ProjectReference Include="..\Orchard.Workflows\Orchard.Workflows.csproj">
|
||||||
<Project>{7059493c-8251-4764-9c1e-2368b8b485bc}</Project>
|
<Project>{7059493c-8251-4764-9c1e-2368b8b485bc}</Project>
|
||||||
<Name>Orchard.Workflows</Name>
|
<Name>Orchard.Workflows</Name>
|
||||||
|
@@ -0,0 +1,65 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
using Orchard.ContentManagement.MetaData.Builders;
|
||||||
|
|
||||||
|
namespace Orchard.ContentManagement.MetaData {
|
||||||
|
public static class MetaDataExtensions {
|
||||||
|
/// <summary>
|
||||||
|
/// This extension method can be used for easy image part creation. Adds all necessary parts and settings to the part.
|
||||||
|
/// </summary>
|
||||||
|
public static ContentTypeDefinitionBuilder AsImage(this ContentTypeDefinitionBuilder builder) {
|
||||||
|
return builder
|
||||||
|
.AsMedia()
|
||||||
|
.WithPart("ImagePart");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This extension method can be used for easy vector image part creation. Adds all necessary parts and settings to the part.
|
||||||
|
/// </summary>
|
||||||
|
public static ContentTypeDefinitionBuilder AsVectorImage(this ContentTypeDefinitionBuilder builder) {
|
||||||
|
return builder
|
||||||
|
.AsMedia()
|
||||||
|
.WithPart("VectorImagePart");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This extension method can be used for easy audio part creation. Adds all necessary parts and settings to the part.
|
||||||
|
/// </summary>
|
||||||
|
public static ContentTypeDefinitionBuilder AsAudio(this ContentTypeDefinitionBuilder builder) {
|
||||||
|
return builder
|
||||||
|
.AsMedia()
|
||||||
|
.WithPart("AudioPart");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This extension method can be used for video image part creation. Adds all necessary parts and settings to the part.
|
||||||
|
/// </summary>
|
||||||
|
public static ContentTypeDefinitionBuilder AsVideo(this ContentTypeDefinitionBuilder builder) {
|
||||||
|
return builder
|
||||||
|
.AsMedia()
|
||||||
|
.WithPart("VideoPart");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This extension method can be used for easy document part creation. Adds all necessary parts and settings to the part.
|
||||||
|
/// </summary>
|
||||||
|
public static ContentTypeDefinitionBuilder AsDocument(this ContentTypeDefinitionBuilder builder) {
|
||||||
|
return builder
|
||||||
|
.AsMedia()
|
||||||
|
.WithPart("DocumentPart");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This extension method can be used for easy media part creation. Adds all necessary parts and settings to the part.
|
||||||
|
/// </summary>
|
||||||
|
public static ContentTypeDefinitionBuilder AsMedia(this ContentTypeDefinitionBuilder builder) {
|
||||||
|
return builder
|
||||||
|
.WithSetting("Stereotype", "Media")
|
||||||
|
.WithPart("CommonPart")
|
||||||
|
.WithPart("MediaPart")
|
||||||
|
.WithPart("TitlePart");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -57,57 +57,37 @@ namespace Orchard.MediaLibrary {
|
|||||||
|
|
||||||
ContentDefinitionManager.AlterTypeDefinition("Image", td => td
|
ContentDefinitionManager.AlterTypeDefinition("Image", td => td
|
||||||
.DisplayedAs("Image")
|
.DisplayedAs("Image")
|
||||||
.WithSetting("Stereotype", "Media")
|
|
||||||
.WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True")
|
.WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True")
|
||||||
|
.AsImage()
|
||||||
.WithPart("IdentityPart")
|
.WithPart("IdentityPart")
|
||||||
.WithPart("CommonPart")
|
|
||||||
.WithPart("MediaPart")
|
|
||||||
.WithPart("ImagePart")
|
|
||||||
.WithPart("TitlePart")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
ContentDefinitionManager.AlterTypeDefinition("VectorImage", td => td
|
ContentDefinitionManager.AlterTypeDefinition("VectorImage", td => td
|
||||||
.DisplayedAs("Vector Image")
|
.DisplayedAs("Vector Image")
|
||||||
.WithSetting("Stereotype", "Media")
|
|
||||||
.WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True")
|
.WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True")
|
||||||
|
.AsVectorImage()
|
||||||
.WithPart("IdentityPart")
|
.WithPart("IdentityPart")
|
||||||
.WithPart("CommonPart")
|
|
||||||
.WithPart("MediaPart")
|
|
||||||
.WithPart("VectorImagePart")
|
|
||||||
.WithPart("TitlePart")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
ContentDefinitionManager.AlterTypeDefinition("Video", td => td
|
ContentDefinitionManager.AlterTypeDefinition("Video", td => td
|
||||||
.DisplayedAs("Video")
|
.DisplayedAs("Video")
|
||||||
.WithSetting("Stereotype", "Media")
|
|
||||||
.WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True")
|
.WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True")
|
||||||
|
.AsVideo()
|
||||||
.WithPart("IdentityPart")
|
.WithPart("IdentityPart")
|
||||||
.WithPart("CommonPart")
|
|
||||||
.WithPart("MediaPart")
|
|
||||||
.WithPart("VideoPart")
|
|
||||||
.WithPart("TitlePart")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
ContentDefinitionManager.AlterTypeDefinition("Audio", td => td
|
ContentDefinitionManager.AlterTypeDefinition("Audio", td => td
|
||||||
.DisplayedAs("Audio")
|
.DisplayedAs("Audio")
|
||||||
.WithSetting("Stereotype", "Media")
|
|
||||||
.WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True")
|
.WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True")
|
||||||
|
.AsAudio()
|
||||||
.WithPart("IdentityPart")
|
.WithPart("IdentityPart")
|
||||||
.WithPart("CommonPart")
|
|
||||||
.WithPart("MediaPart")
|
|
||||||
.WithPart("AudioPart")
|
|
||||||
.WithPart("TitlePart")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
ContentDefinitionManager.AlterTypeDefinition("Document", td => td
|
ContentDefinitionManager.AlterTypeDefinition("Document", td => td
|
||||||
.DisplayedAs("Document")
|
.DisplayedAs("Document")
|
||||||
.WithSetting("Stereotype", "Media")
|
|
||||||
.WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True")
|
.WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True")
|
||||||
|
.AsDocument()
|
||||||
.WithPart("IdentityPart")
|
.WithPart("IdentityPart")
|
||||||
.WithPart("CommonPart")
|
|
||||||
.WithPart("MediaPart")
|
|
||||||
.WithPart("DocumentPart")
|
|
||||||
.WithPart("TitlePart")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
ContentDefinitionManager.AlterTypeDefinition("OEmbed", td => td
|
ContentDefinitionManager.AlterTypeDefinition("OEmbed", td => td
|
||||||
|
@@ -101,6 +101,7 @@
|
|||||||
<Content Include="Scripts\Web.config" />
|
<Content Include="Scripts\Web.config" />
|
||||||
<Content Include="Styles\Web.config" />
|
<Content Include="Styles\Web.config" />
|
||||||
<Compile Include="Drivers\VectorImagePartDriver.cs" />
|
<Compile Include="Drivers\VectorImagePartDriver.cs" />
|
||||||
|
<Compile Include="Extensions\MetaDataExtensions.cs" />
|
||||||
<Compile Include="Factories\VectorImageFactory.cs" />
|
<Compile Include="Factories\VectorImageFactory.cs" />
|
||||||
<Compile Include="Handlers\MediaLibrarySettingsPartHandler.cs" />
|
<Compile Include="Handlers\MediaLibrarySettingsPartHandler.cs" />
|
||||||
<Compile Include="Models\MediaLibrarySettingsPart.cs" />
|
<Compile Include="Models\MediaLibrarySettingsPart.cs" />
|
||||||
|
@@ -11,10 +11,7 @@ namespace Orchard.Search {
|
|||||||
ContentDefinitionManager.AlterTypeDefinition("SearchForm",
|
ContentDefinitionManager.AlterTypeDefinition("SearchForm",
|
||||||
cfg => cfg
|
cfg => cfg
|
||||||
.WithPart("SearchFormPart")
|
.WithPart("SearchFormPart")
|
||||||
.WithPart("CommonPart")
|
.AsWidgetWithIdentity()
|
||||||
.WithPart("WidgetPart")
|
|
||||||
.WithPart("IdentityPart")
|
|
||||||
.WithSetting("Stereotype", "Widget")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return 3;
|
return 3;
|
||||||
|
@@ -105,6 +105,10 @@
|
|||||||
<Project>{73a7688a-5bd3-4f7e-adfa-ce36c5a10e3b}</Project>
|
<Project>{73a7688a-5bd3-4f7e-adfa-ce36c5a10e3b}</Project>
|
||||||
<Name>Orchard.MediaLibrary</Name>
|
<Name>Orchard.MediaLibrary</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\Orchard.Widgets\Orchard.Widgets.csproj">
|
||||||
|
<Project>{194d3ccc-1153-474d-8176-fde8d7d0d0bd}</Project>
|
||||||
|
<Name>Orchard.Widgets</Name>
|
||||||
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Module.txt" />
|
<Content Include="Module.txt" />
|
||||||
|
@@ -47,9 +47,7 @@ namespace Orchard.Tags {
|
|||||||
"TagCloud",
|
"TagCloud",
|
||||||
cfg => cfg
|
cfg => cfg
|
||||||
.WithPart("TagCloudPart")
|
.WithPart("TagCloudPart")
|
||||||
.WithPart("CommonPart")
|
.AsWidget()
|
||||||
.WithPart("WidgetPart")
|
|
||||||
.WithSetting("Stereotype", "Widget")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -135,6 +135,10 @@
|
|||||||
<Project>{66FCCD76-2761-47E3-8D11-B45D0001DDAA}</Project>
|
<Project>{66FCCD76-2761-47E3-8D11-B45D0001DDAA}</Project>
|
||||||
<Name>Orchard.Autoroute</Name>
|
<Name>Orchard.Autoroute</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\Orchard.Widgets\Orchard.Widgets.csproj">
|
||||||
|
<Project>{194d3ccc-1153-474d-8176-fde8d7d0d0bd}</Project>
|
||||||
|
<Name>Orchard.Widgets</Name>
|
||||||
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Placement.info">
|
<Content Include="Placement.info">
|
||||||
|
@@ -0,0 +1,32 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
using Orchard.ContentManagement.MetaData.Builders;
|
||||||
|
|
||||||
|
namespace Orchard.ContentManagement.MetaData {
|
||||||
|
public static class MetaDataExtensions {
|
||||||
|
/// <summary>
|
||||||
|
/// This extension method can be used for easy widget creation. Adds all necessary parts and settings to the part.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The ContentTypeDefinitionBuilder object on which this method is called.</returns>
|
||||||
|
public static ContentTypeDefinitionBuilder AsWidget(this ContentTypeDefinitionBuilder builder) {
|
||||||
|
return builder
|
||||||
|
.WithPart("CommonPart")
|
||||||
|
.WithPart("WidgetPart")
|
||||||
|
.WithSetting("Stereotype", "Widget");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This extension method can be used for easy widget creation. Adds all necessary parts and settings to the part. And adds IdentityPart too.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The ContentTypeDefinitionBuilder object on which this method is called.</returns>
|
||||||
|
public static ContentTypeDefinitionBuilder AsWidgetWithIdentity(this ContentTypeDefinitionBuilder builder) {
|
||||||
|
return builder
|
||||||
|
.WithPart("CommonPart")
|
||||||
|
.WithPart("WidgetPart")
|
||||||
|
.WithPart("IdentityPart")
|
||||||
|
.WithSetting("Stereotype", "Widget");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -36,11 +36,8 @@ namespace Orchard.Widgets {
|
|||||||
|
|
||||||
ContentDefinitionManager.AlterTypeDefinition("HtmlWidget",
|
ContentDefinitionManager.AlterTypeDefinition("HtmlWidget",
|
||||||
cfg => cfg
|
cfg => cfg
|
||||||
.WithPart("WidgetPart")
|
|
||||||
.WithPart("BodyPart")
|
.WithPart("BodyPart")
|
||||||
.WithPart("CommonPart")
|
.AsWidgetWithIdentity()
|
||||||
.WithPart("IdentityPart")
|
|
||||||
.WithSetting("Stereotype", "Widget")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return 5;
|
return 5;
|
||||||
|
@@ -72,6 +72,7 @@
|
|||||||
<Compile Include="Controllers\AdminController.cs" />
|
<Compile Include="Controllers\AdminController.cs" />
|
||||||
<Compile Include="ControlWrapper.cs" />
|
<Compile Include="ControlWrapper.cs" />
|
||||||
<Compile Include="Drivers\LayerPartDriver.cs" />
|
<Compile Include="Drivers\LayerPartDriver.cs" />
|
||||||
|
<Compile Include="Extensions\MetaDataExtensions.cs" />
|
||||||
<Compile Include="Handlers\DisplayedContentItemHandler.cs" />
|
<Compile Include="Handlers\DisplayedContentItemHandler.cs" />
|
||||||
<Compile Include="Handlers\LayerHintHandler.cs" />
|
<Compile Include="Handlers\LayerHintHandler.cs" />
|
||||||
<Compile Include="Drivers\WidgetPartDriver.cs" />
|
<Compile Include="Drivers\WidgetPartDriver.cs" />
|
||||||
|
Reference in New Issue
Block a user