mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-20 18:57:56 +08:00
Adding version history options to data export.
--HG-- branch : dev
This commit is contained in:
@@ -8,6 +8,7 @@ using Orchard.ImportExport.Services;
|
|||||||
using Orchard.ImportExport.ViewModels;
|
using Orchard.ImportExport.ViewModels;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
using Orchard.UI.Notify;
|
using Orchard.UI.Notify;
|
||||||
|
using Orchard.ImportExport.Models;
|
||||||
|
|
||||||
namespace Orchard.ImportExport.Controllers {
|
namespace Orchard.ImportExport.Controllers {
|
||||||
public class AdminController : Controller {
|
public class AdminController : Controller {
|
||||||
@@ -68,7 +69,12 @@ namespace Orchard.ImportExport.Controllers {
|
|||||||
try {
|
try {
|
||||||
UpdateModel(viewModel);
|
UpdateModel(viewModel);
|
||||||
var contentTypesToExport = viewModel.ContentTypes.Where(c => c.IsChecked).Select(c => c.ContentTypeName);
|
var contentTypesToExport = viewModel.ContentTypes.Where(c => c.IsChecked).Select(c => c.ContentTypeName);
|
||||||
var exportFile = _importExportService.Export(contentTypesToExport, viewModel.Metadata, viewModel.Data, viewModel.SiteSettings);
|
var dataExportOptions = new DataExportOptions();
|
||||||
|
if (viewModel.Data) {
|
||||||
|
dataExportOptions.ExportData = true;
|
||||||
|
dataExportOptions.VersionHistoryOptions = (VersionHistoryOptions)Enum.Parse(typeof(VersionHistoryOptions), viewModel.DataImportChoice, true);
|
||||||
|
}
|
||||||
|
var exportFile = _importExportService.Export(contentTypesToExport, dataExportOptions, viewModel.Metadata, viewModel.SiteSettings);
|
||||||
Services.Notifier.Information(T("Your export file has been created at <a href=\"{0}\" />", exportFile));
|
Services.Notifier.Information(T("Your export file has been created at <a href=\"{0}\" />", exportFile));
|
||||||
|
|
||||||
return RedirectToAction("Export");
|
return RedirectToAction("Export");
|
||||||
|
@@ -0,0 +1,12 @@
|
|||||||
|
namespace Orchard.ImportExport.Models {
|
||||||
|
public class DataExportOptions {
|
||||||
|
public bool ExportData { get; set; }
|
||||||
|
public VersionHistoryOptions VersionHistoryOptions { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum VersionHistoryOptions {
|
||||||
|
Published,
|
||||||
|
Draft,
|
||||||
|
AllVersions
|
||||||
|
}
|
||||||
|
}
|
@@ -46,6 +46,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="AdminMenu.cs" />
|
<Compile Include="AdminMenu.cs" />
|
||||||
<Compile Include="Controllers\AdminController.cs" />
|
<Compile Include="Controllers\AdminController.cs" />
|
||||||
|
<Compile Include="Models\DataExportOptions.cs" />
|
||||||
<Compile Include="Permissions.cs" />
|
<Compile Include="Permissions.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Services\IImportExportService.cs" />
|
<Compile Include="Services\IImportExportService.cs" />
|
||||||
|
@@ -1,10 +1,12 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Orchard.ImportExport.Models;
|
||||||
|
|
||||||
namespace Orchard.ImportExport.Services {
|
namespace Orchard.ImportExport.Services {
|
||||||
public interface IImportExportService : IDependency {
|
public interface IImportExportService : IDependency {
|
||||||
void Import(string recipeText);
|
void Import(string recipeText);
|
||||||
string Export(IEnumerable<string> contentTypes, bool exportMetadata, bool exportData, bool exportSettings);
|
string Export(IEnumerable<string> contentTypes, DataExportOptions dataExportOptions, bool exportMetadata, bool exportSettings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Orchard.Environment.Descriptor;
|
using Orchard.Environment.Descriptor;
|
||||||
|
using Orchard.ImportExport.Models;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
using Orchard.Logging;
|
using Orchard.Logging;
|
||||||
using Orchard.Recipes.Models;
|
using Orchard.Recipes.Models;
|
||||||
@@ -32,7 +33,7 @@ namespace Orchard.ImportExport.Services {
|
|||||||
UpdateShell();
|
UpdateShell();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Export(IEnumerable<string> contentTypes, bool exportMetadata, bool exportData, bool exportSettings) {
|
public string Export(IEnumerable<string> contentTypes, DataExportOptions dataExportOptions, bool exportMetadata, bool exportSettings) {
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -5,6 +5,7 @@ namespace Orchard.ImportExport.ViewModels {
|
|||||||
public IList<ContentTypeEntry> ContentTypes { get; set; }
|
public IList<ContentTypeEntry> ContentTypes { get; set; }
|
||||||
public virtual bool Metadata { get; set; }
|
public virtual bool Metadata { get; set; }
|
||||||
public virtual bool Data { get; set; }
|
public virtual bool Data { get; set; }
|
||||||
|
public virtual string DataImportChoice { get; set; }
|
||||||
public virtual bool SiteSettings { get; set; }
|
public virtual bool SiteSettings { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -27,8 +27,21 @@
|
|||||||
<div>
|
<div>
|
||||||
@Html.EditorFor(m => m.Data)
|
@Html.EditorFor(m => m.Data)
|
||||||
<label class="forcheckbox" for="@Html.FieldIdFor( m => m.Data)">@T("Data")</label>
|
<label class="forcheckbox" for="@Html.FieldIdFor( m => m.Data)">@T("Data")</label>
|
||||||
<p>@T("Data is the actual content of your site.")</p><br />
|
<p>@T("Data is the actual content of your site.")</p>
|
||||||
|
<p>@T("Version History")</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
@Html.RadioButtonFor(m => m.DataImportChoice, "Published", new { id = "Published", Checked = "Checked" })
|
||||||
|
<label for="@Html.FieldIdFor(m => m.DataImportChoice)" class="forcheckbox">@T("Only Published Versions")</label>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
@Html.RadioButtonFor(m => m.DataImportChoice, "Draft", new { id = "Draft" })
|
||||||
|
<label for="@Html.FieldIdFor(m => m.DataImportChoice)" class="forcheckbox">@T("Only Drafts")</label>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
@Html.RadioButtonFor(m => m.DataImportChoice, "AllVersions", new { id = "AllVersions" })
|
||||||
|
<label for="@Html.FieldIdFor(m => m.DataImportChoice)" class="forcheckbox">@T("All Versions")</label>
|
||||||
|
</div><br />
|
||||||
<div>
|
<div>
|
||||||
@Html.EditorFor(m => m.SiteSettings)
|
@Html.EditorFor(m => m.SiteSettings)
|
||||||
<label class="forcheckbox" for="@Html.FieldIdFor( m => m.SiteSettings)">@T("Site Settings")</label><br />
|
<label class="forcheckbox" for="@Html.FieldIdFor( m => m.SiteSettings)">@T("Site Settings")</label><br />
|
||||||
|
Reference in New Issue
Block a user