2010-10-14 11:15:22 -07:00
|
|
|
|
using System.Linq;
|
2009-12-21 22:43:10 +00:00
|
|
|
|
using JetBrains.Annotations;
|
2010-07-29 13:55:52 -07:00
|
|
|
|
using Orchard.Blogs.Extensions;
|
2009-12-21 22:43:10 +00:00
|
|
|
|
using Orchard.Blogs.Models;
|
|
|
|
|
using Orchard.Blogs.Services;
|
|
|
|
|
using Orchard.ContentManagement;
|
|
|
|
|
using Orchard.ContentManagement.Drivers;
|
2010-07-29 13:55:52 -07:00
|
|
|
|
using Orchard.Core.Feeds;
|
2010-09-17 01:00:24 -07:00
|
|
|
|
using Orchard.DisplayManagement;
|
2010-01-20 01:19:16 +00:00
|
|
|
|
using Orchard.Localization;
|
2009-12-21 22:43:10 +00:00
|
|
|
|
|
2010-03-03 23:31:42 -08:00
|
|
|
|
namespace Orchard.Blogs.Drivers {
|
2009-12-21 22:43:10 +00:00
|
|
|
|
[UsedImplicitly]
|
2010-09-17 01:00:24 -07:00
|
|
|
|
public class BlogPartDriver : ContentPartDriver<BlogPart> {
|
2010-03-01 17:41:25 -08:00
|
|
|
|
public IOrchardServices Services { get; set; }
|
|
|
|
|
|
2009-12-21 22:43:10 +00:00
|
|
|
|
private readonly IContentManager _contentManager;
|
|
|
|
|
private readonly IBlogPostService _blogPostService;
|
2010-07-29 13:55:52 -07:00
|
|
|
|
private readonly IFeedManager _feedManager;
|
2009-12-21 22:43:10 +00:00
|
|
|
|
|
2010-10-15 17:24:30 -07:00
|
|
|
|
public BlogPartDriver(
|
|
|
|
|
IOrchardServices services,
|
|
|
|
|
IContentManager contentManager,
|
|
|
|
|
IBlogPostService blogPostService,
|
|
|
|
|
IFeedManager feedManager) {
|
2010-03-01 17:41:25 -08:00
|
|
|
|
Services = services;
|
2009-12-21 22:43:10 +00:00
|
|
|
|
_contentManager = contentManager;
|
|
|
|
|
_blogPostService = blogPostService;
|
2010-07-29 13:55:52 -07:00
|
|
|
|
_feedManager = feedManager;
|
2010-01-20 01:19:16 +00:00
|
|
|
|
T = NullLocalizer.Instance;
|
2009-12-21 22:43:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-15 17:24:30 -07:00
|
|
|
|
|
2010-06-02 13:54:50 -07:00
|
|
|
|
public Localizer T { get; set; }
|
2010-01-20 01:19:16 +00:00
|
|
|
|
|
2009-12-21 22:43:10 +00:00
|
|
|
|
protected override string Prefix { get { return ""; } }
|
|
|
|
|
|
2010-10-11 02:06:01 -07:00
|
|
|
|
protected override DriverResult Display(BlogPart part, string displayType, dynamic shapeHelper) {
|
2010-10-14 11:15:22 -07:00
|
|
|
|
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)),
|
2010-10-15 14:40:35 -07:00
|
|
|
|
// todo: (heskew) implement a paging solution that doesn't require blog posts to be tied to the blog within the controller
|
2010-10-14 11:15:22 -07:00
|
|
|
|
ContentShape("Parts_Blogs_BlogPost_List",
|
|
|
|
|
() => {
|
|
|
|
|
_feedManager.Register(part);
|
2010-10-15 14:40:35 -07:00
|
|
|
|
return null;
|
|
|
|
|
// 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);
|
2010-10-14 11:15:22 -07:00
|
|
|
|
}),
|
|
|
|
|
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);
|
|
|
|
|
})
|
|
|
|
|
);
|
2009-12-21 22:43:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-11 02:06:01 -07:00
|
|
|
|
protected override DriverResult Editor(BlogPart blogPart, dynamic shapeHelper) {
|
2010-10-14 11:15:22 -07:00
|
|
|
|
return ContentShape("Parts_Blogs_Blog_Fields",
|
|
|
|
|
() => shapeHelper.EditorTemplate(TemplateName: "Parts/Blogs.Blog.Fields", Model: blogPart, Prefix: Prefix));
|
2009-12-21 22:43:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-11 02:06:01 -07:00
|
|
|
|
protected override DriverResult Editor(BlogPart blogPart, IUpdateModel updater, dynamic shapeHelper) {
|
2010-07-22 11:08:14 -07:00
|
|
|
|
updater.TryUpdateModel(blogPart, Prefix, null, null);
|
2010-10-11 02:06:01 -07:00
|
|
|
|
return Editor(blogPart, shapeHelper);
|
2009-12-21 22:43:10 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2010-03-03 23:31:42 -08:00
|
|
|
|
}
|