mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Code styling
This commit is contained in:
@@ -4,13 +4,13 @@ using System.Web.Mvc;
|
||||
using System.Xml;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.Core.Containers.Models;
|
||||
using Orchard.Core.Containers.Services;
|
||||
using Orchard.Core.Containers.Settings;
|
||||
using Orchard.Core.Containers.ViewModels;
|
||||
using Orchard.Localization;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
|
||||
namespace Orchard.Core.Containers.Drivers {
|
||||
public class ContainablePartDriver : ContentPartDriver<ContainablePart> {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Routing;
|
||||
using System.Xml;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
@@ -11,12 +12,11 @@ using Orchard.Core.Common.Models;
|
||||
using Orchard.Core.Containers.Models;
|
||||
using Orchard.Core.Containers.Services;
|
||||
using Orchard.Core.Containers.ViewModels;
|
||||
using Orchard.Localization;
|
||||
using Orchard.UI.Notify;
|
||||
using System.Web.Routing;
|
||||
using Orchard.Settings;
|
||||
using Orchard.Core.Feeds;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Settings;
|
||||
using Orchard.UI.Navigation;
|
||||
using Orchard.UI.Notify;
|
||||
|
||||
namespace Orchard.Core.Containers.Drivers {
|
||||
public class ContainerPartDriver : ContentPartDriver<ContainerPart> {
|
||||
@@ -57,7 +57,7 @@ namespace Orchard.Core.Containers.Drivers {
|
||||
|
||||
var metadata = container.ContentManager.GetItemMetadata(container);
|
||||
if (metadata != null) {
|
||||
_feedManager.Register(metadata.DisplayText, "rss", new RouteValueDictionary {{"containerid", container.Id}});
|
||||
_feedManager.Register(metadata.DisplayText, "rss", new RouteValueDictionary { { "containerid", container.Id } });
|
||||
}
|
||||
|
||||
// Retrieving pager parameters.
|
||||
|
||||
@@ -443,7 +443,7 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
if (!Services.Authorizer.Authorize(Permissions.CreateContent, originalContentItem, T("Couldn't clone content")))
|
||||
return new HttpUnauthorizedResult();
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
// pass a dummy content to the authorization check to check for "own" variations
|
||||
var dummyContent = _contentManager.New(originalContentItem.ContentType);
|
||||
|
||||
@@ -30,9 +30,7 @@ namespace Orchard.Core.Navigation.Drivers {
|
||||
if (!_authorizationService.TryCheckAccess(Permissions.ManageMenus, currentUser, menu)) // tests if the current user has permissions to manage that specific menu
|
||||
return null;
|
||||
|
||||
if (updater != null) {
|
||||
updater.TryUpdateModel(part, Prefix, null, null);
|
||||
}
|
||||
updater?.TryUpdateModel(part, Prefix, null, null);
|
||||
|
||||
return Editor(part, shapeHelper);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace Orchard.Core.Navigation.Drivers {
|
||||
protected override DriverResult Editor(MenuPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
var model = new MenuPartViewModel();
|
||||
|
||||
if(updater.TryUpdateModel(model, Prefix, null, null)) {
|
||||
if (updater.TryUpdateModel(model, Prefix, null, null)) {
|
||||
var menu = model.OnMenu ? _orchardServices.ContentManager.Get(model.CurrentMenuId) : null;
|
||||
|
||||
if (!_authorizationService.TryCheckAccess(Permissions.ManageMenus, _orchardServices.WorkContext.CurrentUser, menu))
|
||||
@@ -104,7 +104,7 @@ namespace Orchard.Core.Navigation.Drivers {
|
||||
|
||||
protected override void Exporting(MenuPart part, ContentManagement.Handlers.ExportContentContext context) {
|
||||
// is it on a menu ?
|
||||
if(part.Menu == null) {
|
||||
if (part.Menu == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ using Orchard.Core.Title.Models;
|
||||
using Orchard.Localization;
|
||||
using Orchard.UI.Navigation;
|
||||
using Orchard.Utility.Extensions;
|
||||
using Orchard.ContentManagement.Utilities;
|
||||
|
||||
namespace Orchard.Core.Navigation.Drivers {
|
||||
public class MenuWidgetPartDriver : ContentPartDriver<MenuWidgetPart> {
|
||||
@@ -41,10 +40,10 @@ namespace Orchard.Core.Navigation.Drivers {
|
||||
}
|
||||
|
||||
protected override DriverResult Display(MenuWidgetPart part, string displayType, dynamic shapeHelper) {
|
||||
return ContentShape( "Parts_MenuWidget", () => {
|
||||
return ContentShape("Parts_MenuWidget", () => {
|
||||
var menu = _menuService.GetMenu(part.MenuContentItemId);
|
||||
|
||||
if(menu == null) {
|
||||
if (menu == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -57,9 +56,9 @@ namespace Orchard.Core.Navigation.Drivers {
|
||||
}
|
||||
|
||||
var localized = new List<MenuItem>();
|
||||
foreach(var menuItem in menuItems) {
|
||||
foreach (var menuItem in menuItems) {
|
||||
// if there is no associated content, it as culture neutral
|
||||
if(menuItem.Content == null) {
|
||||
if (menuItem.Content == null) {
|
||||
localized.Add(menuItem);
|
||||
}
|
||||
|
||||
@@ -135,9 +134,9 @@ namespace Orchard.Core.Navigation.Drivers {
|
||||
}
|
||||
|
||||
// limit the number of levels to display (down from and including the start level)
|
||||
if(part.Levels > 0) {
|
||||
if (part.Levels > 0) {
|
||||
var current = topLevelItems.ToList();
|
||||
for (var i = 1; current.Any() && i < part.Levels; i++ ) {
|
||||
for (var i = 1; current.Any() && i < part.Levels; i++) {
|
||||
var temp = new List<MenuItem>();
|
||||
foreach (var menuItem in current) {
|
||||
temp.AddRange(menuItem.Items);
|
||||
@@ -164,25 +163,25 @@ namespace Orchard.Core.Navigation.Drivers {
|
||||
protected override DriverResult Editor(MenuWidgetPart part, dynamic shapeHelper) {
|
||||
return ContentShape("Parts_MenuWidget_Edit", () => {
|
||||
|
||||
var model = new MenuWidgetViewModel {
|
||||
CurrentMenuId = part.MenuContentItemId,
|
||||
StartLevel = part.StartLevel,
|
||||
StopLevel = part.Levels,
|
||||
Breadcrumb = part.Breadcrumb,
|
||||
AddCurrentPage = part.AddCurrentPage,
|
||||
AddHomePage = part.AddHomePage,
|
||||
ShowFullMenu = part.ShowFullMenu,
|
||||
Menus = _menuService.GetMenus(),
|
||||
};
|
||||
var model = new MenuWidgetViewModel {
|
||||
CurrentMenuId = part.MenuContentItemId,
|
||||
StartLevel = part.StartLevel,
|
||||
StopLevel = part.Levels,
|
||||
Breadcrumb = part.Breadcrumb,
|
||||
AddCurrentPage = part.AddCurrentPage,
|
||||
AddHomePage = part.AddHomePage,
|
||||
ShowFullMenu = part.ShowFullMenu,
|
||||
Menus = _menuService.GetMenus(),
|
||||
};
|
||||
|
||||
return shapeHelper.EditorTemplate(TemplateName: "Parts.MenuWidget.Edit", Model: model, Prefix: Prefix);
|
||||
});
|
||||
return shapeHelper.EditorTemplate(TemplateName: "Parts.MenuWidget.Edit", Model: model, Prefix: Prefix);
|
||||
});
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(MenuWidgetPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
var model = new MenuWidgetViewModel();
|
||||
|
||||
if(updater.TryUpdateModel(model, Prefix, null, null)) {
|
||||
if (updater.TryUpdateModel(model, Prefix, null, null)) {
|
||||
part.StartLevel = model.StartLevel;
|
||||
part.Levels = model.StopLevel;
|
||||
part.Breadcrumb = model.Breadcrumb;
|
||||
@@ -232,6 +231,5 @@ namespace Orchard.Core.Navigation.Drivers {
|
||||
clonePart.ShowFullMenu = originalPart.ShowFullMenu;
|
||||
clonePart.MenuContentItemId = originalPart.MenuContentItemId;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using Orchard.AntiSpam.Models;
|
||||
using Orchard.AntiSpam.Settings;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Localization;
|
||||
@@ -40,11 +39,8 @@ namespace Orchard.AntiSpam.Drivers {
|
||||
|
||||
var status = context.Attribute(part.PartDefinition.Name, "Status");
|
||||
|
||||
if (status != null) {
|
||||
SpamStatus value;
|
||||
if(Enum.TryParse(status, out value)) {
|
||||
part.Status = value;
|
||||
}
|
||||
if (status != null && Enum.TryParse(status, out SpamStatus value)) {
|
||||
part.Status = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Orchard.ArchiveLater.Drivers {
|
||||
var model = BuildViewModelFromPart(part);
|
||||
|
||||
return ContentShape("Parts_ArchiveLater_Edit",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix));
|
||||
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix));
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(ArchiveLaterPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
@@ -76,7 +76,7 @@ namespace Orchard.ArchiveLater.Drivers {
|
||||
if (model.ArchiveLater) {
|
||||
try {
|
||||
var utcDateTime = _dateLocalizationServices.ConvertFromLocalizedString(model.Editor.Date, model.Editor.Time);
|
||||
_archiveLaterService.ArchiveLater(model.ContentItem, utcDateTime.HasValue ? utcDateTime.Value : DateTime.MaxValue);
|
||||
_archiveLaterService.ArchiveLater(model.ContentItem, utcDateTime ?? DateTime.MaxValue);
|
||||
}
|
||||
catch (FormatException) {
|
||||
updater.AddModelError(Prefix, T("'{0} {1}' could not be parsed as a valid date and time.", model.Editor.Date, model.Editor.Time));
|
||||
@@ -88,7 +88,7 @@ namespace Orchard.ArchiveLater.Drivers {
|
||||
}
|
||||
|
||||
return ContentShape("Parts_ArchiveLater_Edit",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix));
|
||||
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix));
|
||||
}
|
||||
|
||||
protected override void Importing(ArchiveLaterPart part, ImportContentContext context) {
|
||||
|
||||
@@ -13,7 +13,6 @@ using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Localization.Services;
|
||||
using Orchard.Mvc;
|
||||
using Orchard.Security;
|
||||
using Orchard.UI.Notify;
|
||||
using Orchard.Utility.Extensions;
|
||||
|
||||
@@ -32,7 +31,6 @@ namespace Orchard.Autoroute.Drivers {
|
||||
INotifier notifier,
|
||||
IHomeAliasService homeAliasService,
|
||||
IAliasService aliasService,
|
||||
IAuthorizer authorizer,
|
||||
ICultureManager cultureManager,
|
||||
IContentManager contentManager,
|
||||
IHttpContextAccessor httpContextAccessor) {
|
||||
@@ -100,10 +98,12 @@ namespace Orchard.Autoroute.Drivers {
|
||||
if (!String.IsNullOrWhiteSpace(settings.DefaultPatternIndex)) {
|
||||
var patternIndex = settings.DefaultPatternIndex;
|
||||
settings.DefaultPatterns.Add(new DefaultPattern { PatternIndex = patternIndex, Culture = itemCulture });
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
settings.DefaultPatterns.Add(new DefaultPattern { PatternIndex = "0", Culture = itemCulture });
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
settings.DefaultPatterns.Add(new DefaultPattern { PatternIndex = "0", Culture = itemCulture });
|
||||
}
|
||||
}
|
||||
@@ -137,7 +137,7 @@ namespace Orchard.Autoroute.Drivers {
|
||||
part.DisplayAlias = viewModel.CurrentUrl;
|
||||
|
||||
// Reset the alias if we need to force regeneration, and the user didn't provide a custom one.
|
||||
if(settings.AutomaticAdjustmentOnEdit && previous == part.DisplayAlias) {
|
||||
if (settings.AutomaticAdjustmentOnEdit && previous == part.DisplayAlias) {
|
||||
part.DisplayAlias = String.Empty;
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace Orchard.Autoroute.Drivers {
|
||||
updater.AddModelError("CurrentUrl", T("Please do not use any of the following characters in your permalink: \":\", \"?\", \"#\", \"[\", \"]\", \"@\", \"!\", \"$\", \"&\", \"'\", \"(\", \")\", \"*\", \"+\", \",\", \";\", \"=\", \", \"<\", \">\", \"\\\", \"|\", \"%\", \".\". No spaces are allowed (please use dashes or underscores instead)."));
|
||||
}
|
||||
|
||||
if (part.DisplayAlias != null && part.DisplayAlias.Length > 1850){
|
||||
if (part.DisplayAlias != null && part.DisplayAlias.Length > 1850) {
|
||||
updater.AddModelError("CurrentUrl", T("Your permalink is too long. The permalink can only be up to 1,850 characters."));
|
||||
}
|
||||
|
||||
|
||||
@@ -22,15 +22,14 @@ namespace Orchard.Blogs.Drivers {
|
||||
}
|
||||
|
||||
protected override DriverResult Display(BlogArchivesPart part, string displayType, dynamic shapeHelper) {
|
||||
return ContentShape("Parts_Blogs_BlogArchives",
|
||||
() => {
|
||||
var blog = _blogService.Get(part.BlogId, VersionOptions.Published).As<BlogPart>();
|
||||
return ContentShape("Parts_Blogs_BlogArchives", () => {
|
||||
var blog = _blogService.Get(part.BlogId, VersionOptions.Published).As<BlogPart>();
|
||||
|
||||
if (blog == null)
|
||||
return null;
|
||||
if (blog == null)
|
||||
return null;
|
||||
|
||||
return shapeHelper.Parts_Blogs_BlogArchives(Blog: blog, Archives: _blogPostService.GetArchives(blog));
|
||||
});
|
||||
return shapeHelper.Parts_Blogs_BlogArchives(Blog: blog, Archives: _blogPostService.GetArchives(blog));
|
||||
});
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(BlogArchivesPart part, dynamic shapeHelper) {
|
||||
@@ -40,7 +39,7 @@ namespace Orchard.Blogs.Drivers {
|
||||
};
|
||||
|
||||
return ContentShape("Parts_Blogs_BlogArchives_Edit",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: "Parts.Blogs.BlogArchives", Model: viewModel, Prefix: Prefix));
|
||||
() => shapeHelper.EditorTemplate(TemplateName: "Parts.Blogs.BlogArchives", Model: viewModel, Prefix: Prefix));
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(BlogArchivesPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Orchard.Blogs.Drivers {
|
||||
return Editor(blogPart, shapeHelper);
|
||||
}
|
||||
|
||||
protected override void Importing(BlogPart part, ContentManagement.Handlers.ImportContentContext context) {
|
||||
protected override void Importing(BlogPart part, ImportContentContext context) {
|
||||
// Don't do anything if the tag is not specified.
|
||||
if (context.Data.Element(part.PartDefinition.Name) == null) {
|
||||
return;
|
||||
@@ -51,7 +51,7 @@ namespace Orchard.Blogs.Drivers {
|
||||
);
|
||||
}
|
||||
|
||||
protected override void Exporting(BlogPart part, ContentManagement.Handlers.ExportContentContext context) {
|
||||
protected override void Exporting(BlogPart part, ExportContentContext context) {
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("Description", part.Description);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("PostCount", part.PostCount);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("FeedProxyUrl", part.FeedProxyUrl);
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Orchard.Blogs.Drivers {
|
||||
|
||||
protected override DriverResult Display(RecentBlogPostsPart part, string displayType, dynamic shapeHelper) {
|
||||
return ContentShape("Parts_Blogs_RecentBlogPosts", () => {
|
||||
var blog = _contentManager.Get<BlogPart>(part.BlogId);
|
||||
var blog = _contentManager.Get<BlogPart>(part.BlogId);
|
||||
|
||||
if (blog == null) {
|
||||
return null;
|
||||
|
||||
@@ -2,14 +2,14 @@ using System;
|
||||
using System.Globalization;
|
||||
using System.Xml;
|
||||
using Orchard.Comments.Models;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.Services;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Comments.Services;
|
||||
using Orchard.UI.Notify;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Services;
|
||||
using Orchard.UI.Notify;
|
||||
|
||||
namespace Orchard.Comments.Drivers {
|
||||
public class CommentPartDriver : ContentPartDriver<CommentPart> {
|
||||
@@ -42,7 +42,7 @@ namespace Orchard.Comments.Drivers {
|
||||
return Combined(
|
||||
ContentShape("Parts_Comment", () => shapeHelper.Parts_Comment()),
|
||||
ContentShape("Parts_Comment_SummaryAdmin", () => shapeHelper.Parts_Comment_SummaryAdmin())
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
// GET
|
||||
@@ -103,7 +103,7 @@ namespace Orchard.Comments.Drivers {
|
||||
}
|
||||
|
||||
var currentUser = workContext.CurrentUser;
|
||||
part.UserName = (currentUser != null ? currentUser.UserName : null);
|
||||
part.UserName = currentUser?.UserName;
|
||||
|
||||
if (currentUser != null)
|
||||
part.Author = currentUser.UserName;
|
||||
|
||||
@@ -5,13 +5,13 @@ using System.Xml;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.ContentPermissions.Models;
|
||||
using Orchard.ContentPermissions.Settings;
|
||||
using Orchard.ContentPermissions.ViewModels;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Roles.Models;
|
||||
using Orchard.Roles.Services;
|
||||
using Orchard.Security;
|
||||
using Orchard.ContentPermissions.Models;
|
||||
using Orchard.ContentPermissions.Settings;
|
||||
using Orchard.ContentPermissions.ViewModels;
|
||||
|
||||
namespace Orchard.ContentPermissions.Drivers {
|
||||
public class ContentPermissionsPartDriver : ContentPartDriver<ContentPermissionsPart> {
|
||||
@@ -50,7 +50,7 @@ namespace Orchard.ContentPermissions.Drivers {
|
||||
|
||||
var allRoles = _roleService.GetRoles().Select(x => x.Name).OrderBy(x => x).ToList();
|
||||
|
||||
if(settings == null) {
|
||||
if (settings == null) {
|
||||
settings = new ContentPermissionsPartSettings {
|
||||
View = ContentPermissionsPartViewModel.SerializePermissions(allRoles.Select(x => new RoleEntry { Role = x, Checked = _authorizationService.TryCheckAccess(Core.Contents.Permissions.ViewContent, UserSimulation.Create(x), null) }).ToList()),
|
||||
ViewOwn = ContentPermissionsPartViewModel.SerializePermissions(allRoles.Select(x => new RoleEntry { Role = x, Checked = _authorizationService.TryCheckAccess(Core.Contents.Permissions.ViewOwnContent, UserSimulation.Create(x), null) }).ToList()),
|
||||
@@ -73,12 +73,12 @@ namespace Orchard.ContentPermissions.Drivers {
|
||||
model = new ContentPermissionsPartViewModel {
|
||||
ViewRoles = ContentPermissionsPartViewModel.ExtractRoleEntries(allRoles, settings.View),
|
||||
ViewOwnRoles = ContentPermissionsPartViewModel.ExtractRoleEntries(allRoles, settings.ViewOwn),
|
||||
PublishRoles= ContentPermissionsPartViewModel.ExtractRoleEntries(allRoles, settings.Publish),
|
||||
PublishOwnRoles= ContentPermissionsPartViewModel.ExtractRoleEntries(allRoles, settings.PublishOwn),
|
||||
EditRoles= ContentPermissionsPartViewModel.ExtractRoleEntries(allRoles, settings.Edit),
|
||||
EditOwnRoles= ContentPermissionsPartViewModel.ExtractRoleEntries(allRoles, settings.EditOwn),
|
||||
DeleteRoles= ContentPermissionsPartViewModel.ExtractRoleEntries(allRoles, settings.Delete),
|
||||
DeleteOwnRoles= ContentPermissionsPartViewModel.ExtractRoleEntries(allRoles, settings.DeleteOwn),
|
||||
PublishRoles = ContentPermissionsPartViewModel.ExtractRoleEntries(allRoles, settings.Publish),
|
||||
PublishOwnRoles = ContentPermissionsPartViewModel.ExtractRoleEntries(allRoles, settings.PublishOwn),
|
||||
EditRoles = ContentPermissionsPartViewModel.ExtractRoleEntries(allRoles, settings.Edit),
|
||||
EditOwnRoles = ContentPermissionsPartViewModel.ExtractRoleEntries(allRoles, settings.EditOwn),
|
||||
DeleteRoles = ContentPermissionsPartViewModel.ExtractRoleEntries(allRoles, settings.Delete),
|
||||
DeleteOwnRoles = ContentPermissionsPartViewModel.ExtractRoleEntries(allRoles, settings.DeleteOwn),
|
||||
PreviewRoles = ContentPermissionsPartViewModel.ExtractRoleEntries(allRoles, settings.Preview),
|
||||
PreviewOwnRoles = ContentPermissionsPartViewModel.ExtractRoleEntries(allRoles, settings.PreviewOwn),
|
||||
AllRoles = ContentPermissionsPartViewModel.ExtractRoleEntries(allRoles, settings.DisplayedRoles)
|
||||
@@ -202,43 +202,43 @@ namespace Orchard.ContentPermissions.Drivers {
|
||||
private void OverrideDefaultPermissions(ContentPermissionsPart part, List<string> allRoles, ContentPermissionsPartSettings settings) {
|
||||
// reset permissions the user can't change
|
||||
if (!_authorizer.Authorize(Core.Contents.Permissions.ViewContent, part.ContentItem)) {
|
||||
part.ViewContent = settings == null ? ContentPermissionsPartViewModel.SerializePermissions(allRoles.Select(x => new RoleEntry {Role = x, Checked = _authorizationService.TryCheckAccess(Core.Contents.Permissions.ViewContent, UserSimulation.Create(x), null)})) : settings.View;
|
||||
part.ViewContent = settings == null ? ContentPermissionsPartViewModel.SerializePermissions(allRoles.Select(x => new RoleEntry { Role = x, Checked = _authorizationService.TryCheckAccess(Core.Contents.Permissions.ViewContent, UserSimulation.Create(x), null) })) : settings.View;
|
||||
}
|
||||
|
||||
if (!_authorizer.Authorize(Core.Contents.Permissions.ViewOwnContent, part.ContentItem)) {
|
||||
part.ViewOwnContent = settings == null ? ContentPermissionsPartViewModel.SerializePermissions(allRoles.Select(x => new RoleEntry {Role = x, Checked = _authorizationService.TryCheckAccess(Core.Contents.Permissions.ViewOwnContent, UserSimulation.Create(x), null)})) : settings.ViewOwn;
|
||||
part.ViewOwnContent = settings == null ? ContentPermissionsPartViewModel.SerializePermissions(allRoles.Select(x => new RoleEntry { Role = x, Checked = _authorizationService.TryCheckAccess(Core.Contents.Permissions.ViewOwnContent, UserSimulation.Create(x), null) })) : settings.ViewOwn;
|
||||
}
|
||||
|
||||
if (!_authorizer.Authorize(Core.Contents.Permissions.PublishContent, part.ContentItem)) {
|
||||
part.PublishContent = settings == null ? ContentPermissionsPartViewModel.SerializePermissions(allRoles.Select(x => new RoleEntry {Role = x, Checked = _authorizationService.TryCheckAccess(Core.Contents.Permissions.PublishContent, UserSimulation.Create(x), null)})) : settings.Publish;
|
||||
part.PublishContent = settings == null ? ContentPermissionsPartViewModel.SerializePermissions(allRoles.Select(x => new RoleEntry { Role = x, Checked = _authorizationService.TryCheckAccess(Core.Contents.Permissions.PublishContent, UserSimulation.Create(x), null) })) : settings.Publish;
|
||||
}
|
||||
|
||||
if (!_authorizer.Authorize(Core.Contents.Permissions.PublishOwnContent, part.ContentItem)) {
|
||||
part.PublishOwnContent = settings == null ? ContentPermissionsPartViewModel.SerializePermissions(allRoles.Select(x => new RoleEntry {Role = x, Checked = _authorizationService.TryCheckAccess(Core.Contents.Permissions.PublishOwnContent, UserSimulation.Create(x), null)})) : settings.PublishOwn;
|
||||
part.PublishOwnContent = settings == null ? ContentPermissionsPartViewModel.SerializePermissions(allRoles.Select(x => new RoleEntry { Role = x, Checked = _authorizationService.TryCheckAccess(Core.Contents.Permissions.PublishOwnContent, UserSimulation.Create(x), null) })) : settings.PublishOwn;
|
||||
}
|
||||
|
||||
if (!_authorizer.Authorize(Core.Contents.Permissions.EditContent, part.ContentItem)) {
|
||||
part.EditContent = settings == null ? ContentPermissionsPartViewModel.SerializePermissions(allRoles.Select(x => new RoleEntry {Role = x, Checked = _authorizationService.TryCheckAccess(Core.Contents.Permissions.EditContent, UserSimulation.Create(x), null)})) : settings.Edit;
|
||||
part.EditContent = settings == null ? ContentPermissionsPartViewModel.SerializePermissions(allRoles.Select(x => new RoleEntry { Role = x, Checked = _authorizationService.TryCheckAccess(Core.Contents.Permissions.EditContent, UserSimulation.Create(x), null) })) : settings.Edit;
|
||||
}
|
||||
|
||||
if (!_authorizer.Authorize(Core.Contents.Permissions.EditOwnContent, part.ContentItem)) {
|
||||
part.EditOwnContent = settings == null ? ContentPermissionsPartViewModel.SerializePermissions(allRoles.Select(x => new RoleEntry {Role = x, Checked = _authorizationService.TryCheckAccess(Core.Contents.Permissions.EditOwnContent, UserSimulation.Create(x), null)})) : settings.EditOwn;
|
||||
part.EditOwnContent = settings == null ? ContentPermissionsPartViewModel.SerializePermissions(allRoles.Select(x => new RoleEntry { Role = x, Checked = _authorizationService.TryCheckAccess(Core.Contents.Permissions.EditOwnContent, UserSimulation.Create(x), null) })) : settings.EditOwn;
|
||||
}
|
||||
|
||||
if (!_authorizer.Authorize(Core.Contents.Permissions.DeleteContent, part.ContentItem)) {
|
||||
part.DeleteContent = settings == null ? ContentPermissionsPartViewModel.SerializePermissions(allRoles.Select(x => new RoleEntry {Role = x, Checked = _authorizationService.TryCheckAccess(Core.Contents.Permissions.DeleteContent, UserSimulation.Create(x), null)})) : settings.Delete;
|
||||
part.DeleteContent = settings == null ? ContentPermissionsPartViewModel.SerializePermissions(allRoles.Select(x => new RoleEntry { Role = x, Checked = _authorizationService.TryCheckAccess(Core.Contents.Permissions.DeleteContent, UserSimulation.Create(x), null) })) : settings.Delete;
|
||||
}
|
||||
|
||||
if (!_authorizer.Authorize(Core.Contents.Permissions.DeleteOwnContent, part.ContentItem)) {
|
||||
part.DeleteOwnContent = settings == null ? ContentPermissionsPartViewModel.SerializePermissions(allRoles.Select(x => new RoleEntry {Role = x, Checked = _authorizationService.TryCheckAccess(Core.Contents.Permissions.DeleteOwnContent, UserSimulation.Create(x), null)})) : settings.DeleteOwn;
|
||||
part.DeleteOwnContent = settings == null ? ContentPermissionsPartViewModel.SerializePermissions(allRoles.Select(x => new RoleEntry { Role = x, Checked = _authorizationService.TryCheckAccess(Core.Contents.Permissions.DeleteOwnContent, UserSimulation.Create(x), null) })) : settings.DeleteOwn;
|
||||
}
|
||||
|
||||
if (!_authorizer.Authorize(Core.Contents.Permissions.PreviewContent, part.ContentItem)) {
|
||||
part.PreviewContent = settings == null ? ContentPermissionsPartViewModel.SerializePermissions(allRoles.Select(x => new RoleEntry {Role = x, Checked = _authorizationService.TryCheckAccess(Core.Contents.Permissions.PreviewContent, UserSimulation.Create(x), null)})) : settings.Preview;
|
||||
part.PreviewContent = settings == null ? ContentPermissionsPartViewModel.SerializePermissions(allRoles.Select(x => new RoleEntry { Role = x, Checked = _authorizationService.TryCheckAccess(Core.Contents.Permissions.PreviewContent, UserSimulation.Create(x), null) })) : settings.Preview;
|
||||
}
|
||||
|
||||
if (!_authorizer.Authorize(Core.Contents.Permissions.PreviewOwnContent, part.ContentItem)) {
|
||||
part.PreviewOwnContent = settings == null ? ContentPermissionsPartViewModel.SerializePermissions(allRoles.Select(x => new RoleEntry {Role = x, Checked = _authorizationService.TryCheckAccess(Core.Contents.Permissions.PreviewOwnContent, UserSimulation.Create(x), null)})) : settings.PreviewOwn;
|
||||
part.PreviewOwnContent = settings == null ? ContentPermissionsPartViewModel.SerializePermissions(allRoles.Select(x => new RoleEntry { Role = x, Checked = _authorizationService.TryCheckAccess(Core.Contents.Permissions.PreviewOwnContent, UserSimulation.Create(x), null) })) : settings.PreviewOwn;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,6 @@ using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.ContentPicker.Models;
|
||||
using Orchard.ContentPicker.ViewModels;
|
||||
using Orchard.Core.Navigation;
|
||||
using Orchard.Core.Navigation.Models;
|
||||
using Orchard.Core.Navigation.ViewModels;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Security;
|
||||
|
||||
@@ -29,14 +27,13 @@ namespace Orchard.ContentPicker.Drivers {
|
||||
public Localizer T { get; set; }
|
||||
|
||||
protected override DriverResult Editor(ContentMenuItemPart part, dynamic shapeHelper) {
|
||||
return ContentShape("Parts_ContentMenuItem_Edit",
|
||||
() => {
|
||||
var model = new ContentMenuItemEditViewModel {
|
||||
ContentItemId = part.Content == null ? -1 : part.Content.Id,
|
||||
Part = part
|
||||
};
|
||||
return shapeHelper.EditorTemplate(TemplateName: "Parts.ContentMenuItem.Edit", Model: model, Prefix: Prefix);
|
||||
});
|
||||
return ContentShape("Parts_ContentMenuItem_Edit", () => {
|
||||
var model = new ContentMenuItemEditViewModel {
|
||||
ContentItemId = part.Content == null ? -1 : part.Content.Id,
|
||||
Part = part
|
||||
};
|
||||
return shapeHelper.EditorTemplate(TemplateName: "Parts.ContentMenuItem.Edit", Model: model, Prefix: Prefix);
|
||||
});
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(ContentMenuItemPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
@@ -48,9 +45,9 @@ namespace Orchard.ContentPicker.Drivers {
|
||||
|
||||
var model = new ContentMenuItemEditViewModel();
|
||||
|
||||
if(updater.TryUpdateModel(model, Prefix, null, null)) {
|
||||
if (updater.TryUpdateModel(model, Prefix, null, null)) {
|
||||
var contentItem = _contentManager.Get(model.ContentItemId, VersionOptions.Latest);
|
||||
if(contentItem == null) {
|
||||
if (contentItem == null) {
|
||||
updater.AddModelError("ContentItemId", T("You must select a Content Item"));
|
||||
}
|
||||
else {
|
||||
@@ -67,12 +64,14 @@ namespace Orchard.ContentPicker.Drivers {
|
||||
return;
|
||||
}
|
||||
|
||||
context.ImportAttribute(part.PartDefinition.Name, "ContentItem",
|
||||
context.ImportAttribute(
|
||||
part.PartDefinition.Name,
|
||||
"ContentItem",
|
||||
contentItemId => {
|
||||
var contentItem = context.GetItemFromSession(contentItemId);
|
||||
part.Content = contentItem;
|
||||
}, () =>
|
||||
part.Content = null
|
||||
},
|
||||
() => part.Content = null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Orchard.MediaLibrary.Drivers {
|
||||
ContentShape("Parts_Audio_SummaryAdmin", () => shapeHelper.Parts_Audio_SummaryAdmin()),
|
||||
ContentShape("Parts_Audio_Summary", () => shapeHelper.Parts_Audio_Summary()),
|
||||
ContentShape("Parts_Audio", () => shapeHelper.Parts_Audio())
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
protected override void Exporting(AudioPart part, ContentManagement.Handlers.ExportContentContext context) {
|
||||
|
||||
@@ -32,10 +32,11 @@ namespace Orchard.MediaLibrary.Drivers {
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(MediaPart part, dynamic shapeHelper) {
|
||||
return ContentShape("Parts_Media_Edit", () => shapeHelper.EditorTemplate(TemplateName: "Parts.Media.Edit", Model: part, Prefix: Prefix));
|
||||
return ContentShape("Parts_Media_Edit",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: "Parts.Media.Edit", Model: part, Prefix: Prefix));
|
||||
}
|
||||
|
||||
protected override void Importing(MediaPart part, ContentManagement.Handlers.ImportContentContext context) {
|
||||
protected override void Importing(MediaPart part, ImportContentContext context) {
|
||||
// Don't do anything if the tag is not specified.
|
||||
if (context.Data.Element(part.PartDefinition.Name) == null) {
|
||||
return;
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
using Orchard.ContentManagement;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.ContentManagement.FieldStorage.InfosetStorage;
|
||||
using Orchard.MediaLibrary.Models;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using System.Collections;
|
||||
using Orchard.MediaLibrary.Models;
|
||||
|
||||
namespace Orchard.MediaLibrary.Drivers {
|
||||
public class OEmbedPartDriver : ContentPartDriver<OEmbedPart> {
|
||||
|
||||
@@ -28,7 +28,6 @@ namespace Orchard.Projections.Drivers {
|
||||
|
||||
protected override DriverResult Editor(NavigationQueryPart part, dynamic shapeHelper) {
|
||||
return ContentShape("Parts_NavigationQueryPart_Edit", () => {
|
||||
|
||||
var model = new NavigationQueryPartEditViewModel {
|
||||
Items = part.Items,
|
||||
Skip = part.Skip,
|
||||
|
||||
@@ -10,7 +10,6 @@ using Orchard.Projections.Services;
|
||||
using Orchard.Projections.ViewModels;
|
||||
|
||||
namespace Orchard.Projections.Drivers {
|
||||
|
||||
public class QueryPartDriver : ContentPartDriver<QueryPart> {
|
||||
private readonly IProjectionManager _projectionManager;
|
||||
private readonly IFormManager _formManager;
|
||||
|
||||
@@ -56,12 +56,12 @@ namespace Orchard.PublishLater.Drivers {
|
||||
protected override DriverResult Display(PublishLaterPart part, string displayType, dynamic shapeHelper) {
|
||||
return Combined(
|
||||
ContentShape("Parts_PublishLater_Metadata",
|
||||
() => shapeHelper.Parts_PublishLater_Metadata(ScheduledPublishUtc: part.ScheduledPublishUtc.Value)),
|
||||
() => shapeHelper.Parts_PublishLater_Metadata(ScheduledPublishUtc: part.ScheduledPublishUtc.Value)),
|
||||
ContentShape("Parts_PublishLater_Metadata_Summary",
|
||||
() => shapeHelper.Parts_PublishLater_Metadata_Summary(ScheduledPublishUtc: part.ScheduledPublishUtc.Value)),
|
||||
() => shapeHelper.Parts_PublishLater_Metadata_Summary(ScheduledPublishUtc: part.ScheduledPublishUtc.Value)),
|
||||
ContentShape("Parts_PublishLater_Metadata_SummaryAdmin",
|
||||
() => shapeHelper.Parts_PublishLater_Metadata_SummaryAdmin(ScheduledPublishUtc: part.ScheduledPublishUtc.Value))
|
||||
);
|
||||
() => shapeHelper.Parts_PublishLater_Metadata_SummaryAdmin(ScheduledPublishUtc: part.ScheduledPublishUtc.Value))
|
||||
);
|
||||
}
|
||||
|
||||
private PublishLaterViewModel BuildViewModelFromPart(PublishLaterPart part) {
|
||||
@@ -79,7 +79,7 @@ namespace Orchard.PublishLater.Drivers {
|
||||
var model = BuildViewModelFromPart(part);
|
||||
|
||||
return ContentShape("Parts_PublishLater_Edit",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix));
|
||||
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix));
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(PublishLaterPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
|
||||
@@ -52,40 +52,36 @@ namespace Orchard.Roles.Drivers {
|
||||
|
||||
private readonly Lazy<IEnumerable<RoleRecord>> _allRoles;
|
||||
|
||||
protected override DriverResult Editor(UserRolesPart userRolesPart, dynamic shapeHelper) {
|
||||
|
||||
return ContentShape("Parts_Roles_UserRoles_Edit",
|
||||
() => {
|
||||
var currentUser = _authenticationService.GetAuthenticatedUser();
|
||||
// Get the roles we are authorized to assign
|
||||
var authorizedRoleIds = _allRoles.Value
|
||||
.Where(rr => _authorizationService.TryCheckAccess(
|
||||
Permissions.CreatePermissionForAssignRole(rr.Name),
|
||||
currentUser,
|
||||
userRolesPart))
|
||||
.Select(rr => rr.Id).ToList();
|
||||
// If the user has no roles they can assign, we will show nothing
|
||||
if (!authorizedRoleIds.Any()) {
|
||||
return null;
|
||||
}
|
||||
var allRoles = _allRoles.Value
|
||||
.Select(x => new UserRoleEntry {
|
||||
RoleId = x.Id,
|
||||
Name = x.Name,
|
||||
Granted = userRolesPart.Roles.Contains(x.Name)
|
||||
});
|
||||
var model = new UserRolesViewModel {
|
||||
User = userRolesPart.As<IUser>(),
|
||||
UserRoles = userRolesPart,
|
||||
Roles = allRoles.ToList(),
|
||||
AuthorizedRoleIds = authorizedRoleIds
|
||||
};
|
||||
return shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix);
|
||||
});
|
||||
}
|
||||
protected override DriverResult Editor(UserRolesPart userRolesPart, dynamic shapeHelper) =>
|
||||
ContentShape("Parts_Roles_UserRoles_Edit", () => {
|
||||
var currentUser = _authenticationService.GetAuthenticatedUser();
|
||||
// Get the roles we are authorized to assign
|
||||
var authorizedRoleIds = _allRoles.Value
|
||||
.Where(rr => _authorizationService.TryCheckAccess(
|
||||
Permissions.CreatePermissionForAssignRole(rr.Name),
|
||||
currentUser,
|
||||
userRolesPart))
|
||||
.Select(rr => rr.Id).ToList();
|
||||
// If the user has no roles they can assign, we will show nothing
|
||||
if (!authorizedRoleIds.Any()) {
|
||||
return null;
|
||||
}
|
||||
var allRoles = _allRoles.Value
|
||||
.Select(x => new UserRoleEntry {
|
||||
RoleId = x.Id,
|
||||
Name = x.Name,
|
||||
Granted = userRolesPart.Roles.Contains(x.Name)
|
||||
});
|
||||
var model = new UserRolesViewModel {
|
||||
User = userRolesPart.As<IUser>(),
|
||||
UserRoles = userRolesPart,
|
||||
Roles = allRoles.ToList(),
|
||||
AuthorizedRoleIds = authorizedRoleIds
|
||||
};
|
||||
return shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix);
|
||||
});
|
||||
|
||||
protected override DriverResult Editor(UserRolesPart userRolesPart, IUpdateModel updater, dynamic shapeHelper) {
|
||||
|
||||
var currentUser = _authenticationService.GetAuthenticatedUser();
|
||||
// Get the roles we are authorized to assign
|
||||
var authorizedRoleIds = _allRoles.Value
|
||||
@@ -136,9 +132,8 @@ namespace Orchard.Roles.Drivers {
|
||||
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix));
|
||||
}
|
||||
|
||||
private static UserRolesViewModel BuildEditorViewModel(UserRolesPart userRolesPart) {
|
||||
return new UserRolesViewModel { User = userRolesPart.As<IUser>(), UserRoles = userRolesPart };
|
||||
}
|
||||
private static UserRolesViewModel BuildEditorViewModel(UserRolesPart userRolesPart) =>
|
||||
new UserRolesViewModel { User = userRolesPart.As<IUser>(), UserRoles = userRolesPart };
|
||||
|
||||
protected override void Importing(UserRolesPart part, ImportContentContext context) {
|
||||
// Don't do anything if the tag is not specified.
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Orchard.Search.Drivers {
|
||||
};
|
||||
|
||||
if (updater != null) {
|
||||
if (updater.TryUpdateModel(viewModel, Prefix, null, new[] {"AvailableIndexes"})) {
|
||||
if (updater.TryUpdateModel(viewModel, Prefix, null, new[] { "AvailableIndexes" })) {
|
||||
part.OverrideIndex = viewModel.OverrideIndex;
|
||||
part.SelectedIndex = viewModel.SelectedIndex;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ using Orchard.Search.Models;
|
||||
using Orchard.Search.ViewModels;
|
||||
|
||||
namespace Orchard.Search.Drivers {
|
||||
|
||||
public class SearchSettingsPartDriver : ContentPartDriver<SearchSettingsPart> {
|
||||
private readonly IIndexManager _indexManager;
|
||||
|
||||
|
||||
@@ -8,29 +8,20 @@ using Orchard.Tags.Models;
|
||||
namespace Orchard.Tags.Drivers {
|
||||
[OrchardFeature("Orchard.Tags.TagCloud")]
|
||||
public class TagCloudDriver : ContentPartDriver<TagCloudPart> {
|
||||
|
||||
protected override string Prefix {
|
||||
get {
|
||||
return "tagcloud";
|
||||
}
|
||||
}
|
||||
protected override string Prefix => "tagcloud";
|
||||
|
||||
protected override DriverResult Display(TagCloudPart part, string displayType, dynamic shapeHelper) {
|
||||
return ContentShape("Parts_TagCloud",
|
||||
() => shapeHelper.Parts_TagCloud(
|
||||
TagCounts: part.TagCounts,
|
||||
ContentPart: part,
|
||||
ContentItem: part.ContentItem));
|
||||
return ContentShape("Parts_TagCloud", () => shapeHelper.Parts_TagCloud(
|
||||
TagCounts: part.TagCounts,
|
||||
ContentPart: part,
|
||||
ContentItem: part.ContentItem));
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(TagCloudPart part, dynamic shapeHelper) {
|
||||
|
||||
return ContentShape("Parts_TagCloud_Edit",
|
||||
() => shapeHelper.EditorTemplate(
|
||||
TemplateName: "Parts/TagCloud",
|
||||
Model: part,
|
||||
Prefix: Prefix));
|
||||
}
|
||||
protected override DriverResult Editor(TagCloudPart part, dynamic shapeHelper) =>
|
||||
ContentShape("Parts_TagCloud_Edit", () => shapeHelper.EditorTemplate(
|
||||
TemplateName: "Parts/TagCloud",
|
||||
Model: part,
|
||||
Prefix: Prefix));
|
||||
|
||||
protected override DriverResult Editor(TagCloudPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
updater.TryUpdateModel(part, Prefix, null, null);
|
||||
|
||||
@@ -23,9 +23,8 @@ namespace Orchard.Taxonomies.Drivers {
|
||||
|
||||
protected override string Prefix { get { return "TaxonomyNavigationPart"; } }
|
||||
|
||||
protected override DriverResult Editor(TaxonomyNavigationPart part, dynamic shapeHelper) {
|
||||
return Editor(part, null, shapeHelper);
|
||||
}
|
||||
protected override DriverResult Editor(TaxonomyNavigationPart part, dynamic shapeHelper) =>
|
||||
Editor(part, null, shapeHelper);
|
||||
|
||||
protected override DriverResult Editor(TaxonomyNavigationPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
return ContentShape(
|
||||
@@ -112,21 +111,15 @@ namespace Orchard.Taxonomies.Drivers {
|
||||
part.LevelsToDisplay = Int32.Parse(context.Attribute(part.PartDefinition.Name, "LevelsToDisplay"));
|
||||
|
||||
var taxonomyId = context.Attribute(part.PartDefinition.Name, "TaxonomyId");
|
||||
var taxonomy = context.GetItemFromSession(taxonomyId);
|
||||
|
||||
if (taxonomy == null) {
|
||||
throw new OrchardException(T("Unknown taxonomy: {0}", taxonomyId));
|
||||
}
|
||||
var taxonomy = context.GetItemFromSession(taxonomyId)
|
||||
?? throw new OrchardException(T("Unknown taxonomy: {0}", taxonomyId));
|
||||
|
||||
part.TaxonomyId = taxonomy.Id;
|
||||
|
||||
var termId = context.Attribute(part.PartDefinition.Name, "TermId");
|
||||
if (!String.IsNullOrEmpty(termId)) {
|
||||
var term = context.GetItemFromSession(termId);
|
||||
|
||||
if (term == null) {
|
||||
throw new OrchardException(T("Unknown term: {0}", termId));
|
||||
}
|
||||
if (!String.IsNullOrEmpty(termId)) {
|
||||
var term = context.GetItemFromSession(termId)
|
||||
?? throw new OrchardException(T("Unknown term: {0}", termId));
|
||||
|
||||
part.TermId = term.Id;
|
||||
}
|
||||
|
||||
@@ -5,13 +5,13 @@ using System.Xml.Linq;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Core.Title.Models;
|
||||
using Orchard.Data;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Templates.Models;
|
||||
using Orchard.Templates.Services;
|
||||
using Orchard.Templates.ViewModels;
|
||||
using Orchard.Utility.Extensions;
|
||||
using Orchard.Core.Title.Models;
|
||||
|
||||
namespace Orchard.Templates.Drivers {
|
||||
public class ShapePartDriver : ContentPartDriver<ShapePart> {
|
||||
@@ -31,13 +31,11 @@ namespace Orchard.Templates.Drivers {
|
||||
|
||||
Localizer T { get; set; }
|
||||
|
||||
protected override DriverResult Display(ShapePart part, string displayType, dynamic shapeHelper) {
|
||||
return ContentShape("Parts_Shape_SummaryAdmin", () => shapeHelper.Parts_Shape_SummaryAdmin());
|
||||
}
|
||||
protected override DriverResult Display(ShapePart part, string displayType, dynamic shapeHelper) =>
|
||||
ContentShape("Parts_Shape_SummaryAdmin", () => shapeHelper.Parts_Shape_SummaryAdmin());
|
||||
|
||||
protected override DriverResult Editor(ShapePart part, dynamic shapeHelper) {
|
||||
return Editor(part, null, shapeHelper);
|
||||
}
|
||||
protected override DriverResult Editor(ShapePart part, dynamic shapeHelper) =>
|
||||
Editor(part, null, shapeHelper);
|
||||
|
||||
protected override DriverResult Editor(ShapePart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
var viewModel = new ShapePartViewModel {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Orchard.Conditions.Services;
|
||||
using Orchard.ContentManagement;
|
||||
@@ -10,7 +9,6 @@ using Orchard.Widgets.Models;
|
||||
using Orchard.Widgets.Services;
|
||||
|
||||
namespace Orchard.Widgets.Drivers {
|
||||
|
||||
public class LayerPartDriver : ContentPartDriver<LayerPart> {
|
||||
private readonly IConditionManager _conditionManager;
|
||||
private readonly IWidgetsService _widgetsService;
|
||||
@@ -18,7 +16,6 @@ namespace Orchard.Widgets.Drivers {
|
||||
public LayerPartDriver(
|
||||
IConditionManager conditionManager,
|
||||
IWidgetsService widgetsService) {
|
||||
|
||||
_conditionManager = conditionManager;
|
||||
_widgetsService = widgetsService;
|
||||
|
||||
@@ -27,14 +24,9 @@ namespace Orchard.Widgets.Drivers {
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
protected override DriverResult Editor(LayerPart layerPart, dynamic shapeHelper) {
|
||||
var results = new List<DriverResult> {
|
||||
ContentShape("Parts_Widgets_LayerPart",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: "Parts.Widgets.LayerPart", Model: layerPart, Prefix: Prefix))
|
||||
};
|
||||
|
||||
return Combined(results.ToArray());
|
||||
}
|
||||
protected override DriverResult Editor(LayerPart layerPart, dynamic shapeHelper) =>
|
||||
ContentShape("Parts_Widgets_LayerPart",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: "Parts.Widgets.LayerPart", Model: layerPart, Prefix: Prefix));
|
||||
|
||||
protected override DriverResult Editor(LayerPart layerPart, IUpdateModel updater, dynamic shapeHelper) {
|
||||
if (updater.TryUpdateModel(layerPart, Prefix, null, null)) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
@@ -9,7 +8,6 @@ using Orchard.Widgets.Models;
|
||||
using Orchard.Widgets.Services;
|
||||
|
||||
namespace Orchard.Widgets.Drivers {
|
||||
|
||||
public class WidgetPartDriver : ContentPartDriver<WidgetPart> {
|
||||
private readonly IWidgetsService _widgetsService;
|
||||
private readonly IContentManager _contentManager;
|
||||
@@ -17,7 +15,6 @@ namespace Orchard.Widgets.Drivers {
|
||||
public WidgetPartDriver(IWidgetsService widgetsService, IContentManager contentManager) {
|
||||
_widgetsService = widgetsService;
|
||||
_contentManager = contentManager;
|
||||
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
@@ -31,12 +28,8 @@ namespace Orchard.Widgets.Drivers {
|
||||
widgetPart.AvailableZones = _widgetsService.GetZones();
|
||||
widgetPart.AvailableLayers = _widgetsService.GetLayers();
|
||||
|
||||
var results = new List<DriverResult> {
|
||||
ContentShape("Parts_Widgets_WidgetPart",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: "Parts.Widgets.WidgetPart", Model: widgetPart, Prefix: Prefix))
|
||||
};
|
||||
|
||||
return Combined(results.ToArray());
|
||||
return ContentShape("Parts_Widgets_WidgetPart",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: "Parts.Widgets.WidgetPart", Model: widgetPart, Prefix: Prefix));
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(WidgetPart widgetPart, IUpdateModel updater, dynamic shapeHelper) {
|
||||
|
||||
@@ -45,24 +45,21 @@ namespace Orchard.ContentManagement.Drivers.Coordinators {
|
||||
public override void BuildDisplay(BuildDisplayContext context) {
|
||||
_drivers.Invoke(driver => {
|
||||
var result = driver.BuildDisplay(context);
|
||||
if (result != null)
|
||||
result.Apply(context);
|
||||
result?.Apply(context);
|
||||
}, Logger);
|
||||
}
|
||||
|
||||
public override void BuildEditor(BuildEditorContext context) {
|
||||
_drivers.Invoke(driver => {
|
||||
var result = driver.BuildEditor(context);
|
||||
if (result != null)
|
||||
result.Apply(context);
|
||||
result?.Apply(context);
|
||||
}, Logger);
|
||||
}
|
||||
|
||||
public override void UpdateEditor(UpdateEditorContext context) {
|
||||
_drivers.Invoke(driver => {
|
||||
var result = driver.UpdateEditor(context);
|
||||
if (result != null)
|
||||
result.Apply(context);
|
||||
result?.Apply(context);
|
||||
}, Logger);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user