mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
HasTags -> TagsPart
- updating part names to conform to a <name>Part convention --HG-- branch : dev rename : src/Orchard.Web/Modules/Orchard.Tags/Drivers/HasTagsDriver.cs => src/Orchard.Web/Modules/Orchard.Tags/Drivers/TagsPartDriver.cs rename : src/Orchard.Web/Modules/Orchard.Tags/Handlers/HasTagsHandler.cs => src/Orchard.Web/Modules/Orchard.Tags/Handlers/TagsPartHandler.cs rename : src/Orchard.Web/Modules/Orchard.Tags/Models/HasTags.cs => src/Orchard.Web/Modules/Orchard.Tags/Models/TagsPart.cs
This commit is contained in:
@@ -25,7 +25,7 @@ namespace Orchard.Tags.DataMigrations {
|
||||
return 1;
|
||||
}
|
||||
public int UpdateFrom1() {
|
||||
ContentDefinitionManager.AlterPartDefinition(typeof(HasTags).Name, cfg => cfg
|
||||
ContentDefinitionManager.AlterPartDefinition(typeof(TagsPart).Name, cfg => cfg
|
||||
.WithLocation(new Dictionary<string, ContentLocation> {
|
||||
{"Default", new ContentLocation { Zone = "primary", Position = "49" }},
|
||||
{"Editor", new ContentLocation { Zone = "primary", Position = "9" }},
|
||||
|
@@ -11,11 +11,11 @@ using Orchard.Tags.ViewModels;
|
||||
|
||||
namespace Orchard.Tags.Drivers {
|
||||
[UsedImplicitly]
|
||||
public class HasTagsDriver : ContentPartDriver<HasTags> {
|
||||
public class TagsPartDriver : ContentPartDriver<TagsPart> {
|
||||
private readonly ITagService _tagService;
|
||||
private readonly IAuthorizationService _authorizationService;
|
||||
|
||||
public HasTagsDriver(ITagService tagService,
|
||||
public TagsPartDriver(ITagService tagService,
|
||||
IAuthorizationService authorizationService) {
|
||||
_tagService = tagService;
|
||||
_authorizationService = authorizationService;
|
||||
@@ -23,11 +23,11 @@ namespace Orchard.Tags.Drivers {
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(HasTags part) {
|
||||
protected override DriverResult Editor(TagsPart part) {
|
||||
if (!_authorizationService.TryCheckAccess(Permissions.ApplyTag, CurrentUser, part))
|
||||
return null;
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Orchard.Tags.Drivers {
|
||||
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))
|
||||
return null;
|
||||
|
@@ -8,10 +8,10 @@ using Orchard.Tags.Models;
|
||||
|
||||
namespace Orchard.Tags.Handlers {
|
||||
[UsedImplicitly]
|
||||
public class HasTagsHandler : ContentHandler {
|
||||
public HasTagsHandler(IRepository<Tag> tagsRepository, IRepository<TagsContentItems> tagsContentItemsRepository) {
|
||||
public class TagsPartHandler : ContentHandler {
|
||||
public TagsPartHandler(IRepository<Tag> tagsRepository, IRepository<TagsContentItems> tagsContentItemsRepository) {
|
||||
|
||||
OnLoading<HasTags>((context, tags) => {
|
||||
OnLoading<TagsPart>((context, tags) => {
|
||||
|
||||
// provide names of all tags on demand
|
||||
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();
|
||||
|
||||
HasTags tags = context.ContentItem.As<HasTags>();
|
||||
foreach (var tag in tags.CurrentTags) {
|
||||
TagsPart tagsPart = context.ContentItem.As<TagsPart>();
|
||||
foreach (var tag in tagsPart.CurrentTags) {
|
||||
if (!tagsContentItemsRepository.Fetch(x => x.ContentItemId == context.ContentItem.Id).Any()) {
|
||||
tagsRepository.Delete(tag);
|
||||
}
|
@@ -3,8 +3,8 @@ using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Utilities;
|
||||
|
||||
namespace Orchard.Tags.Models {
|
||||
public class HasTags : ContentPart {
|
||||
public HasTags() {
|
||||
public class TagsPart : ContentPart {
|
||||
public TagsPart() {
|
||||
AllTags = new List<Tag>();
|
||||
CurrentTags = new List<Tag>();
|
||||
}
|
@@ -72,11 +72,11 @@
|
||||
<Compile Include="Services\ITagService.cs" />
|
||||
<Compile Include="ViewModels\EditTagsViewModel.cs" />
|
||||
<Compile Include="Controllers\HomeController.cs" />
|
||||
<Compile Include="Drivers\HasTagsDriver.cs" />
|
||||
<Compile Include="Drivers\TagsPartDriver.cs" />
|
||||
<Compile Include="Helpers\TagHelpers.cs" />
|
||||
<Compile Include="Models\HasTags.cs" />
|
||||
<Compile Include="Models\TagsPart.cs" />
|
||||
<Compile Include="Models\Tag.cs" />
|
||||
<Compile Include="Handlers\HasTagsHandler.cs" />
|
||||
<Compile Include="Handlers\TagsPartHandler.cs" />
|
||||
<Compile Include="Permissions.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.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" %>
|
||||
<% if (Model.CurrentTags.Count > 0) { %>
|
||||
<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" %>
|
||||
<% if (Model.CurrentTags.Count > 0) { %>
|
||||
<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" %>
|
||||
<% if (Model.CurrentTags.Count > 0) { %>
|
||||
<p class="tags group">
|
||||
|
Reference in New Issue
Block a user