mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Added backward compatibility with Metadata and Data recipe steps and added more granular control over ordering.
This commit is contained in:
@@ -33,7 +33,7 @@ namespace Orchard.ImportExport.Providers.ExportActions {
|
||||
}
|
||||
|
||||
public override dynamic UpdateEditor(dynamic shapeFactory, IUpdateModel updater) {
|
||||
var builderSteps = _recipeBuilderSteps.OrderByDescending(x => x.Priority).Select(x => new ExportStepViewModel {
|
||||
var builderSteps = _recipeBuilderSteps.OrderBy(x => x.Position).Select(x => new ExportStepViewModel {
|
||||
Name = x.Name,
|
||||
DisplayName = x.DisplayName,
|
||||
Description = x.Description,
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using System.Xml.Linq;
|
||||
|
||||
@@ -30,7 +30,8 @@ namespace Orchard.ImportExport.Recipes.Builders {
|
||||
get { return T("Exports additional items."); }
|
||||
}
|
||||
|
||||
public override int Priority { get { return 60; } }
|
||||
public override int Priority { get { return -50; } }
|
||||
public override int Position { get { return 500; } }
|
||||
|
||||
public IList<string> CustomSteps { get; set; }
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Orchard.FileSystems.AppData;
|
||||
using Orchard.Localization;
|
||||
|
||||
@@ -143,7 +143,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<Content Include="Views\EditorTemplates\ExportSteps\Feature.cshtml" />
|
||||
<Content Include="Views\EditorTemplates\BuilderSteps\Feature.cshtml" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
|
||||
@@ -27,7 +27,8 @@ namespace Orchard.Modules.Recipes.Builders {
|
||||
get { return T("Exports enabled and disabled features."); }
|
||||
}
|
||||
|
||||
public override int Priority { get { return 0; } }
|
||||
public override int Priority { get { return 500; } }
|
||||
public override int Position { get { return 70; } }
|
||||
|
||||
public bool ExportEnabledFeatures { get; set; }
|
||||
public bool ExportDisabledFeatures { get; set; }
|
||||
@@ -44,7 +45,7 @@ namespace Orchard.Modules.Recipes.Builders {
|
||||
ExportDisabledFeatures = viewModel.ExportDisabledFeatures;
|
||||
}
|
||||
|
||||
return shapeFactory.EditorTemplate(TemplateName: "ExportSteps/Feature", Model: viewModel, Prefix: Prefix);
|
||||
return shapeFactory.EditorTemplate(TemplateName: "BuilderSteps/Feature", Model: viewModel, Prefix: Prefix);
|
||||
}
|
||||
|
||||
public override void Build(BuildContext context) {
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
<Compile Include="Providers\Executors\CommandStep.cs" />
|
||||
<Compile Include="ViewModels\ContentExecutionStepViewModel.cs" />
|
||||
<Compile Include="Providers\Executors\ContentStep.cs" />
|
||||
<Compile Include="Providers\Executors\ContentSchemaStep.cs" />
|
||||
<Compile Include="Providers\Executors\ContentDefinitionStep.cs" />
|
||||
<Compile Include="Providers\Executors\MigrationStep.cs" />
|
||||
<Compile Include="Providers\Executors\ModuleStep.cs" />
|
||||
<Compile Include="Providers\Executors\SettingsStep.cs" />
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace Orchard.Recipes.Providers.Builders {
|
||||
}
|
||||
|
||||
public override int Priority { get { return 20; } }
|
||||
public override int Position { get { return 20; } }
|
||||
|
||||
public IList<string> SchemaContentTypes { get; set; }
|
||||
public IList<string> DataContentTypes { get; set; }
|
||||
@@ -103,7 +104,7 @@ namespace Orchard.Recipes.Providers.Builders {
|
||||
partsElement.Add(_contentDefinitionWriter.Export(part));
|
||||
}
|
||||
|
||||
return new XElement("ContentSchema", typesElement, partsElement);
|
||||
return new XElement("ContentDefinition", typesElement, partsElement);
|
||||
}
|
||||
|
||||
private XElement ExportData(IEnumerable<string> contentTypes, IEnumerable<ContentItem> contentItems) {
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace Orchard.Recipes.Providers.Builders {
|
||||
}
|
||||
|
||||
public override int Priority { get { return 1000; } }
|
||||
public override int Position { get { return -1000; } }
|
||||
|
||||
public string RecipeName { get; set; }
|
||||
public string RecipeDescription { get; set; }
|
||||
|
||||
@@ -26,7 +26,8 @@ namespace Orchard.Recipes.Providers.Builders {
|
||||
get { return T("Exports settings."); }
|
||||
}
|
||||
|
||||
public override int Priority { get { return 10; } }
|
||||
public override int Priority { get { return 30; } }
|
||||
public override int Position { get { return 60; } }
|
||||
|
||||
public override dynamic BuildEditor(dynamic shapeFactory) {
|
||||
return UpdateEditor(shapeFactory, null);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
using Orchard.ContentManagement.MetaData;
|
||||
using Orchard.ContentTypes.Events;
|
||||
@@ -7,14 +8,19 @@ using Orchard.Recipes.Models;
|
||||
using Orchard.Recipes.Services;
|
||||
|
||||
namespace Orchard.Recipes.Providers.Executors {
|
||||
public class ContentSchemaStep : RecipeExecutionStep {
|
||||
public class ContentDefinitionStep : RecipeExecutionStep {
|
||||
private readonly IContentDefinitionManager _contentDefinitionManager;
|
||||
private readonly IContentDefinitionReader _contentDefinitionReader;
|
||||
private readonly IContentDefinitionEventHandler _contentDefinitonEventHandlers;
|
||||
|
||||
public override string Name { get { return "ContentSchema"; } }
|
||||
public override string Name { get { return "ContentDefinition"; } }
|
||||
|
||||
public ContentSchemaStep(
|
||||
public override IEnumerable<string> Names
|
||||
{
|
||||
get { return new[] {Name, "Metadata"}; }
|
||||
}
|
||||
|
||||
public ContentDefinitionStep(
|
||||
IContentDefinitionManager contentDefinitionManager,
|
||||
IContentDefinitionReader contentDefinitionReader,
|
||||
IContentDefinitionEventHandler contentDefinitonEventHandlers) {
|
||||
@@ -19,13 +19,15 @@ namespace Orchard.Recipes.Providers.Executors {
|
||||
_transactionManager = transactionManager;
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
public override string Name {
|
||||
get { return "Content"; }
|
||||
}
|
||||
|
||||
public override LocalizedString DisplayName
|
||||
{
|
||||
public override IEnumerable<string> Names {
|
||||
get { return new[] { Name, "Data" }; }
|
||||
}
|
||||
|
||||
public override LocalizedString DisplayName {
|
||||
get { return T("Content"); }
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Orchard.Recipes.Providers.RecipeHandlers {
|
||||
}
|
||||
|
||||
public void ExecuteRecipeStep(RecipeContext recipeContext) {
|
||||
var executionStep = _recipeExecutionSteps.FirstOrDefault(x => x.Name == recipeContext.RecipeStep.Name);
|
||||
var executionStep = _recipeExecutionSteps.FirstOrDefault(x => x.Names.Contains(recipeContext.RecipeStep.Name));
|
||||
var recipeExecutionContext = new RecipeExecutionContext {ExecutionId = recipeContext.ExecutionId, RecipeStep = recipeContext.RecipeStep};
|
||||
|
||||
if (executionStep != null) {
|
||||
|
||||
@@ -6,7 +6,17 @@ namespace Orchard.Recipes.Services {
|
||||
string Name { get; }
|
||||
LocalizedString DisplayName { get; }
|
||||
LocalizedString Description { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The order in which this builder should execute.
|
||||
/// </summary>
|
||||
int Priority { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The order in which this builder should be displayed.
|
||||
/// </summary>
|
||||
int Position { get; }
|
||||
|
||||
dynamic BuildEditor(dynamic shapeFactory);
|
||||
dynamic UpdateEditor(dynamic shapeFactory, IUpdateModel updater);
|
||||
void Build(BuildContext context);
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
using Orchard.ContentManagement;
|
||||
using System.Collections.Generic;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Recipes.Models;
|
||||
|
||||
namespace Orchard.Recipes.Services {
|
||||
public interface IRecipeExecutionStep : IDependency {
|
||||
string Name { get; }
|
||||
IEnumerable<string> Names { get; }
|
||||
LocalizedString DisplayName { get; }
|
||||
LocalizedString Description { get; }
|
||||
dynamic BuildEditor(dynamic shapeFactory);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Orchard.Services;
|
||||
|
||||
@@ -15,7 +16,7 @@ namespace Orchard.Recipes.Services {
|
||||
RecipeDocument = CreateRecipeRoot()
|
||||
};
|
||||
|
||||
foreach (var step in steps) {
|
||||
foreach (var step in steps.OrderByDescending(x => x.Priority)) {
|
||||
step.Build(context);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace Orchard.Recipes.Services {
|
||||
public abstract LocalizedString DisplayName { get; }
|
||||
public abstract LocalizedString Description { get; }
|
||||
public virtual int Priority { get { return 0; } }
|
||||
public virtual int Position { get { return 0; } }
|
||||
|
||||
protected virtual string Prefix {
|
||||
get { return GetType().Name; }
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Recipes.Models;
|
||||
@@ -6,6 +7,10 @@ namespace Orchard.Recipes.Services {
|
||||
public abstract class RecipeExecutionStep : Component, IRecipeExecutionStep {
|
||||
public abstract string Name { get; }
|
||||
|
||||
public virtual IEnumerable<string> Names {
|
||||
get { yield return Name; }
|
||||
}
|
||||
|
||||
public virtual LocalizedString DisplayName {
|
||||
get { return T(Name); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user