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:
Nathan Heskew
2010-07-22 12:52:16 -07:00
parent 3302c026b6
commit 5b02277fee
49 changed files with 228 additions and 228 deletions

View File

@@ -25,7 +25,7 @@ using System.Web.Mvc;
namespace Orchard.Core.Tests.Common.Providers {
[TestFixture]
public class CommonAspectProviderTests : DatabaseEnabledTestsBase {
public class CommonPartProviderTests : DatabaseEnabledTestsBase {
private Mock<IAuthenticationService> _authn;
private Mock<IAuthorizationService> _authz;
private Mock<IMembershipService> _membership;
@@ -35,7 +35,7 @@ namespace Orchard.Core.Tests.Common.Providers {
builder.RegisterType<DefaultContentManager>().As<IContentManager>();
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
builder.RegisterType<TestHandler>().As<IContentHandler>();
builder.RegisterType<CommonAspectHandler>().As<IContentHandler>();
builder.RegisterType<CommonPartHandler>().As<IContentHandler>();
builder.RegisterType<CommonService>().As<ICommonService>();
builder.RegisterType<PublishingTaskManager>().As<IPublishingTaskManager>();
builder.RegisterType<ScheduledTaskManager>().As<IScheduledTaskManager>();
@@ -57,8 +57,8 @@ namespace Orchard.Core.Tests.Common.Providers {
typeof(ContentTypeRecord),
typeof(ContentItemRecord),
typeof(ContentItemVersionRecord),
typeof(CommonRecord),
typeof(CommonVersionRecord),
typeof(CommonPartRecord),
typeof(CommonPartVersionRecord),
typeof(ScheduledTaskRecord),
};
}
@@ -67,8 +67,8 @@ namespace Orchard.Core.Tests.Common.Providers {
[UsedImplicitly]
class TestHandler : ContentHandler {
public TestHandler() {
Filters.Add(new ActivatingFilter<CommonAspect>("test-item"));
Filters.Add(new ActivatingFilter<ContentPart<CommonVersionRecord>>("test-item"));
Filters.Add(new ActivatingFilter<CommonPart>("test-item"));
Filters.Add(new ActivatingFilter<ContentPart<CommonPartVersionRecord>>("test-item"));
Filters.Add(new ActivatingFilter<TestUser>("User"));
}
}
@@ -82,7 +82,7 @@ namespace Orchard.Core.Tests.Common.Providers {
[Test]
public void OwnerShouldBeNullAndZeroByDefault() {
var contentManager = _container.Resolve<IContentManager>();
var item = contentManager.Create<CommonAspect>("test-item", init => { });
var item = contentManager.Create<CommonPart>("test-item", init => { });
ClearSession();
Assert.That(item.Owner, Is.Null);
@@ -99,7 +99,7 @@ namespace Orchard.Core.Tests.Common.Providers {
_authn.Setup(x => x.GetAuthenticatedUser()).Returns(user);
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" };
updateModel.Setup(x => x.TryUpdateModel(viewModel, "", null, null)).Returns(true);
contentManager.UpdateEditorModel(item.ContentItem, updateModel.Object);
@@ -131,7 +131,7 @@ namespace Orchard.Core.Tests.Common.Providers {
{
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");
_authn.Setup(x => x.GetAuthenticatedUser()).Returns(user);
@@ -149,7 +149,7 @@ namespace Orchard.Core.Tests.Common.Providers {
{
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");
_authn.Setup(x => x.GetAuthenticatedUser()).Returns(user);
@@ -161,7 +161,7 @@ namespace Orchard.Core.Tests.Common.Providers {
contentManager.UpdateEditorModel(item.ContentItem, updater);
Assert.That(updater.ModelErrors.ContainsKey("CommonAspect.Owner"), Is.True);
Assert.That(updater.ModelErrors.ContainsKey("CommonPart.Owner"), Is.True);
}
[Test]
@@ -170,7 +170,7 @@ namespace Orchard.Core.Tests.Common.Providers {
var contentManager = _container.Resolve<IContentManager>();
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.PublishedUtc, Is.Null);
@@ -190,7 +190,7 @@ namespace Orchard.Core.Tests.Common.Providers {
var contentManager = _container.Resolve<IContentManager>();
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.PublishedUtc, Is.Null);
@@ -204,7 +204,7 @@ namespace Orchard.Core.Tests.Common.Providers {
_clock.Advance(TimeSpan.FromMinutes(1));
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));
var publish2Utc = _clock.UtcNow;
@@ -232,7 +232,7 @@ namespace Orchard.Core.Tests.Common.Providers {
var contentManager = _container.Resolve<IContentManager>();
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.PublishedUtc, Is.Null);
@@ -252,9 +252,9 @@ namespace Orchard.Core.Tests.Common.Providers {
_session.Flush();
_session.Clear();
var publishedItem = contentManager.Get<ICommonAspect>(item.ContentItem.Id, VersionOptions.Published);
var latestItem = contentManager.Get<ICommonAspect>(item.ContentItem.Id, VersionOptions.Latest);
var draftItem = contentManager.Get<ICommonAspect>(item.ContentItem.Id, VersionOptions.Draft);
var publishedItem = contentManager.Get<ICommonPart>(item.ContentItem.Id, VersionOptions.Published);
var latestItem = contentManager.Get<ICommonPart>(item.ContentItem.Id, VersionOptions.Latest);
var draftItem = contentManager.Get<ICommonPart>(item.ContentItem.Id, VersionOptions.Draft);
var allVersions = contentManager.GetAllVersions(item.ContentItem.Id);
Assert.That(publishedItem, Is.Null);

View File

@@ -189,8 +189,8 @@ namespace Orchard.Core.Tests.Common.Services {
typeof(ContentTypeRecord),
typeof(ContentItemRecord),
typeof(ContentItemVersionRecord),
typeof(CommonRecord),
typeof(CommonVersionRecord),
typeof(CommonPartRecord),
typeof(CommonPartVersionRecord),
};
}
}
@@ -199,8 +199,8 @@ namespace Orchard.Core.Tests.Common.Services {
public class ThingHandler : ContentHandler {
public ThingHandler() {
Filters.Add(new ActivatingFilter<Thing>(ThingDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<ContentPart<CommonVersionRecord>>(ThingDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<CommonAspect>(ThingDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<ContentPart<CommonPartVersionRecord>>(ThingDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<CommonPart>(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 StuffHandler() {
Filters.Add(new ActivatingFilter<Stuff>(StuffDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<ContentPart<CommonVersionRecord>>(StuffDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<CommonAspect>(StuffDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<ContentPart<CommonPartVersionRecord>>(StuffDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<CommonPart>(StuffDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<IsRoutable>(StuffDriver.ContentType.Name));
}
}

View File

@@ -148,18 +148,18 @@ namespace Orchard.Core.Tests.Feeds.Controllers {
public void CorePartValuesAreExtracted() {
var clock = new StubClock();
var hello = new ContentItemBuilder(new ContentTypeDefinitionBuilder().Named("hello").Build())
.Weld<CommonAspect>()
.Weld<CommonPart>()
.Weld<IsRoutable>()
.Weld<BodyAspect>()
.Weld<BodyPart>()
.Build();
hello.As<CommonAspect>().Record = new CommonRecord();
hello.As<CommonPart>().Record = new CommonPartRecord();
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>().Slug = "beta";
hello.As<BodyAspect>().Text = "gamma";
hello.As<BodyPart>().Text = "gamma";
var query = new StubQuery(new[] {
hello,

View File

@@ -100,7 +100,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Common\Providers\CommonAspectProviderTests.cs" />
<Compile Include="Common\Providers\CommonPartProviderTests.cs" />
<Compile Include="Common\Services\RoutableServiceTests.cs" />
<Compile Include="Feeds\Controllers\FeedControllerTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />

View File

@@ -9,15 +9,15 @@ using Orchard.Data.Migration;
namespace Orchard.Core.Common.DataMigrations {
public class CommonDataMigration : DataMigrationImpl {
public int Create() {
//CREATE TABLE Common_BodyRecord (Id INTEGER not null, Text TEXT, Format TEXT, ContentItemRecord_id INTEGER, primary key (Id));
SchemaBuilder.CreateTable("BodyRecord", table => table
//CREATE TABLE Common_BodyPartRecord (Id INTEGER not null, Text TEXT, Format TEXT, ContentItemRecord_id INTEGER, primary key (Id));
SchemaBuilder.CreateTable("BodyPartRecord", table => table
.ContentPartVersionRecord()
.Column<string>("Text", column => column.Unlimited())
.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));
SchemaBuilder.CreateTable("CommonRecord", table => table
//CREATE TABLE Common_CommonPartRecord (Id INTEGER not null, OwnerId INTEGER, CreatedUtc DATETIME, PublishedUtc DATETIME, ModifiedUtc DATETIME, Container_id INTEGER, primary key (Id));
SchemaBuilder.CreateTable("CommonPartRecord", table => table
.ContentPartRecord()
.Column<int>("OwnerId")
.Column<DateTime>("CreatedUtc")
@@ -26,8 +26,8 @@ namespace Orchard.Core.Common.DataMigrations {
.Column<int>("Container_id")
);
//CREATE TABLE Common_CommonVersionRecord (Id INTEGER not null, CreatedUtc DATETIME, PublishedUtc DATETIME, ModifiedUtc DATETIME, ContentItemRecord_id INTEGER, primary key (Id));
SchemaBuilder.CreateTable("CommonVersionRecord", table => table
//CREATE TABLE Common_CommonPartVersionRecord (Id INTEGER not null, CreatedUtc DATETIME, PublishedUtc DATETIME, ModifiedUtc DATETIME, ContentItemRecord_id INTEGER, primary key (Id));
SchemaBuilder.CreateTable("CommonPartVersionRecord", table => table
.ContentPartVersionRecord()
.Column<DateTime>("CreatedUtc")
.Column<DateTime>("PublishedUtc")
@@ -38,7 +38,7 @@ namespace Orchard.Core.Common.DataMigrations {
}
public int UpdateFrom1() {
ContentDefinitionManager.AlterPartDefinition(typeof(BodyAspect).Name, cfg => cfg
ContentDefinitionManager.AlterPartDefinition(typeof(BodyPart).Name, cfg => cfg
.WithLocation(new Dictionary<string, ContentLocation> {
{"Default", new ContentLocation { Zone = "primary", Position = "5" }},
}));
@@ -46,7 +46,7 @@ namespace Orchard.Core.Common.DataMigrations {
}
public int UpdateFrom2() {
ContentDefinitionManager.AlterPartDefinition(typeof(CommonAspect).Name, cfg => cfg
ContentDefinitionManager.AlterPartDefinition(typeof(CommonPart).Name, cfg => cfg
.WithLocation(new Dictionary<string, ContentLocation> {
{"Default", new ContentLocation { Zone = "metadata", Position = "5" }},
{"Editor", new ContentLocation { Zone = "primary", Position = "20" }},

View File

@@ -11,13 +11,13 @@ using Orchard.Core.Routable.Models;
namespace Orchard.Core.Common.Drivers {
[UsedImplicitly]
public class BodyDriver : ContentPartDriver<BodyAspect> {
public class BodyPartDriver : ContentPartDriver<BodyPart> {
public IOrchardServices Services { get; set; }
private const string TemplateName = "Parts/Common.Body";
private const string DefaultTextEditorTemplate = "TinyMceTextEditor";
private const string PlainTextEditorTemplate = "PlainTextEditor";
public BodyDriver(IOrchardServices services) {
public BodyPartDriver(IOrchardServices 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 \/\/
protected override DriverResult Display(BodyAspect part, string displayType) {
var model = new BodyDisplayViewModel { BodyAspect = part, Text = BbcodeReplace(part.Text) };
protected override DriverResult Display(BodyPart part, string displayType) {
var model = new BodyDisplayViewModel { BodyPart = part, Text = BbcodeReplace(part.Text) };
var location = part.GetLocation(displayType);
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);
}
protected override DriverResult Editor(BodyAspect part) {
protected override DriverResult Editor(BodyPart part) {
var model = BuildEditorViewModel(part);
var location = part.GetLocation("Editor");
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);
updater.TryUpdateModel(model, Prefix, null, null);
@@ -55,15 +55,15 @@ namespace Orchard.Core.Common.Drivers {
return ContentPartTemplate(model, TemplateName, Prefix).Location(location);
}
private static BodyEditorViewModel BuildEditorViewModel(BodyAspect part) {
private static BodyEditorViewModel BuildEditorViewModel(BodyPart part) {
return new BodyEditorViewModel {
BodyAspect = part,
BodyPart = part,
TextEditorTemplate = GetFlavor(part) == "html" ? DefaultTextEditorTemplate : PlainTextEditorTemplate,
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>();
return (typePartSettings != null && !string.IsNullOrWhiteSpace(typePartSettings.Flavor))
? typePartSettings.Flavor
@@ -89,7 +89,7 @@ namespace Orchard.Core.Common.Drivers {
}
public PathBuilder AddContainerSlug() {
var common = _content.As<ICommonAspect>();
var common = _content.As<ICommonPart>();
if (common == null)
return this;

View File

@@ -8,15 +8,15 @@ using Orchard.Security;
using Orchard.Services;
namespace Orchard.Core.Common.Drivers {
public class CommonDriver : ContentPartDriver<CommonAspect> {
private const string TemplatePrefix = "CommonAspect";
public class CommonPartDriver : ContentPartDriver<CommonPart> {
private const string TemplatePrefix = "CommonPart";
private readonly IContentManager _contentManager;
private readonly IAuthenticationService _authenticationService;
private readonly IAuthorizationService _authorizationService;
private readonly IMembershipService _membershipService;
private readonly IClock _clock;
public CommonDriver(
public CommonPartDriver(
IOrchardServices services,
IContentManager contentManager,
IAuthenticationService authenticationService,
@@ -35,19 +35,19 @@ namespace Orchard.Core.Common.Drivers {
public Localizer T { 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")
.LongestMatch(displayType, "Summary", "SummaryAdmin")
.Location(part.GetLocation(displayType));
}
protected override DriverResult Editor(CommonAspect part) {
protected override DriverResult Editor(CommonPart part) {
return Combined(
OwnerEditor(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.
instance.ModifiedUtc = _clock.UtcNow;
instance.VersionModifiedUtc = _clock.UtcNow;
@@ -57,7 +57,7 @@ namespace Orchard.Core.Common.Drivers {
ContainerEditor(instance, updater));
}
DriverResult OwnerEditor(CommonAspect part, IUpdateModel updater) {
DriverResult OwnerEditor(CommonPart part, IUpdateModel updater) {
var currentUser = _authenticationService.GetAuthenticatedUser();
if (!_authorizationService.TryCheckAccess(Permissions.ChangeOwner, currentUser, part)) {
return null;
@@ -74,7 +74,7 @@ namespace Orchard.Core.Common.Drivers {
if (model.Owner != null && model.Owner != priorOwner) {
var newOwner = _membershipService.GetUser(model.Owner);
if (newOwner == null) {
updater.AddModelError("CommonAspect.Owner", T("Invalid user name"));
updater.AddModelError("CommonPart.Owner", T("Invalid user name"));
}
else {
part.Owner = newOwner;
@@ -85,7 +85,7 @@ namespace Orchard.Core.Common.Drivers {
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();
if (!_authorizationService.TryCheckAccess(Permissions.ChangeOwner, currentUser, part)) {
return null;
@@ -102,7 +102,7 @@ namespace Orchard.Core.Common.Drivers {
if (model.ContainerId != null && model.ContainerId != priorContainerId) {
var newContainer = _contentManager.Get((int)model.ContainerId, VersionOptions.Latest);
if (newContainer == null) {
updater.AddModelError("CommonAspect.ContainerId", T("Invalid container"));
updater.AddModelError("CommonPart.ContainerId", T("Invalid container"));
}
else {
part.Container = newContainer;

View File

@@ -5,13 +5,13 @@ using Orchard.ContentManagement.Handlers;
namespace Orchard.Core.Common.Handlers {
[UsedImplicitly]
public class BodyAspectHandler : ContentHandler {
public BodyAspectHandler(IRepository<BodyRecord> bodyRepository) {
public class BodyPartHandler : ContentHandler {
public BodyPartHandler(IRepository<BodyPartRecord> bodyRepository) {
Filters.Add(StorageFilter.For(bodyRepository));
OnIndexing<BodyAspect>((context, bodyAspect) => context.DocumentIndex
.Add("body", bodyAspect.Record.Text).RemoveTags().Analyze()
.Add("format", bodyAspect.Record.Format).Store());
OnIndexing<BodyPart>((context, bodyPart) => context.DocumentIndex
.Add("body", bodyPart.Record.Text).RemoveTags().Analyze()
.Add("format", bodyPart.Record.Format).Store());
}
}
}

View File

@@ -9,14 +9,14 @@ using Orchard.Services;
namespace Orchard.Core.Common.Handlers {
[UsedImplicitly]
public class CommonAspectHandler : ContentHandler {
public class CommonPartHandler : ContentHandler {
private readonly IClock _clock;
private readonly IAuthenticationService _authenticationService;
private readonly IContentManager _contentManager;
public CommonAspectHandler(
IRepository<CommonRecord> commonRepository,
IRepository<CommonVersionRecord> commonVersionRepository,
public CommonPartHandler(
IRepository<CommonPartRecord> commonRepository,
IRepository<CommonPartVersionRecord> commonVersionRepository,
IClock clock,
IAuthenticationService authenticationService,
IContentManager contentManager) {
@@ -29,56 +29,56 @@ namespace Orchard.Core.Common.Handlers {
Filters.Add(StorageFilter.For(commonRepository));
Filters.Add(StorageFilter.For(commonVersionRepository));
OnInitializing<CommonAspect>(PropertySetHandlers);
OnInitializing<CommonAspect>(AssignCreatingOwner);
OnInitializing<ContentPart<CommonRecord>>(AssignCreatingDates);
OnInitializing<ContentPart<CommonVersionRecord>>(AssignCreatingDates);
OnInitializing<CommonPart>(PropertySetHandlers);
OnInitializing<CommonPart>(AssignCreatingOwner);
OnInitializing<ContentPart<CommonPartRecord>>(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<CommonVersionRecord>>(AssignPublishingDates);
OnPublishing<ContentPart<CommonPartRecord>>(AssignPublishingDates);
OnPublishing<ContentPart<CommonPartVersionRecord>>(AssignPublishingDates);
//OnGetDisplayViewModel<CommonAspect>();
//OnGetEditorViewModel<CommonAspect>(GetEditor);
//OnUpdateEditorViewModel<CommonAspect>(UpdateEditor);
//OnGetDisplayViewModel<CommonPart>();
//OnGetEditorViewModel<CommonPart>(GetEditor);
//OnUpdateEditorViewModel<CommonPart>(UpdateEditor);
OnIndexing<CommonAspect>((context, commonAspect) => context.DocumentIndex
.Add("type", commonAspect.ContentItem.ContentType).Store()
.Add("author", commonAspect.Owner.UserName).Store()
.Add("created", commonAspect.CreatedUtc ?? _clock.UtcNow).Store()
.Add("published", commonAspect.PublishedUtc ?? _clock.UtcNow).Store()
.Add("modified", commonAspect.ModifiedUtc ?? _clock.UtcNow).Store()
OnIndexing<CommonPart>((context, commonPart) => context.DocumentIndex
.Add("type", commonPart.ContentItem.ContentType).Store()
.Add("author", commonPart.Owner.UserName).Store()
.Add("created", commonPart.CreatedUtc ?? _clock.UtcNow).Store()
.Add("published", commonPart.PublishedUtc ?? _clock.UtcNow).Store()
.Add("modified", commonPart.ModifiedUtc ?? _clock.UtcNow).Store()
);
}
public Localizer T { get; set; }
void AssignCreatingOwner(InitializingContentContext context, CommonAspect part) {
void AssignCreatingOwner(InitializingContentContext context, CommonPart part) {
// and use the current user as Owner
if (part.Record.OwnerId == 0) {
part.Owner = _authenticationService.GetAuthenticatedUser();
}
}
void AssignCreatingDates(InitializingContentContext context, ContentPart<CommonRecord> part) {
void AssignCreatingDates(InitializingContentContext context, ContentPart<CommonPartRecord> part) {
// assign default create/modified dates
part.Record.CreatedUtc = _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
part.Record.CreatedUtc = _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
building.Record.CreatedUtc = _clock.UtcNow;
building.Record.ModifiedUtc = _clock.UtcNow;
@@ -87,7 +87,7 @@ namespace Orchard.Core.Common.Handlers {
building.Record.PublishedUtc = null;
}
void AssignPublishingDates(PublishContentContext context, ContentPart<CommonRecord> part) {
void AssignPublishingDates(PublishContentContext context, ContentPart<CommonPartRecord> part) {
// don't assign dates when unpublishing
if (context.PublishingItemVersionRecord == null)
return;
@@ -96,7 +96,7 @@ namespace Orchard.Core.Common.Handlers {
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
if (context.PublishingItemVersionRecord == null)
return;
@@ -105,51 +105,51 @@ namespace Orchard.Core.Common.Handlers {
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.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
aspect.OwnerField.Loader(() => _contentManager.Get<IUser>(aspect.Record.OwnerId));
aspect.ContainerField.Loader(() => aspect.Record.Container == null ? null : _contentManager.Get(aspect.Record.Container.Id));
part.OwnerField.Loader(() => _contentManager.Get<IUser>(part.Record.OwnerId));
part.ContainerField.Loader(() => part.Record.Container == null ? null : _contentManager.Get(part.Record.Container.Id));
}
static void PropertySetHandlers(InitializingContentContext context, CommonAspect aspect) {
// add handlers that will update records when aspect properties are set
static void PropertySetHandlers(InitializingContentContext context, CommonPart part) {
// add handlers that will update records when part properties are set
aspect.OwnerField.Setter(user => {
part.OwnerField.Setter(user => {
if (user == null) {
aspect.Record.OwnerId = 0;
part.Record.OwnerId = 0;
}
else {
aspect.Record.OwnerId = user.ContentItem.Id;
part.Record.OwnerId = user.ContentItem.Id;
}
return user;
});
// Force call to setter if we had already set a value
if (aspect.OwnerField.Value != null)
aspect.OwnerField.Value = aspect.OwnerField.Value;
if (part.OwnerField.Value != null)
part.OwnerField.Value = part.OwnerField.Value;
aspect.ContainerField.Setter(container => {
part.ContainerField.Setter(container => {
if (container == null) {
aspect.Record.Container = null;
part.Record.Container = null;
}
else {
aspect.Record.Container = container.ContentItem.Record;
part.Record.Container = container.ContentItem.Record;
}
return container;
});
// Force call to setter if we had already set a value
if (aspect.ContainerField.Value != null)
aspect.ContainerField.Value = aspect.ContainerField.Value;
if (part.ContainerField.Value != null)
part.ContainerField.Value = part.ContainerField.Value;
}
//private void GetEditor(BuildEditorModelContext context, CommonAspect instance) {
//private void GetEditor(BuildEditorModelContext context, CommonPart instance) {
// var currentUser = _authenticationService.GetAuthenticatedUser();
// if (!_authorizationService.TryCheckAccess(Permissions.ChangeOwner, currentUser, instance)) {
// return;
@@ -158,11 +158,11 @@ namespace Orchard.Core.Common.Handlers {
// if (instance.Owner != null)
// 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.
// // kind of a loose rule of thumb. may not be sufficient
// instance.ModifiedUtc = _clock.UtcNow;
@@ -178,19 +178,19 @@ namespace Orchard.Core.Common.Handlers {
// viewModel.Owner = instance.Owner.UserName;
// 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) {
// var newOwner = _membershipService.GetUser(viewModel.Owner);
// if (newOwner == null) {
// context.Updater.AddModelError("CommonAspect.Owner", T("Invalid user name"));
// context.Updater.AddModelError("CommonPart.Owner", T("Invalid user name"));
// }
// else {
// 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" });
//}
}
}

View File

@@ -1,7 +1,7 @@
using Orchard.ContentManagement;
namespace Orchard.Core.Common.Models {
public class BodyAspect : ContentPart<BodyRecord> {
public class BodyPart : ContentPart<BodyPartRecord> {
public string Text {
get { return Record.Text; }
set { Record.Text = value; }

View File

@@ -2,7 +2,7 @@ using Orchard.ContentManagement.Records;
using Orchard.Data.Conventions;
namespace Orchard.Core.Common.Models {
public class BodyRecord : ContentPartVersionRecord {
public class BodyPartRecord : ContentPartVersionRecord {
[StringLengthMax]
public virtual string Text { get; set; }

View File

@@ -5,7 +5,7 @@ using Orchard.ContentManagement.Aspects;
using Orchard.Security;
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<IContent> _container = new LazyField<IContent>();
@@ -38,42 +38,42 @@ namespace Orchard.Core.Common.Models {
set { Record.ModifiedUtc = value; }
}
CommonVersionRecord VersionRecord {
CommonPartVersionRecord PartVersionRecord {
get {
var versionPart = this.As<ContentPart<CommonVersionRecord>>();
var versionPart = this.As<ContentPart<CommonPartVersionRecord>>();
return versionPart == null ? null : versionPart.Record;
}
}
public DateTime? VersionCreatedUtc {
get {
return VersionRecord == null ? CreatedUtc : VersionRecord.CreatedUtc;
return PartVersionRecord == null ? CreatedUtc : PartVersionRecord.CreatedUtc;
}
set {
if (VersionRecord != null) {
VersionRecord.CreatedUtc = value;
if (PartVersionRecord != null) {
PartVersionRecord.CreatedUtc = value;
}
}
}
public DateTime? VersionPublishedUtc {
get {
return VersionRecord == null ? PublishedUtc : VersionRecord.PublishedUtc;
return PartVersionRecord == null ? PublishedUtc : PartVersionRecord.PublishedUtc;
}
set {
if (VersionRecord != null) {
VersionRecord.PublishedUtc = value;
if (PartVersionRecord != null) {
PartVersionRecord.PublishedUtc = value;
}
}
}
public DateTime? VersionModifiedUtc {
get {
return VersionRecord == null ? ModifiedUtc : VersionRecord.ModifiedUtc;
return PartVersionRecord == null ? ModifiedUtc : PartVersionRecord.ModifiedUtc;
}
set {
if (VersionRecord != null) {
VersionRecord.ModifiedUtc = value;
if (PartVersionRecord != null) {
PartVersionRecord.ModifiedUtc = value;
}
}
}

View File

@@ -2,7 +2,7 @@
using Orchard.ContentManagement.Records;
namespace Orchard.Core.Common.Models {
public class CommonRecord : ContentPartRecord {
public class CommonPartRecord : ContentPartRecord {
public virtual int OwnerId { get; set; }
public virtual ContentItemRecord Container { get; set; }
public virtual DateTime? CreatedUtc { get; set; }

View File

@@ -2,7 +2,7 @@ using System;
using Orchard.ContentManagement.Records;
namespace Orchard.Core.Common.Models {
public class CommonVersionRecord : ContentPartVersionRecord {
public class CommonPartVersionRecord : ContentPartVersionRecord {
public virtual DateTime? CreatedUtc { get; set; }
public virtual DateTime? PublishedUtc { get; set; }
public virtual DateTime? ModifiedUtc { get; set; }

View File

@@ -23,7 +23,7 @@ namespace Orchard.Core.Common.Settings {
public class BodySettingsHooks : ContentDefinitionEditorEventsBase {
public override IEnumerable<TemplateViewModel> TypePartEditor(ContentTypeDefinition.Part definition) {
if (definition.PartDefinition.Name != "BodyAspect")
if (definition.PartDefinition.Name != "BodyPart")
yield break;
var model = definition.Settings.GetModel<BodyTypePartSettings>();
@@ -37,7 +37,7 @@ namespace Orchard.Core.Common.Settings {
}
public override IEnumerable<TemplateViewModel> PartEditor(ContentPartDefinition definition) {
if (definition.Name != "BodyAspect")
if (definition.Name != "BodyPart")
yield break;
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) {
if (builder.Name != "BodyAspect")
if (builder.Name != "BodyPart")
yield break;
var model = new BodyTypePartSettings();
@@ -55,7 +55,7 @@ namespace Orchard.Core.Common.Settings {
}
public override IEnumerable<TemplateViewModel> PartEditorUpdate(ContentPartDefinitionBuilder builder, IUpdateModel updateModel) {
if (builder.Name != "BodyAspect")
if (builder.Name != "BodyPart")
yield break;
var model = new BodyPartSettings();

View File

@@ -2,7 +2,7 @@
namespace Orchard.Core.Common.ViewModels {
public class BodyDisplayViewModel {
public BodyAspect BodyAspect { get; set; }
public BodyPart BodyPart { get; set; }
public string Text { get; set; }
}
}

View File

@@ -2,16 +2,16 @@
namespace Orchard.Core.Common.ViewModels {
public class BodyEditorViewModel {
public BodyAspect BodyAspect { get; set; }
public BodyPart BodyPart { get; set; }
public string Text {
get { return BodyAspect.Record.Text; }
set { BodyAspect.Record.Text = value; }
get { return BodyPart.Record.Text; }
set { BodyPart.Record.Text = value; }
}
public string Format {
get { return BodyAspect.Record.Format; }
set { BodyAspect.Record.Format = value; }
get { return BodyPart.Record.Format; }
set { BodyPart.Record.Format = value; }
}
public string TextEditorTemplate { get; set; }

View File

@@ -4,20 +4,20 @@ using Orchard.Security;
namespace Orchard.Core.Common.ViewModels {
public class CommonMetadataViewModel {
private readonly CommonAspect _commonAspect;
private readonly CommonPart _commonPart;
public CommonMetadataViewModel(CommonAspect commonAspect) {
_commonAspect = commonAspect;
public CommonMetadataViewModel(CommonPart commonPart) {
_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? PublishedUtc { get { return _commonAspect.PublishedUtc; } }
public DateTime? ModifiedUtc { get { return _commonAspect.ModifiedUtc; } }
public DateTime? CreatedUtc { get { return _commonPart.CreatedUtc; } }
public DateTime? PublishedUtc { get { return _commonPart.PublishedUtc; } }
public DateTime? ModifiedUtc { get { return _commonPart.ModifiedUtc; } }
public DateTime? VersionCreatedUtc { get { return _commonAspect.VersionCreatedUtc; } }
public DateTime? VersionPublishedUtc { get { return _commonAspect.VersionPublishedUtc; } }
public DateTime? VersionModifiedUtc { get { return _commonAspect.VersionModifiedUtc; } }
public DateTime? VersionCreatedUtc { get { return _commonPart.VersionCreatedUtc; } }
public DateTime? VersionPublishedUtc { get { return _commonPart.VersionPublishedUtc; } }
public DateTime? VersionModifiedUtc { get { return _commonPart.VersionModifiedUtc; } }
}
}

View File

@@ -1,5 +1,5 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BodyDisplayViewModel>" %>
<%@ Import Namespace="Orchard.Core.Common.ViewModels"%>
<div class="manage">
<%: Html.ItemEditLinkWithReturnUrl(T("Edit").ToString(), Model.BodyAspect.ContentItem) %>
<%: Html.ItemEditLinkWithReturnUrl(T("Edit").ToString(), Model.BodyPart.ContentItem) %>
</div>

View File

@@ -6,4 +6,4 @@
<%: new HtmlString(string.Format(
"<p>{0} {1}</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))) %>

View File

@@ -64,19 +64,19 @@ namespace Orchard.Core.Contents.Controllers {
}
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
//-- want something like
//switch (model.Options.OrderBy) {
// case ContentsOrder.Modified:
// query = query.OrderByDescending<CommonRecord, DateTime?>(cr => cr.ModifiedUtc);
// query = query.OrderByDescending<CommonPartRecord, DateTime?>(cr => cr.ModifiedUtc);
// break;
// case ContentsOrder.Published:
// query = query.OrderByDescending<CommonRecord, DateTime?>(cr => cr.PublishedUtc);
// query = query.OrderByDescending<CommonPartRecord, DateTime?>(cr => cr.PublishedUtc);
// break;
// case ContentsOrder.Created:
// query = query.OrderByDescending<CommonRecord, DateTime?>(cr => cr.CreatedUtc);
// query = query.OrderByDescending<CommonPartRecord, DateTime?>(cr => cr.CreatedUtc);
// break;
//}

View File

@@ -9,16 +9,16 @@ namespace Orchard.Core.Feeds.StandardBuilders {
public class ItemInspector {
private readonly IContent _item;
private readonly ContentItemMetadata _metadata;
private readonly ICommonAspect _common;
private readonly ICommonPart _common;
private readonly IsRoutable _routable;
private readonly BodyAspect _body;
private readonly BodyPart _body;
public ItemInspector(IContent item, ContentItemMetadata metadata) {
_item = item;
_metadata = metadata;
_common = item.Get<ICommonAspect>();
_common = item.Get<ICommonPart>();
_routable = item.Get<IsRoutable>();
_body = item.Get<BodyAspect>();
_body = item.Get<BodyPart>();
}
public string Title {

View File

@@ -58,7 +58,7 @@ namespace Orchard.Core.Feeds.StandardQueries {
}
var items = _contentManager.Query()
.Where<CommonRecord>(x => x.Container == container.Record)
.Where<CommonPartRecord>(x => x.Container == container.Record)
.OrderByDescending(x => x.PublishedUtc)
.Slice(0, limit);

View File

@@ -62,8 +62,8 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Common\DataMigrations\CommonDataMigration.cs" />
<Compile Include="Common\Drivers\BodyDriver.cs" />
<Compile Include="Common\Drivers\CommonDriver.cs" />
<Compile Include="Common\Drivers\BodyPartDriver.cs" />
<Compile Include="Common\Drivers\CommonPartDriver.cs" />
<Compile Include="Common\Drivers\TextFieldDriver.cs" />
<Compile Include="Common\Extensions\HtmlHelperExtensions.cs" />
<Compile Include="Common\Fields\TextField.cs" />
@@ -116,14 +116,14 @@
<Compile Include="Routable\IRoutablePathConstraint.cs" />
<Compile Include="Routable\Models\IsRoutable.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\Handlers\CommonAspectHandler.cs" />
<Compile Include="Common\Models\CommonAspect.cs" />
<Compile Include="Common\Handlers\BodyAspectHandler.cs" />
<Compile Include="Common\Models\BodyAspect.cs" />
<Compile Include="Common\Models\BodyRecord.cs" />
<Compile Include="Common\Models\CommonRecord.cs" />
<Compile Include="Common\Handlers\CommonPartHandler.cs" />
<Compile Include="Common\Models\CommonPart.cs" />
<Compile Include="Common\Handlers\BodyPartHandler.cs" />
<Compile Include="Common\Models\BodyPart.cs" />
<Compile Include="Common\Models\BodyPartRecord.cs" />
<Compile Include="Common\Models\CommonPartRecord.cs" />
<Compile Include="Common\ViewModels\BodyDisplayViewModel.cs" />
<Compile Include="Common\ViewModels\BodyEditorViewModel.cs" />
<Compile Include="Common\ViewModels\OwnerEditorViewModel.cs" />

View File

@@ -33,7 +33,7 @@ namespace Orchard.Core.PublishLater.ViewModels {
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; }

View File

@@ -67,7 +67,7 @@ namespace Orchard.Core.Routable.Controllers {
if (containerId != null) {
var containerItem = _contentManager.Get((int)containerId);
contentItem.As<ICommonAspect>().Container = containerItem;
contentItem.As<ICommonPart>().Container = containerItem;
}
}

View File

@@ -28,15 +28,15 @@ namespace Orchard.Core.Routable.Drivers {
}
int? GetContainerId(IContent item) {
var commonAspect = item.As<ICommonAspect>();
if (commonAspect != null && commonAspect.Container != null) {
return commonAspect.Container.ContentItem.Id;
var commonPart = item.As<ICommonPart>();
if (commonPart != null && commonPart.Container != null) {
return commonPart.Container.ContentItem.Id;
}
return null;
}
string GetContainerSlug(IContent item) {
var commonAspect = item.As<ICommonAspect>();
var commonAspect = item.As<ICommonPart>();
if (commonAspect != null && commonAspect.Container != null) {
var routable = commonAspect.Container.As<IRoutableAspect>();
if (routable != null) {

View File

@@ -35,7 +35,7 @@ namespace Futures.Widgets.Controllers {
init.Record.Scope = hasWidgetsRecord;
init.Record.Zone = zoneName;
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 });

View File

@@ -30,7 +30,7 @@ namespace Futures.Widgets.DataMigrations {
ContentDefinitionManager.AlterTypeDefinition("HtmlWidget",
cfg => cfg
.WithPart("Widget")
.WithPart("BodyAspect")
.WithPart("BodyPart")
);
return 2;

View File

@@ -53,7 +53,7 @@ namespace Orchard.Blogs.Commands {
}
var blog = _contentManager.New("Blog");
blog.As<ICommonAspect>().Owner = admin;
blog.As<ICommonPart>().Owner = admin;
blog.As<IsRoutable>().Slug = Slug;
blog.As<IsRoutable>().Title = Title;
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)));
var post = _contentManager.New("BlogPost");
post.As<ICommonAspect>().Owner = admin;
post.As<ICommonAspect>().Container = blog;
post.As<ICommonPart>().Owner = admin;
post.As<ICommonPart>().Container = blog;
post.As<IsRoutable>().Slug = Slugify(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);
}

View File

@@ -32,17 +32,17 @@ namespace Orchard.Blogs.DataMigrations {
ContentDefinitionManager.AlterTypeDefinition("Blog",
cfg => cfg
.WithPart("BlogPart")
.WithPart("CommonAspect")
.WithPart("CommonPart")
.WithPart("IsRoutable")
);
ContentDefinitionManager.AlterTypeDefinition("BlogPost",
cfg => cfg
.WithPart("BlogPostPart")
.WithPart("CommonAspect")
.WithPart("CommonPart")
.WithPart("PublishLaterPart")
.WithPart("IsRoutable")
.WithPart("BodyAspect")
.WithPart("BodyPart")
);
return 2;

View File

@@ -11,12 +11,12 @@ using Orchard.Data;
namespace Orchard.Blogs.Handlers {
[UsedImplicitly]
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));
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();
//INFO: (erikpo) Remove all current blog archive records

View File

@@ -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: 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)) {
int cId;
if (int.TryParse(containerId, out cId)) {

View File

@@ -24,18 +24,18 @@ namespace Orchard.Blogs.Models {
}
public string Text {
get { return this.As<BodyAspect>().Text; }
set { this.As<BodyAspect>().Text = value; }
get { return this.As<BodyPart>().Text; }
set { this.As<BodyPart>().Text = value; }
}
public BlogPart BlogPart {
get { return this.As<ICommonAspect>().Container.As<BlogPart>(); }
set { this.As<ICommonAspect>().Container = value; }
get { return this.As<ICommonPart>().Container.As<BlogPart>(); }
set { this.As<ICommonPart>().Container = value; }
}
public IUser Creator {
get { return this.As<ICommonAspect>().Owner; }
set { this.As<ICommonAspect>().Owner = value; }
get { return this.As<ICommonPart>().Owner; }
set { this.As<ICommonPart>().Owner = value; }
}
public bool IsPublished {
@@ -58,7 +58,7 @@ namespace Orchard.Blogs.Models {
}
public DateTime? CreatedUtc {
get { return this.As<ICommonAspect>().CreatedUtc; }
get { return this.As<ICommonPart>().CreatedUtc; }
}
public DateTime? ScheduledPublishUtc { get; set; }

View File

@@ -30,7 +30,7 @@ namespace Orchard.Blogs.Services {
public BlogPostPart Get(BlogPart blogPart, string slug, VersionOptions versionOptions) {
return
_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>();
}
@@ -110,9 +110,9 @@ namespace Orchard.Blogs.Services {
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
_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);
}
}

View File

@@ -8,5 +8,5 @@
<%@ Import Namespace="Orchard.Core.Common.ViewModels" %>
<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %>
<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>

View File

@@ -53,7 +53,7 @@ namespace Orchard.Comments.DataMigrations {
ContentDefinitionManager.AlterTypeDefinition("Comment",
cfg => cfg
.WithPart("Comment")
.WithPart("CommonAspect")
.WithPart("CommonPart")
);
ContentDefinitionManager.AlterTypeDefinition("Blog",

View File

@@ -24,7 +24,7 @@ namespace Orchard.Comments.Drivers {
private static CommentCountViewModel CreateViewModel(ContentItem contentItem) {
// Find all contents item with this part as the container
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
int count = parts.Aggregate(0, (seed, item) => seed + (item.Has<HasComments>() ? item.As<HasComments>().Comments.Count : 0));

View File

@@ -86,7 +86,7 @@ namespace Orchard.Comments.Services {
// 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)
var commentedOn = _contentManager.Get<ICommonAspect>(comment.Record.CommentedOn);
var commentedOn = _contentManager.Get<ICommonPart>(comment.Record.CommentedOn);
if (commentedOn != null && commentedOn.Container != null) {
comment.Record.CommentedOnContainer = commentedOn.Container.ContentItem.Id;
}

View File

@@ -26,11 +26,11 @@ namespace Orchard.DevTools.Commands {
var pageName = "page" + index;
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>().Path = pageName;
page.As<IsRoutable>().Title = pageName;
page.As<BodyAspect>().Text = pageName;
page.As<BodyPart>().Text = pageName;
page.As<MenuPart>().OnMainMenu = true;
page.As<MenuPart>().MenuPosition = "5." + index;
page.As<MenuPart>().MenuText = pageName;
@@ -38,7 +38,7 @@ namespace Orchard.DevTools.Commands {
var blogName = "blog" + index;
var blog = _contentManager.New("Blog");
blog.As<ICommonAspect>().Owner = admin;
blog.As<ICommonPart>().Owner = admin;
blog.As<IsRoutable>().Slug = blogName;
blog.As<IsRoutable>().Path = blogName;
blog.As<IsRoutable>().Title = blogName;
@@ -51,11 +51,11 @@ namespace Orchard.DevTools.Commands {
//for (var index2 = 0; index2 != 5; ++index2) {
// var postName = "post" + index;
// var post = _contentManager.New("BlogPost");
// post.As<ICommonAspect>().Owner = admin;
// post.As<ICommonAspect>().Container = blog;
// post.As<ICommonPart>().Owner = admin;
// post.As<ICommonPart>().Container = blog;
// post.As<RoutableAspect>().Slug = postName;
// post.As<RoutableAspect>().Title = postName;
// post.As<BodyAspect>().Text = postName;
// post.As<BodyPart>().Text = postName;
// _contentManager.Create(post);
//}
}

View File

@@ -14,15 +14,15 @@ namespace Orchard.Indexing.Handlers {
public CreateIndexingTaskHandler(IIndexingTaskManager indexingTaskManager) {
_indexingTaskManager = indexingTaskManager;
OnPublishing<ContentPart<CommonRecord>>(CreateIndexingTask);
OnRemoved<ContentPart<CommonRecord>>(RemoveIndexingTask);
OnPublishing<ContentPart<CommonPartRecord>>(CreateIndexingTask);
OnRemoved<ContentPart<CommonPartRecord>>(RemoveIndexingTask);
}
void CreateIndexingTask(PublishContentContext context, ContentPart<CommonRecord> part) {
void CreateIndexingTask(PublishContentContext context, ContentPart<CommonPartRecord> part) {
_indexingTaskManager.CreateUpdateIndexTask(context.ContentItem);
}
void RemoveIndexingTask(RemoveContentContext context, ContentPart<CommonRecord> part) {
void RemoveIndexingTask(RemoveContentContext context, ContentPart<CommonPartRecord> part) {
_indexingTaskManager.CreateDeleteIndexTask(context.ContentItem);
}

View File

@@ -9,9 +9,9 @@ namespace Orchard.Pages.DataMigrations {
ContentDefinitionManager.AlterTypeDefinition("Page",
cfg => cfg
.WithPart("Page")
.WithPart("CommonAspect")
.WithPart("CommonPart")
.WithPart("IsRoutable")
.WithPart("BodyAspect")
.WithPart("BodyPart")
);
return 1;

View File

@@ -21,8 +21,8 @@ namespace Orchard.Pages.Models {
}
public IUser Creator {
get { return this.As<CommonAspect>().Owner; }
set { this.As<CommonAspect>().Owner = value; }
get { return this.As<CommonPart>().Owner; }
set { this.As<CommonPart>().Owner = value; }
}
public bool IsPublished {

View File

@@ -26,7 +26,7 @@ namespace Orchard.Pages.Security {
if (user==null || content==null)
return false;
var common = content.As<ICommonAspect>();
var common = content.As<ICommonPart>();
if (common==null || common.Owner==null)
return false;

View File

@@ -65,10 +65,10 @@ using (Html.BeginFormAntiForgeryPost()) { %>
<%: Html.DateTime(pageEntry.Page.ScheduledPublishUtc.Value, T("M/d/yyyy h:mm tt"))%><%
}
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 { %>
<%: 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)) %><%
} %>&nbsp;&#124;&nbsp;
</li>
<li><%: T("By {0}", pageEntry.Page.Creator.UserName)%></li>

View File

@@ -23,9 +23,9 @@ namespace Orchard.Sandbox.DataMigrations {
ContentDefinitionManager.AlterTypeDefinition("SandboxPage",
cfg => cfg
.WithPart("SandboxPage")
.WithPart("CommonAspect")
.WithPart("CommonPart")
.WithPart("IsRoutable")
.WithPart("BodyAspect")
.WithPart("BodyPart")
);
return 2;

View File

@@ -197,24 +197,24 @@ namespace Orchard.Setup.Services {
.Indexed());
contentDefinitionManager.AlterTypeDefinition("Page", cfg => cfg
.DisplayedAs("Page")
.WithPart("CommonAspect")
.WithPart("CommonPart")
.WithPart("PublishLaterPart")
.WithPart("IsRoutable")
.WithPart("BodyAspect")
.WithPart("BodyPart")
.WithPart("HasComments")
.WithPart("HasTags")
.WithPart("Localized")
.Indexed());
contentDefinitionManager.AlterPartDefinition("BodyAspect", cfg => cfg
contentDefinitionManager.AlterPartDefinition("BodyPart", cfg => cfg
.WithSetting("BodyPartSettings.FlavorDefault", BodyPartSettings.FlavorDefaultDefault));
// create home page as a CMS page
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>().Path = "home";
page.As<IsRoutable>().Title = T("Home").ToString();
page.As<CommonAspect>().Owner = user;
page.As<CommonPart>().Owner = user;
if (page.Has<HasComments>()) {
page.As<HasComments>().CommentsShown = false;
}

View File

@@ -2,7 +2,7 @@
using Orchard.Security;
namespace Orchard.ContentManagement.Aspects {
public interface ICommonAspect : IContent {
public interface ICommonPart : IContent {
IUser Owner { get; set; }
IContent Container { get; set; }

View File

@@ -137,7 +137,7 @@
<Compile Include="Collections\PageOfItems.cs" />
<Compile Include="Commands\CommandBackgroundService.cs" />
<Compile Include="Commands\CommandHostEnvironment.cs" />
<Compile Include="ContentManagement\Aspects\ICommonAspect.cs">
<Compile Include="ContentManagement\Aspects\ICommonPart.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Aspects\IPublishingControlAspect.cs" />