First step into getting versioning/publishing working for blog posts and pages

Publishing/versioning/draft is now mostly working according to spec, next big thing to work on is scheduled publishing (use the TaskScheduler)

--HG--
extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4045915
This commit is contained in:
rpaquay
2010-01-24 07:46:16 +00:00
parent 980b741a25
commit 966462667e
22 changed files with 82 additions and 81 deletions

View File

@@ -1,4 +1,3 @@
using JetBrains.Annotations;
using Orchard.Core.Common.Models;
using Orchard.Core.Common.Records;
using Orchard.Core.Common.ViewModels;
@@ -11,7 +10,6 @@ using Orchard.Security;
using Orchard.Services;
namespace Orchard.Core.Common.Providers {
[UsedImplicitly]
public class CommonAspectHandler : ContentHandler {
private readonly IClock _clock;
private readonly IAuthenticationService _authenticationService;
@@ -40,12 +38,17 @@ namespace Orchard.Core.Common.Providers {
OnActivated<CommonAspect>(PropertySetHandlers);
OnActivated<CommonAspect>(AssignCreatingOwner);
OnActivated <ContentPart<CommonRecord>>(AssignCreatingDates);
OnActivated<ContentPart<CommonRecord>>(AssignCreatingDates);
OnActivated<ContentPart<CommonVersionRecord>>(AssignCreatingDates);
OnLoaded<CommonAspect>(LazyLoadHandlers);
OnVersioning<CommonAspect>(CopyOwnerAndContainer);
OnVersioned<ContentPart<CommonVersionRecord>>(AssignVersioningDates);
OnPublishing<ContentPart<CommonRecord>>(AssignPublishingDates);
OnPublishing<ContentPart<CommonVersionRecord>>(AssignPublishingDates);
OnLoaded<CommonAspect>(LazyLoadHandlers);
//OnGetDisplayViewModel<CommonAspect>();
OnGetEditorViewModel<CommonAspect>(GetEditor);
@@ -55,7 +58,7 @@ namespace Orchard.Core.Common.Providers {
public Localizer T { get; set; }
void AssignCreatingOwner(ActivatedContentContext context, CommonAspect part) {
void AssignCreatingOwner(ActivatedContentContext context, CommonAspect part) {
// and use the current user as Owner
if (part.Record.OwnerId == 0) {
part.Owner = _authenticationService.GetAuthenticatedUser();
@@ -101,6 +104,11 @@ namespace Orchard.Core.Common.Providers {
part.Record.PublishedUtc = _clock.UtcNow;
}
private static void CopyOwnerAndContainer(VersionContentContext c, CommonAspect c1, CommonAspect c2) {
c2.Owner = c1.Owner;
c2.Container = c1.Container;
}
void LazyLoadHandlers(LoadContentContext context, CommonAspect aspect) {
// add handlers that will load content for id's just-in-time
aspect.OwnerField.Loader(() => _contentManager.Get<IUser>(aspect.Record.OwnerId));

View File

@@ -5,6 +5,6 @@ namespace Orchard.Core.Common.Records {
public class CommonVersionRecord : ContentPartVersionRecord {
public virtual DateTime? CreatedUtc { get; set; }
public virtual DateTime? PublishedUtc { get; set; }
public virtual DateTime? ModifiedUtc { get; set; }
public virtual DateTime? ModifiedUtc { get; set; }
}
}

View File

@@ -9,7 +9,7 @@ namespace Orchard.Core.Settings.Models {
public SiteSettingsHandler(IRepository<SiteSettingsRecord> repository){
Filters.Add(new ActivatingFilter<SiteSettings>("site"));
Filters.Add(new StorageFilter<SiteSettingsRecord>(repository));
Filters.Add(StorageFilter.For(repository));
}
}
}

View File

@@ -9,7 +9,7 @@ namespace Orchard.Core.Themes.Models {
public ThemeSiteSettingsHandler(IRepository<ThemeSiteSettingsRecord> repository) {
_themeSiteSettingsRepository = repository;
Filters.Add(new ActivatingFilter<ThemeSiteSettings>("site"));
Filters.Add(new StorageFilter<ThemeSiteSettingsRecord>(_themeSiteSettingsRepository));
Filters.Add(StorageFilter.For(_themeSiteSettingsRepository));
Filters.Add(new TemplateFilterForRecord<ThemeSiteSettingsRecord>("ThemeSiteSettings", "Parts/Themes.SiteSettings"));
}
}