mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-24 13:33:34 +08:00
BodyAspect -> BodyPart; CommonAspect -> CommonPart
- updating part names to conform to a <name>Part convention --HG-- branch : dev rename : src/Orchard.Core.Tests/Common/Providers/CommonAspectProviderTests.cs => src/Orchard.Core.Tests/Common/Providers/CommonPartProviderTests.cs rename : src/Orchard.Web/Core/Common/Drivers/BodyDriver.cs => src/Orchard.Web/Core/Common/Drivers/BodyPartDriver.cs rename : src/Orchard.Web/Core/Common/Drivers/CommonDriver.cs => src/Orchard.Web/Core/Common/Drivers/CommonPartDriver.cs rename : src/Orchard.Web/Core/Common/Handlers/BodyAspectHandler.cs => src/Orchard.Web/Core/Common/Handlers/BodyPartHandler.cs rename : src/Orchard.Web/Core/Common/Handlers/CommonAspectHandler.cs => src/Orchard.Web/Core/Common/Handlers/CommonPartHandler.cs rename : src/Orchard.Web/Core/Common/Models/BodyAspect.cs => src/Orchard.Web/Core/Common/Models/BodyPart.cs rename : src/Orchard.Web/Core/Common/Models/BodyRecord.cs => src/Orchard.Web/Core/Common/Models/BodyPartRecord.cs rename : src/Orchard.Web/Core/Common/Models/CommonAspect.cs => src/Orchard.Web/Core/Common/Models/CommonPart.cs rename : src/Orchard.Web/Core/Common/Models/CommonRecord.cs => src/Orchard.Web/Core/Common/Models/CommonPartRecord.cs rename : src/Orchard.Web/Core/Common/Models/CommonVersionRecord.cs => src/Orchard.Web/Core/Common/Models/CommonPartVersionRecord.cs rename : src/Orchard/ContentManagement/Aspects/ICommonAspect.cs => src/Orchard/ContentManagement/Aspects/ICommonPart.cs
This commit is contained in:
@@ -25,7 +25,7 @@ using System.Web.Mvc;
|
|||||||
|
|
||||||
namespace Orchard.Core.Tests.Common.Providers {
|
namespace Orchard.Core.Tests.Common.Providers {
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class CommonAspectProviderTests : DatabaseEnabledTestsBase {
|
public class CommonPartProviderTests : DatabaseEnabledTestsBase {
|
||||||
private Mock<IAuthenticationService> _authn;
|
private Mock<IAuthenticationService> _authn;
|
||||||
private Mock<IAuthorizationService> _authz;
|
private Mock<IAuthorizationService> _authz;
|
||||||
private Mock<IMembershipService> _membership;
|
private Mock<IMembershipService> _membership;
|
||||||
@@ -35,7 +35,7 @@ namespace Orchard.Core.Tests.Common.Providers {
|
|||||||
builder.RegisterType<DefaultContentManager>().As<IContentManager>();
|
builder.RegisterType<DefaultContentManager>().As<IContentManager>();
|
||||||
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
|
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
|
||||||
builder.RegisterType<TestHandler>().As<IContentHandler>();
|
builder.RegisterType<TestHandler>().As<IContentHandler>();
|
||||||
builder.RegisterType<CommonAspectHandler>().As<IContentHandler>();
|
builder.RegisterType<CommonPartHandler>().As<IContentHandler>();
|
||||||
builder.RegisterType<CommonService>().As<ICommonService>();
|
builder.RegisterType<CommonService>().As<ICommonService>();
|
||||||
builder.RegisterType<PublishingTaskManager>().As<IPublishingTaskManager>();
|
builder.RegisterType<PublishingTaskManager>().As<IPublishingTaskManager>();
|
||||||
builder.RegisterType<ScheduledTaskManager>().As<IScheduledTaskManager>();
|
builder.RegisterType<ScheduledTaskManager>().As<IScheduledTaskManager>();
|
||||||
@@ -57,8 +57,8 @@ namespace Orchard.Core.Tests.Common.Providers {
|
|||||||
typeof(ContentTypeRecord),
|
typeof(ContentTypeRecord),
|
||||||
typeof(ContentItemRecord),
|
typeof(ContentItemRecord),
|
||||||
typeof(ContentItemVersionRecord),
|
typeof(ContentItemVersionRecord),
|
||||||
typeof(CommonRecord),
|
typeof(CommonPartRecord),
|
||||||
typeof(CommonVersionRecord),
|
typeof(CommonPartVersionRecord),
|
||||||
typeof(ScheduledTaskRecord),
|
typeof(ScheduledTaskRecord),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -67,8 +67,8 @@ namespace Orchard.Core.Tests.Common.Providers {
|
|||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
class TestHandler : ContentHandler {
|
class TestHandler : ContentHandler {
|
||||||
public TestHandler() {
|
public TestHandler() {
|
||||||
Filters.Add(new ActivatingFilter<CommonAspect>("test-item"));
|
Filters.Add(new ActivatingFilter<CommonPart>("test-item"));
|
||||||
Filters.Add(new ActivatingFilter<ContentPart<CommonVersionRecord>>("test-item"));
|
Filters.Add(new ActivatingFilter<ContentPart<CommonPartVersionRecord>>("test-item"));
|
||||||
Filters.Add(new ActivatingFilter<TestUser>("User"));
|
Filters.Add(new ActivatingFilter<TestUser>("User"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -82,7 +82,7 @@ namespace Orchard.Core.Tests.Common.Providers {
|
|||||||
[Test]
|
[Test]
|
||||||
public void OwnerShouldBeNullAndZeroByDefault() {
|
public void OwnerShouldBeNullAndZeroByDefault() {
|
||||||
var contentManager = _container.Resolve<IContentManager>();
|
var contentManager = _container.Resolve<IContentManager>();
|
||||||
var item = contentManager.Create<CommonAspect>("test-item", init => { });
|
var item = contentManager.Create<CommonPart>("test-item", init => { });
|
||||||
ClearSession();
|
ClearSession();
|
||||||
|
|
||||||
Assert.That(item.Owner, Is.Null);
|
Assert.That(item.Owner, Is.Null);
|
||||||
@@ -99,7 +99,7 @@ namespace Orchard.Core.Tests.Common.Providers {
|
|||||||
_authn.Setup(x => x.GetAuthenticatedUser()).Returns(user);
|
_authn.Setup(x => x.GetAuthenticatedUser()).Returns(user);
|
||||||
|
|
||||||
var createUtc = _clock.UtcNow;
|
var createUtc = _clock.UtcNow;
|
||||||
var item = contentManager.Create<ICommonAspect>("test-item", VersionOptions.Draft, init => { });
|
var item = contentManager.Create<ICommonPart>("test-item", VersionOptions.Draft, init => { });
|
||||||
var viewModel = new OwnerEditorViewModel() { Owner = "User" };
|
var viewModel = new OwnerEditorViewModel() { Owner = "User" };
|
||||||
updateModel.Setup(x => x.TryUpdateModel(viewModel, "", null, null)).Returns(true);
|
updateModel.Setup(x => x.TryUpdateModel(viewModel, "", null, null)).Returns(true);
|
||||||
contentManager.UpdateEditorModel(item.ContentItem, updateModel.Object);
|
contentManager.UpdateEditorModel(item.ContentItem, updateModel.Object);
|
||||||
@@ -131,7 +131,7 @@ namespace Orchard.Core.Tests.Common.Providers {
|
|||||||
{
|
{
|
||||||
var contentManager = _container.Resolve<IContentManager>();
|
var contentManager = _container.Resolve<IContentManager>();
|
||||||
|
|
||||||
var item = contentManager.Create<ICommonAspect>("test-item", VersionOptions.Draft, init => { });
|
var item = contentManager.Create<ICommonPart>("test-item", VersionOptions.Draft, init => { });
|
||||||
|
|
||||||
var user = contentManager.New<IUser>("User");
|
var user = contentManager.New<IUser>("User");
|
||||||
_authn.Setup(x => x.GetAuthenticatedUser()).Returns(user);
|
_authn.Setup(x => x.GetAuthenticatedUser()).Returns(user);
|
||||||
@@ -149,7 +149,7 @@ namespace Orchard.Core.Tests.Common.Providers {
|
|||||||
{
|
{
|
||||||
var contentManager = _container.Resolve<IContentManager>();
|
var contentManager = _container.Resolve<IContentManager>();
|
||||||
|
|
||||||
var item = contentManager.Create<ICommonAspect>("test-item", VersionOptions.Draft, init => { });
|
var item = contentManager.Create<ICommonPart>("test-item", VersionOptions.Draft, init => { });
|
||||||
|
|
||||||
var user = contentManager.New<IUser>("User");
|
var user = contentManager.New<IUser>("User");
|
||||||
_authn.Setup(x => x.GetAuthenticatedUser()).Returns(user);
|
_authn.Setup(x => x.GetAuthenticatedUser()).Returns(user);
|
||||||
@@ -161,7 +161,7 @@ namespace Orchard.Core.Tests.Common.Providers {
|
|||||||
|
|
||||||
contentManager.UpdateEditorModel(item.ContentItem, updater);
|
contentManager.UpdateEditorModel(item.ContentItem, updater);
|
||||||
|
|
||||||
Assert.That(updater.ModelErrors.ContainsKey("CommonAspect.Owner"), Is.True);
|
Assert.That(updater.ModelErrors.ContainsKey("CommonPart.Owner"), Is.True);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@@ -170,7 +170,7 @@ namespace Orchard.Core.Tests.Common.Providers {
|
|||||||
var contentManager = _container.Resolve<IContentManager>();
|
var contentManager = _container.Resolve<IContentManager>();
|
||||||
|
|
||||||
var createUtc = _clock.UtcNow;
|
var createUtc = _clock.UtcNow;
|
||||||
var item = contentManager.Create<ICommonAspect>("test-item", VersionOptions.Draft, init => { });
|
var item = contentManager.Create<ICommonPart>("test-item", VersionOptions.Draft, init => { });
|
||||||
|
|
||||||
Assert.That(item.CreatedUtc, Is.EqualTo(createUtc));
|
Assert.That(item.CreatedUtc, Is.EqualTo(createUtc));
|
||||||
Assert.That(item.PublishedUtc, Is.Null);
|
Assert.That(item.PublishedUtc, Is.Null);
|
||||||
@@ -190,7 +190,7 @@ namespace Orchard.Core.Tests.Common.Providers {
|
|||||||
var contentManager = _container.Resolve<IContentManager>();
|
var contentManager = _container.Resolve<IContentManager>();
|
||||||
|
|
||||||
var createUtc = _clock.UtcNow;
|
var createUtc = _clock.UtcNow;
|
||||||
var item1 = contentManager.Create<ICommonAspect>("test-item", VersionOptions.Draft, init => { });
|
var item1 = contentManager.Create<ICommonPart>("test-item", VersionOptions.Draft, init => { });
|
||||||
|
|
||||||
Assert.That(item1.CreatedUtc, Is.EqualTo(createUtc));
|
Assert.That(item1.CreatedUtc, Is.EqualTo(createUtc));
|
||||||
Assert.That(item1.PublishedUtc, Is.Null);
|
Assert.That(item1.PublishedUtc, Is.Null);
|
||||||
@@ -204,7 +204,7 @@ namespace Orchard.Core.Tests.Common.Providers {
|
|||||||
|
|
||||||
_clock.Advance(TimeSpan.FromMinutes(1));
|
_clock.Advance(TimeSpan.FromMinutes(1));
|
||||||
var draftUtc = _clock.UtcNow;
|
var draftUtc = _clock.UtcNow;
|
||||||
var item2 = contentManager.GetDraftRequired<ICommonAspect>(item1.ContentItem.Id);
|
var item2 = contentManager.GetDraftRequired<ICommonPart>(item1.ContentItem.Id);
|
||||||
|
|
||||||
_clock.Advance(TimeSpan.FromMinutes(1));
|
_clock.Advance(TimeSpan.FromMinutes(1));
|
||||||
var publish2Utc = _clock.UtcNow;
|
var publish2Utc = _clock.UtcNow;
|
||||||
@@ -232,7 +232,7 @@ namespace Orchard.Core.Tests.Common.Providers {
|
|||||||
var contentManager = _container.Resolve<IContentManager>();
|
var contentManager = _container.Resolve<IContentManager>();
|
||||||
|
|
||||||
var createUtc = _clock.UtcNow;
|
var createUtc = _clock.UtcNow;
|
||||||
var item = contentManager.Create<ICommonAspect>("test-item", VersionOptions.Draft, init => { });
|
var item = contentManager.Create<ICommonPart>("test-item", VersionOptions.Draft, init => { });
|
||||||
|
|
||||||
Assert.That(item.CreatedUtc, Is.EqualTo(createUtc));
|
Assert.That(item.CreatedUtc, Is.EqualTo(createUtc));
|
||||||
Assert.That(item.PublishedUtc, Is.Null);
|
Assert.That(item.PublishedUtc, Is.Null);
|
||||||
@@ -252,9 +252,9 @@ namespace Orchard.Core.Tests.Common.Providers {
|
|||||||
_session.Flush();
|
_session.Flush();
|
||||||
_session.Clear();
|
_session.Clear();
|
||||||
|
|
||||||
var publishedItem = contentManager.Get<ICommonAspect>(item.ContentItem.Id, VersionOptions.Published);
|
var publishedItem = contentManager.Get<ICommonPart>(item.ContentItem.Id, VersionOptions.Published);
|
||||||
var latestItem = contentManager.Get<ICommonAspect>(item.ContentItem.Id, VersionOptions.Latest);
|
var latestItem = contentManager.Get<ICommonPart>(item.ContentItem.Id, VersionOptions.Latest);
|
||||||
var draftItem = contentManager.Get<ICommonAspect>(item.ContentItem.Id, VersionOptions.Draft);
|
var draftItem = contentManager.Get<ICommonPart>(item.ContentItem.Id, VersionOptions.Draft);
|
||||||
var allVersions = contentManager.GetAllVersions(item.ContentItem.Id);
|
var allVersions = contentManager.GetAllVersions(item.ContentItem.Id);
|
||||||
|
|
||||||
Assert.That(publishedItem, Is.Null);
|
Assert.That(publishedItem, Is.Null);
|
@@ -189,8 +189,8 @@ namespace Orchard.Core.Tests.Common.Services {
|
|||||||
typeof(ContentTypeRecord),
|
typeof(ContentTypeRecord),
|
||||||
typeof(ContentItemRecord),
|
typeof(ContentItemRecord),
|
||||||
typeof(ContentItemVersionRecord),
|
typeof(ContentItemVersionRecord),
|
||||||
typeof(CommonRecord),
|
typeof(CommonPartRecord),
|
||||||
typeof(CommonVersionRecord),
|
typeof(CommonPartVersionRecord),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -199,8 +199,8 @@ namespace Orchard.Core.Tests.Common.Services {
|
|||||||
public class ThingHandler : ContentHandler {
|
public class ThingHandler : ContentHandler {
|
||||||
public ThingHandler() {
|
public ThingHandler() {
|
||||||
Filters.Add(new ActivatingFilter<Thing>(ThingDriver.ContentType.Name));
|
Filters.Add(new ActivatingFilter<Thing>(ThingDriver.ContentType.Name));
|
||||||
Filters.Add(new ActivatingFilter<ContentPart<CommonVersionRecord>>(ThingDriver.ContentType.Name));
|
Filters.Add(new ActivatingFilter<ContentPart<CommonPartVersionRecord>>(ThingDriver.ContentType.Name));
|
||||||
Filters.Add(new ActivatingFilter<CommonAspect>(ThingDriver.ContentType.Name));
|
Filters.Add(new ActivatingFilter<CommonPart>(ThingDriver.ContentType.Name));
|
||||||
Filters.Add(new ActivatingFilter<IsRoutable>(ThingDriver.ContentType.Name));
|
Filters.Add(new ActivatingFilter<IsRoutable>(ThingDriver.ContentType.Name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -230,8 +230,8 @@ namespace Orchard.Core.Tests.Common.Services {
|
|||||||
public class StuffHandler : ContentHandler {
|
public class StuffHandler : ContentHandler {
|
||||||
public StuffHandler() {
|
public StuffHandler() {
|
||||||
Filters.Add(new ActivatingFilter<Stuff>(StuffDriver.ContentType.Name));
|
Filters.Add(new ActivatingFilter<Stuff>(StuffDriver.ContentType.Name));
|
||||||
Filters.Add(new ActivatingFilter<ContentPart<CommonVersionRecord>>(StuffDriver.ContentType.Name));
|
Filters.Add(new ActivatingFilter<ContentPart<CommonPartVersionRecord>>(StuffDriver.ContentType.Name));
|
||||||
Filters.Add(new ActivatingFilter<CommonAspect>(StuffDriver.ContentType.Name));
|
Filters.Add(new ActivatingFilter<CommonPart>(StuffDriver.ContentType.Name));
|
||||||
Filters.Add(new ActivatingFilter<IsRoutable>(StuffDriver.ContentType.Name));
|
Filters.Add(new ActivatingFilter<IsRoutable>(StuffDriver.ContentType.Name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -148,18 +148,18 @@ namespace Orchard.Core.Tests.Feeds.Controllers {
|
|||||||
public void CorePartValuesAreExtracted() {
|
public void CorePartValuesAreExtracted() {
|
||||||
var clock = new StubClock();
|
var clock = new StubClock();
|
||||||
var hello = new ContentItemBuilder(new ContentTypeDefinitionBuilder().Named("hello").Build())
|
var hello = new ContentItemBuilder(new ContentTypeDefinitionBuilder().Named("hello").Build())
|
||||||
.Weld<CommonAspect>()
|
.Weld<CommonPart>()
|
||||||
.Weld<IsRoutable>()
|
.Weld<IsRoutable>()
|
||||||
.Weld<BodyAspect>()
|
.Weld<BodyPart>()
|
||||||
.Build();
|
.Build();
|
||||||
hello.As<CommonAspect>().Record = new CommonRecord();
|
hello.As<CommonPart>().Record = new CommonPartRecord();
|
||||||
hello.As<IsRoutable>().Record = new RoutableRecord();
|
hello.As<IsRoutable>().Record = new RoutableRecord();
|
||||||
hello.As<BodyAspect>().Record = new BodyRecord();
|
hello.As<BodyPart>().Record = new BodyPartRecord();
|
||||||
|
|
||||||
hello.As<CommonAspect>().PublishedUtc = clock.UtcNow;
|
hello.As<CommonPart>().PublishedUtc = clock.UtcNow;
|
||||||
hello.As<IsRoutable>().Title = "alpha";
|
hello.As<IsRoutable>().Title = "alpha";
|
||||||
hello.As<IsRoutable>().Slug = "beta";
|
hello.As<IsRoutable>().Slug = "beta";
|
||||||
hello.As<BodyAspect>().Text = "gamma";
|
hello.As<BodyPart>().Text = "gamma";
|
||||||
|
|
||||||
var query = new StubQuery(new[] {
|
var query = new StubQuery(new[] {
|
||||||
hello,
|
hello,
|
||||||
|
@@ -100,7 +100,7 @@
|
|||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Common\Providers\CommonAspectProviderTests.cs" />
|
<Compile Include="Common\Providers\CommonPartProviderTests.cs" />
|
||||||
<Compile Include="Common\Services\RoutableServiceTests.cs" />
|
<Compile Include="Common\Services\RoutableServiceTests.cs" />
|
||||||
<Compile Include="Feeds\Controllers\FeedControllerTests.cs" />
|
<Compile Include="Feeds\Controllers\FeedControllerTests.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
@@ -9,15 +9,15 @@ using Orchard.Data.Migration;
|
|||||||
namespace Orchard.Core.Common.DataMigrations {
|
namespace Orchard.Core.Common.DataMigrations {
|
||||||
public class CommonDataMigration : DataMigrationImpl {
|
public class CommonDataMigration : DataMigrationImpl {
|
||||||
public int Create() {
|
public int Create() {
|
||||||
//CREATE TABLE Common_BodyRecord (Id INTEGER not null, Text TEXT, Format TEXT, ContentItemRecord_id INTEGER, primary key (Id));
|
//CREATE TABLE Common_BodyPartRecord (Id INTEGER not null, Text TEXT, Format TEXT, ContentItemRecord_id INTEGER, primary key (Id));
|
||||||
SchemaBuilder.CreateTable("BodyRecord", table => table
|
SchemaBuilder.CreateTable("BodyPartRecord", table => table
|
||||||
.ContentPartVersionRecord()
|
.ContentPartVersionRecord()
|
||||||
.Column<string>("Text", column => column.Unlimited())
|
.Column<string>("Text", column => column.Unlimited())
|
||||||
.Column<string>("Format")
|
.Column<string>("Format")
|
||||||
);
|
);
|
||||||
|
|
||||||
//CREATE TABLE Common_CommonRecord (Id INTEGER not null, OwnerId INTEGER, CreatedUtc DATETIME, PublishedUtc DATETIME, ModifiedUtc DATETIME, Container_id INTEGER, primary key (Id));
|
//CREATE TABLE Common_CommonPartRecord (Id INTEGER not null, OwnerId INTEGER, CreatedUtc DATETIME, PublishedUtc DATETIME, ModifiedUtc DATETIME, Container_id INTEGER, primary key (Id));
|
||||||
SchemaBuilder.CreateTable("CommonRecord", table => table
|
SchemaBuilder.CreateTable("CommonPartRecord", table => table
|
||||||
.ContentPartRecord()
|
.ContentPartRecord()
|
||||||
.Column<int>("OwnerId")
|
.Column<int>("OwnerId")
|
||||||
.Column<DateTime>("CreatedUtc")
|
.Column<DateTime>("CreatedUtc")
|
||||||
@@ -26,8 +26,8 @@ namespace Orchard.Core.Common.DataMigrations {
|
|||||||
.Column<int>("Container_id")
|
.Column<int>("Container_id")
|
||||||
);
|
);
|
||||||
|
|
||||||
//CREATE TABLE Common_CommonVersionRecord (Id INTEGER not null, CreatedUtc DATETIME, PublishedUtc DATETIME, ModifiedUtc DATETIME, ContentItemRecord_id INTEGER, primary key (Id));
|
//CREATE TABLE Common_CommonPartVersionRecord (Id INTEGER not null, CreatedUtc DATETIME, PublishedUtc DATETIME, ModifiedUtc DATETIME, ContentItemRecord_id INTEGER, primary key (Id));
|
||||||
SchemaBuilder.CreateTable("CommonVersionRecord", table => table
|
SchemaBuilder.CreateTable("CommonPartVersionRecord", table => table
|
||||||
.ContentPartVersionRecord()
|
.ContentPartVersionRecord()
|
||||||
.Column<DateTime>("CreatedUtc")
|
.Column<DateTime>("CreatedUtc")
|
||||||
.Column<DateTime>("PublishedUtc")
|
.Column<DateTime>("PublishedUtc")
|
||||||
@@ -38,7 +38,7 @@ namespace Orchard.Core.Common.DataMigrations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int UpdateFrom1() {
|
public int UpdateFrom1() {
|
||||||
ContentDefinitionManager.AlterPartDefinition(typeof(BodyAspect).Name, cfg => cfg
|
ContentDefinitionManager.AlterPartDefinition(typeof(BodyPart).Name, cfg => cfg
|
||||||
.WithLocation(new Dictionary<string, ContentLocation> {
|
.WithLocation(new Dictionary<string, ContentLocation> {
|
||||||
{"Default", new ContentLocation { Zone = "primary", Position = "5" }},
|
{"Default", new ContentLocation { Zone = "primary", Position = "5" }},
|
||||||
}));
|
}));
|
||||||
@@ -46,7 +46,7 @@ namespace Orchard.Core.Common.DataMigrations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int UpdateFrom2() {
|
public int UpdateFrom2() {
|
||||||
ContentDefinitionManager.AlterPartDefinition(typeof(CommonAspect).Name, cfg => cfg
|
ContentDefinitionManager.AlterPartDefinition(typeof(CommonPart).Name, cfg => cfg
|
||||||
.WithLocation(new Dictionary<string, ContentLocation> {
|
.WithLocation(new Dictionary<string, ContentLocation> {
|
||||||
{"Default", new ContentLocation { Zone = "metadata", Position = "5" }},
|
{"Default", new ContentLocation { Zone = "metadata", Position = "5" }},
|
||||||
{"Editor", new ContentLocation { Zone = "primary", Position = "20" }},
|
{"Editor", new ContentLocation { Zone = "primary", Position = "20" }},
|
||||||
|
@@ -11,13 +11,13 @@ using Orchard.Core.Routable.Models;
|
|||||||
|
|
||||||
namespace Orchard.Core.Common.Drivers {
|
namespace Orchard.Core.Common.Drivers {
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public class BodyDriver : ContentPartDriver<BodyAspect> {
|
public class BodyPartDriver : ContentPartDriver<BodyPart> {
|
||||||
public IOrchardServices Services { get; set; }
|
public IOrchardServices Services { get; set; }
|
||||||
private const string TemplateName = "Parts/Common.Body";
|
private const string TemplateName = "Parts/Common.Body";
|
||||||
private const string DefaultTextEditorTemplate = "TinyMceTextEditor";
|
private const string DefaultTextEditorTemplate = "TinyMceTextEditor";
|
||||||
private const string PlainTextEditorTemplate = "PlainTextEditor";
|
private const string PlainTextEditorTemplate = "PlainTextEditor";
|
||||||
|
|
||||||
public BodyDriver(IOrchardServices services) {
|
public BodyPartDriver(IOrchardServices services) {
|
||||||
Services = services;
|
Services = services;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,8 +26,8 @@ namespace Orchard.Core.Common.Drivers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// \/\/ Hackalicious on many accounts - don't copy what has been done here for the wrapper \/\/
|
// \/\/ Hackalicious on many accounts - don't copy what has been done here for the wrapper \/\/
|
||||||
protected override DriverResult Display(BodyAspect part, string displayType) {
|
protected override DriverResult Display(BodyPart part, string displayType) {
|
||||||
var model = new BodyDisplayViewModel { BodyAspect = part, Text = BbcodeReplace(part.Text) };
|
var model = new BodyDisplayViewModel { BodyPart = part, Text = BbcodeReplace(part.Text) };
|
||||||
var location = part.GetLocation(displayType);
|
var location = part.GetLocation(displayType);
|
||||||
|
|
||||||
return Combined(
|
return Combined(
|
||||||
@@ -37,13 +37,13 @@ namespace Orchard.Core.Common.Drivers {
|
|||||||
Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Common.Body.ManageWrapperPost").LongestMatch(displayType, "SummaryAdmin").Location(location) : null);
|
Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Common.Body.ManageWrapperPost").LongestMatch(displayType, "SummaryAdmin").Location(location) : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override DriverResult Editor(BodyAspect part) {
|
protected override DriverResult Editor(BodyPart part) {
|
||||||
var model = BuildEditorViewModel(part);
|
var model = BuildEditorViewModel(part);
|
||||||
var location = part.GetLocation("Editor");
|
var location = part.GetLocation("Editor");
|
||||||
return ContentPartTemplate(model, TemplateName, Prefix).Location(location);
|
return ContentPartTemplate(model, TemplateName, Prefix).Location(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override DriverResult Editor(BodyAspect part, IUpdateModel updater) {
|
protected override DriverResult Editor(BodyPart part, IUpdateModel updater) {
|
||||||
var model = BuildEditorViewModel(part);
|
var model = BuildEditorViewModel(part);
|
||||||
updater.TryUpdateModel(model, Prefix, null, null);
|
updater.TryUpdateModel(model, Prefix, null, null);
|
||||||
|
|
||||||
@@ -55,15 +55,15 @@ namespace Orchard.Core.Common.Drivers {
|
|||||||
return ContentPartTemplate(model, TemplateName, Prefix).Location(location);
|
return ContentPartTemplate(model, TemplateName, Prefix).Location(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BodyEditorViewModel BuildEditorViewModel(BodyAspect part) {
|
private static BodyEditorViewModel BuildEditorViewModel(BodyPart part) {
|
||||||
return new BodyEditorViewModel {
|
return new BodyEditorViewModel {
|
||||||
BodyAspect = part,
|
BodyPart = part,
|
||||||
TextEditorTemplate = GetFlavor(part) == "html" ? DefaultTextEditorTemplate : PlainTextEditorTemplate,
|
TextEditorTemplate = GetFlavor(part) == "html" ? DefaultTextEditorTemplate : PlainTextEditorTemplate,
|
||||||
AddMediaPath= new PathBuilder(part).AddContentType().AddContainerSlug().AddSlug().ToString()
|
AddMediaPath= new PathBuilder(part).AddContentType().AddContainerSlug().AddSlug().ToString()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetFlavor(BodyAspect part) {
|
private static string GetFlavor(BodyPart part) {
|
||||||
var typePartSettings = part.Settings.GetModel<BodyTypePartSettings>();
|
var typePartSettings = part.Settings.GetModel<BodyTypePartSettings>();
|
||||||
return (typePartSettings != null && !string.IsNullOrWhiteSpace(typePartSettings.Flavor))
|
return (typePartSettings != null && !string.IsNullOrWhiteSpace(typePartSettings.Flavor))
|
||||||
? typePartSettings.Flavor
|
? typePartSettings.Flavor
|
||||||
@@ -89,7 +89,7 @@ namespace Orchard.Core.Common.Drivers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PathBuilder AddContainerSlug() {
|
public PathBuilder AddContainerSlug() {
|
||||||
var common = _content.As<ICommonAspect>();
|
var common = _content.As<ICommonPart>();
|
||||||
if (common == null)
|
if (common == null)
|
||||||
return this;
|
return this;
|
||||||
|
|
@@ -8,15 +8,15 @@ using Orchard.Security;
|
|||||||
using Orchard.Services;
|
using Orchard.Services;
|
||||||
|
|
||||||
namespace Orchard.Core.Common.Drivers {
|
namespace Orchard.Core.Common.Drivers {
|
||||||
public class CommonDriver : ContentPartDriver<CommonAspect> {
|
public class CommonPartDriver : ContentPartDriver<CommonPart> {
|
||||||
private const string TemplatePrefix = "CommonAspect";
|
private const string TemplatePrefix = "CommonPart";
|
||||||
private readonly IContentManager _contentManager;
|
private readonly IContentManager _contentManager;
|
||||||
private readonly IAuthenticationService _authenticationService;
|
private readonly IAuthenticationService _authenticationService;
|
||||||
private readonly IAuthorizationService _authorizationService;
|
private readonly IAuthorizationService _authorizationService;
|
||||||
private readonly IMembershipService _membershipService;
|
private readonly IMembershipService _membershipService;
|
||||||
private readonly IClock _clock;
|
private readonly IClock _clock;
|
||||||
|
|
||||||
public CommonDriver(
|
public CommonPartDriver(
|
||||||
IOrchardServices services,
|
IOrchardServices services,
|
||||||
IContentManager contentManager,
|
IContentManager contentManager,
|
||||||
IAuthenticationService authenticationService,
|
IAuthenticationService authenticationService,
|
||||||
@@ -35,19 +35,19 @@ namespace Orchard.Core.Common.Drivers {
|
|||||||
public Localizer T { get; set; }
|
public Localizer T { get; set; }
|
||||||
public IOrchardServices Services { get; set; }
|
public IOrchardServices Services { get; set; }
|
||||||
|
|
||||||
protected override DriverResult Display(CommonAspect part, string displayType) {
|
protected override DriverResult Display(CommonPart part, string displayType) {
|
||||||
return ContentPartTemplate(new CommonMetadataViewModel(part), "Parts/Common.Metadata")
|
return ContentPartTemplate(new CommonMetadataViewModel(part), "Parts/Common.Metadata")
|
||||||
.LongestMatch(displayType, "Summary", "SummaryAdmin")
|
.LongestMatch(displayType, "Summary", "SummaryAdmin")
|
||||||
.Location(part.GetLocation(displayType));
|
.Location(part.GetLocation(displayType));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override DriverResult Editor(CommonAspect part) {
|
protected override DriverResult Editor(CommonPart part) {
|
||||||
return Combined(
|
return Combined(
|
||||||
OwnerEditor(part, null),
|
OwnerEditor(part, null),
|
||||||
ContainerEditor(part, null));
|
ContainerEditor(part, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override DriverResult Editor(CommonAspect instance, ContentManagement.IUpdateModel updater) {
|
protected override DriverResult Editor(CommonPart instance, ContentManagement.IUpdateModel updater) {
|
||||||
// this event is hooked so the modified timestamp is changed when an edit-post occurs.
|
// this event is hooked so the modified timestamp is changed when an edit-post occurs.
|
||||||
instance.ModifiedUtc = _clock.UtcNow;
|
instance.ModifiedUtc = _clock.UtcNow;
|
||||||
instance.VersionModifiedUtc = _clock.UtcNow;
|
instance.VersionModifiedUtc = _clock.UtcNow;
|
||||||
@@ -57,7 +57,7 @@ namespace Orchard.Core.Common.Drivers {
|
|||||||
ContainerEditor(instance, updater));
|
ContainerEditor(instance, updater));
|
||||||
}
|
}
|
||||||
|
|
||||||
DriverResult OwnerEditor(CommonAspect part, IUpdateModel updater) {
|
DriverResult OwnerEditor(CommonPart part, IUpdateModel updater) {
|
||||||
var currentUser = _authenticationService.GetAuthenticatedUser();
|
var currentUser = _authenticationService.GetAuthenticatedUser();
|
||||||
if (!_authorizationService.TryCheckAccess(Permissions.ChangeOwner, currentUser, part)) {
|
if (!_authorizationService.TryCheckAccess(Permissions.ChangeOwner, currentUser, part)) {
|
||||||
return null;
|
return null;
|
||||||
@@ -74,7 +74,7 @@ namespace Orchard.Core.Common.Drivers {
|
|||||||
if (model.Owner != null && model.Owner != priorOwner) {
|
if (model.Owner != null && model.Owner != priorOwner) {
|
||||||
var newOwner = _membershipService.GetUser(model.Owner);
|
var newOwner = _membershipService.GetUser(model.Owner);
|
||||||
if (newOwner == null) {
|
if (newOwner == null) {
|
||||||
updater.AddModelError("CommonAspect.Owner", T("Invalid user name"));
|
updater.AddModelError("CommonPart.Owner", T("Invalid user name"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
part.Owner = newOwner;
|
part.Owner = newOwner;
|
||||||
@@ -85,7 +85,7 @@ namespace Orchard.Core.Common.Drivers {
|
|||||||
return ContentPartTemplate(model, "Parts/Common.Owner", TemplatePrefix).Location(part.GetLocation("Editor"));
|
return ContentPartTemplate(model, "Parts/Common.Owner", TemplatePrefix).Location(part.GetLocation("Editor"));
|
||||||
}
|
}
|
||||||
|
|
||||||
DriverResult ContainerEditor(CommonAspect part, IUpdateModel updater) {
|
DriverResult ContainerEditor(CommonPart part, IUpdateModel updater) {
|
||||||
var currentUser = _authenticationService.GetAuthenticatedUser();
|
var currentUser = _authenticationService.GetAuthenticatedUser();
|
||||||
if (!_authorizationService.TryCheckAccess(Permissions.ChangeOwner, currentUser, part)) {
|
if (!_authorizationService.TryCheckAccess(Permissions.ChangeOwner, currentUser, part)) {
|
||||||
return null;
|
return null;
|
||||||
@@ -102,7 +102,7 @@ namespace Orchard.Core.Common.Drivers {
|
|||||||
if (model.ContainerId != null && model.ContainerId != priorContainerId) {
|
if (model.ContainerId != null && model.ContainerId != priorContainerId) {
|
||||||
var newContainer = _contentManager.Get((int)model.ContainerId, VersionOptions.Latest);
|
var newContainer = _contentManager.Get((int)model.ContainerId, VersionOptions.Latest);
|
||||||
if (newContainer == null) {
|
if (newContainer == null) {
|
||||||
updater.AddModelError("CommonAspect.ContainerId", T("Invalid container"));
|
updater.AddModelError("CommonPart.ContainerId", T("Invalid container"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
part.Container = newContainer;
|
part.Container = newContainer;
|
@@ -5,13 +5,13 @@ using Orchard.ContentManagement.Handlers;
|
|||||||
|
|
||||||
namespace Orchard.Core.Common.Handlers {
|
namespace Orchard.Core.Common.Handlers {
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public class BodyAspectHandler : ContentHandler {
|
public class BodyPartHandler : ContentHandler {
|
||||||
public BodyAspectHandler(IRepository<BodyRecord> bodyRepository) {
|
public BodyPartHandler(IRepository<BodyPartRecord> bodyRepository) {
|
||||||
Filters.Add(StorageFilter.For(bodyRepository));
|
Filters.Add(StorageFilter.For(bodyRepository));
|
||||||
|
|
||||||
OnIndexing<BodyAspect>((context, bodyAspect) => context.DocumentIndex
|
OnIndexing<BodyPart>((context, bodyPart) => context.DocumentIndex
|
||||||
.Add("body", bodyAspect.Record.Text).RemoveTags().Analyze()
|
.Add("body", bodyPart.Record.Text).RemoveTags().Analyze()
|
||||||
.Add("format", bodyAspect.Record.Format).Store());
|
.Add("format", bodyPart.Record.Format).Store());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -9,14 +9,14 @@ using Orchard.Services;
|
|||||||
|
|
||||||
namespace Orchard.Core.Common.Handlers {
|
namespace Orchard.Core.Common.Handlers {
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public class CommonAspectHandler : ContentHandler {
|
public class CommonPartHandler : ContentHandler {
|
||||||
private readonly IClock _clock;
|
private readonly IClock _clock;
|
||||||
private readonly IAuthenticationService _authenticationService;
|
private readonly IAuthenticationService _authenticationService;
|
||||||
private readonly IContentManager _contentManager;
|
private readonly IContentManager _contentManager;
|
||||||
|
|
||||||
public CommonAspectHandler(
|
public CommonPartHandler(
|
||||||
IRepository<CommonRecord> commonRepository,
|
IRepository<CommonPartRecord> commonRepository,
|
||||||
IRepository<CommonVersionRecord> commonVersionRepository,
|
IRepository<CommonPartVersionRecord> commonVersionRepository,
|
||||||
IClock clock,
|
IClock clock,
|
||||||
IAuthenticationService authenticationService,
|
IAuthenticationService authenticationService,
|
||||||
IContentManager contentManager) {
|
IContentManager contentManager) {
|
||||||
@@ -29,56 +29,56 @@ namespace Orchard.Core.Common.Handlers {
|
|||||||
Filters.Add(StorageFilter.For(commonRepository));
|
Filters.Add(StorageFilter.For(commonRepository));
|
||||||
Filters.Add(StorageFilter.For(commonVersionRepository));
|
Filters.Add(StorageFilter.For(commonVersionRepository));
|
||||||
|
|
||||||
OnInitializing<CommonAspect>(PropertySetHandlers);
|
OnInitializing<CommonPart>(PropertySetHandlers);
|
||||||
OnInitializing<CommonAspect>(AssignCreatingOwner);
|
OnInitializing<CommonPart>(AssignCreatingOwner);
|
||||||
OnInitializing<ContentPart<CommonRecord>>(AssignCreatingDates);
|
OnInitializing<ContentPart<CommonPartRecord>>(AssignCreatingDates);
|
||||||
OnInitializing<ContentPart<CommonVersionRecord>>(AssignCreatingDates);
|
OnInitializing<ContentPart<CommonPartVersionRecord>>(AssignCreatingDates);
|
||||||
|
|
||||||
OnLoaded<CommonAspect>(LazyLoadHandlers);
|
OnLoaded<CommonPart>(LazyLoadHandlers);
|
||||||
|
|
||||||
OnVersioning<CommonAspect>(CopyOwnerAndContainer);
|
OnVersioning<CommonPart>(CopyOwnerAndContainer);
|
||||||
|
|
||||||
OnVersioned<ContentPart<CommonVersionRecord>>(AssignVersioningDates);
|
OnVersioned<ContentPart<CommonPartVersionRecord>>(AssignVersioningDates);
|
||||||
|
|
||||||
OnPublishing<ContentPart<CommonRecord>>(AssignPublishingDates);
|
OnPublishing<ContentPart<CommonPartRecord>>(AssignPublishingDates);
|
||||||
OnPublishing<ContentPart<CommonVersionRecord>>(AssignPublishingDates);
|
OnPublishing<ContentPart<CommonPartVersionRecord>>(AssignPublishingDates);
|
||||||
|
|
||||||
//OnGetDisplayViewModel<CommonAspect>();
|
//OnGetDisplayViewModel<CommonPart>();
|
||||||
//OnGetEditorViewModel<CommonAspect>(GetEditor);
|
//OnGetEditorViewModel<CommonPart>(GetEditor);
|
||||||
//OnUpdateEditorViewModel<CommonAspect>(UpdateEditor);
|
//OnUpdateEditorViewModel<CommonPart>(UpdateEditor);
|
||||||
|
|
||||||
OnIndexing<CommonAspect>((context, commonAspect) => context.DocumentIndex
|
OnIndexing<CommonPart>((context, commonPart) => context.DocumentIndex
|
||||||
.Add("type", commonAspect.ContentItem.ContentType).Store()
|
.Add("type", commonPart.ContentItem.ContentType).Store()
|
||||||
.Add("author", commonAspect.Owner.UserName).Store()
|
.Add("author", commonPart.Owner.UserName).Store()
|
||||||
.Add("created", commonAspect.CreatedUtc ?? _clock.UtcNow).Store()
|
.Add("created", commonPart.CreatedUtc ?? _clock.UtcNow).Store()
|
||||||
.Add("published", commonAspect.PublishedUtc ?? _clock.UtcNow).Store()
|
.Add("published", commonPart.PublishedUtc ?? _clock.UtcNow).Store()
|
||||||
.Add("modified", commonAspect.ModifiedUtc ?? _clock.UtcNow).Store()
|
.Add("modified", commonPart.ModifiedUtc ?? _clock.UtcNow).Store()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Localizer T { get; set; }
|
public Localizer T { get; set; }
|
||||||
|
|
||||||
|
|
||||||
void AssignCreatingOwner(InitializingContentContext context, CommonAspect part) {
|
void AssignCreatingOwner(InitializingContentContext context, CommonPart part) {
|
||||||
// and use the current user as Owner
|
// and use the current user as Owner
|
||||||
if (part.Record.OwnerId == 0) {
|
if (part.Record.OwnerId == 0) {
|
||||||
part.Owner = _authenticationService.GetAuthenticatedUser();
|
part.Owner = _authenticationService.GetAuthenticatedUser();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssignCreatingDates(InitializingContentContext context, ContentPart<CommonRecord> part) {
|
void AssignCreatingDates(InitializingContentContext context, ContentPart<CommonPartRecord> part) {
|
||||||
// assign default create/modified dates
|
// assign default create/modified dates
|
||||||
part.Record.CreatedUtc = _clock.UtcNow;
|
part.Record.CreatedUtc = _clock.UtcNow;
|
||||||
part.Record.ModifiedUtc = _clock.UtcNow;
|
part.Record.ModifiedUtc = _clock.UtcNow;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssignCreatingDates(InitializingContentContext context, ContentPart<CommonVersionRecord> part) {
|
void AssignCreatingDates(InitializingContentContext context, ContentPart<CommonPartVersionRecord> part) {
|
||||||
// assign default create/modified dates
|
// assign default create/modified dates
|
||||||
part.Record.CreatedUtc = _clock.UtcNow;
|
part.Record.CreatedUtc = _clock.UtcNow;
|
||||||
part.Record.ModifiedUtc = _clock.UtcNow;
|
part.Record.ModifiedUtc = _clock.UtcNow;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssignVersioningDates(VersionContentContext context, ContentPart<CommonVersionRecord> existing, ContentPart<CommonVersionRecord> building) {
|
void AssignVersioningDates(VersionContentContext context, ContentPart<CommonPartVersionRecord> existing, ContentPart<CommonPartVersionRecord> building) {
|
||||||
// assign create/modified dates for the new version
|
// assign create/modified dates for the new version
|
||||||
building.Record.CreatedUtc = _clock.UtcNow;
|
building.Record.CreatedUtc = _clock.UtcNow;
|
||||||
building.Record.ModifiedUtc = _clock.UtcNow;
|
building.Record.ModifiedUtc = _clock.UtcNow;
|
||||||
@@ -87,7 +87,7 @@ namespace Orchard.Core.Common.Handlers {
|
|||||||
building.Record.PublishedUtc = null;
|
building.Record.PublishedUtc = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssignPublishingDates(PublishContentContext context, ContentPart<CommonRecord> part) {
|
void AssignPublishingDates(PublishContentContext context, ContentPart<CommonPartRecord> part) {
|
||||||
// don't assign dates when unpublishing
|
// don't assign dates when unpublishing
|
||||||
if (context.PublishingItemVersionRecord == null)
|
if (context.PublishingItemVersionRecord == null)
|
||||||
return;
|
return;
|
||||||
@@ -96,7 +96,7 @@ namespace Orchard.Core.Common.Handlers {
|
|||||||
part.Record.PublishedUtc = _clock.UtcNow;
|
part.Record.PublishedUtc = _clock.UtcNow;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssignPublishingDates(PublishContentContext context, ContentPart<CommonVersionRecord> part) {
|
void AssignPublishingDates(PublishContentContext context, ContentPart<CommonPartVersionRecord> part) {
|
||||||
// don't assign dates when unpublishing
|
// don't assign dates when unpublishing
|
||||||
if (context.PublishingItemVersionRecord == null)
|
if (context.PublishingItemVersionRecord == null)
|
||||||
return;
|
return;
|
||||||
@@ -105,51 +105,51 @@ namespace Orchard.Core.Common.Handlers {
|
|||||||
part.Record.PublishedUtc = _clock.UtcNow;
|
part.Record.PublishedUtc = _clock.UtcNow;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void CopyOwnerAndContainer(VersionContentContext c, CommonAspect c1, CommonAspect c2) {
|
private static void CopyOwnerAndContainer(VersionContentContext c, CommonPart c1, CommonPart c2) {
|
||||||
c2.Owner = c1.Owner;
|
c2.Owner = c1.Owner;
|
||||||
c2.Container = c1.Container;
|
c2.Container = c1.Container;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LazyLoadHandlers(LoadContentContext context, CommonAspect aspect) {
|
void LazyLoadHandlers(LoadContentContext context, CommonPart part) {
|
||||||
// add handlers that will load content for id's just-in-time
|
// add handlers that will load content for id's just-in-time
|
||||||
aspect.OwnerField.Loader(() => _contentManager.Get<IUser>(aspect.Record.OwnerId));
|
part.OwnerField.Loader(() => _contentManager.Get<IUser>(part.Record.OwnerId));
|
||||||
aspect.ContainerField.Loader(() => aspect.Record.Container == null ? null : _contentManager.Get(aspect.Record.Container.Id));
|
part.ContainerField.Loader(() => part.Record.Container == null ? null : _contentManager.Get(part.Record.Container.Id));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PropertySetHandlers(InitializingContentContext context, CommonAspect aspect) {
|
static void PropertySetHandlers(InitializingContentContext context, CommonPart part) {
|
||||||
// add handlers that will update records when aspect properties are set
|
// add handlers that will update records when part properties are set
|
||||||
|
|
||||||
aspect.OwnerField.Setter(user => {
|
part.OwnerField.Setter(user => {
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
aspect.Record.OwnerId = 0;
|
part.Record.OwnerId = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
aspect.Record.OwnerId = user.ContentItem.Id;
|
part.Record.OwnerId = user.ContentItem.Id;
|
||||||
}
|
}
|
||||||
return user;
|
return user;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Force call to setter if we had already set a value
|
// Force call to setter if we had already set a value
|
||||||
if (aspect.OwnerField.Value != null)
|
if (part.OwnerField.Value != null)
|
||||||
aspect.OwnerField.Value = aspect.OwnerField.Value;
|
part.OwnerField.Value = part.OwnerField.Value;
|
||||||
|
|
||||||
aspect.ContainerField.Setter(container => {
|
part.ContainerField.Setter(container => {
|
||||||
if (container == null) {
|
if (container == null) {
|
||||||
aspect.Record.Container = null;
|
part.Record.Container = null;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
aspect.Record.Container = container.ContentItem.Record;
|
part.Record.Container = container.ContentItem.Record;
|
||||||
}
|
}
|
||||||
return container;
|
return container;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Force call to setter if we had already set a value
|
// Force call to setter if we had already set a value
|
||||||
if (aspect.ContainerField.Value != null)
|
if (part.ContainerField.Value != null)
|
||||||
aspect.ContainerField.Value = aspect.ContainerField.Value;
|
part.ContainerField.Value = part.ContainerField.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//private void GetEditor(BuildEditorModelContext context, CommonAspect instance) {
|
//private void GetEditor(BuildEditorModelContext context, CommonPart instance) {
|
||||||
// var currentUser = _authenticationService.GetAuthenticatedUser();
|
// var currentUser = _authenticationService.GetAuthenticatedUser();
|
||||||
// if (!_authorizationService.TryCheckAccess(Permissions.ChangeOwner, currentUser, instance)) {
|
// if (!_authorizationService.TryCheckAccess(Permissions.ChangeOwner, currentUser, instance)) {
|
||||||
// return;
|
// return;
|
||||||
@@ -158,11 +158,11 @@ namespace Orchard.Core.Common.Handlers {
|
|||||||
// if (instance.Owner != null)
|
// if (instance.Owner != null)
|
||||||
// viewModel.Owner = instance.Owner.UserName;
|
// viewModel.Owner = instance.Owner.UserName;
|
||||||
|
|
||||||
// context.AddEditor(new TemplateViewModel(viewModel, "CommonAspect") { TemplateName = "Parts/Common.Owner", ZoneName = "primary", Position = "999" });
|
// context.AddEditor(new TemplateViewModel(viewModel, "CommonPart") { TemplateName = "Parts/Common.Owner", ZoneName = "primary", Position = "999" });
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
//private void UpdateEditor(UpdateEditorModelContext context, CommonAspect instance) {
|
//private void UpdateEditor(UpdateEditorModelContext context, CommonPart instance) {
|
||||||
// // this event is hooked so the modified timestamp is changed when an edit-post occurs.
|
// // this event is hooked so the modified timestamp is changed when an edit-post occurs.
|
||||||
// // kind of a loose rule of thumb. may not be sufficient
|
// // kind of a loose rule of thumb. may not be sufficient
|
||||||
// instance.ModifiedUtc = _clock.UtcNow;
|
// instance.ModifiedUtc = _clock.UtcNow;
|
||||||
@@ -178,19 +178,19 @@ namespace Orchard.Core.Common.Handlers {
|
|||||||
// viewModel.Owner = instance.Owner.UserName;
|
// viewModel.Owner = instance.Owner.UserName;
|
||||||
|
|
||||||
// var priorOwner = viewModel.Owner;
|
// var priorOwner = viewModel.Owner;
|
||||||
// context.Updater.TryUpdateModel(viewModel, "CommonAspect", null, null);
|
// context.Updater.TryUpdateModel(viewModel, "CommonPart", null, null);
|
||||||
|
|
||||||
// if (viewModel.Owner != null && viewModel.Owner != priorOwner) {
|
// if (viewModel.Owner != null && viewModel.Owner != priorOwner) {
|
||||||
// var newOwner = _membershipService.GetUser(viewModel.Owner);
|
// var newOwner = _membershipService.GetUser(viewModel.Owner);
|
||||||
// if (newOwner == null) {
|
// if (newOwner == null) {
|
||||||
// context.Updater.AddModelError("CommonAspect.Owner", T("Invalid user name"));
|
// context.Updater.AddModelError("CommonPart.Owner", T("Invalid user name"));
|
||||||
// }
|
// }
|
||||||
// else {
|
// else {
|
||||||
// instance.Owner = newOwner;
|
// instance.Owner = newOwner;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// context.AddEditor(new TemplateViewModel(viewModel, "CommonAspect") { TemplateName = "Parts/Common.Owner", ZoneName = "primary", Position = "999" });
|
// context.AddEditor(new TemplateViewModel(viewModel, "CommonPart") { TemplateName = "Parts/Common.Owner", ZoneName = "primary", Position = "999" });
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,7 +1,7 @@
|
|||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
|
|
||||||
namespace Orchard.Core.Common.Models {
|
namespace Orchard.Core.Common.Models {
|
||||||
public class BodyAspect : ContentPart<BodyRecord> {
|
public class BodyPart : ContentPart<BodyPartRecord> {
|
||||||
public string Text {
|
public string Text {
|
||||||
get { return Record.Text; }
|
get { return Record.Text; }
|
||||||
set { Record.Text = value; }
|
set { Record.Text = value; }
|
@@ -2,7 +2,7 @@ using Orchard.ContentManagement.Records;
|
|||||||
using Orchard.Data.Conventions;
|
using Orchard.Data.Conventions;
|
||||||
|
|
||||||
namespace Orchard.Core.Common.Models {
|
namespace Orchard.Core.Common.Models {
|
||||||
public class BodyRecord : ContentPartVersionRecord {
|
public class BodyPartRecord : ContentPartVersionRecord {
|
||||||
[StringLengthMax]
|
[StringLengthMax]
|
||||||
public virtual string Text { get; set; }
|
public virtual string Text { get; set; }
|
||||||
|
|
@@ -5,7 +5,7 @@ using Orchard.ContentManagement.Aspects;
|
|||||||
using Orchard.Security;
|
using Orchard.Security;
|
||||||
|
|
||||||
namespace Orchard.Core.Common.Models {
|
namespace Orchard.Core.Common.Models {
|
||||||
public class CommonAspect : ContentPart<CommonRecord>, ICommonAspect {
|
public class CommonPart : ContentPart<CommonPartRecord>, ICommonPart {
|
||||||
private readonly LazyField<IUser> _owner = new LazyField<IUser>();
|
private readonly LazyField<IUser> _owner = new LazyField<IUser>();
|
||||||
private readonly LazyField<IContent> _container = new LazyField<IContent>();
|
private readonly LazyField<IContent> _container = new LazyField<IContent>();
|
||||||
|
|
||||||
@@ -38,42 +38,42 @@ namespace Orchard.Core.Common.Models {
|
|||||||
set { Record.ModifiedUtc = value; }
|
set { Record.ModifiedUtc = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
CommonVersionRecord VersionRecord {
|
CommonPartVersionRecord PartVersionRecord {
|
||||||
get {
|
get {
|
||||||
var versionPart = this.As<ContentPart<CommonVersionRecord>>();
|
var versionPart = this.As<ContentPart<CommonPartVersionRecord>>();
|
||||||
return versionPart == null ? null : versionPart.Record;
|
return versionPart == null ? null : versionPart.Record;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DateTime? VersionCreatedUtc {
|
public DateTime? VersionCreatedUtc {
|
||||||
get {
|
get {
|
||||||
return VersionRecord == null ? CreatedUtc : VersionRecord.CreatedUtc;
|
return PartVersionRecord == null ? CreatedUtc : PartVersionRecord.CreatedUtc;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
if (VersionRecord != null) {
|
if (PartVersionRecord != null) {
|
||||||
VersionRecord.CreatedUtc = value;
|
PartVersionRecord.CreatedUtc = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DateTime? VersionPublishedUtc {
|
public DateTime? VersionPublishedUtc {
|
||||||
get {
|
get {
|
||||||
return VersionRecord == null ? PublishedUtc : VersionRecord.PublishedUtc;
|
return PartVersionRecord == null ? PublishedUtc : PartVersionRecord.PublishedUtc;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
if (VersionRecord != null) {
|
if (PartVersionRecord != null) {
|
||||||
VersionRecord.PublishedUtc = value;
|
PartVersionRecord.PublishedUtc = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DateTime? VersionModifiedUtc {
|
public DateTime? VersionModifiedUtc {
|
||||||
get {
|
get {
|
||||||
return VersionRecord == null ? ModifiedUtc : VersionRecord.ModifiedUtc;
|
return PartVersionRecord == null ? ModifiedUtc : PartVersionRecord.ModifiedUtc;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
if (VersionRecord != null) {
|
if (PartVersionRecord != null) {
|
||||||
VersionRecord.ModifiedUtc = value;
|
PartVersionRecord.ModifiedUtc = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -2,7 +2,7 @@
|
|||||||
using Orchard.ContentManagement.Records;
|
using Orchard.ContentManagement.Records;
|
||||||
|
|
||||||
namespace Orchard.Core.Common.Models {
|
namespace Orchard.Core.Common.Models {
|
||||||
public class CommonRecord : ContentPartRecord {
|
public class CommonPartRecord : ContentPartRecord {
|
||||||
public virtual int OwnerId { get; set; }
|
public virtual int OwnerId { get; set; }
|
||||||
public virtual ContentItemRecord Container { get; set; }
|
public virtual ContentItemRecord Container { get; set; }
|
||||||
public virtual DateTime? CreatedUtc { get; set; }
|
public virtual DateTime? CreatedUtc { get; set; }
|
@@ -2,7 +2,7 @@ using System;
|
|||||||
using Orchard.ContentManagement.Records;
|
using Orchard.ContentManagement.Records;
|
||||||
|
|
||||||
namespace Orchard.Core.Common.Models {
|
namespace Orchard.Core.Common.Models {
|
||||||
public class CommonVersionRecord : ContentPartVersionRecord {
|
public class CommonPartVersionRecord : ContentPartVersionRecord {
|
||||||
public virtual DateTime? CreatedUtc { get; set; }
|
public virtual DateTime? CreatedUtc { get; set; }
|
||||||
public virtual DateTime? PublishedUtc { get; set; }
|
public virtual DateTime? PublishedUtc { get; set; }
|
||||||
public virtual DateTime? ModifiedUtc { get; set; }
|
public virtual DateTime? ModifiedUtc { get; set; }
|
@@ -23,7 +23,7 @@ namespace Orchard.Core.Common.Settings {
|
|||||||
|
|
||||||
public class BodySettingsHooks : ContentDefinitionEditorEventsBase {
|
public class BodySettingsHooks : ContentDefinitionEditorEventsBase {
|
||||||
public override IEnumerable<TemplateViewModel> TypePartEditor(ContentTypeDefinition.Part definition) {
|
public override IEnumerable<TemplateViewModel> TypePartEditor(ContentTypeDefinition.Part definition) {
|
||||||
if (definition.PartDefinition.Name != "BodyAspect")
|
if (definition.PartDefinition.Name != "BodyPart")
|
||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
var model = definition.Settings.GetModel<BodyTypePartSettings>();
|
var model = definition.Settings.GetModel<BodyTypePartSettings>();
|
||||||
@@ -37,7 +37,7 @@ namespace Orchard.Core.Common.Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override IEnumerable<TemplateViewModel> PartEditor(ContentPartDefinition definition) {
|
public override IEnumerable<TemplateViewModel> PartEditor(ContentPartDefinition definition) {
|
||||||
if (definition.Name != "BodyAspect")
|
if (definition.Name != "BodyPart")
|
||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
var model = definition.Settings.GetModel<BodyPartSettings>();
|
var model = definition.Settings.GetModel<BodyPartSettings>();
|
||||||
@@ -45,7 +45,7 @@ namespace Orchard.Core.Common.Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypeDefinitionBuilder.PartConfigurer builder, IUpdateModel updateModel) {
|
public override IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypeDefinitionBuilder.PartConfigurer builder, IUpdateModel updateModel) {
|
||||||
if (builder.Name != "BodyAspect")
|
if (builder.Name != "BodyPart")
|
||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
var model = new BodyTypePartSettings();
|
var model = new BodyTypePartSettings();
|
||||||
@@ -55,7 +55,7 @@ namespace Orchard.Core.Common.Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override IEnumerable<TemplateViewModel> PartEditorUpdate(ContentPartDefinitionBuilder builder, IUpdateModel updateModel) {
|
public override IEnumerable<TemplateViewModel> PartEditorUpdate(ContentPartDefinitionBuilder builder, IUpdateModel updateModel) {
|
||||||
if (builder.Name != "BodyAspect")
|
if (builder.Name != "BodyPart")
|
||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
var model = new BodyPartSettings();
|
var model = new BodyPartSettings();
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Orchard.Core.Common.ViewModels {
|
namespace Orchard.Core.Common.ViewModels {
|
||||||
public class BodyDisplayViewModel {
|
public class BodyDisplayViewModel {
|
||||||
public BodyAspect BodyAspect { get; set; }
|
public BodyPart BodyPart { get; set; }
|
||||||
public string Text { get; set; }
|
public string Text { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -2,16 +2,16 @@
|
|||||||
|
|
||||||
namespace Orchard.Core.Common.ViewModels {
|
namespace Orchard.Core.Common.ViewModels {
|
||||||
public class BodyEditorViewModel {
|
public class BodyEditorViewModel {
|
||||||
public BodyAspect BodyAspect { get; set; }
|
public BodyPart BodyPart { get; set; }
|
||||||
|
|
||||||
public string Text {
|
public string Text {
|
||||||
get { return BodyAspect.Record.Text; }
|
get { return BodyPart.Record.Text; }
|
||||||
set { BodyAspect.Record.Text = value; }
|
set { BodyPart.Record.Text = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Format {
|
public string Format {
|
||||||
get { return BodyAspect.Record.Format; }
|
get { return BodyPart.Record.Format; }
|
||||||
set { BodyAspect.Record.Format = value; }
|
set { BodyPart.Record.Format = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string TextEditorTemplate { get; set; }
|
public string TextEditorTemplate { get; set; }
|
||||||
|
@@ -4,20 +4,20 @@ using Orchard.Security;
|
|||||||
|
|
||||||
namespace Orchard.Core.Common.ViewModels {
|
namespace Orchard.Core.Common.ViewModels {
|
||||||
public class CommonMetadataViewModel {
|
public class CommonMetadataViewModel {
|
||||||
private readonly CommonAspect _commonAspect;
|
private readonly CommonPart _commonPart;
|
||||||
|
|
||||||
public CommonMetadataViewModel(CommonAspect commonAspect) {
|
public CommonMetadataViewModel(CommonPart commonPart) {
|
||||||
_commonAspect = commonAspect;
|
_commonPart = commonPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IUser Creator { get { return _commonAspect.Owner; } }
|
public IUser Creator { get { return _commonPart.Owner; } }
|
||||||
|
|
||||||
public DateTime? CreatedUtc { get { return _commonAspect.CreatedUtc; } }
|
public DateTime? CreatedUtc { get { return _commonPart.CreatedUtc; } }
|
||||||
public DateTime? PublishedUtc { get { return _commonAspect.PublishedUtc; } }
|
public DateTime? PublishedUtc { get { return _commonPart.PublishedUtc; } }
|
||||||
public DateTime? ModifiedUtc { get { return _commonAspect.ModifiedUtc; } }
|
public DateTime? ModifiedUtc { get { return _commonPart.ModifiedUtc; } }
|
||||||
|
|
||||||
public DateTime? VersionCreatedUtc { get { return _commonAspect.VersionCreatedUtc; } }
|
public DateTime? VersionCreatedUtc { get { return _commonPart.VersionCreatedUtc; } }
|
||||||
public DateTime? VersionPublishedUtc { get { return _commonAspect.VersionPublishedUtc; } }
|
public DateTime? VersionPublishedUtc { get { return _commonPart.VersionPublishedUtc; } }
|
||||||
public DateTime? VersionModifiedUtc { get { return _commonAspect.VersionModifiedUtc; } }
|
public DateTime? VersionModifiedUtc { get { return _commonPart.VersionModifiedUtc; } }
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,5 +1,5 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BodyDisplayViewModel>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BodyDisplayViewModel>" %>
|
||||||
<%@ Import Namespace="Orchard.Core.Common.ViewModels"%>
|
<%@ Import Namespace="Orchard.Core.Common.ViewModels"%>
|
||||||
<div class="manage">
|
<div class="manage">
|
||||||
<%: Html.ItemEditLinkWithReturnUrl(T("Edit").ToString(), Model.BodyAspect.ContentItem) %>
|
<%: Html.ItemEditLinkWithReturnUrl(T("Edit").ToString(), Model.BodyPart.ContentItem) %>
|
||||||
</div>
|
</div>
|
@@ -6,4 +6,4 @@
|
|||||||
<%: new HtmlString(string.Format(
|
<%: new HtmlString(string.Format(
|
||||||
"<p>{0} {1}</p>",
|
"<p>{0} {1}</p>",
|
||||||
Html.Excerpt(Model.Text, 200).ToString().Replace(Environment.NewLine, "</p>" + Environment.NewLine + "<p>"),
|
Html.Excerpt(Model.Text, 200).ToString().Replace(Environment.NewLine, "</p>" + Environment.NewLine + "<p>"),
|
||||||
Html.ItemDisplayLink(T("[more]").ToString(), Model.BodyAspect.ContentItem))) %>
|
Html.ItemDisplayLink(T("[more]").ToString(), Model.BodyPart.ContentItem))) %>
|
@@ -64,19 +64,19 @@ namespace Orchard.Core.Contents.Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (model.ContainerId != null)
|
if (model.ContainerId != null)
|
||||||
query = query.Join<CommonRecord>().Where(cr => cr.Container.Id == model.ContainerId);
|
query = query.Join<CommonPartRecord>().Where(cr => cr.Container.Id == model.ContainerId);
|
||||||
|
|
||||||
// Ordering
|
// Ordering
|
||||||
//-- want something like
|
//-- want something like
|
||||||
//switch (model.Options.OrderBy) {
|
//switch (model.Options.OrderBy) {
|
||||||
// case ContentsOrder.Modified:
|
// case ContentsOrder.Modified:
|
||||||
// query = query.OrderByDescending<CommonRecord, DateTime?>(cr => cr.ModifiedUtc);
|
// query = query.OrderByDescending<CommonPartRecord, DateTime?>(cr => cr.ModifiedUtc);
|
||||||
// break;
|
// break;
|
||||||
// case ContentsOrder.Published:
|
// case ContentsOrder.Published:
|
||||||
// query = query.OrderByDescending<CommonRecord, DateTime?>(cr => cr.PublishedUtc);
|
// query = query.OrderByDescending<CommonPartRecord, DateTime?>(cr => cr.PublishedUtc);
|
||||||
// break;
|
// break;
|
||||||
// case ContentsOrder.Created:
|
// case ContentsOrder.Created:
|
||||||
// query = query.OrderByDescending<CommonRecord, DateTime?>(cr => cr.CreatedUtc);
|
// query = query.OrderByDescending<CommonPartRecord, DateTime?>(cr => cr.CreatedUtc);
|
||||||
// break;
|
// break;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
@@ -9,16 +9,16 @@ namespace Orchard.Core.Feeds.StandardBuilders {
|
|||||||
public class ItemInspector {
|
public class ItemInspector {
|
||||||
private readonly IContent _item;
|
private readonly IContent _item;
|
||||||
private readonly ContentItemMetadata _metadata;
|
private readonly ContentItemMetadata _metadata;
|
||||||
private readonly ICommonAspect _common;
|
private readonly ICommonPart _common;
|
||||||
private readonly IsRoutable _routable;
|
private readonly IsRoutable _routable;
|
||||||
private readonly BodyAspect _body;
|
private readonly BodyPart _body;
|
||||||
|
|
||||||
public ItemInspector(IContent item, ContentItemMetadata metadata) {
|
public ItemInspector(IContent item, ContentItemMetadata metadata) {
|
||||||
_item = item;
|
_item = item;
|
||||||
_metadata = metadata;
|
_metadata = metadata;
|
||||||
_common = item.Get<ICommonAspect>();
|
_common = item.Get<ICommonPart>();
|
||||||
_routable = item.Get<IsRoutable>();
|
_routable = item.Get<IsRoutable>();
|
||||||
_body = item.Get<BodyAspect>();
|
_body = item.Get<BodyPart>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Title {
|
public string Title {
|
||||||
|
@@ -58,7 +58,7 @@ namespace Orchard.Core.Feeds.StandardQueries {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var items = _contentManager.Query()
|
var items = _contentManager.Query()
|
||||||
.Where<CommonRecord>(x => x.Container == container.Record)
|
.Where<CommonPartRecord>(x => x.Container == container.Record)
|
||||||
.OrderByDescending(x => x.PublishedUtc)
|
.OrderByDescending(x => x.PublishedUtc)
|
||||||
.Slice(0, limit);
|
.Slice(0, limit);
|
||||||
|
|
||||||
|
@@ -62,8 +62,8 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Common\DataMigrations\CommonDataMigration.cs" />
|
<Compile Include="Common\DataMigrations\CommonDataMigration.cs" />
|
||||||
<Compile Include="Common\Drivers\BodyDriver.cs" />
|
<Compile Include="Common\Drivers\BodyPartDriver.cs" />
|
||||||
<Compile Include="Common\Drivers\CommonDriver.cs" />
|
<Compile Include="Common\Drivers\CommonPartDriver.cs" />
|
||||||
<Compile Include="Common\Drivers\TextFieldDriver.cs" />
|
<Compile Include="Common\Drivers\TextFieldDriver.cs" />
|
||||||
<Compile Include="Common\Extensions\HtmlHelperExtensions.cs" />
|
<Compile Include="Common\Extensions\HtmlHelperExtensions.cs" />
|
||||||
<Compile Include="Common\Fields\TextField.cs" />
|
<Compile Include="Common\Fields\TextField.cs" />
|
||||||
@@ -116,14 +116,14 @@
|
|||||||
<Compile Include="Routable\IRoutablePathConstraint.cs" />
|
<Compile Include="Routable\IRoutablePathConstraint.cs" />
|
||||||
<Compile Include="Routable\Models\IsRoutable.cs" />
|
<Compile Include="Routable\Models\IsRoutable.cs" />
|
||||||
<Compile Include="Common\Permissions.cs" />
|
<Compile Include="Common\Permissions.cs" />
|
||||||
<Compile Include="Common\Models\CommonVersionRecord.cs" />
|
<Compile Include="Common\Models\CommonPartVersionRecord.cs" />
|
||||||
<Compile Include="Common\Utilities\LazyField.cs" />
|
<Compile Include="Common\Utilities\LazyField.cs" />
|
||||||
<Compile Include="Common\Handlers\CommonAspectHandler.cs" />
|
<Compile Include="Common\Handlers\CommonPartHandler.cs" />
|
||||||
<Compile Include="Common\Models\CommonAspect.cs" />
|
<Compile Include="Common\Models\CommonPart.cs" />
|
||||||
<Compile Include="Common\Handlers\BodyAspectHandler.cs" />
|
<Compile Include="Common\Handlers\BodyPartHandler.cs" />
|
||||||
<Compile Include="Common\Models\BodyAspect.cs" />
|
<Compile Include="Common\Models\BodyPart.cs" />
|
||||||
<Compile Include="Common\Models\BodyRecord.cs" />
|
<Compile Include="Common\Models\BodyPartRecord.cs" />
|
||||||
<Compile Include="Common\Models\CommonRecord.cs" />
|
<Compile Include="Common\Models\CommonPartRecord.cs" />
|
||||||
<Compile Include="Common\ViewModels\BodyDisplayViewModel.cs" />
|
<Compile Include="Common\ViewModels\BodyDisplayViewModel.cs" />
|
||||||
<Compile Include="Common\ViewModels\BodyEditorViewModel.cs" />
|
<Compile Include="Common\ViewModels\BodyEditorViewModel.cs" />
|
||||||
<Compile Include="Common\ViewModels\OwnerEditorViewModel.cs" />
|
<Compile Include="Common\ViewModels\OwnerEditorViewModel.cs" />
|
||||||
|
@@ -33,7 +33,7 @@ namespace Orchard.Core.PublishLater.ViewModels {
|
|||||||
get { return IsPublished || ContentItem.ContentManager.Get(ContentItem.Id, VersionOptions.Published) != null; }
|
get { return IsPublished || ContentItem.ContentManager.Get(ContentItem.Id, VersionOptions.Published) != null; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public DateTime? VersionPublishedUtc { get { return ContentItem.As<CommonAspect>() == null ? null : ContentItem.As<CommonAspect>().VersionPublishedUtc; } }
|
public DateTime? VersionPublishedUtc { get { return ContentItem.As<CommonPart>() == null ? null : ContentItem.As<CommonPart>().VersionPublishedUtc; } }
|
||||||
|
|
||||||
public DateTime? ScheduledPublishUtc { get; set; }
|
public DateTime? ScheduledPublishUtc { get; set; }
|
||||||
|
|
||||||
|
@@ -67,7 +67,7 @@ namespace Orchard.Core.Routable.Controllers {
|
|||||||
|
|
||||||
if (containerId != null) {
|
if (containerId != null) {
|
||||||
var containerItem = _contentManager.Get((int)containerId);
|
var containerItem = _contentManager.Get((int)containerId);
|
||||||
contentItem.As<ICommonAspect>().Container = containerItem;
|
contentItem.As<ICommonPart>().Container = containerItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -28,15 +28,15 @@ namespace Orchard.Core.Routable.Drivers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int? GetContainerId(IContent item) {
|
int? GetContainerId(IContent item) {
|
||||||
var commonAspect = item.As<ICommonAspect>();
|
var commonPart = item.As<ICommonPart>();
|
||||||
if (commonAspect != null && commonAspect.Container != null) {
|
if (commonPart != null && commonPart.Container != null) {
|
||||||
return commonAspect.Container.ContentItem.Id;
|
return commonPart.Container.ContentItem.Id;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
string GetContainerSlug(IContent item) {
|
string GetContainerSlug(IContent item) {
|
||||||
var commonAspect = item.As<ICommonAspect>();
|
var commonAspect = item.As<ICommonPart>();
|
||||||
if (commonAspect != null && commonAspect.Container != null) {
|
if (commonAspect != null && commonAspect.Container != null) {
|
||||||
var routable = commonAspect.Container.As<IRoutableAspect>();
|
var routable = commonAspect.Container.As<IRoutableAspect>();
|
||||||
if (routable != null) {
|
if (routable != null) {
|
||||||
|
@@ -35,7 +35,7 @@ namespace Futures.Widgets.Controllers {
|
|||||||
init.Record.Scope = hasWidgetsRecord;
|
init.Record.Scope = hasWidgetsRecord;
|
||||||
init.Record.Zone = zoneName;
|
init.Record.Zone = zoneName;
|
||||||
init.Record.Position = "1";
|
init.Record.Position = "1";
|
||||||
init.As<BodyAspect>().Text = System.IO.File.ReadAllText(physicalPath);
|
init.As<BodyPart>().Text = System.IO.File.ReadAllText(physicalPath);
|
||||||
});
|
});
|
||||||
|
|
||||||
return RedirectToAction("Edit", new { widget.ContentItem.Id, returnUrl });
|
return RedirectToAction("Edit", new { widget.ContentItem.Id, returnUrl });
|
||||||
|
@@ -30,7 +30,7 @@ namespace Futures.Widgets.DataMigrations {
|
|||||||
ContentDefinitionManager.AlterTypeDefinition("HtmlWidget",
|
ContentDefinitionManager.AlterTypeDefinition("HtmlWidget",
|
||||||
cfg => cfg
|
cfg => cfg
|
||||||
.WithPart("Widget")
|
.WithPart("Widget")
|
||||||
.WithPart("BodyAspect")
|
.WithPart("BodyPart")
|
||||||
);
|
);
|
||||||
|
|
||||||
return 2;
|
return 2;
|
||||||
|
@@ -53,7 +53,7 @@ namespace Orchard.Blogs.Commands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var blog = _contentManager.New("Blog");
|
var blog = _contentManager.New("Blog");
|
||||||
blog.As<ICommonAspect>().Owner = admin;
|
blog.As<ICommonPart>().Owner = admin;
|
||||||
blog.As<IsRoutable>().Slug = Slug;
|
blog.As<IsRoutable>().Slug = Slug;
|
||||||
blog.As<IsRoutable>().Title = Title;
|
blog.As<IsRoutable>().Title = Title;
|
||||||
if ( !String.IsNullOrWhiteSpace(MenuText) ) {
|
if ( !String.IsNullOrWhiteSpace(MenuText) ) {
|
||||||
@@ -95,11 +95,11 @@ namespace Orchard.Blogs.Commands {
|
|||||||
|
|
||||||
Context.Output.WriteLine("Adding post: {0}...", postName.Substring(0, Math.Min(postName.Length, 40)));
|
Context.Output.WriteLine("Adding post: {0}...", postName.Substring(0, Math.Min(postName.Length, 40)));
|
||||||
var post = _contentManager.New("BlogPost");
|
var post = _contentManager.New("BlogPost");
|
||||||
post.As<ICommonAspect>().Owner = admin;
|
post.As<ICommonPart>().Owner = admin;
|
||||||
post.As<ICommonAspect>().Container = blog;
|
post.As<ICommonPart>().Container = blog;
|
||||||
post.As<IsRoutable>().Slug = Slugify(postName);
|
post.As<IsRoutable>().Slug = Slugify(postName);
|
||||||
post.As<IsRoutable>().Title = postName;
|
post.As<IsRoutable>().Title = postName;
|
||||||
post.As<BodyAspect>().Text = item.Element("description").Value;
|
post.As<BodyPart>().Text = item.Element("description").Value;
|
||||||
_contentManager.Create(post);
|
_contentManager.Create(post);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -32,17 +32,17 @@ namespace Orchard.Blogs.DataMigrations {
|
|||||||
ContentDefinitionManager.AlterTypeDefinition("Blog",
|
ContentDefinitionManager.AlterTypeDefinition("Blog",
|
||||||
cfg => cfg
|
cfg => cfg
|
||||||
.WithPart("BlogPart")
|
.WithPart("BlogPart")
|
||||||
.WithPart("CommonAspect")
|
.WithPart("CommonPart")
|
||||||
.WithPart("IsRoutable")
|
.WithPart("IsRoutable")
|
||||||
);
|
);
|
||||||
|
|
||||||
ContentDefinitionManager.AlterTypeDefinition("BlogPost",
|
ContentDefinitionManager.AlterTypeDefinition("BlogPost",
|
||||||
cfg => cfg
|
cfg => cfg
|
||||||
.WithPart("BlogPostPart")
|
.WithPart("BlogPostPart")
|
||||||
.WithPart("CommonAspect")
|
.WithPart("CommonPart")
|
||||||
.WithPart("PublishLaterPart")
|
.WithPart("PublishLaterPart")
|
||||||
.WithPart("IsRoutable")
|
.WithPart("IsRoutable")
|
||||||
.WithPart("BodyAspect")
|
.WithPart("BodyPart")
|
||||||
);
|
);
|
||||||
|
|
||||||
return 2;
|
return 2;
|
||||||
|
@@ -11,12 +11,12 @@ using Orchard.Data;
|
|||||||
namespace Orchard.Blogs.Handlers {
|
namespace Orchard.Blogs.Handlers {
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public class BlogArchiveHandler : ContentHandler {
|
public class BlogArchiveHandler : ContentHandler {
|
||||||
public BlogArchiveHandler(IRepository<BlogPartArchiveRecord> blogArchiveRepository, IRepository<CommonRecord> commonRepository) {
|
public BlogArchiveHandler(IRepository<BlogPartArchiveRecord> blogArchiveRepository, IRepository<CommonPartRecord> commonRepository) {
|
||||||
OnPublished<BlogPostPart>((context, bp) => RecalculateBlogArchive(blogArchiveRepository, commonRepository, bp));
|
OnPublished<BlogPostPart>((context, bp) => RecalculateBlogArchive(blogArchiveRepository, commonRepository, bp));
|
||||||
OnRemoved<BlogPostPart>((context, bp) => RecalculateBlogArchive(blogArchiveRepository, commonRepository, bp));
|
OnRemoved<BlogPostPart>((context, bp) => RecalculateBlogArchive(blogArchiveRepository, commonRepository, bp));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void RecalculateBlogArchive(IRepository<BlogPartArchiveRecord> blogArchiveRepository, IRepository<CommonRecord> commonRepository, BlogPostPart blogPostPart) {
|
private static void RecalculateBlogArchive(IRepository<BlogPartArchiveRecord> blogArchiveRepository, IRepository<CommonPartRecord> commonRepository, BlogPostPart blogPostPart) {
|
||||||
blogArchiveRepository.Flush();
|
blogArchiveRepository.Flush();
|
||||||
|
|
||||||
//INFO: (erikpo) Remove all current blog archive records
|
//INFO: (erikpo) Remove all current blog archive records
|
||||||
|
@@ -37,7 +37,7 @@ namespace Orchard.Blogs.Handlers {
|
|||||||
|
|
||||||
//todo: don't get at the container form data directly. right now the container is set in the common driver editor (updater)
|
//todo: don't get at the container form data directly. right now the container is set in the common driver editor (updater)
|
||||||
//todo: which is too late for what's needed (currently) in this handler
|
//todo: which is too late for what's needed (currently) in this handler
|
||||||
var containerId = requestContext.HttpContext.Request.Form["CommonAspect.containerId"];
|
var containerId = requestContext.HttpContext.Request.Form["CommonPart.containerId"];
|
||||||
if (!string.IsNullOrEmpty(containerId)) {
|
if (!string.IsNullOrEmpty(containerId)) {
|
||||||
int cId;
|
int cId;
|
||||||
if (int.TryParse(containerId, out cId)) {
|
if (int.TryParse(containerId, out cId)) {
|
||||||
|
@@ -24,18 +24,18 @@ namespace Orchard.Blogs.Models {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public string Text {
|
public string Text {
|
||||||
get { return this.As<BodyAspect>().Text; }
|
get { return this.As<BodyPart>().Text; }
|
||||||
set { this.As<BodyAspect>().Text = value; }
|
set { this.As<BodyPart>().Text = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlogPart BlogPart {
|
public BlogPart BlogPart {
|
||||||
get { return this.As<ICommonAspect>().Container.As<BlogPart>(); }
|
get { return this.As<ICommonPart>().Container.As<BlogPart>(); }
|
||||||
set { this.As<ICommonAspect>().Container = value; }
|
set { this.As<ICommonPart>().Container = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public IUser Creator {
|
public IUser Creator {
|
||||||
get { return this.As<ICommonAspect>().Owner; }
|
get { return this.As<ICommonPart>().Owner; }
|
||||||
set { this.As<ICommonAspect>().Owner = value; }
|
set { this.As<ICommonPart>().Owner = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsPublished {
|
public bool IsPublished {
|
||||||
@@ -58,7 +58,7 @@ namespace Orchard.Blogs.Models {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DateTime? CreatedUtc {
|
public DateTime? CreatedUtc {
|
||||||
get { return this.As<ICommonAspect>().CreatedUtc; }
|
get { return this.As<ICommonPart>().CreatedUtc; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public DateTime? ScheduledPublishUtc { get; set; }
|
public DateTime? ScheduledPublishUtc { get; set; }
|
||||||
|
@@ -30,7 +30,7 @@ namespace Orchard.Blogs.Services {
|
|||||||
public BlogPostPart Get(BlogPart blogPart, string slug, VersionOptions versionOptions) {
|
public BlogPostPart Get(BlogPart blogPart, string slug, VersionOptions versionOptions) {
|
||||||
return
|
return
|
||||||
_contentManager.Query(versionOptions, BlogPostPartDriver.ContentType.Name).Join<RoutableRecord>().Where(rr => rr.Slug == slug).
|
_contentManager.Query(versionOptions, BlogPostPartDriver.ContentType.Name).Join<RoutableRecord>().Where(rr => rr.Slug == slug).
|
||||||
Join<CommonRecord>().Where(cr => cr.Container == blogPart.Record.ContentItemRecord).List().
|
Join<CommonPartRecord>().Where(cr => cr.Container == blogPart.Record.ContentItemRecord).List().
|
||||||
SingleOrDefault().As<BlogPostPart>();
|
SingleOrDefault().As<BlogPostPart>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,9 +110,9 @@ namespace Orchard.Blogs.Services {
|
|||||||
return (task == null ? null : task.ScheduledUtc);
|
return (task == null ? null : task.ScheduledUtc);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IContentQuery<ContentItem, CommonRecord> GetBlogQuery(ContentPart<BlogPartRecord> blog, VersionOptions versionOptions) {
|
private IContentQuery<ContentItem, CommonPartRecord> GetBlogQuery(ContentPart<BlogPartRecord> blog, VersionOptions versionOptions) {
|
||||||
return
|
return
|
||||||
_contentManager.Query(versionOptions, BlogPostPartDriver.ContentType.Name).Join<CommonRecord>().Where(
|
_contentManager.Query(versionOptions, BlogPostPartDriver.ContentType.Name).Join<CommonPartRecord>().Where(
|
||||||
cr => cr.Container == blog.Record.ContentItemRecord).OrderByDescending(cr => cr.CreatedUtc);
|
cr => cr.Container == blog.Record.ContentItemRecord).OrderByDescending(cr => cr.CreatedUtc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -8,5 +8,5 @@
|
|||||||
<%@ Import Namespace="Orchard.Core.Common.ViewModels" %>
|
<%@ Import Namespace="Orchard.Core.Common.ViewModels" %>
|
||||||
<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %>
|
<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %>
|
||||||
<h2><%: Html.Link(Model.Item.Title, Url.BlogPost(Model.Item)) %></h2>
|
<h2><%: Html.Link(Model.Item.Title, Url.BlogPost(Model.Item)) %></h2>
|
||||||
<div class="meta"><%: Html.PublishedState(new CommonMetadataViewModel(Model.Item.As<CommonAspect>()), T) %> | <%Html.Zone("meta");%></div>
|
<div class="meta"><%: Html.PublishedState(new CommonMetadataViewModel(Model.Item.As<CommonPart>()), T) %> | <%Html.Zone("meta");%></div>
|
||||||
<div class="content"><% Html.Zone("primary", ":manage :metadata");%></div>
|
<div class="content"><% Html.Zone("primary", ":manage :metadata");%></div>
|
||||||
|
@@ -53,7 +53,7 @@ namespace Orchard.Comments.DataMigrations {
|
|||||||
ContentDefinitionManager.AlterTypeDefinition("Comment",
|
ContentDefinitionManager.AlterTypeDefinition("Comment",
|
||||||
cfg => cfg
|
cfg => cfg
|
||||||
.WithPart("Comment")
|
.WithPart("Comment")
|
||||||
.WithPart("CommonAspect")
|
.WithPart("CommonPart")
|
||||||
);
|
);
|
||||||
|
|
||||||
ContentDefinitionManager.AlterTypeDefinition("Blog",
|
ContentDefinitionManager.AlterTypeDefinition("Blog",
|
||||||
|
@@ -24,7 +24,7 @@ namespace Orchard.Comments.Drivers {
|
|||||||
private static CommentCountViewModel CreateViewModel(ContentItem contentItem) {
|
private static CommentCountViewModel CreateViewModel(ContentItem contentItem) {
|
||||||
// Find all contents item with this part as the container
|
// Find all contents item with this part as the container
|
||||||
var parts = contentItem.ContentManager.Query()
|
var parts = contentItem.ContentManager.Query()
|
||||||
.Where<CommonRecord>(rec => rec.Container == contentItem.Record).List();
|
.Where<CommonPartRecord>(rec => rec.Container == contentItem.Record).List();
|
||||||
|
|
||||||
// Count comments and create template
|
// Count comments and create template
|
||||||
int count = parts.Aggregate(0, (seed, item) => seed + (item.Has<HasComments>() ? item.As<HasComments>().Comments.Count : 0));
|
int count = parts.Aggregate(0, (seed, item) => seed + (item.Has<HasComments>() ? item.As<HasComments>().Comments.Count : 0));
|
||||||
|
@@ -86,7 +86,7 @@ namespace Orchard.Comments.Services {
|
|||||||
|
|
||||||
// store id of the next layer for large-grained operations, e.g. rss on blog
|
// store id of the next layer for large-grained operations, e.g. rss on blog
|
||||||
//TODO:(rpaquay) Get rid of this (comment aspect takes care of container)
|
//TODO:(rpaquay) Get rid of this (comment aspect takes care of container)
|
||||||
var commentedOn = _contentManager.Get<ICommonAspect>(comment.Record.CommentedOn);
|
var commentedOn = _contentManager.Get<ICommonPart>(comment.Record.CommentedOn);
|
||||||
if (commentedOn != null && commentedOn.Container != null) {
|
if (commentedOn != null && commentedOn.Container != null) {
|
||||||
comment.Record.CommentedOnContainer = commentedOn.Container.ContentItem.Id;
|
comment.Record.CommentedOnContainer = commentedOn.Container.ContentItem.Id;
|
||||||
}
|
}
|
||||||
|
@@ -26,11 +26,11 @@ namespace Orchard.DevTools.Commands {
|
|||||||
|
|
||||||
var pageName = "page" + index;
|
var pageName = "page" + index;
|
||||||
var page = _contentManager.Create("Page", VersionOptions.Draft);
|
var page = _contentManager.Create("Page", VersionOptions.Draft);
|
||||||
page.As<ICommonAspect>().Owner = admin;
|
page.As<ICommonPart>().Owner = admin;
|
||||||
page.As<IsRoutable>().Slug = pageName;
|
page.As<IsRoutable>().Slug = pageName;
|
||||||
page.As<IsRoutable>().Path = pageName;
|
page.As<IsRoutable>().Path = pageName;
|
||||||
page.As<IsRoutable>().Title = pageName;
|
page.As<IsRoutable>().Title = pageName;
|
||||||
page.As<BodyAspect>().Text = pageName;
|
page.As<BodyPart>().Text = pageName;
|
||||||
page.As<MenuPart>().OnMainMenu = true;
|
page.As<MenuPart>().OnMainMenu = true;
|
||||||
page.As<MenuPart>().MenuPosition = "5." + index;
|
page.As<MenuPart>().MenuPosition = "5." + index;
|
||||||
page.As<MenuPart>().MenuText = pageName;
|
page.As<MenuPart>().MenuText = pageName;
|
||||||
@@ -38,7 +38,7 @@ namespace Orchard.DevTools.Commands {
|
|||||||
|
|
||||||
var blogName = "blog" + index;
|
var blogName = "blog" + index;
|
||||||
var blog = _contentManager.New("Blog");
|
var blog = _contentManager.New("Blog");
|
||||||
blog.As<ICommonAspect>().Owner = admin;
|
blog.As<ICommonPart>().Owner = admin;
|
||||||
blog.As<IsRoutable>().Slug = blogName;
|
blog.As<IsRoutable>().Slug = blogName;
|
||||||
blog.As<IsRoutable>().Path = blogName;
|
blog.As<IsRoutable>().Path = blogName;
|
||||||
blog.As<IsRoutable>().Title = blogName;
|
blog.As<IsRoutable>().Title = blogName;
|
||||||
@@ -51,11 +51,11 @@ namespace Orchard.DevTools.Commands {
|
|||||||
//for (var index2 = 0; index2 != 5; ++index2) {
|
//for (var index2 = 0; index2 != 5; ++index2) {
|
||||||
// var postName = "post" + index;
|
// var postName = "post" + index;
|
||||||
// var post = _contentManager.New("BlogPost");
|
// var post = _contentManager.New("BlogPost");
|
||||||
// post.As<ICommonAspect>().Owner = admin;
|
// post.As<ICommonPart>().Owner = admin;
|
||||||
// post.As<ICommonAspect>().Container = blog;
|
// post.As<ICommonPart>().Container = blog;
|
||||||
// post.As<RoutableAspect>().Slug = postName;
|
// post.As<RoutableAspect>().Slug = postName;
|
||||||
// post.As<RoutableAspect>().Title = postName;
|
// post.As<RoutableAspect>().Title = postName;
|
||||||
// post.As<BodyAspect>().Text = postName;
|
// post.As<BodyPart>().Text = postName;
|
||||||
// _contentManager.Create(post);
|
// _contentManager.Create(post);
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
@@ -14,15 +14,15 @@ namespace Orchard.Indexing.Handlers {
|
|||||||
public CreateIndexingTaskHandler(IIndexingTaskManager indexingTaskManager) {
|
public CreateIndexingTaskHandler(IIndexingTaskManager indexingTaskManager) {
|
||||||
_indexingTaskManager = indexingTaskManager;
|
_indexingTaskManager = indexingTaskManager;
|
||||||
|
|
||||||
OnPublishing<ContentPart<CommonRecord>>(CreateIndexingTask);
|
OnPublishing<ContentPart<CommonPartRecord>>(CreateIndexingTask);
|
||||||
OnRemoved<ContentPart<CommonRecord>>(RemoveIndexingTask);
|
OnRemoved<ContentPart<CommonPartRecord>>(RemoveIndexingTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateIndexingTask(PublishContentContext context, ContentPart<CommonRecord> part) {
|
void CreateIndexingTask(PublishContentContext context, ContentPart<CommonPartRecord> part) {
|
||||||
_indexingTaskManager.CreateUpdateIndexTask(context.ContentItem);
|
_indexingTaskManager.CreateUpdateIndexTask(context.ContentItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveIndexingTask(RemoveContentContext context, ContentPart<CommonRecord> part) {
|
void RemoveIndexingTask(RemoveContentContext context, ContentPart<CommonPartRecord> part) {
|
||||||
_indexingTaskManager.CreateDeleteIndexTask(context.ContentItem);
|
_indexingTaskManager.CreateDeleteIndexTask(context.ContentItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -9,9 +9,9 @@ namespace Orchard.Pages.DataMigrations {
|
|||||||
ContentDefinitionManager.AlterTypeDefinition("Page",
|
ContentDefinitionManager.AlterTypeDefinition("Page",
|
||||||
cfg => cfg
|
cfg => cfg
|
||||||
.WithPart("Page")
|
.WithPart("Page")
|
||||||
.WithPart("CommonAspect")
|
.WithPart("CommonPart")
|
||||||
.WithPart("IsRoutable")
|
.WithPart("IsRoutable")
|
||||||
.WithPart("BodyAspect")
|
.WithPart("BodyPart")
|
||||||
);
|
);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -21,8 +21,8 @@ namespace Orchard.Pages.Models {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public IUser Creator {
|
public IUser Creator {
|
||||||
get { return this.As<CommonAspect>().Owner; }
|
get { return this.As<CommonPart>().Owner; }
|
||||||
set { this.As<CommonAspect>().Owner = value; }
|
set { this.As<CommonPart>().Owner = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsPublished {
|
public bool IsPublished {
|
||||||
|
@@ -26,7 +26,7 @@ namespace Orchard.Pages.Security {
|
|||||||
if (user==null || content==null)
|
if (user==null || content==null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var common = content.As<ICommonAspect>();
|
var common = content.As<ICommonPart>();
|
||||||
if (common==null || common.Owner==null)
|
if (common==null || common.Owner==null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@@ -65,10 +65,10 @@ using (Html.BeginFormAntiForgeryPost()) { %>
|
|||||||
<%: Html.DateTime(pageEntry.Page.ScheduledPublishUtc.Value, T("M/d/yyyy h:mm tt"))%><%
|
<%: Html.DateTime(pageEntry.Page.ScheduledPublishUtc.Value, T("M/d/yyyy h:mm tt"))%><%
|
||||||
}
|
}
|
||||||
else if (pageEntry.Page.IsPublished) { %>
|
else if (pageEntry.Page.IsPublished) { %>
|
||||||
<%: T("Published: {0}", Html.DateTimeRelative(pageEntry.Page.As<ICommonAspect>().VersionPublishedUtc.Value, T)) %><%
|
<%: T("Published: {0}", Html.DateTimeRelative(pageEntry.Page.As<ICommonPart>().VersionPublishedUtc.Value, T)) %><%
|
||||||
}
|
}
|
||||||
else { %>
|
else { %>
|
||||||
<%: T("Last modified: {0}", Html.DateTimeRelative(pageEntry.Page.As<ICommonAspect>().ModifiedUtc.Value, T)) %><%
|
<%: T("Last modified: {0}", Html.DateTimeRelative(pageEntry.Page.As<ICommonPart>().ModifiedUtc.Value, T)) %><%
|
||||||
} %> |
|
} %> |
|
||||||
</li>
|
</li>
|
||||||
<li><%: T("By {0}", pageEntry.Page.Creator.UserName)%></li>
|
<li><%: T("By {0}", pageEntry.Page.Creator.UserName)%></li>
|
||||||
|
@@ -23,9 +23,9 @@ namespace Orchard.Sandbox.DataMigrations {
|
|||||||
ContentDefinitionManager.AlterTypeDefinition("SandboxPage",
|
ContentDefinitionManager.AlterTypeDefinition("SandboxPage",
|
||||||
cfg => cfg
|
cfg => cfg
|
||||||
.WithPart("SandboxPage")
|
.WithPart("SandboxPage")
|
||||||
.WithPart("CommonAspect")
|
.WithPart("CommonPart")
|
||||||
.WithPart("IsRoutable")
|
.WithPart("IsRoutable")
|
||||||
.WithPart("BodyAspect")
|
.WithPart("BodyPart")
|
||||||
);
|
);
|
||||||
|
|
||||||
return 2;
|
return 2;
|
||||||
|
@@ -197,24 +197,24 @@ namespace Orchard.Setup.Services {
|
|||||||
.Indexed());
|
.Indexed());
|
||||||
contentDefinitionManager.AlterTypeDefinition("Page", cfg => cfg
|
contentDefinitionManager.AlterTypeDefinition("Page", cfg => cfg
|
||||||
.DisplayedAs("Page")
|
.DisplayedAs("Page")
|
||||||
.WithPart("CommonAspect")
|
.WithPart("CommonPart")
|
||||||
.WithPart("PublishLaterPart")
|
.WithPart("PublishLaterPart")
|
||||||
.WithPart("IsRoutable")
|
.WithPart("IsRoutable")
|
||||||
.WithPart("BodyAspect")
|
.WithPart("BodyPart")
|
||||||
.WithPart("HasComments")
|
.WithPart("HasComments")
|
||||||
.WithPart("HasTags")
|
.WithPart("HasTags")
|
||||||
.WithPart("Localized")
|
.WithPart("Localized")
|
||||||
.Indexed());
|
.Indexed());
|
||||||
contentDefinitionManager.AlterPartDefinition("BodyAspect", cfg => cfg
|
contentDefinitionManager.AlterPartDefinition("BodyPart", cfg => cfg
|
||||||
.WithSetting("BodyPartSettings.FlavorDefault", BodyPartSettings.FlavorDefaultDefault));
|
.WithSetting("BodyPartSettings.FlavorDefault", BodyPartSettings.FlavorDefaultDefault));
|
||||||
|
|
||||||
// create home page as a CMS page
|
// create home page as a CMS page
|
||||||
var page = contentManager.Create("Page", VersionOptions.Draft);
|
var page = contentManager.Create("Page", VersionOptions.Draft);
|
||||||
page.As<BodyAspect>().Text = "<p>Welcome to Orchard!</p><p>Congratulations, you've successfully set-up your Orchard site.</p><p>This is the home page of your new site. We've taken the liberty to write here about a few things you could look at next in order to get familiar with the application. Once you feel confident you don't need this anymore, just click <a href=\"Admin/Pages/Edit/3\">Edit</a> to go into edit mode and replace this with whatever you want on your home page to make it your own.</p><p>One thing you could do (but you don't have to) is go into <a href=\"Admin/Settings\">Manage Settings</a> (follow the <a href=\"Admin\">Admin</a> link and then look for it under \"Settings\" in the menu on the left) and check that everything is configured the way you want.</p><p>You probably want to make the site your own. One of the ways you can do that is by clicking <a href=\"Admin/Themes\">Manage Themes</a> in the admin menu. A theme is a packaged look and feel that affects the whole site.</p><p>Next, you can start playing with the content types that we installed. For example, go ahead and click <a href=\"Admin/Pages/Create\">Add New Page</a> in the admin menu and create an \"about\" page. Then, add it to the navigation menu by going to <a href=\"Admin/Navigation\">Manage Menu</a>. You can also click <a href=\"Admin/Blogs/Create\">Add New Blog</a> and start posting by clicking \"Add New Post\".</p><p>Finally, Orchard has been designed to be extended. It comes with a few built-in modules such as pages and blogs or themes. You can install new themes by going to <a href=\"Admin/Themes\">Manage Themes</a> and clicking <a href=\"Admin/Themes/Install\">Install a new Theme</a>. Like for themes, modules are created by other users of Orchard just like you so if you feel up to it, please <a href=\"http://www.orchardproject.net/\">consider participating</a>.</p><p>--The Orchard Crew</p>";
|
page.As<BodyPart>().Text = "<p>Welcome to Orchard!</p><p>Congratulations, you've successfully set-up your Orchard site.</p><p>This is the home page of your new site. We've taken the liberty to write here about a few things you could look at next in order to get familiar with the application. Once you feel confident you don't need this anymore, just click <a href=\"Admin/Pages/Edit/3\">Edit</a> to go into edit mode and replace this with whatever you want on your home page to make it your own.</p><p>One thing you could do (but you don't have to) is go into <a href=\"Admin/Settings\">Manage Settings</a> (follow the <a href=\"Admin\">Admin</a> link and then look for it under \"Settings\" in the menu on the left) and check that everything is configured the way you want.</p><p>You probably want to make the site your own. One of the ways you can do that is by clicking <a href=\"Admin/Themes\">Manage Themes</a> in the admin menu. A theme is a packaged look and feel that affects the whole site.</p><p>Next, you can start playing with the content types that we installed. For example, go ahead and click <a href=\"Admin/Pages/Create\">Add New Page</a> in the admin menu and create an \"about\" page. Then, add it to the navigation menu by going to <a href=\"Admin/Navigation\">Manage Menu</a>. You can also click <a href=\"Admin/Blogs/Create\">Add New Blog</a> and start posting by clicking \"Add New Post\".</p><p>Finally, Orchard has been designed to be extended. It comes with a few built-in modules such as pages and blogs or themes. You can install new themes by going to <a href=\"Admin/Themes\">Manage Themes</a> and clicking <a href=\"Admin/Themes/Install\">Install a new Theme</a>. Like for themes, modules are created by other users of Orchard just like you so if you feel up to it, please <a href=\"http://www.orchardproject.net/\">consider participating</a>.</p><p>--The Orchard Crew</p>";
|
||||||
page.As<IsRoutable>().Slug = "home";
|
page.As<IsRoutable>().Slug = "home";
|
||||||
page.As<IsRoutable>().Path = "home";
|
page.As<IsRoutable>().Path = "home";
|
||||||
page.As<IsRoutable>().Title = T("Home").ToString();
|
page.As<IsRoutable>().Title = T("Home").ToString();
|
||||||
page.As<CommonAspect>().Owner = user;
|
page.As<CommonPart>().Owner = user;
|
||||||
if (page.Has<HasComments>()) {
|
if (page.Has<HasComments>()) {
|
||||||
page.As<HasComments>().CommentsShown = false;
|
page.As<HasComments>().CommentsShown = false;
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
using Orchard.Security;
|
using Orchard.Security;
|
||||||
|
|
||||||
namespace Orchard.ContentManagement.Aspects {
|
namespace Orchard.ContentManagement.Aspects {
|
||||||
public interface ICommonAspect : IContent {
|
public interface ICommonPart : IContent {
|
||||||
IUser Owner { get; set; }
|
IUser Owner { get; set; }
|
||||||
IContent Container { get; set; }
|
IContent Container { get; set; }
|
||||||
|
|
@@ -137,7 +137,7 @@
|
|||||||
<Compile Include="Collections\PageOfItems.cs" />
|
<Compile Include="Collections\PageOfItems.cs" />
|
||||||
<Compile Include="Commands\CommandBackgroundService.cs" />
|
<Compile Include="Commands\CommandBackgroundService.cs" />
|
||||||
<Compile Include="Commands\CommandHostEnvironment.cs" />
|
<Compile Include="Commands\CommandHostEnvironment.cs" />
|
||||||
<Compile Include="ContentManagement\Aspects\ICommonAspect.cs">
|
<Compile Include="ContentManagement\Aspects\ICommonPart.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="ContentManagement\Aspects\IPublishingControlAspect.cs" />
|
<Compile Include="ContentManagement\Aspects\IPublishingControlAspect.cs" />
|
||||||
|
Reference in New Issue
Block a user