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

@@ -0,0 +1,116 @@
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.Core.Common.Models;
using Orchard.Core.Common.ViewModels;
using Orchard.Core.ContentsLocation.Models;
using Orchard.Localization;
using Orchard.Security;
using Orchard.Services;
namespace Orchard.Core.Common.Drivers {
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 CommonPartDriver(
IOrchardServices services,
IContentManager contentManager,
IAuthenticationService authenticationService,
IAuthorizationService authorizationService,
IMembershipService membershipService,
IClock clock) {
_contentManager = contentManager;
_authenticationService = authenticationService;
_authorizationService = authorizationService;
_membershipService = membershipService;
_clock = clock;
T = NullLocalizer.Instance;
Services = services;
}
public Localizer T { get; set; }
public IOrchardServices Services { get; set; }
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(CommonPart part) {
return Combined(
OwnerEditor(part, null),
ContainerEditor(part, null));
}
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;
return Combined(
OwnerEditor(instance, updater),
ContainerEditor(instance, updater));
}
DriverResult OwnerEditor(CommonPart part, IUpdateModel updater) {
var currentUser = _authenticationService.GetAuthenticatedUser();
if (!_authorizationService.TryCheckAccess(Permissions.ChangeOwner, currentUser, part)) {
return null;
}
var model = new OwnerEditorViewModel();
if (part.Owner != null)
model.Owner = part.Owner.UserName;
if (updater != null) {
var priorOwner = model.Owner;
updater.TryUpdateModel(model, TemplatePrefix, null, null);
if (model.Owner != null && model.Owner != priorOwner) {
var newOwner = _membershipService.GetUser(model.Owner);
if (newOwner == null) {
updater.AddModelError("CommonPart.Owner", T("Invalid user name"));
}
else {
part.Owner = newOwner;
}
}
}
return ContentPartTemplate(model, "Parts/Common.Owner", TemplatePrefix).Location(part.GetLocation("Editor"));
}
DriverResult ContainerEditor(CommonPart part, IUpdateModel updater) {
var currentUser = _authenticationService.GetAuthenticatedUser();
if (!_authorizationService.TryCheckAccess(Permissions.ChangeOwner, currentUser, part)) {
return null;
}
var model = new ContainerEditorViewModel();
if (part.Container != null)
model.ContainerId = part.Container.ContentItem.Id;
if (updater != null) {
var priorContainerId = model.ContainerId;
updater.TryUpdateModel(model, TemplatePrefix, null, null);
if (model.ContainerId != null && model.ContainerId != priorContainerId) {
var newContainer = _contentManager.Get((int)model.ContainerId, VersionOptions.Latest);
if (newContainer == null) {
updater.AddModelError("CommonPart.ContainerId", T("Invalid container"));
}
else {
part.Container = newContainer;
}
}
}
return ContentPartTemplate(model, "Parts/Common.Container", TemplatePrefix).Location(part.GetLocation("Editor"));
}
}
}