mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-12-03 20:13:52 +08:00
Merge
--HG-- branch : dev
This commit is contained in:
@@ -0,0 +1,9 @@
|
|||||||
|
using Orchard.ContentManagement.MetaData.Builders;
|
||||||
|
|
||||||
|
namespace Orchard.Core.Contents.Extensions {
|
||||||
|
public static class MetaDataExtensions {
|
||||||
|
public static ContentTypeDefinitionBuilder Creatable(this ContentTypeDefinitionBuilder builder, bool creatable = true) {
|
||||||
|
return builder.WithSetting("ContentTypeSettings.Creatable", creatable.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -81,6 +81,7 @@
|
|||||||
<Compile Include="Common\ViewModels\TextContentFieldEditorViewModel.cs" />
|
<Compile Include="Common\ViewModels\TextContentFieldEditorViewModel.cs" />
|
||||||
<Compile Include="Contents\Controllers\ItemController.cs" />
|
<Compile Include="Contents\Controllers\ItemController.cs" />
|
||||||
<Compile Include="Contents\Drivers\ContentsDriver.cs" />
|
<Compile Include="Contents\Drivers\ContentsDriver.cs" />
|
||||||
|
<Compile Include="Contents\Extensions\MetaDataExtensions.cs" />
|
||||||
<Compile Include="Contents\Handlers\ContentsHandler.cs" />
|
<Compile Include="Contents\Handlers\ContentsHandler.cs" />
|
||||||
<Compile Include="Contents\Permissions.cs" />
|
<Compile Include="Contents\Permissions.cs" />
|
||||||
<Compile Include="Contents\Routes.cs" />
|
<Compile Include="Contents\Routes.cs" />
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ using Orchard.ContentManagement;
|
|||||||
using Orchard.ContentManagement.MetaData;
|
using Orchard.ContentManagement.MetaData;
|
||||||
using Orchard.Core.Common.Models;
|
using Orchard.Core.Common.Models;
|
||||||
using Orchard.Core.Common.Settings;
|
using Orchard.Core.Common.Settings;
|
||||||
using Orchard.Core.Contents.Settings;
|
using Orchard.Core.Contents.Extensions;
|
||||||
using Orchard.Core.Navigation.Models;
|
using Orchard.Core.Navigation.Models;
|
||||||
using Orchard.Core.Routable.Models;
|
using Orchard.Core.Routable.Models;
|
||||||
using Orchard.Core.Settings.Descriptor.Records;
|
using Orchard.Core.Settings.Descriptor.Records;
|
||||||
@@ -194,7 +194,7 @@ namespace Orchard.Setup.Services {
|
|||||||
contentDefinitionManager.AlterTypeDefinition("BlogPost", cfg => cfg
|
contentDefinitionManager.AlterTypeDefinition("BlogPost", cfg => cfg
|
||||||
.DisplayedAs("Blog Post")
|
.DisplayedAs("Blog Post")
|
||||||
.WithPart("CommentsPart")
|
.WithPart("CommentsPart")
|
||||||
.WithPart("HasTags")
|
.WithPart("TagsPart")
|
||||||
.WithPart("Localized")
|
.WithPart("Localized")
|
||||||
.Creatable()
|
.Creatable()
|
||||||
.Indexed());
|
.Indexed());
|
||||||
@@ -205,7 +205,7 @@ namespace Orchard.Setup.Services {
|
|||||||
.WithPart("IsRoutable")
|
.WithPart("IsRoutable")
|
||||||
.WithPart("BodyPart")
|
.WithPart("BodyPart")
|
||||||
.WithPart("CommentsPart")
|
.WithPart("CommentsPart")
|
||||||
.WithPart("HasTags")
|
.WithPart("TagsPart")
|
||||||
.WithPart("Localized")
|
.WithPart("Localized")
|
||||||
.Creatable()
|
.Creatable()
|
||||||
.Indexed());
|
.Indexed());
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace Orchard.Tags.DataMigrations {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
public int UpdateFrom1() {
|
public int UpdateFrom1() {
|
||||||
ContentDefinitionManager.AlterPartDefinition(typeof(HasTags).Name, cfg => cfg
|
ContentDefinitionManager.AlterPartDefinition(typeof(TagsPart).Name, cfg => cfg
|
||||||
.WithLocation(new Dictionary<string, ContentLocation> {
|
.WithLocation(new Dictionary<string, ContentLocation> {
|
||||||
{"Default", new ContentLocation { Zone = "primary", Position = "49" }},
|
{"Default", new ContentLocation { Zone = "primary", Position = "49" }},
|
||||||
{"Editor", new ContentLocation { Zone = "primary", Position = "9" }},
|
{"Editor", new ContentLocation { Zone = "primary", Position = "9" }},
|
||||||
|
|||||||
@@ -11,11 +11,11 @@ using Orchard.Tags.ViewModels;
|
|||||||
|
|
||||||
namespace Orchard.Tags.Drivers {
|
namespace Orchard.Tags.Drivers {
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public class HasTagsDriver : ContentPartDriver<HasTags> {
|
public class TagsPartDriver : ContentPartDriver<TagsPart> {
|
||||||
private readonly ITagService _tagService;
|
private readonly ITagService _tagService;
|
||||||
private readonly IAuthorizationService _authorizationService;
|
private readonly IAuthorizationService _authorizationService;
|
||||||
|
|
||||||
public HasTagsDriver(ITagService tagService,
|
public TagsPartDriver(ITagService tagService,
|
||||||
IAuthorizationService authorizationService) {
|
IAuthorizationService authorizationService) {
|
||||||
_tagService = tagService;
|
_tagService = tagService;
|
||||||
_authorizationService = authorizationService;
|
_authorizationService = authorizationService;
|
||||||
@@ -23,11 +23,11 @@ namespace Orchard.Tags.Drivers {
|
|||||||
|
|
||||||
public virtual IUser CurrentUser { get; set; }
|
public virtual IUser CurrentUser { get; set; }
|
||||||
|
|
||||||
protected override DriverResult Display(HasTags part, string displayType) {
|
protected override DriverResult Display(TagsPart part, string displayType) {
|
||||||
return ContentPartTemplate(part, "Parts/Tags.ShowTags").Location(part.GetLocation(displayType));
|
return ContentPartTemplate(part, "Parts/Tags.ShowTags").Location(part.GetLocation(displayType));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override DriverResult Editor(HasTags part) {
|
protected override DriverResult Editor(TagsPart part) {
|
||||||
if (!_authorizationService.TryCheckAccess(Permissions.ApplyTag, CurrentUser, part))
|
if (!_authorizationService.TryCheckAccess(Permissions.ApplyTag, CurrentUser, part))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ namespace Orchard.Tags.Drivers {
|
|||||||
return ContentPartTemplate(model, "Parts/Tags.EditTags").Location(part.GetLocation("Editor"));
|
return ContentPartTemplate(model, "Parts/Tags.EditTags").Location(part.GetLocation("Editor"));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override DriverResult Editor(HasTags part, IUpdateModel updater) {
|
protected override DriverResult Editor(TagsPart part, IUpdateModel updater) {
|
||||||
if (!_authorizationService.TryCheckAccess(Permissions.ApplyTag, CurrentUser, part))
|
if (!_authorizationService.TryCheckAccess(Permissions.ApplyTag, CurrentUser, part))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@@ -8,10 +8,10 @@ using Orchard.Tags.Models;
|
|||||||
|
|
||||||
namespace Orchard.Tags.Handlers {
|
namespace Orchard.Tags.Handlers {
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public class HasTagsHandler : ContentHandler {
|
public class TagsPartHandler : ContentHandler {
|
||||||
public HasTagsHandler(IRepository<Tag> tagsRepository, IRepository<TagsContentItems> tagsContentItemsRepository) {
|
public TagsPartHandler(IRepository<Tag> tagsRepository, IRepository<TagsContentItems> tagsContentItemsRepository) {
|
||||||
|
|
||||||
OnLoading<HasTags>((context, tags) => {
|
OnLoading<TagsPart>((context, tags) => {
|
||||||
|
|
||||||
// provide names of all tags on demand
|
// provide names of all tags on demand
|
||||||
tags._allTags.Loader(list => tagsRepository.Table.ToList());
|
tags._allTags.Loader(list => tagsRepository.Table.ToList());
|
||||||
@@ -28,11 +28,11 @@ namespace Orchard.Tags.Handlers {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
OnRemoved<HasTags>((context, ht) => {
|
OnRemoved<TagsPart>((context, tags) => {
|
||||||
tagsContentItemsRepository.Flush();
|
tagsContentItemsRepository.Flush();
|
||||||
|
|
||||||
HasTags tags = context.ContentItem.As<HasTags>();
|
TagsPart tagsPart = context.ContentItem.As<TagsPart>();
|
||||||
foreach (var tag in tags.CurrentTags) {
|
foreach (var tag in tagsPart.CurrentTags) {
|
||||||
if (!tagsContentItemsRepository.Fetch(x => x.ContentItemId == context.ContentItem.Id).Any()) {
|
if (!tagsContentItemsRepository.Fetch(x => x.ContentItemId == context.ContentItem.Id).Any()) {
|
||||||
tagsRepository.Delete(tag);
|
tagsRepository.Delete(tag);
|
||||||
}
|
}
|
||||||
@@ -3,8 +3,8 @@ using Orchard.ContentManagement;
|
|||||||
using Orchard.ContentManagement.Utilities;
|
using Orchard.ContentManagement.Utilities;
|
||||||
|
|
||||||
namespace Orchard.Tags.Models {
|
namespace Orchard.Tags.Models {
|
||||||
public class HasTags : ContentPart {
|
public class TagsPart : ContentPart {
|
||||||
public HasTags() {
|
public TagsPart() {
|
||||||
AllTags = new List<Tag>();
|
AllTags = new List<Tag>();
|
||||||
CurrentTags = new List<Tag>();
|
CurrentTags = new List<Tag>();
|
||||||
}
|
}
|
||||||
@@ -72,11 +72,11 @@
|
|||||||
<Compile Include="Services\ITagService.cs" />
|
<Compile Include="Services\ITagService.cs" />
|
||||||
<Compile Include="ViewModels\EditTagsViewModel.cs" />
|
<Compile Include="ViewModels\EditTagsViewModel.cs" />
|
||||||
<Compile Include="Controllers\HomeController.cs" />
|
<Compile Include="Controllers\HomeController.cs" />
|
||||||
<Compile Include="Drivers\HasTagsDriver.cs" />
|
<Compile Include="Drivers\TagsPartDriver.cs" />
|
||||||
<Compile Include="Helpers\TagHelpers.cs" />
|
<Compile Include="Helpers\TagHelpers.cs" />
|
||||||
<Compile Include="Models\HasTags.cs" />
|
<Compile Include="Models\TagsPart.cs" />
|
||||||
<Compile Include="Models\Tag.cs" />
|
<Compile Include="Models\Tag.cs" />
|
||||||
<Compile Include="Handlers\HasTagsHandler.cs" />
|
<Compile Include="Handlers\TagsPartHandler.cs" />
|
||||||
<Compile Include="Permissions.cs" />
|
<Compile Include="Permissions.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Routes.cs" />
|
<Compile Include="Routes.cs" />
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<HasTags>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<TagsPart>" %>
|
||||||
<%@ Import Namespace="Orchard.Tags.Models" %>
|
<%@ Import Namespace="Orchard.Tags.Models" %>
|
||||||
<% if (Model.CurrentTags.Count > 0) { %>
|
<% if (Model.CurrentTags.Count > 0) { %>
|
||||||
<p class="tags">
|
<p class="tags">
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<HasTags>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<TagsPart>" %>
|
||||||
<%@ Import Namespace="Orchard.Tags.Models" %>
|
<%@ Import Namespace="Orchard.Tags.Models" %>
|
||||||
<% if (Model.CurrentTags.Count > 0) { %>
|
<% if (Model.CurrentTags.Count > 0) { %>
|
||||||
<p class="tags group">
|
<p class="tags group">
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<HasTags>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<TagsPart>" %>
|
||||||
<%@ Import Namespace="Orchard.Tags.Models" %>
|
<%@ Import Namespace="Orchard.Tags.Models" %>
|
||||||
<% if (Model.CurrentTags.Count > 0) { %>
|
<% if (Model.CurrentTags.Count > 0) { %>
|
||||||
<p class="tags group">
|
<p class="tags group">
|
||||||
|
|||||||
Reference in New Issue
Block a user