2010-01-22 02:06:07 +00:00
|
|
|
|
using JetBrains.Annotations;
|
2010-02-23 20:54:19 -08:00
|
|
|
|
using Orchard.Comments.Models;
|
2010-01-22 02:06:07 +00:00
|
|
|
|
using Orchard.Comments.ViewModels;
|
2009-12-24 04:49:43 +00:00
|
|
|
|
using Orchard.ContentManagement;
|
|
|
|
|
using Orchard.ContentManagement.Drivers;
|
|
|
|
|
|
2010-02-23 20:54:19 -08:00
|
|
|
|
namespace Orchard.Comments.Controllers {
|
2010-01-22 02:06:07 +00:00
|
|
|
|
[UsedImplicitly]
|
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-22 02:06:07 +00:00
|
|
|
|
else if (displayType == "SummaryAdmin") {
|
|
|
|
|
var model = new CommentCountViewModel(part);
|
|
|
|
|
return ContentPartTemplate(model, "Parts/Comments.CountAdmin").Location("meta");
|
|
|
|
|
}
|
|
|
|
|
else if (displayType.Contains("Summary")) {
|
|
|
|
|
var model = new CommentCountViewModel(part);
|
|
|
|
|
return ContentPartTemplate(model, "Parts/Comments.Count").Location("meta");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
var model = new CommentCountViewModel(part);
|
|
|
|
|
return ContentPartTemplate(model, "Parts/Comments.Count").Location("primary", "before.5");
|
2010-01-21 07:27:47 +00:00
|
|
|
|
}
|
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
|
|
|
|
}
|
|
|
|
|
}
|
2010-01-23 23:21:08 +00:00
|
|
|
|
}
|