mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 03:25:23 +08:00
Make PublishedDate and PublishedWhen shape methods
--HG-- branch : dev
This commit is contained in:
@@ -1,15 +1,26 @@
|
||||
using System;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Mvc.Html;
|
||||
|
||||
namespace Orchard.Core.Common.Extensions {
|
||||
public static class HtmlHelperExtensions {
|
||||
public static LocalizedString PublishedState(this HtmlHelper htmlHelper, DateTime? versionPublishedUtc, Localizer T) {
|
||||
return htmlHelper.DateTime(versionPublishedUtc, T("Draft"));
|
||||
public class Shapes {
|
||||
public Shapes() {
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
public static LocalizedString PublishedWhen(this HtmlHelper htmlHelper, DateTime? versionPublishedUtc, Localizer T) {
|
||||
return htmlHelper.DateTimeRelative(versionPublishedUtc, T("as a Draft"), T);
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
[Shape]
|
||||
public IHtmlString PublishedState(HtmlHelper Html, DateTime? versionPublishedUtc) {
|
||||
return Html.DateTime(versionPublishedUtc, T("Draft"));
|
||||
}
|
||||
|
||||
[Shape]
|
||||
public IHtmlString PublishedWhen(dynamic Display, HtmlHelper Html, DateTime? versionPublishedUtc) {
|
||||
return Display.DateTimeRelative(dateTime: versionPublishedUtc, defaultIfNull: T("as a Draft"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,2 +1,2 @@
|
||||
@using Orchard.Core.Common.Extensions;
|
||||
<div class="published">@Html.PublishedState((DateTime?)Model.ContentPart.VersionPublishedUtc, T)</div>
|
||||
<div class="published">@Display.PublishedState(versionPublishedUtc: (DateTime?)Model.ContentPart.VersionPublishedUtc)</div>
|
@@ -1,2 +1,2 @@
|
||||
@using Orchard.Core.Common.Extensions;
|
||||
<div class="published">@Html.PublishedState((DateTime?)Model.ContentPart.VersionPublishedUtc, T)</div>
|
||||
<div class="published">@Display.PublishedState(versionPublishedUtc: (DateTime?)Model.ContentPart.VersionPublishedUtc)</div>
|
@@ -3,5 +3,5 @@
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
<%
|
||||
if (Model.Creator != null) {
|
||||
%><%=_Encoded(" | Posted by {0} {1}", Model.Creator.UserName, Html.PublishedWhen(Model)) %><%
|
||||
%><%=_Encoded(" | Posted by {0} {1}", Model.Creator.UserName, Display.PublishedWhen(versionPublishedUtc: Model))%><%
|
||||
} %>
|
||||
|
@@ -4,7 +4,7 @@
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
<%@ Import Namespace="Orchard.Core.Common.Extensions" %>
|
||||
<h3><%: Html.Link(Model.Item.Title, Url.BlogPost(Model.Item)) %></h3>
|
||||
<div class="meta"><%: Html.PublishedState(Model.Item, T) %> | <%Html.Zone("meta");%></div>
|
||||
<div class="meta"><%: Display.PublishedState(versionPublishedUtc: Model.Item)%> | <%Html.Zone("meta");%></div>
|
||||
<div class="postsummary">
|
||||
<% Html.Zone("primary"); %>
|
||||
</div>
|
@@ -3,5 +3,5 @@
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
<%@ Import Namespace="Orchard.Core.Common.Extensions" %><%
|
||||
if (Model.Creator != null) {
|
||||
%><%: T("Posted by {0} {1}", Model.Creator.UserName, Html.PublishedWhen(Model, T)) %><%
|
||||
%><%: T("Posted by {0} {1}", Model.Creator.UserName, Display.PublishedWhen(versionPublishedUtc: Model))%><%
|
||||
} %>
|
@@ -8,7 +8,7 @@
|
||||
|
||||
<!-- TODO: Meta should be it's own shape and not part of the blog summary view. Theme authors will need access to it. -->
|
||||
<div class="meta">
|
||||
@Html.PublishedState(new CommonMetadataViewModel((CommonPart)Model.ContentItem.Get(typeof(CommonPart))), T)
|
||||
@Display.PublishedState(versionPublishedUtc: new CommonMetadataViewModel((CommonPart)Model.ContentItem.Get(typeof(CommonPart))))
|
||||
@Display(Model.meta)
|
||||
</div>
|
||||
|
||||
|
Reference in New Issue
Block a user