mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-01-22 21:02:08 +08:00
Update comment counts to be consistent with post count:
In admin, display total # of comments (active+pending) following (optionally) by the number of pending comments --HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4045979
This commit is contained in:
@@ -9,13 +9,16 @@ namespace Orchard.Comments.Extensions {
|
||||
string commentText = "";
|
||||
|
||||
if (item.Id != 0) {
|
||||
if (commentCount == 0) {
|
||||
//
|
||||
int totalCommentCount = commentCount + pendingCount;
|
||||
|
||||
if (totalCommentCount == 0) {
|
||||
commentText += html.Encode(T("no comments"));
|
||||
}
|
||||
else {
|
||||
commentText +=
|
||||
html.ActionLink(
|
||||
T("{0} comment{1}", commentCount, commentCount == 1 ? "" : "s").ToString(),
|
||||
T("{0} comment{1}", totalCommentCount, totalCommentCount == 1 ? "" : "s").ToString(),
|
||||
"Details",
|
||||
new {
|
||||
Area = "Orchard.Comments",
|
||||
@@ -26,7 +29,7 @@ namespace Orchard.Comments.Extensions {
|
||||
}
|
||||
|
||||
if (pendingCount > 0) {
|
||||
commentText += " - ";
|
||||
commentText += " (";
|
||||
commentText += html.ActionLink(T("{0} pending", pendingCount).ToString(),
|
||||
"Details",
|
||||
new {
|
||||
@@ -35,6 +38,7 @@ namespace Orchard.Comments.Extensions {
|
||||
id = item.Id,
|
||||
returnUrl = html.ViewContext.HttpContext.Request.Url
|
||||
});
|
||||
commentText += ") ";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Orchard.Comments.Models {
|
||||
.Where<CommonRecord>(rec => rec.Container == contentItem.Record).List();
|
||||
|
||||
// Count comments and create template
|
||||
int count = parts.Aggregate(0, (seed, item) => seed + (ContentExtensions.Has<HasComments>(item) ? ContentExtensions.As<HasComments>(item).Comments.Count : 0));
|
||||
int count = parts.Aggregate(0, (seed, item) => seed + (item.Has<HasComments>() ? item.As<HasComments>().Comments.Count : 0));
|
||||
int pendingCount = parts.Aggregate(0, (seed, item) => seed + (item.Has<HasComments>() ? item.As<HasComments>().PendingComments.Count : 0));
|
||||
|
||||
return new CommentCountViewModel { Item = contentItem, CommentCount = count, PendingCount = pendingCount};
|
||||
|
||||
Reference in New Issue
Block a user