mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-01-09 11:21:04 +08:00
Migrating SiteSettingsPart
This commit is contained in:
@@ -8,6 +8,7 @@ using Autofac;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.FieldStorage.InfosetStorage;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.ContentManagement.MetaData.Builders;
|
||||
using Orchard.Core.Common.Models;
|
||||
@@ -150,6 +151,7 @@ namespace Orchard.Core.Tests.Feeds.Controllers {
|
||||
.Weld<CommonPart>()
|
||||
.Weld<TitlePart>()
|
||||
.Weld<BodyPart>()
|
||||
.Weld<InfosetPart>()
|
||||
.Build();
|
||||
hello.As<CommonPart>().Record = new CommonPartRecord();
|
||||
hello.As<TitlePart>().Record = new TitlePartRecord();
|
||||
|
||||
@@ -7,6 +7,8 @@ using System.Linq;
|
||||
using Autofac;
|
||||
using NHibernate;
|
||||
using NUnit.Framework;
|
||||
using Orchard.ContentManagement.FieldStorage.InfosetStorage;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Data;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Services;
|
||||
@@ -45,6 +47,7 @@ namespace Orchard.Tests.Modules {
|
||||
|
||||
var builder = new ContainerBuilder();
|
||||
//builder.RegisterModule(new ImplicitCollectionSupportModule());
|
||||
builder.RegisterType<InfosetHandler>().As<IContentHandler>();
|
||||
builder.RegisterInstance(new StubLocator(_session)).As<ISessionLocator>();
|
||||
builder.RegisterInstance(_clock).As<IClock>();
|
||||
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
|
||||
|
||||
@@ -15,7 +15,6 @@ using Orchard.ContentManagement.MetaData.Models;
|
||||
using Orchard.ContentManagement.MetaData.Services;
|
||||
using Orchard.ContentManagement.Records;
|
||||
using Orchard.Core.Settings.Descriptor.Records;
|
||||
using Orchard.Core.Settings.Handlers;
|
||||
using Orchard.Core.Settings.Metadata;
|
||||
using Orchard.Core.Settings.Models;
|
||||
using Orchard.Core.Settings.Services;
|
||||
|
||||
@@ -102,8 +102,6 @@ namespace Orchard.Tests.Modules.Users.Controllers {
|
||||
protected override IEnumerable<Type> DatabaseTypes {
|
||||
get {
|
||||
return new[] { typeof(UserPartRecord),
|
||||
typeof(SiteSettingsPartRecord),
|
||||
typeof(SiteSettings2PartRecord),
|
||||
typeof(RegistrationSettingsPartRecord),
|
||||
typeof(ContentTypeRecord),
|
||||
typeof(ContentItemRecord),
|
||||
|
||||
@@ -6,6 +6,8 @@ using System.Linq;
|
||||
using Autofac;
|
||||
using NHibernate;
|
||||
using NUnit.Framework;
|
||||
using Orchard.ContentManagement.FieldStorage.InfosetStorage;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Data;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Services;
|
||||
@@ -41,6 +43,7 @@ namespace Orchard.Tests {
|
||||
|
||||
var builder = new ContainerBuilder();
|
||||
//builder.RegisterModule(new ImplicitCollectionSupportModule());
|
||||
builder.RegisterType<InfosetHandler>().As<IContentHandler>();
|
||||
builder.RegisterInstance(new StubLocator(_session)).As<ISessionLocator>();
|
||||
builder.RegisterInstance(_clock).As<IClock>();
|
||||
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.FieldStorage.InfosetStorage;
|
||||
|
||||
namespace Orchard.Core.Common.Models {
|
||||
public class BodyPart : ContentPart<BodyPartRecord> {
|
||||
public string Text {
|
||||
get { return this.As<InfosetPart>().Get<BodyPart>("Text"); }
|
||||
get { return Get("Text"); }
|
||||
set {
|
||||
this.As<InfosetPart>().Set<BodyPart>("Text", value);
|
||||
Set("Text", value);
|
||||
Record.Text = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Xml;
|
||||
using Orchard.ContentManagement.FieldStorage.InfosetStorage;
|
||||
using Orchard.Core.Common.Utilities;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
@@ -27,85 +26,71 @@ namespace Orchard.Core.Common.Models {
|
||||
|
||||
public DateTime? CreatedUtc {
|
||||
get {
|
||||
var dateTime = this.As<InfosetPart>().Get<CommonPart>("CreatedUtc");
|
||||
return dateTime == "" ? (DateTime?)null : XmlConvert.ToDateTime(dateTime, XmlDateTimeSerializationMode.Utc);
|
||||
var dateTime = Get("CreatedUtc");
|
||||
return String.IsNullOrEmpty(dateTime) ? (DateTime?)null : XmlConvert.ToDateTime(dateTime, XmlDateTimeSerializationMode.Utc);
|
||||
}
|
||||
set {
|
||||
string dateTime = value.HasValue ? XmlConvert.ToString(value.Value, XmlDateTimeSerializationMode.Utc) : "";
|
||||
this.As<InfosetPart>().Set<CommonPart>("CreatedUtc", dateTime);
|
||||
Set("CreatedUtc", dateTime);
|
||||
Record.CreatedUtc = value;
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime? PublishedUtc {
|
||||
get {
|
||||
var dateTime = this.As<InfosetPart>().Get<CommonPart>("PublishedUtc");
|
||||
return dateTime == "" ? (DateTime?)null : XmlConvert.ToDateTime(dateTime, XmlDateTimeSerializationMode.Utc);
|
||||
var dateTime = Get("PublishedUtc");
|
||||
return String.IsNullOrEmpty(dateTime) ? (DateTime?)null : XmlConvert.ToDateTime(dateTime, XmlDateTimeSerializationMode.Utc);
|
||||
}
|
||||
set {
|
||||
string dateTime = value.HasValue ? XmlConvert.ToString(value.Value, XmlDateTimeSerializationMode.Utc) : "";
|
||||
this.As<InfosetPart>().Set<CommonPart>("PublishedUtc", dateTime);
|
||||
Set("PublishedUtc", dateTime);
|
||||
Record.PublishedUtc = value;
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime? ModifiedUtc {
|
||||
get {
|
||||
var dateTime = this.As<InfosetPart>().Get<CommonPart>("ModifiedUtc");
|
||||
return dateTime == "" ? (DateTime?)null : XmlConvert.ToDateTime(dateTime, XmlDateTimeSerializationMode.Utc);
|
||||
var dateTime = Get("ModifiedUtc");
|
||||
return String.IsNullOrEmpty(dateTime) ? (DateTime?)null : XmlConvert.ToDateTime(dateTime, XmlDateTimeSerializationMode.Utc);
|
||||
}
|
||||
set {
|
||||
string dateTime = value.HasValue ? XmlConvert.ToString(value.Value, XmlDateTimeSerializationMode.Utc) : "";
|
||||
this.As<InfosetPart>().Set<CommonPart>("ModifiedUtc", dateTime);
|
||||
Set("ModifiedUtc", dateTime);
|
||||
Record.ModifiedUtc = value;
|
||||
}
|
||||
}
|
||||
|
||||
CommonPartVersionRecord PartVersionRecord {
|
||||
get {
|
||||
var versionPart = this.As<ContentPart<CommonPartVersionRecord>>();
|
||||
return versionPart == null ? null : versionPart.Record;
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime? VersionCreatedUtc {
|
||||
get {
|
||||
var dateTime = this.As<InfosetPart>().Get<ContentPart<CommonPartVersionRecord>>("CreatedUtc");
|
||||
return dateTime == "" ? (DateTime?)null : XmlConvert.ToDateTime(dateTime, XmlDateTimeSerializationMode.Utc);
|
||||
var dateTime = this.As<ContentPart<CommonPartVersionRecord>>().Get("CreatedUtc");
|
||||
return String.IsNullOrEmpty(dateTime) ? (DateTime?)null : XmlConvert.ToDateTime(dateTime, XmlDateTimeSerializationMode.Utc);
|
||||
}
|
||||
set {
|
||||
string dateTime = value.HasValue ? XmlConvert.ToString(value.Value, XmlDateTimeSerializationMode.Utc) : "";
|
||||
this.As<InfosetPart>().Set<ContentPart<CommonPartVersionRecord>>("CreatedUtc", dateTime);
|
||||
if (PartVersionRecord != null)
|
||||
PartVersionRecord.CreatedUtc = value;
|
||||
this.As<ContentPart<CommonPartVersionRecord>>().Set("CreatedUtc", dateTime);
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime? VersionPublishedUtc {
|
||||
get {
|
||||
var dateTime = this.As<InfosetPart>().Get<ContentPart<CommonPartVersionRecord>>("PublishedUtc");
|
||||
return dateTime == "" ? (DateTime?)null : XmlConvert.ToDateTime(dateTime, XmlDateTimeSerializationMode.Utc);
|
||||
var dateTime = this.As<ContentPart<CommonPartVersionRecord>>().Get("PublishedUtc");
|
||||
return String.IsNullOrEmpty(dateTime) ? (DateTime?)null : XmlConvert.ToDateTime(dateTime, XmlDateTimeSerializationMode.Utc);
|
||||
}
|
||||
set {
|
||||
string dateTime = value.HasValue ? XmlConvert.ToString(value.Value, XmlDateTimeSerializationMode.Utc) : "";
|
||||
this.As<InfosetPart>().Set<ContentPart<CommonPartVersionRecord>>("PublishedUtc", dateTime);
|
||||
if (PartVersionRecord != null)
|
||||
PartVersionRecord.PublishedUtc = value;
|
||||
this.As<ContentPart<CommonPartVersionRecord>>().Set("PublishedUtc", dateTime);
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime? VersionModifiedUtc {
|
||||
get {
|
||||
var dateTime = this.As<InfosetPart>().Get<ContentPart<CommonPartVersionRecord>>("ModifiedUtc");
|
||||
return dateTime == "" ? (DateTime?)null : XmlConvert.ToDateTime(dateTime, XmlDateTimeSerializationMode.Utc);
|
||||
var dateTime = this.As<ContentPart<CommonPartVersionRecord>>().Get("ModifiedUtc");
|
||||
return String.IsNullOrEmpty(dateTime) ? (DateTime?)null : XmlConvert.ToDateTime(dateTime, XmlDateTimeSerializationMode.Utc);
|
||||
}
|
||||
set {
|
||||
string dateTime = value.HasValue ? XmlConvert.ToString(value.Value, XmlDateTimeSerializationMode.Utc) : "";
|
||||
this.As<InfosetPart>().Set<ContentPart<CommonPartVersionRecord>>("ModifiedUtc", dateTime);
|
||||
if (PartVersionRecord != null)
|
||||
PartVersionRecord.ModifiedUtc = value;
|
||||
this.As<ContentPart<CommonPartVersionRecord>>().Set("ModifiedUtc", dateTime);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.FieldStorage.InfosetStorage;
|
||||
|
||||
namespace Orchard.Core.Common.Models {
|
||||
public class IdentityPart : ContentPart<IdentityPartRecord> {
|
||||
public string Identifier {
|
||||
get { return this.As<InfosetPart>().Get<IdentityPart>("Identifier"); }
|
||||
get { return Get("Identifier"); }
|
||||
set {
|
||||
this.As<InfosetPart>().Set<IdentityPart>("Identifier", value);
|
||||
Set("Identifier", value);
|
||||
Record.Identifier = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,47 +1,46 @@
|
||||
using System.Globalization;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.FieldStorage.InfosetStorage;
|
||||
using Orchard.ContentManagement.Records;
|
||||
|
||||
namespace Orchard.Core.Navigation.Models {
|
||||
public class MenuWidgetPart : ContentPart<MenuWidgetPartRecord> {
|
||||
|
||||
public int StartLevel {
|
||||
get { return int.Parse(this.As<InfosetPart>().Get<MenuWidgetPart>("StartLevel") ?? "0", CultureInfo.InvariantCulture); }
|
||||
get { return int.Parse(Get("StartLevel") ?? "0", CultureInfo.InvariantCulture); }
|
||||
set {
|
||||
this.As<InfosetPart>().Set<MenuWidgetPart>("StartLevel", value.ToString(CultureInfo.InvariantCulture));
|
||||
Set("StartLevel", value.ToString(CultureInfo.InvariantCulture));
|
||||
Record.StartLevel = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int Levels {
|
||||
get { return int.Parse(this.As<InfosetPart>().Get<MenuWidgetPart>("Levels") ?? "0", CultureInfo.InvariantCulture); }
|
||||
get { return int.Parse(Get("Levels") ?? "0", CultureInfo.InvariantCulture); }
|
||||
set {
|
||||
this.As<InfosetPart>().Set<MenuWidgetPart>("Levels", value.ToString(CultureInfo.InvariantCulture));
|
||||
Set("Levels", value.ToString(CultureInfo.InvariantCulture));
|
||||
Record.Levels = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Breadcrumb {
|
||||
get { return bool.Parse(this.As<InfosetPart>().Get<MenuWidgetPart>("Breadcrumb") ?? "false"); }
|
||||
get { return bool.Parse(Get("Breadcrumb") ?? "false"); }
|
||||
set {
|
||||
this.As<InfosetPart>().Set<MenuWidgetPart>("Breadcrumb", value.ToString());
|
||||
Set("Breadcrumb", value.ToString());
|
||||
Record.Breadcrumb = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool AddHomePage {
|
||||
get { return bool.Parse(this.As<InfosetPart>().Get<MenuWidgetPart>("AddHomePage") ?? "false"); }
|
||||
get { return bool.Parse(Get("AddHomePage") ?? "false"); }
|
||||
set {
|
||||
this.As<InfosetPart>().Set<MenuWidgetPart>("AddHomePage", value.ToString());
|
||||
Set("AddHomePage", value.ToString());
|
||||
Record.AddHomePage = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool AddCurrentPage {
|
||||
get { return bool.Parse(this.As<InfosetPart>().Get<MenuWidgetPart>("AddCurrentPage") ?? "false"); }
|
||||
get { return bool.Parse(Get("AddCurrentPage") ?? "false"); }
|
||||
set {
|
||||
this.As<InfosetPart>().Set<MenuWidgetPart>("AddCurrentPage", value.ToString());
|
||||
Set("AddCurrentPage", value.ToString());
|
||||
Record.AddCurrentPage = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Orchard.Core.Navigation.Services {
|
||||
}
|
||||
|
||||
public IContent GetMenu(int menuId) {
|
||||
return _contentManager.Get(menuId, VersionOptions.Published, new QueryHints().ExpandRecords<TitlePartRecord>());
|
||||
return _contentManager.Get(menuId, VersionOptions.Published);
|
||||
}
|
||||
|
||||
public MenuPart Get(int menuPartId) {
|
||||
|
||||
@@ -221,8 +221,6 @@
|
||||
<Compile Include="Scheduling\Services\ScheduledTaskExecutor.cs" />
|
||||
<Compile Include="Scheduling\Models\Task.cs" />
|
||||
<Compile Include="Settings\Commands\SiteSettingsCommands.cs" />
|
||||
<Compile Include="Settings\Models\SiteSettings2Part.cs" />
|
||||
<Compile Include="Settings\Models\SiteSettings2PartRecord.cs" />
|
||||
<Compile Include="Settings\ResourceManifest.cs" />
|
||||
<Compile Include="Settings\Migrations.cs" />
|
||||
<Compile Include="Settings\Drivers\SiteSettingsPartDriver.cs" />
|
||||
@@ -235,7 +233,6 @@
|
||||
<Compile Include="Settings\Metadata\Records\ContentPartFieldDefinitionRecord.cs" />
|
||||
<Compile Include="Settings\Metadata\Records\ContentTypeDefinitionRecord.cs" />
|
||||
<Compile Include="Settings\Metadata\Records\ContentTypePartDefinitionRecord.cs" />
|
||||
<Compile Include="Settings\Models\SiteSettingsPartRecord.cs" />
|
||||
<Compile Include="Settings\State\Records\ShellFeatureStateRecord.cs" />
|
||||
<Compile Include="Settings\State\Records\ShellStateRecord.cs" />
|
||||
<Compile Include="Settings\State\ShellStateManager.cs" />
|
||||
@@ -375,6 +372,7 @@
|
||||
<ItemGroup>
|
||||
<Folder Include="App_Data\" />
|
||||
<Folder Include="Containers\Services\" />
|
||||
<Folder Include="Settings\Handlers\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Contents\Views\Web.config" />
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Core.Settings.Models;
|
||||
using Orchard.Data;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
|
||||
namespace Orchard.Core.Settings.Handlers {
|
||||
[UsedImplicitly]
|
||||
public class SiteSettingsPartHandler : ContentHandler {
|
||||
public SiteSettingsPartHandler(IRepository<SiteSettingsPartRecord> repository, IRepository<SiteSettings2PartRecord> repository2) {
|
||||
public SiteSettingsPartHandler() {
|
||||
Filters.Add(new ActivatingFilter<SiteSettingsPart>("Site"));
|
||||
Filters.Add(new ActivatingFilter<SiteSettings2Part>("Site"));
|
||||
Filters.Add(StorageFilter.For(repository));
|
||||
Filters.Add(StorageFilter.For(repository2));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -81,27 +81,10 @@ namespace Orchard.Core.Settings {
|
||||
.Column<string>("Unused")
|
||||
);
|
||||
|
||||
SchemaBuilder.CreateTable("SiteSettingsPartRecord",
|
||||
table => table
|
||||
.ContentPartRecord()
|
||||
.Column<string>("SiteSalt")
|
||||
.Column<string>("SiteName")
|
||||
.Column<string>("SuperUser")
|
||||
.Column<string>("PageTitleSeparator")
|
||||
.Column<string>("HomePage")
|
||||
.Column<string>("SiteCulture")
|
||||
.Column<string>("ResourceDebugMode", c => c.WithDefault("FromAppSetting"))
|
||||
.Column<int>("PageSize")
|
||||
.Column<string>("SiteTimeZone")
|
||||
);
|
||||
// declare the Site content type to let users alter it
|
||||
ContentDefinitionManager.AlterTypeDefinition("Site", cfg => { });
|
||||
|
||||
SchemaBuilder.CreateTable("SiteSettings2PartRecord",
|
||||
table => table
|
||||
.ContentPartRecord()
|
||||
.Column<string>("BaseUrl", c => c.Unlimited())
|
||||
);
|
||||
|
||||
return 3;
|
||||
return 4;
|
||||
}
|
||||
|
||||
public int UpdateFrom1() {
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Data.Conventions;
|
||||
|
||||
namespace Orchard.Core.Settings.Models {
|
||||
public sealed class SiteSettings2Part : ContentPart<SiteSettings2PartRecord> {
|
||||
[StringLengthMax]
|
||||
public string BaseUrl {
|
||||
get { return Record.BaseUrl; }
|
||||
set { Record.BaseUrl = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using Orchard.ContentManagement.Records;
|
||||
using Orchard.Data.Conventions;
|
||||
|
||||
namespace Orchard.Core.Settings.Models {
|
||||
public class SiteSettings2PartRecord : ContentPartRecord {
|
||||
[StringLengthMax]
|
||||
public virtual string BaseUrl { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,64 +1,62 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Globalization;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Data.Conventions;
|
||||
using Orchard.Settings;
|
||||
|
||||
namespace Orchard.Core.Settings.Models {
|
||||
public sealed class SiteSettingsPart : ContentPart<SiteSettingsPartRecord>, ISite {
|
||||
public sealed class SiteSettingsPart : ContentPart, ISite {
|
||||
|
||||
public const int DefaultPageSize = 10;
|
||||
public string PageTitleSeparator {
|
||||
get { return Record.PageTitleSeparator; }
|
||||
set { Record.PageTitleSeparator = value; }
|
||||
get { return Get("PageTitleSeparator"); }
|
||||
set { Set("PageTitleSeparator", value); }
|
||||
}
|
||||
|
||||
public string SiteName {
|
||||
get { return Record.SiteName; }
|
||||
set { Record.SiteName = value; }
|
||||
get { return Get("SiteName"); }
|
||||
set { Set("SiteName", value); }
|
||||
}
|
||||
|
||||
public string SiteSalt {
|
||||
get { return Record.SiteSalt; }
|
||||
get { return Get("SiteSalt"); }
|
||||
set { Set("SiteSalt", value); }
|
||||
}
|
||||
|
||||
public string SuperUser {
|
||||
get { return Record.SuperUser; }
|
||||
set { Record.SuperUser = value; }
|
||||
get { return Get("SuperUser"); }
|
||||
set { Set("SuperUser", value); }
|
||||
}
|
||||
|
||||
public string HomePage {
|
||||
get { return Record.HomePage; }
|
||||
set { Record.HomePage = value; }
|
||||
get { return Get("HomePage"); }
|
||||
set { Set("HomePage", value); }
|
||||
}
|
||||
|
||||
public string SiteCulture {
|
||||
get { return Record.SiteCulture; }
|
||||
set { Record.SiteCulture = value; }
|
||||
get { return Get("SiteCulture"); }
|
||||
set { Set("SiteCulture", value); }
|
||||
}
|
||||
|
||||
public ResourceDebugMode ResourceDebugMode {
|
||||
get { return Record.ResourceDebugMode; }
|
||||
set { Record.ResourceDebugMode = value; }
|
||||
get {
|
||||
var value = Get("ResourceDebugMode");
|
||||
return String.IsNullOrEmpty(value) ? ResourceDebugMode.Disabled : (ResourceDebugMode)Enum.Parse(typeof(ResourceDebugMode), value);
|
||||
}
|
||||
set { Set("ResourceDebugMode", value.ToString()); }
|
||||
}
|
||||
|
||||
public int PageSize {
|
||||
get { return Record.PageSize; }
|
||||
set { Record.PageSize = value; }
|
||||
get { return int.Parse(Get("PageSize") ?? "0", CultureInfo.InvariantCulture); }
|
||||
set { Set("PageSize", value.ToString(CultureInfo.InvariantCulture)); }
|
||||
}
|
||||
|
||||
public string SiteTimeZone {
|
||||
get { return Record.SiteTimeZone; }
|
||||
set { Record.SiteTimeZone = value; }
|
||||
get { return Get("SiteTimeZone"); }
|
||||
set { Set("SiteTimeZone", value); }
|
||||
}
|
||||
|
||||
[StringLengthMax]
|
||||
public string BaseUrl {
|
||||
get {
|
||||
return this.As<SiteSettings2Part>().BaseUrl;
|
||||
}
|
||||
set {
|
||||
this.As<SiteSettings2Part>().BaseUrl = value;
|
||||
}
|
||||
get { return Get("BaseUrl"); }
|
||||
set { Set("BaseUrl", value); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
using System;
|
||||
using Orchard.ContentManagement.Records;
|
||||
using Orchard.Settings;
|
||||
|
||||
namespace Orchard.Core.Settings.Models {
|
||||
public class SiteSettingsPartRecord : ContentPartRecord {
|
||||
public const int DefaultPageSize = 10;
|
||||
|
||||
public SiteSettingsPartRecord() {
|
||||
PageSize = DefaultPageSize;
|
||||
}
|
||||
|
||||
public virtual string SiteSalt { get; set; }
|
||||
|
||||
public virtual string SiteName { get; set; }
|
||||
|
||||
public virtual string SuperUser { get; set; }
|
||||
|
||||
public virtual string PageTitleSeparator { get; set; }
|
||||
|
||||
public virtual string HomePage { get; set; }
|
||||
|
||||
public virtual string SiteCulture { get; set; }
|
||||
|
||||
public virtual ResourceDebugMode ResourceDebugMode { get; set; }
|
||||
|
||||
public virtual int PageSize { get; set; }
|
||||
|
||||
public virtual string SiteTimeZone { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Caching;
|
||||
using Orchard.Core.Settings.Models;
|
||||
using Orchard.Data;
|
||||
using Orchard.Logging;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Settings;
|
||||
@@ -15,7 +14,6 @@ namespace Orchard.Core.Settings.Services {
|
||||
private readonly ICacheManager _cacheManager;
|
||||
|
||||
public SiteService(
|
||||
IRepository<SiteSettingsPartRecord> siteSettingsRepository,
|
||||
IContentManager contentManager,
|
||||
ICacheManager cacheManager) {
|
||||
_contentManager = contentManager;
|
||||
@@ -33,17 +31,17 @@ namespace Orchard.Core.Settings.Services {
|
||||
|
||||
if (site == null) {
|
||||
site = _contentManager.Create<SiteSettingsPart>("Site", item => {
|
||||
item.Record.SiteSalt = Guid.NewGuid().ToString("N");
|
||||
item.Record.SiteName = "My Orchard Project Application";
|
||||
item.Record.PageTitleSeparator = " - ";
|
||||
item.Record.SiteTimeZone = TimeZoneInfo.Local.Id;
|
||||
item.SiteSalt = Guid.NewGuid().ToString("N");
|
||||
item.SiteName = "My Orchard Project Application";
|
||||
item.PageTitleSeparator = " - ";
|
||||
item.SiteTimeZone = TimeZoneInfo.Local.Id;
|
||||
}).ContentItem;
|
||||
}
|
||||
|
||||
return site.Id;
|
||||
});
|
||||
|
||||
return _contentManager.Get<ISite>(siteId, VersionOptions.Published, new QueryHints().ExpandRecords<SiteSettingsPartRecord>());
|
||||
return _contentManager.Get<ISite>(siteId, VersionOptions.Published);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,16 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.ContentManagement.FieldStorage.InfosetStorage;
|
||||
|
||||
namespace Orchard.Core.Title.Models {
|
||||
public class TitlePart : ContentPart<TitlePartRecord>, ITitleAspect {
|
||||
[Required]
|
||||
public string Title {
|
||||
get { return this.As<InfosetPart>().Get<TitlePart>("Title"); }
|
||||
get {
|
||||
return Get("Title");
|
||||
}
|
||||
set {
|
||||
this.As<InfosetPart>().Set<TitlePart>("Title", value);
|
||||
Set("Title", value);
|
||||
Record.Title = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +1,29 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.ContentManagement.FieldStorage.InfosetStorage;
|
||||
|
||||
namespace Orchard.Autoroute.Models {
|
||||
public class AutoroutePart : ContentPart<AutoroutePartRecord>, IAliasAspect {
|
||||
|
||||
public string CustomPattern {
|
||||
get { return this.As<InfosetPart>().Get<AutoroutePart>("CustomPattern"); }
|
||||
get { return Get("CustomPattern"); }
|
||||
set {
|
||||
this.As<InfosetPart>().Set<AutoroutePart>("CustomPattern", value);
|
||||
Set("CustomPattern", value);
|
||||
Record.CustomPattern = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool UseCustomPattern {
|
||||
get { return bool.Parse(this.As<InfosetPart>().Get<AutoroutePart>("UseCustomPattern")); }
|
||||
get { return bool.Parse(Get("UseCustomPattern")); }
|
||||
set {
|
||||
this.As<InfosetPart>().Set<AutoroutePart>("UseCustomPattern", value.ToString());
|
||||
Set("UseCustomPattern", value.ToString());
|
||||
Record.UseCustomPattern = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string DisplayAlias {
|
||||
get { return this.As<InfosetPart>().Get<AutoroutePart>("DisplayAlias"); }
|
||||
get { return Get("DisplayAlias"); }
|
||||
set {
|
||||
this.As<InfosetPart>().Set<AutoroutePart>("DisplayAlias", value);
|
||||
Set("DisplayAlias", value);
|
||||
Record.DisplayAlias = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,10 +186,10 @@ namespace Orchard.Setup.Services {
|
||||
// set site name and settings
|
||||
var siteService = environment.Resolve<ISiteService>();
|
||||
var siteSettings = siteService.GetSiteSettings().As<SiteSettingsPart>();
|
||||
siteSettings.Record.SiteSalt = Guid.NewGuid().ToString("N");
|
||||
siteSettings.Record.SiteName = context.SiteName;
|
||||
siteSettings.Record.SuperUser = context.AdminUsername;
|
||||
siteSettings.Record.SiteCulture = "en-US";
|
||||
siteSettings.SiteSalt = Guid.NewGuid().ToString("N");
|
||||
siteSettings.SiteName = context.SiteName;
|
||||
siteSettings.SuperUser = context.AdminUsername;
|
||||
siteSettings.SiteCulture = "en-US";
|
||||
|
||||
// add default culture
|
||||
var cultureManager = environment.Resolve<ICultureManager>();
|
||||
|
||||
@@ -182,7 +182,7 @@ namespace Orchard.Setup {
|
||||
}
|
||||
|
||||
public int PageSize {
|
||||
get { return SiteSettingsPartRecord.DefaultPageSize; }
|
||||
get { return SiteSettingsPart.DefaultPageSize; }
|
||||
set { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,6 @@ namespace Orchard.Taxonomies.Services {
|
||||
.Query<TaxonomyPart>()
|
||||
.Join<TitlePartRecord>()
|
||||
.Where(r => r.Title == name)
|
||||
.WithQueryHints(new QueryHints().ExpandRecords<AutoroutePartRecord, CommonPartRecord>())
|
||||
.List()
|
||||
.FirstOrDefault();
|
||||
}
|
||||
@@ -132,7 +131,6 @@ namespace Orchard.Taxonomies.Services {
|
||||
public IEnumerable<TermPart> GetTerms(int taxonomyId) {
|
||||
var result = _contentManager.Query<TermPart, TermPartRecord>()
|
||||
.Where(x => x.TaxonomyId == taxonomyId)
|
||||
.WithQueryHints(new QueryHints().ExpandRecords<AutoroutePartRecord, TitlePartRecord, CommonPartRecord>())
|
||||
.List();
|
||||
|
||||
return TermPart.Sort(result);
|
||||
@@ -141,7 +139,6 @@ namespace Orchard.Taxonomies.Services {
|
||||
public TermPart GetTermByPath(string path) {
|
||||
return _contentManager.Query<TermPart, TermPartRecord>()
|
||||
.Join<AutoroutePartRecord>()
|
||||
.WithQueryHints(new QueryHints().ExpandRecords<TitlePartRecord, CommonPartRecord>())
|
||||
.Where(rr => rr.DisplayAlias == path)
|
||||
.List()
|
||||
.FirstOrDefault();
|
||||
@@ -150,7 +147,6 @@ namespace Orchard.Taxonomies.Services {
|
||||
public IEnumerable<TermPart> GetAllTerms() {
|
||||
var result = _contentManager
|
||||
.Query<TermPart, TermPartRecord>()
|
||||
.WithQueryHints(new QueryHints().ExpandRecords<AutoroutePartRecord, TitlePartRecord, CommonPartRecord>())
|
||||
.List();
|
||||
return TermPart.Sort(result);
|
||||
}
|
||||
@@ -158,7 +154,6 @@ namespace Orchard.Taxonomies.Services {
|
||||
public TermPart GetTerm(int id) {
|
||||
return _contentManager
|
||||
.Query<TermPart, TermPartRecord>()
|
||||
.WithQueryHints(new QueryHints().ExpandRecords<AutoroutePartRecord, TitlePartRecord, CommonPartRecord>())
|
||||
.Where(x => x.Id == id).List().FirstOrDefault();
|
||||
}
|
||||
|
||||
@@ -171,7 +166,6 @@ namespace Orchard.Taxonomies.Services {
|
||||
public TermPart GetTermByName(int taxonomyId, string name) {
|
||||
return _contentManager
|
||||
.Query<TermPart, TermPartRecord>()
|
||||
.WithQueryHints(new QueryHints().ExpandRecords<AutoroutePartRecord, TitlePartRecord, CommonPartRecord>())
|
||||
.Where(t => t.TaxonomyId == taxonomyId)
|
||||
.Join<TitlePartRecord>()
|
||||
.Where(r => r.Title == name)
|
||||
@@ -236,8 +230,7 @@ namespace Orchard.Taxonomies.Services {
|
||||
var rootPath = term.FullPath + "/";
|
||||
|
||||
var query = _contentManager
|
||||
.Query<TermsPart, TermsPartRecord>()
|
||||
.WithQueryHints(new QueryHints().ExpandRecords<AutoroutePartRecord, TitlePartRecord, CommonPartRecord>());
|
||||
.Query<TermsPart, TermsPartRecord>();
|
||||
|
||||
if (String.IsNullOrWhiteSpace(fieldName)) {
|
||||
query = query.Where(
|
||||
@@ -273,7 +266,6 @@ namespace Orchard.Taxonomies.Services {
|
||||
var rootPath = term.FullPath + "/";
|
||||
|
||||
var result = _contentManager.Query<TermPart, TermPartRecord>()
|
||||
.WithQueryHints(new QueryHints().ExpandRecords<AutoroutePartRecord, TitlePartRecord, CommonPartRecord>())
|
||||
.Where(x => x.Path.StartsWith(rootPath))
|
||||
.List();
|
||||
|
||||
@@ -291,7 +283,6 @@ namespace Orchard.Taxonomies.Services {
|
||||
public IEnumerable<string> GetSlugs() {
|
||||
return _contentManager
|
||||
.Query<TaxonomyPart, TaxonomyPartRecord>()
|
||||
.WithQueryHints(new QueryHints().ExpandRecords<AutoroutePartRecord, TitlePartRecord, CommonPartRecord>())
|
||||
.List()
|
||||
.Select(t => t.Slug);
|
||||
}
|
||||
@@ -299,7 +290,6 @@ namespace Orchard.Taxonomies.Services {
|
||||
public IEnumerable<string> GetTermPaths() {
|
||||
return _contentManager
|
||||
.Query<TermPart, TermPartRecord>()
|
||||
.WithQueryHints(new QueryHints().ExpandRecords<AutoroutePartRecord, TitlePartRecord, CommonPartRecord>())
|
||||
.List()
|
||||
.Select(t => t.Slug);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Orchard.Core.Settings.Models;
|
||||
using Orchard.Localization;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Security;
|
||||
@@ -138,7 +137,7 @@ namespace Orchard.Users.Controllers {
|
||||
|
||||
if (user != null) {
|
||||
if ( user.As<UserPart>().EmailStatus == UserStatus.Pending ) {
|
||||
var siteUrl = _orchardServices.WorkContext.CurrentSite.As<SiteSettings2Part>().BaseUrl;
|
||||
var siteUrl = _orchardServices.WorkContext.CurrentSite.BaseUrl;
|
||||
if(String.IsNullOrWhiteSpace(siteUrl)) {
|
||||
siteUrl = HttpContext.Request.ToRootUrlString();
|
||||
}
|
||||
@@ -190,7 +189,7 @@ namespace Orchard.Users.Controllers {
|
||||
return View();
|
||||
}
|
||||
|
||||
var siteUrl = _orchardServices.WorkContext.CurrentSite.As<SiteSettings2Part>().BaseUrl;
|
||||
var siteUrl = _orchardServices.WorkContext.CurrentSite.BaseUrl;
|
||||
if (String.IsNullOrWhiteSpace(siteUrl)) {
|
||||
siteUrl = HttpContext.Request.ToRootUrlString();
|
||||
}
|
||||
|
||||
@@ -296,7 +296,7 @@ namespace Orchard.Users.Controllers {
|
||||
var user = Services.ContentManager.Get<IUser>(id);
|
||||
|
||||
if ( user != null ) {
|
||||
var siteUrl = Services.WorkContext.CurrentSite.As<SiteSettings2Part>().BaseUrl;
|
||||
var siteUrl = Services.WorkContext.CurrentSite.BaseUrl;
|
||||
if (String.IsNullOrWhiteSpace(siteUrl)) {
|
||||
siteUrl = HttpContext.Request.ToRootUrlString();
|
||||
}
|
||||
|
||||
@@ -13,13 +13,14 @@ namespace Upgrade {
|
||||
public void GetNavigation(NavigationBuilder builder) {
|
||||
builder
|
||||
.AddImageSet("upgrade")
|
||||
.Add(T("Upgrade to 1.7"), "0", menu => menu.Action("Index", "Route", new { area = "Upgrade" })
|
||||
.Add(T("Media (1.7)"), "1", item => item.Action("Index", "Media", new { area = "Upgrade" }).LocalNav().Permission(StandardPermissions.SiteOwner))
|
||||
.Add(T("Taxonomies (1.7)"), "2", item => item.Action("Index", "Taxonomy", new { area = "Upgrade" }).LocalNav().Permission(StandardPermissions.SiteOwner))
|
||||
.Add(T("Content Picker (1.7)"), "2", item => item.Action("Index", "ContentPicker", new { area = "Upgrade" }).LocalNav().Permission(StandardPermissions.SiteOwner))
|
||||
.Add(T("Fields (1.5)"), "3", item => item.Action("Index", "Field", new { area = "Upgrade" }).LocalNav().Permission(StandardPermissions.SiteOwner))
|
||||
.Add(T("Menu (1.5)"), "4", item => item.Action("Index", "Menu", new { area = "Upgrade" }).LocalNav().Permission(StandardPermissions.SiteOwner))
|
||||
.Add(T("Routes (1.4)"), "5", item => item.Action("Index", "Route", new { area = "Upgrade" }).LocalNav().Permission(StandardPermissions.SiteOwner))
|
||||
.Add(T("Upgrade to 1.8"), "0", menu => menu.Action("Index", "Route", new { area = "Upgrade" })
|
||||
.Add(T("Infoset (1.8)"), "1", item => item.Action("Index", "Infoset", new { area = "Upgrade" }).LocalNav().Permission(StandardPermissions.SiteOwner))
|
||||
.Add(T("Media (1.7)"), "2", item => item.Action("Index", "Media", new { area = "Upgrade" }).LocalNav().Permission(StandardPermissions.SiteOwner))
|
||||
.Add(T("Taxonomies (1.7)"), "3", item => item.Action("Index", "Taxonomy", new { area = "Upgrade" }).LocalNav().Permission(StandardPermissions.SiteOwner))
|
||||
.Add(T("Content Picker (1.7)"), "4", item => item.Action("Index", "ContentPicker", new { area = "Upgrade" }).LocalNav().Permission(StandardPermissions.SiteOwner))
|
||||
.Add(T("Fields (1.5)"), "5", item => item.Action("Index", "Field", new { area = "Upgrade" }).LocalNav().Permission(StandardPermissions.SiteOwner))
|
||||
.Add(T("Menu (1.5)"), "6", item => item.Action("Index", "Menu", new { area = "Upgrade" }).LocalNav().Permission(StandardPermissions.SiteOwner))
|
||||
.Add(T("Routes (1.4)"), "7", item => item.Action("Index", "Route", new { area = "Upgrade" }).LocalNav().Permission(StandardPermissions.SiteOwner))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
using System.Linq;
|
||||
using System.Security.Authentication;
|
||||
using System.Web.Mvc;
|
||||
using Orchard;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.Core.Settings.Models;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Security;
|
||||
using Orchard.Settings;
|
||||
using Orchard.UI.Admin;
|
||||
using Orchard.UI.Notify;
|
||||
using Upgrade.Services;
|
||||
|
||||
namespace Upgrade.Controllers {
|
||||
[Admin]
|
||||
public class InfosetController : Controller {
|
||||
private readonly IOrchardServices _orchardServices;
|
||||
private readonly IUpgradeService _upgradeService;
|
||||
|
||||
private const int BATCH = 50;
|
||||
|
||||
public InfosetController(
|
||||
IOrchardServices orchardServices,
|
||||
IUpgradeService upgradeService) {
|
||||
_orchardServices = orchardServices;
|
||||
_upgradeService = upgradeService;
|
||||
|
||||
Logger = NullLogger.Instance;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
public ActionResult Index() {
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost, ActionName("Index")]
|
||||
public ActionResult IndexPost() {
|
||||
if (!_orchardServices.Authorizer.Authorize(StandardPermissions.SiteOwner))
|
||||
throw new AuthenticationException("");
|
||||
|
||||
var site = _orchardServices.WorkContext.CurrentSite.As<SiteSettingsPart>();
|
||||
|
||||
_upgradeService.ExecuteReader("SELECT * FROM " + _upgradeService.GetPrefixedTableName("Orchard_Core_SiteSettingsPartRecord"),
|
||||
(reader, connection) => {
|
||||
site.HomePage = (string)reader["HomePage"];
|
||||
site.PageSize = (int)reader["PageSize"];
|
||||
site.PageTitleSeparator = (string)reader["PageTitleSeparator"];
|
||||
site.ResourceDebugMode = (ResourceDebugMode)reader["ResourceDebugMode"];
|
||||
site.SiteCulture = (string)reader["SiteCulture"];
|
||||
site.SiteName = (string)reader["SiteName"];
|
||||
site.SiteSalt = (string)reader["SiteSalt"];
|
||||
site.SiteTimeZone = (string)reader["SiteTimeZone"];
|
||||
site.SuperUser = (string)reader["SuperUser"];
|
||||
});
|
||||
|
||||
_upgradeService.ExecuteReader("SELECT * FROM " + _upgradeService.GetPrefixedTableName("Orchard_Core_SiteSettings2PartRecord"),
|
||||
(reader, connection) => {
|
||||
site.BaseUrl = (string)reader["BaseUrl"];
|
||||
});
|
||||
|
||||
_upgradeService.ExecuteReader("DROP TABLE " + _upgradeService.GetPrefixedTableName("Orchard_Core_SiteSettingsPartRecord"), null);
|
||||
_upgradeService.ExecuteReader("DROP TABLE " + _upgradeService.GetPrefixedTableName("Orchard_Core_SiteSettings2PartRecord"), null);
|
||||
|
||||
_orchardServices.Notifier.Information(T("Site Settings migrated successfully"));
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public JsonResult MigrateBody(int id) {
|
||||
if (!_orchardServices.Authorizer.Authorize(StandardPermissions.SiteOwner))
|
||||
throw new AuthenticationException("");
|
||||
|
||||
var contentItems = _orchardServices.ContentManager
|
||||
.Query<BodyPart, BodyPartRecord>()
|
||||
.Where(x => x.Id > id)
|
||||
.OrderBy(x => x.Id)
|
||||
.Slice(0, BATCH).ToList();
|
||||
|
||||
foreach (var contentItem in contentItems) {
|
||||
contentItem.Text = contentItem.Text;
|
||||
}
|
||||
|
||||
return new JsonResult { Data = contentItems.Last().Id };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -74,6 +74,7 @@
|
||||
<Content Include="Scripts\Web.config" />
|
||||
<Content Include="Styles\Web.config" />
|
||||
<Compile Include="Controllers\ContentPickerController.cs" />
|
||||
<Compile Include="Controllers\InfosetController.cs" />
|
||||
<Compile Include="Controllers\TaxonomyController.cs" />
|
||||
<Compile Include="Controllers\MediaController.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
@@ -134,7 +135,7 @@
|
||||
<Content Include="Views\ContentPicker\Index.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.Config" />
|
||||
<Content Include="Views\Infoset\Index.cshtml" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
|
||||
67
src/Orchard.Web/Modules/Upgrade/Views/Infoset/Index.cshtml
Normal file
67
src/Orchard.Web/Modules/Upgrade/Views/Infoset/Index.cshtml
Normal file
@@ -0,0 +1,67 @@
|
||||
@{
|
||||
Script.Require("jQuery");
|
||||
Layout.Title = T("Migrate Infosets").ToString();
|
||||
}
|
||||
|
||||
@using (Html.BeginFormAntiForgeryPost(Url.Action("Index", "Infoset"))) {
|
||||
<fieldset>
|
||||
<legend>@T("Migrating Site Settings:")</legend>
|
||||
<span class="hint">@T("This migration step will migrate your Site Settings to Infosets and delete the deprecated records.")</span>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<button type="submit">@T("Migrate")</button>
|
||||
</fieldset>
|
||||
}
|
||||
|
||||
<fieldset>
|
||||
<legend>@T("Migrating Body Parts:")</legend>
|
||||
<span class="hint">@T("This migration step will copy all Body Parts to Infosets.")</span>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<button type="button" class="button" id="button-migrate" data-url="@Url.Action("MigrateBody", "Infoset")">@T("Migrate")</button>
|
||||
<div class="message message-Warning" id="message-progress" style="display: none"></div>
|
||||
</fieldset>
|
||||
|
||||
@using (Script.Foot()) {
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
var antiForgeryToken = '@HttpUtility.JavaScriptStringEncode(Html.AntiForgeryTokenValueOrchard().ToString())';
|
||||
var endMessage = '@HttpUtility.JavaScriptStringEncode(T("All content items have been processed").Text)';
|
||||
|
||||
$('#button-migrate').click(function () {
|
||||
var importUrl = $(this).data('url');
|
||||
|
||||
var processed = 0;
|
||||
$('#message-progress').show();
|
||||
|
||||
var iId = setInterval(function() {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: importUrl,
|
||||
async: false,
|
||||
data: {
|
||||
__RequestVerificationToken: antiForgeryToken
|
||||
},
|
||||
success: function(data) {
|
||||
console.log('items remaining: ' + data);
|
||||
processed += Number(data);
|
||||
|
||||
if (Number(data) == 0) {
|
||||
clearInterval(iId);
|
||||
$('#message-progress').text(endMessage);
|
||||
}
|
||||
},
|
||||
fail: function(result) {
|
||||
processed = 0;
|
||||
console.log("An error occured: " + result);
|
||||
}
|
||||
});
|
||||
|
||||
$('#message-progress').text(processed + ' documents processed ...');
|
||||
|
||||
}, 100);
|
||||
|
||||
});
|
||||
});
|
||||
</script>
|
||||
}
|
||||
@@ -3,7 +3,10 @@ using System.Collections.Generic;
|
||||
using System.Dynamic;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Autofac;
|
||||
using Orchard.ContentManagement.FieldStorage.InfosetStorage;
|
||||
using Orchard.ContentManagement.MetaData.Models;
|
||||
using Orchard.ContentManagement.Records;
|
||||
using Orchard.ContentManagement.Utilities;
|
||||
using Orchard.UI;
|
||||
|
||||
@@ -76,9 +79,35 @@ namespace Orchard.ContentManagement {
|
||||
|
||||
return true;
|
||||
}
|
||||
public virtual string Get(string fieldName) {
|
||||
return this.As<InfosetPart>().Get(GetType().Name, fieldName, null, false);
|
||||
}
|
||||
|
||||
public string GetVersioned(string fieldName) {
|
||||
return this.As<InfosetPart>().Get(GetType().Name, fieldName, null, true);
|
||||
}
|
||||
public virtual void Set(string fieldName, string value) {
|
||||
this.As<InfosetPart>().Set(GetType().Name, fieldName, null, value, false);
|
||||
}
|
||||
public void SetVersionned(string fieldName, string value) {
|
||||
this.As<InfosetPart>().Set(GetType().Name, fieldName, null, value, true);
|
||||
}
|
||||
}
|
||||
|
||||
public class ContentPart<TRecord> : ContentPart {
|
||||
|
||||
static protected bool IsVersionableRecord { get; private set;}
|
||||
static ContentPart() {
|
||||
IsVersionableRecord = typeof (TRecord).IsAssignableTo<ContentItemVersionRecord>();
|
||||
}
|
||||
|
||||
public override string Get(string fieldName) {
|
||||
return this.As<InfosetPart>().Get(GetType().Name, fieldName, null, IsVersionableRecord);
|
||||
}
|
||||
public override void Set(string fieldName, string value) {
|
||||
this.As<InfosetPart>().Set(GetType().Name, fieldName, null, value, IsVersionableRecord);
|
||||
}
|
||||
|
||||
public readonly LazyField<TRecord> _record = new LazyField<TRecord>();
|
||||
public TRecord Record { get { return _record.Value; } set { _record.Value = value; } }
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using Autofac;
|
||||
using Orchard.ContentManagement.Records;
|
||||
|
||||
namespace Orchard.ContentManagement.FieldStorage.InfosetStorage {
|
||||
public class InfosetPart : ContentPart {
|
||||
@@ -17,15 +19,22 @@ namespace Orchard.ContentManagement.FieldStorage.InfosetStorage {
|
||||
}
|
||||
|
||||
public string Get<TPart>(string fieldName, string valueName) {
|
||||
return Get(typeof(TPart).Name, fieldName, valueName);
|
||||
return Get(typeof(TPart).Name, fieldName, valueName, typeof(TPart).IsAssignableTo<ContentItemVersionRecord>());
|
||||
}
|
||||
|
||||
public string Get(string partName, string fieldName) {
|
||||
return Get(partName, fieldName, null);
|
||||
return Get(partName, fieldName, null, false);
|
||||
}
|
||||
|
||||
public string Get(string partName, string fieldName, string valueName) {
|
||||
var partElement = Infoset.Element.Element(XmlConvert.EncodeName(partName));
|
||||
public string GetVersioned(string partName, string fieldName) {
|
||||
return Get(partName, fieldName, null, true);
|
||||
}
|
||||
|
||||
public string Get(string partName, string fieldName, string valueName, bool versionable = false) {
|
||||
|
||||
var element = versionable ? VersionInfoset.Element : Infoset.Element;
|
||||
|
||||
var partElement = element.Element(XmlConvert.EncodeName(partName));
|
||||
if (partElement == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -48,24 +57,35 @@ namespace Orchard.ContentManagement.FieldStorage.InfosetStorage {
|
||||
}
|
||||
|
||||
public void Set<TPart>(string fieldName, string value) {
|
||||
Set(typeof(TPart).Name, fieldName, null, value);
|
||||
Set(typeof(TPart).Name, fieldName, null, value, typeof(TPart).IsAssignableTo<ContentItemVersionRecord>());
|
||||
}
|
||||
|
||||
public void Set(string partName, string fieldName, string value) {
|
||||
Set(partName, fieldName, null, value);
|
||||
Set(partName, fieldName, null, value, false);
|
||||
}
|
||||
|
||||
public void Set(string partName, string fieldName, string valueName, string value) {
|
||||
var partElement = Infoset.Element.Element(XmlConvert.EncodeName(partName));
|
||||
public void SetVersioned(string partName, string fieldName, string value) {
|
||||
Set(partName, fieldName, null, value, true);
|
||||
}
|
||||
|
||||
public void Set(string partName, string fieldName, string valueName, string value, bool versionable = false) {
|
||||
|
||||
var element = versionable ? VersionInfoset.Element : Infoset.Element;
|
||||
|
||||
var encodedPartName = XmlConvert.EncodeName(partName);
|
||||
var partElement = element.Element(encodedPartName);
|
||||
if (partElement == null) {
|
||||
partElement = new XElement(XmlConvert.EncodeName(partName));
|
||||
partElement = new XElement(encodedPartName);
|
||||
Infoset.Element.Add(partElement);
|
||||
}
|
||||
var fieldElement = partElement.Element(XmlConvert.EncodeName(fieldName));
|
||||
|
||||
var encodedFieldName = XmlConvert.EncodeName(fieldName);
|
||||
var fieldElement = partElement.Element(encodedFieldName);
|
||||
if (fieldElement == null) {
|
||||
fieldElement = new XElement(XmlConvert.EncodeName(fieldName));
|
||||
fieldElement = new XElement(encodedFieldName);
|
||||
partElement.Add(fieldElement);
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(valueName)) {
|
||||
fieldElement.Value = value ?? "";
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement;
|
||||
|
||||
namespace Orchard.Settings {
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user