mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Continuing to refactor ModelDriver concept into ContentHandler
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4041352
This commit is contained in:
@@ -6,7 +6,7 @@ using Orchard.Security;
|
||||
using Orchard.Services;
|
||||
|
||||
namespace Orchard.Core.Common.Models {
|
||||
public class CommonDriver : ModelDriver {
|
||||
public class CommonDriver : Orchard.Models.Driver.ContentHandler {
|
||||
private readonly IClock _clock;
|
||||
private readonly IAuthenticationService _authenticationService;
|
||||
private readonly IContentManager _contentManager;
|
||||
@@ -26,7 +26,7 @@ namespace Orchard.Core.Common.Models {
|
||||
AddOnLoaded<CommonModel>(LoadOwnerModel);
|
||||
}
|
||||
|
||||
void SetCreateTimesAndAuthor(CreateModelContext context, CommonModel instance) {
|
||||
void SetCreateTimesAndAuthor(CreateContentContext context, CommonModel instance) {
|
||||
if (instance.Record.CreatedUtc == null) {
|
||||
instance.Record.CreatedUtc = _clock.UtcNow;
|
||||
}
|
||||
@@ -40,7 +40,7 @@ namespace Orchard.Core.Common.Models {
|
||||
}
|
||||
}
|
||||
|
||||
void LoadOwnerModel(LoadModelContext context, CommonModel instance) {
|
||||
void LoadOwnerModel(LoadContentContext context, CommonModel instance) {
|
||||
if (instance.Record.OwnerId != 0) {
|
||||
instance.Owner = _contentManager.Get(instance.Record.OwnerId).As<IUser>();
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
using Orchard.Models.Driver;
|
||||
|
||||
namespace Orchard.Core.Common.Models {
|
||||
public class ContentDriver : ModelDriver {
|
||||
public class ContentDriver : Orchard.Models.Driver.ContentHandler {
|
||||
|
||||
}
|
||||
}
|
@@ -3,7 +3,7 @@ using Orchard.Data;
|
||||
using Orchard.Models.Driver;
|
||||
|
||||
namespace Orchard.Core.Common.Models {
|
||||
public class RoutableDriver : ModelDriver {
|
||||
public class RoutableDriver : Orchard.Models.Driver.ContentHandler {
|
||||
public RoutableDriver(IRepository<RoutableRecord> repository) {
|
||||
Filters.Add(new StorageFilterForRecord<RoutableRecord>(repository));
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@ using Orchard.Models.Driver;
|
||||
|
||||
namespace Orchard.Core.Settings.Controllers {
|
||||
[ValidateInput(false)]
|
||||
public class AdminController : Controller, IModelUpdater {
|
||||
public class AdminController : Controller, IUpdateModel {
|
||||
private readonly ISiteService _siteService;
|
||||
private readonly IContentManager _modelManager;
|
||||
private readonly INotifier _notifier;
|
||||
@@ -43,9 +43,9 @@ namespace Orchard.Core.Settings.Controllers {
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
#region IModelUpdater Members
|
||||
#region IUpdateModel Members
|
||||
|
||||
bool IModelUpdater.TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) {
|
||||
bool IUpdateModel.TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) {
|
||||
return TryUpdateModel(model, prefix, includeProperties, excludeProperties);
|
||||
}
|
||||
|
||||
|
@@ -3,7 +3,7 @@ using Orchard.Data;
|
||||
using Orchard.Models.Driver;
|
||||
|
||||
namespace Orchard.Core.Settings.Models {
|
||||
public class SiteDriver : ModelDriver {
|
||||
public class SiteDriver : ContentHandler {
|
||||
public SiteDriver(IRepository<SiteSettingsRecord> repository){
|
||||
Filters.Add(new ActivatingFilter<SiteModel>("site"));
|
||||
Filters.Add(new StorageFilterForRecord<SiteSettingsRecord>(repository));
|
||||
|
@@ -12,13 +12,13 @@ namespace Orchard.Media.Models {
|
||||
public virtual string RootMediaFolder { get; set; }
|
||||
}
|
||||
|
||||
public class MediaSettingsDriver : ModelDriver {
|
||||
public class MediaSettingsDriver : ContentHandler {
|
||||
public MediaSettingsDriver(IRepository<MediaSettingsRecord> repository) {
|
||||
Filters.Add(new ActivatingFilter<MediaSettings>("site"));
|
||||
Filters.Add(new StorageFilterForRecord<MediaSettingsRecord>(repository) { AutomaticallyCreateMissingRecord = true });
|
||||
}
|
||||
|
||||
protected override void GetEditors(GetModelEditorsContext context) {
|
||||
protected override void GetEditors(GetContentEditorsContext context) {
|
||||
var model = context.ContentItem.As<MediaSettings>();
|
||||
if (model == null)
|
||||
return;
|
||||
@@ -26,7 +26,7 @@ namespace Orchard.Media.Models {
|
||||
context.Editors.Add(ModelTemplate.For(model.Record, "MediaSettings"));
|
||||
}
|
||||
|
||||
protected override void UpdateEditors(UpdateModelContext context) {
|
||||
protected override void UpdateEditors(UpdateContentContext context) {
|
||||
var model = context.ContentItem.As<MediaSettings>();
|
||||
if (model == null)
|
||||
return;
|
||||
|
@@ -11,7 +11,7 @@ using Orchard.UI.Models;
|
||||
using Orchard.UI.Notify;
|
||||
|
||||
namespace Orchard.Roles.Models {
|
||||
public class UserRolesDriver : ModelDriver {
|
||||
public class UserRolesDriver : ContentHandler {
|
||||
private readonly IRepository<UserRolesRecord> _userRolesRepository;
|
||||
private readonly IRoleService _roleService;
|
||||
private readonly INotifier _notifier;
|
||||
@@ -22,19 +22,19 @@ namespace Orchard.Roles.Models {
|
||||
_notifier = notifier;
|
||||
}
|
||||
|
||||
protected override void Activating(ActivatingModelContext context) {
|
||||
if (context.ModelType == "user") {
|
||||
protected override void Activating(ActivatingContentContext context) {
|
||||
if (context.ContentType == "user") {
|
||||
context.Builder.Weld<UserRolesModel>();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Creating(CreateModelContext context) {
|
||||
protected override void Creating(CreateContentContext context) {
|
||||
var userRoles = context.ContentItem.As<UserRolesModel>();
|
||||
if (userRoles != null) {
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Loading(LoadModelContext context) {
|
||||
protected override void Loading(LoadContentContext context) {
|
||||
var userRoles = context.ContentItem.As<UserRolesModel>();
|
||||
if (userRoles != null) {
|
||||
userRoles.Roles = _userRolesRepository.Fetch(x => x.UserId == context.ContentItem.Id)
|
||||
@@ -42,7 +42,7 @@ namespace Orchard.Roles.Models {
|
||||
}
|
||||
}
|
||||
|
||||
protected override void GetEditors(GetModelEditorsContext context) {
|
||||
protected override void GetEditors(GetContentEditorsContext context) {
|
||||
var userRoles = context.ContentItem.As<UserRolesModel>();
|
||||
if (userRoles != null) {
|
||||
var roles =
|
||||
@@ -63,7 +63,7 @@ namespace Orchard.Roles.Models {
|
||||
}
|
||||
}
|
||||
|
||||
protected override void UpdateEditors(UpdateModelContext context) {
|
||||
protected override void UpdateEditors(UpdateContentContext context) {
|
||||
var userRoles = context.ContentItem.As<UserRolesModel>();
|
||||
if (userRoles != null) {
|
||||
var viewModel = new UserRolesViewModel();
|
||||
|
@@ -12,7 +12,7 @@ using Orchard.Users.ViewModels;
|
||||
|
||||
namespace Orchard.Users.Controllers {
|
||||
|
||||
public class AdminController : Controller, IModelUpdater {
|
||||
public class AdminController : Controller, IUpdateModel {
|
||||
private readonly IMembershipService _membershipService;
|
||||
private readonly IContentManager _contentManager;
|
||||
private readonly IRepository<UserRecord> _userRepository;
|
||||
@@ -86,7 +86,7 @@ namespace Orchard.Users.Controllers {
|
||||
}
|
||||
|
||||
|
||||
bool IModelUpdater.TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) {
|
||||
bool IUpdateModel.TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) {
|
||||
return TryUpdateModel(model, prefix, includeProperties, excludeProperties);
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
using Orchard.Models.Driver;
|
||||
|
||||
namespace Orchard.Users.Models {
|
||||
public class UserDriver : ModelDriver {
|
||||
public class UserDriver : ContentHandler {
|
||||
public UserDriver(IRepository<UserRecord> repository) {
|
||||
Filters.Add(new ActivatingFilter<UserModel>("user"));
|
||||
Filters.Add(new StorageFilterForRecord<UserRecord>(repository));
|
||||
|
@@ -6,9 +6,9 @@ using Orchard.Core.Common.Models;
|
||||
using Orchard.Models.Driver;
|
||||
|
||||
namespace Orchard.Wikis.Models {
|
||||
public class WikiPageDriver : ModelDriver {
|
||||
protected override void Activating(ActivatingModelContext context) {
|
||||
if (context.ModelType == "wikipage") {
|
||||
public class WikiPageDriver : ContentHandler {
|
||||
protected override void Activating(ActivatingContentContext context) {
|
||||
if (context.ContentType == "wikipage") {
|
||||
context.Builder
|
||||
.Weld<CommonModel>()
|
||||
.Weld<RoutableModel>()
|
||||
|
@@ -16,7 +16,7 @@ namespace Orchard.Wikis.Models {
|
||||
public virtual string WikiEditTheme { get; set; }
|
||||
}
|
||||
|
||||
public class WikiSettingsDriver : ModelDriver {
|
||||
public class WikiSettingsDriver : ContentHandler {
|
||||
public WikiSettingsDriver(IRepository<WikiSettingsRecord> repository) {
|
||||
Filters.Add(new ActivatingFilter<WikiSettings>("site"));
|
||||
Filters.Add(new StorageFilterForRecord<WikiSettingsRecord>(repository) { AutomaticallyCreateMissingRecord = true });
|
||||
@@ -25,7 +25,7 @@ namespace Orchard.Wikis.Models {
|
||||
Filters.Add(new ActivatingFilter<WikiSettings>("user"));
|
||||
}
|
||||
|
||||
protected override void GetEditors(GetModelEditorsContext context) {
|
||||
protected override void GetEditors(GetContentEditorsContext context) {
|
||||
var model = context.ContentItem.As<WikiSettings>();
|
||||
if (model == null)
|
||||
return;
|
||||
@@ -33,7 +33,7 @@ namespace Orchard.Wikis.Models {
|
||||
context.Editors.Add(ModelTemplate.For(model.Record, "WikiSettings"));
|
||||
}
|
||||
|
||||
protected override void UpdateEditors(UpdateModelContext context) {
|
||||
protected override void UpdateEditors(UpdateContentContext context) {
|
||||
var model = context.ContentItem.As<WikiSettings>();
|
||||
if (model == null)
|
||||
return;
|
||||
|
Reference in New Issue
Block a user