mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Make Comments cound display a shape
--HG-- branch : dev
This commit is contained in:
@@ -1,42 +1,50 @@
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Mvc.Html;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Mvc.Html;
|
||||
using Orchard.Utility.Extensions;
|
||||
|
||||
namespace Orchard.Comments.Extensions {
|
||||
public static class HtmlHelperExtensions {
|
||||
public static MvcHtmlString CommentSummaryLinks(this HtmlHelper html, Localizer T, ContentItem item, int commentCount, int pendingCount) {
|
||||
public class CommentsSummary : IDependency {
|
||||
public CommentsSummary() {
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
[Shape]
|
||||
public MvcHtmlString CommentSummaryLinks(dynamic Display, HtmlHelper Html, ContentItem item, int count, int pendingCount) {
|
||||
var commentText = "";
|
||||
|
||||
if (item.Id != 0) {
|
||||
var totalCommentCount = commentCount + pendingCount;
|
||||
var totalCommentCount = count + pendingCount;
|
||||
var totalCommentText = T.Plural("1 comment", "{0} comments", totalCommentCount);
|
||||
if (totalCommentCount == 0) {
|
||||
commentText += totalCommentText.ToString();
|
||||
}
|
||||
else {
|
||||
commentText +=
|
||||
html.ActionLink(
|
||||
Html.ActionLink(
|
||||
totalCommentText.ToString(),
|
||||
"Details",
|
||||
new {
|
||||
Area = "Orchard.Comments",
|
||||
Controller = "Admin",
|
||||
id = item.Id,
|
||||
returnUrl = html.ViewContext.HttpContext.Request.ToUrlString()
|
||||
returnUrl = Html.ViewContext.HttpContext.Request.ToUrlString()
|
||||
});
|
||||
}
|
||||
|
||||
if (pendingCount > 0) {
|
||||
commentText += " " + html.ActionLink(T("({0} pending)", pendingCount).ToString(),
|
||||
commentText += " " + Html.ActionLink(T("({0} pending)", pendingCount).ToString(),
|
||||
"Details",
|
||||
new {
|
||||
Area = "Orchard.Comments",
|
||||
Controller = "Admin",
|
||||
id = item.Id,
|
||||
returnUrl = html.ViewContext.HttpContext.Request.Url
|
||||
returnUrl = Html.ViewContext.HttpContext.Request.Url
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -44,4 +52,4 @@ namespace Orchard.Comments.Extensions {
|
||||
return MvcHtmlString.Create(commentText);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@
|
||||
<fieldset>
|
||||
<legend>@T("Comments")
|
||||
@if (Model.Comments.Count > 0) {
|
||||
<span>– @Html.CommentSummaryLinks(T, Model.ContentItem, Model.Comments.Count, Model.PendingComments.Count)</span>
|
||||
<span>– @Display.CommentSummaryLinks(item: Model.ContentItem, count: Model.Comments.Count, pendingCount: Model.PendingComments.Count)</span>
|
||||
}
|
||||
</legend>
|
||||
@Html.EditorFor(m => m.CommentsActive)
|
||||
|
@@ -2,4 +2,4 @@
|
||||
@using Orchard.Comments.Extensions;
|
||||
@using Orchard.Comments.ViewModels;
|
||||
@using Orchard.ContentManagement;
|
||||
<span class="commentcount">@Html.CommentSummaryLinks(T, (ContentItem)Model.ContentPart.ContentItem, (int)Model.CommentCount, (int)Model.PendingCount)</span>
|
||||
<span class="commentcount">@Display.CommentSummaryLinks(item: Model.ContentPart.ContentItem, count: Model.CommentCount, pendingCount: Model.PendingCount)</span>
|
Reference in New Issue
Block a user