mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 03:25:23 +08:00

--HG-- branch : dev rename : src/Orchard.Web/Modules/Orchard.Blogs/Views/Items/Content-Blog.DetailAdmin.cshtml => src/Orchard.Web/Modules/Orchard.Blogs/Views/Content-Blog.DetailAdmin.cshtml rename : src/Orchard.Web/Modules/Orchard.Blogs/Views/Items/Content-Blog.Edit.cshtml => src/Orchard.Web/Modules/Orchard.Blogs/Views/Content-Blog.Edit.cshtml rename : src/Orchard.Web/Modules/Orchard.Blogs/Views/Items/Content-Blog.SummaryAdmin.cshtml => src/Orchard.Web/Modules/Orchard.Blogs/Views/Content-Blog.SummaryAdmin.cshtml rename : src/Orchard.Web/Modules/Orchard.Blogs/Views/EditorTemplates/Parts/Blogs.Blog.Fields.cshtml => src/Orchard.Web/Modules/Orchard.Blogs/Views/EditorTemplates/Parts.Blogs.Blog.Fields.cshtml rename : src/Orchard.Web/Modules/Orchard.Blogs/Views/EditorTemplates/Parts/Blogs.BlogArchives.cshtml => src/Orchard.Web/Modules/Orchard.Blogs/Views/EditorTemplates/Parts.Blogs.BlogArchives.cshtml rename : src/Orchard.Web/Modules/Orchard.Blogs/Views/EditorTemplates/Parts/Blogs.RecentBlogPosts.cshtml => src/Orchard.Web/Modules/Orchard.Blogs/Views/EditorTemplates/Parts.Blogs.RecentBlogPosts.cshtml rename : src/Orchard.Web/Modules/Orchard.Blogs/Views/Parts/Blogs.Blog.BlogPostCount.cshtml => src/Orchard.Web/Modules/Orchard.Blogs/Views/Parts.Blogs.Blog.BlogPostCount.cshtml rename : src/Orchard.Web/Modules/Orchard.Blogs/Views/Parts/Blogs.Blog.Description.cshtml => src/Orchard.Web/Modules/Orchard.Blogs/Views/Parts.Blogs.Blog.Description.cshtml rename : src/Orchard.Web/Modules/Orchard.Blogs/Views/Parts/Blogs.Blog.Manage.cshtml => src/Orchard.Web/Modules/Orchard.Blogs/Views/Parts.Blogs.Blog.Manage.cshtml rename : src/Orchard.Web/Modules/Orchard.Blogs/Views/Parts/Blogs.BlogArchives.cshtml => src/Orchard.Web/Modules/Orchard.Blogs/Views/Parts.Blogs.BlogArchives.cshtml rename : src/Orchard.Web/Modules/Orchard.Blogs/Views/Parts/Blogs.BlogPost.List.cshtml => src/Orchard.Web/Modules/Orchard.Blogs/Views/Parts.Blogs.BlogPost.List.cshtml rename : src/Orchard.Web/Modules/Orchard.Blogs/Views/Parts/Blogs.BlogPost.ListAdmin.cshtml => src/Orchard.Web/Modules/Orchard.Blogs/Views/Parts.Blogs.BlogPost.ListAdmin.cshtml rename : src/Orchard.Web/Modules/Orchard.Blogs/Views/Parts/Blogs.RecentBlogPosts.cshtml => src/Orchard.Web/Modules/Orchard.Blogs/Views/Parts.Blogs.RecentBlogPosts.cshtml rename : src/Orchard.Web/Modules/Orchard.Blogs/Views/Parts/Blogs.RemotePublishing.cshtml => src/Orchard.Web/Modules/Orchard.Blogs/Views/Parts.Blogs.RemotePublishing.cshtml
76 lines
3.7 KiB
C#
76 lines
3.7 KiB
C#
using System.Linq;
|
|
using JetBrains.Annotations;
|
|
using Orchard.Blogs.Extensions;
|
|
using Orchard.Blogs.Models;
|
|
using Orchard.Blogs.Services;
|
|
using Orchard.ContentManagement;
|
|
using Orchard.ContentManagement.Drivers;
|
|
using Orchard.Core.Feeds;
|
|
using Orchard.Localization;
|
|
|
|
namespace Orchard.Blogs.Drivers {
|
|
[UsedImplicitly]
|
|
public class BlogPartDriver : ContentPartDriver<BlogPart> {
|
|
public IOrchardServices Services { get; set; }
|
|
|
|
private readonly IContentManager _contentManager;
|
|
private readonly IBlogPostService _blogPostService;
|
|
private readonly IFeedManager _feedManager;
|
|
|
|
public BlogPartDriver(
|
|
IOrchardServices services,
|
|
IContentManager contentManager,
|
|
IBlogPostService blogPostService,
|
|
IFeedManager feedManager) {
|
|
Services = services;
|
|
_contentManager = contentManager;
|
|
_blogPostService = blogPostService;
|
|
_feedManager = feedManager;
|
|
T = NullLocalizer.Instance;
|
|
}
|
|
|
|
|
|
public Localizer T { get; set; }
|
|
|
|
protected override string Prefix { get { return ""; } }
|
|
|
|
protected override DriverResult Display(BlogPart part, string displayType, dynamic shapeHelper) {
|
|
return Combined(
|
|
ContentShape("Parts_Blogs_Blog_Manage",
|
|
() => shapeHelper.Parts_Blogs_Blog_Manage(ContentPart: part)),
|
|
ContentShape("Parts_Blogs_Blog_Description",
|
|
() => shapeHelper.Parts_Blogs_Blog_Description(ContentPart: part, Description: part.Description)),
|
|
ContentShape("Parts_Blogs_Blog_BlogPostCount",
|
|
() => shapeHelper.Parts_Blogs_Blog_BlogPostCount(ContentPart: part, PostCount: part.PostCount))
|
|
//,
|
|
// todo: (heskew) implement a paging solution that doesn't require blog posts to be tied to the blog within the controller
|
|
//ContentShape("Parts_Blogs_BlogPost_List",
|
|
// () => {
|
|
// _feedManager.Register(part);
|
|
// var list = shapeHelper.List();
|
|
// list.AddRange(_blogPostService.Get(part)
|
|
// .Select(bp => _contentManager.BuildDisplay(bp, "Summary")));
|
|
// return shapeHelper.Parts_Blogs_BlogPost_List(ContentPart: part, ContentItems: list);
|
|
// }),
|
|
//ContentShape("Parts_Blogs_BlogPost_List_Admin",
|
|
// () =>
|
|
// {
|
|
// var list = shapeHelper.List();
|
|
// list.AddRange(_blogPostService.Get(part, VersionOptions.Latest)
|
|
// .Select(bp => _contentManager.BuildDisplay(bp, "SummaryAdmin")));
|
|
// return shapeHelper.Parts_Blogs_BlogPost_List_Admin(ContentPart: part, ContentItems: list);
|
|
// })
|
|
);
|
|
}
|
|
|
|
protected override DriverResult Editor(BlogPart blogPart, dynamic shapeHelper) {
|
|
return ContentShape("Parts_Blogs_Blog_Fields",
|
|
() => shapeHelper.EditorTemplate(TemplateName: "Parts.Blogs.Blog.Fields", Model: blogPart, Prefix: Prefix));
|
|
}
|
|
|
|
protected override DriverResult Editor(BlogPart blogPart, IUpdateModel updater, dynamic shapeHelper) {
|
|
updater.TryUpdateModel(blogPart, Prefix, null, null);
|
|
return Editor(blogPart, shapeHelper);
|
|
}
|
|
}
|
|
} |