mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
- Migrating Tags to the shape API.
--HG-- branch : dev
This commit is contained in:
@@ -2,7 +2,6 @@
|
|||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
using Orchard.ContentManagement.Drivers;
|
using Orchard.ContentManagement.Drivers;
|
||||||
using Orchard.Core.ContentsLocation.Models;
|
|
||||||
using Orchard.Security;
|
using Orchard.Security;
|
||||||
using Orchard.Tags.Helpers;
|
using Orchard.Tags.Helpers;
|
||||||
using Orchard.Tags.Models;
|
using Orchard.Tags.Models;
|
||||||
@@ -12,6 +11,7 @@ using Orchard.Tags.ViewModels;
|
|||||||
namespace Orchard.Tags.Drivers {
|
namespace Orchard.Tags.Drivers {
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public class TagsPartDriver : ContentPartDriver<TagsPart> {
|
public class TagsPartDriver : ContentPartDriver<TagsPart> {
|
||||||
|
private const string TemplateName = "Parts/Tags";
|
||||||
private readonly ITagService _tagService;
|
private readonly ITagService _tagService;
|
||||||
private readonly IAuthorizationService _authorizationService;
|
private readonly IAuthorizationService _authorizationService;
|
||||||
|
|
||||||
@@ -23,6 +23,10 @@ namespace Orchard.Tags.Drivers {
|
|||||||
|
|
||||||
public virtual IUser CurrentUser { get; set; }
|
public virtual IUser CurrentUser { get; set; }
|
||||||
|
|
||||||
|
protected override string Prefix {
|
||||||
|
get { return "Tags"; }
|
||||||
|
}
|
||||||
|
|
||||||
protected override DriverResult Display(TagsPart part, string displayType, dynamic shapeHelper) {
|
protected override DriverResult Display(TagsPart part, string displayType, dynamic shapeHelper) {
|
||||||
return ContentShape("Parts_Tags_ShowTags",
|
return ContentShape("Parts_Tags_ShowTags",
|
||||||
() => shapeHelper.Parts_Tags_ShowTags(ContentPart: part, Tags: part.CurrentTags));
|
() => shapeHelper.Parts_Tags_ShowTags(ContentPart: part, Tags: part.CurrentTags));
|
||||||
@@ -35,7 +39,9 @@ namespace Orchard.Tags.Drivers {
|
|||||||
var model = new EditTagsViewModel {
|
var model = new EditTagsViewModel {
|
||||||
Tags = string.Join(", ", part.CurrentTags.Select((t, i) => t.TagName).ToArray())
|
Tags = string.Join(", ", part.CurrentTags.Select((t, i) => t.TagName).ToArray())
|
||||||
};
|
};
|
||||||
return ContentPartTemplate(model, "Parts/Tags.EditTags").Location(part.GetLocation("Editor"));
|
|
||||||
|
return ContentShape("Parts_Tags_Editor",
|
||||||
|
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override DriverResult Editor(TagsPart part, IUpdateModel updater, dynamic shapeHelper) {
|
protected override DriverResult Editor(TagsPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||||
@@ -50,7 +56,8 @@ namespace Orchard.Tags.Drivers {
|
|||||||
_tagService.UpdateTagsForContentItem(part.ContentItem.Id, tagNames);
|
_tagService.UpdateTagsForContentItem(part.ContentItem.Id, tagNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ContentPartTemplate(model, "Parts/Tags.EditTags").Location(part.GetLocation("Editor"));
|
return ContentShape("Parts_Tags_Editor",
|
||||||
|
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,7 +98,7 @@
|
|||||||
<Content Include="Views\Admin\Index.cshtml" />
|
<Content Include="Views\Admin\Index.cshtml" />
|
||||||
<Content Include="Views\Admin\Search.cshtml" />
|
<Content Include="Views\Admin\Search.cshtml" />
|
||||||
<Content Include="Views\Parts\Tags.ShowTags.cshtml" />
|
<Content Include="Views\Parts\Tags.ShowTags.cshtml" />
|
||||||
<Content Include="Views\EditorTemplates\Parts\Tags.EditTags.cshtml" />
|
<Content Include="Views\EditorTemplates\Parts\Tags.cshtml" />
|
||||||
<Content Include="Views\Home\Index.cshtml" />
|
<Content Include="Views\Home\Index.cshtml" />
|
||||||
<Content Include="Views\Home\Search.cshtml" />
|
<Content Include="Views\Home\Search.cshtml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
<Placement>
|
<Placement>
|
||||||
<Place Parts_Tags_ShowTags="Header:after.7"/>
|
<Place Parts_Tags_ShowTags="Header:after.7"/>
|
||||||
|
<Place Parts_Tags_Editor="Primary:7"/>
|
||||||
</Placement>
|
</Placement>
|
||||||
|
|||||||
Reference in New Issue
Block a user