2009-12-24 04:49:43 +00:00
|
|
|
|
using Orchard.Comments.Models;
|
|
|
|
|
using Orchard.ContentManagement;
|
|
|
|
|
using Orchard.ContentManagement.Drivers;
|
|
|
|
|
|
|
|
|
|
namespace Orchard.Comments.Controllers {
|
2010-01-05 21:49:48 +00:00
|
|
|
|
public class HasCommentsDriver : ContentPartDriver<HasComments> {
|
2009-12-24 04:49:43 +00:00
|
|
|
|
protected override DriverResult Display(HasComments part, string displayType) {
|
|
|
|
|
if (part.CommentsShown == false) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-02 07:51:55 +00:00
|
|
|
|
// todo: (heskew) need to be more flexible with displaying parts somehow. e.g. where should the...
|
|
|
|
|
// comment count go in any given skin or what if the skin builder doesn't want the count
|
2009-12-24 04:49:43 +00:00
|
|
|
|
if (displayType.StartsWith("Detail")) {
|
2010-01-07 16:02:50 +00:00
|
|
|
|
//return Combined(
|
|
|
|
|
// ContentPartTemplate(part, "Parts/Comments.Count").Location("body", "above.5"),
|
|
|
|
|
// ContentPartTemplate(part, "Parts/Comments.HasComments").Location("body", "below.5"));
|
|
|
|
|
return ContentPartTemplate(part, "Parts/Comments.HasComments").Location("primary", "after.5");
|
2009-12-24 04:49:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-01-21 07:27:47 +00:00
|
|
|
|
if (displayType.Contains("Summary")) {
|
|
|
|
|
return ContentPartTemplate(part, "Parts/Comments.Count").Location("meta");
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-07 16:02:50 +00:00
|
|
|
|
return ContentPartTemplate(part, "Parts/Comments.Count").Location("primary", "before.5");
|
2009-12-24 04:49:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override DriverResult Editor(HasComments part) {
|
2010-01-05 21:49:48 +00:00
|
|
|
|
return ContentPartTemplate(part, "Parts/Comments.HasComments").Location("primary", "99");
|
2009-12-24 04:49:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override DriverResult Editor(HasComments part, IUpdateModel updater) {
|
|
|
|
|
updater.TryUpdateModel(part, Prefix, null, null);
|
2010-01-05 21:49:48 +00:00
|
|
|
|
return ContentPartTemplate(part, "Parts/Comments.HasComments").Location("primary", "99");
|
2009-12-24 04:49:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|