diff --git a/src/Orchard.Web/Modules/Orchard.Comments/Extensions/HtmlHelperExtensions.cs b/src/Orchard.Web/Modules/Orchard.Comments/Extensions/HtmlHelperExtensions.cs index eca6edfde..c65bcdbac 100644 --- a/src/Orchard.Web/Modules/Orchard.Comments/Extensions/HtmlHelperExtensions.cs +++ b/src/Orchard.Web/Modules/Orchard.Comments/Extensions/HtmlHelperExtensions.cs @@ -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); } } -} \ No newline at end of file +} diff --git a/src/Orchard.Web/Modules/Orchard.Comments/Views/EditorTemplates/Parts/Comments.Comments.cshtml b/src/Orchard.Web/Modules/Orchard.Comments/Views/EditorTemplates/Parts/Comments.Comments.cshtml index 083a213b9..2843d2a95 100644 --- a/src/Orchard.Web/Modules/Orchard.Comments/Views/EditorTemplates/Parts/Comments.Comments.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Comments/Views/EditorTemplates/Parts/Comments.Comments.cshtml @@ -6,7 +6,7 @@
@T("Comments") @if (Model.Comments.Count > 0) { - – @Html.CommentSummaryLinks(T, Model.ContentItem, Model.Comments.Count, Model.PendingComments.Count) + – @Display.CommentSummaryLinks(item: Model.ContentItem, count: Model.Comments.Count, pendingCount: Model.PendingComments.Count) } @Html.EditorFor(m => m.CommentsActive) diff --git a/src/Orchard.Web/Modules/Orchard.Comments/Views/Parts/Comments.Count.SummaryAdmin.cshtml b/src/Orchard.Web/Modules/Orchard.Comments/Views/Parts/Comments.Count.SummaryAdmin.cshtml index fe9da4ea3..ac517912b 100644 --- a/src/Orchard.Web/Modules/Orchard.Comments/Views/Parts/Comments.Count.SummaryAdmin.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Comments/Views/Parts/Comments.Count.SummaryAdmin.cshtml @@ -2,4 +2,4 @@ @using Orchard.Comments.Extensions; @using Orchard.Comments.ViewModels; @using Orchard.ContentManagement; -@Html.CommentSummaryLinks(T, (ContentItem)Model.ContentPart.ContentItem, (int)Model.CommentCount, (int)Model.PendingCount) \ No newline at end of file +@Display.CommentSummaryLinks(item: Model.ContentPart.ContentItem, count: Model.CommentCount, pendingCount: Model.PendingCount) \ No newline at end of file