mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-27 12:29:04 +08:00
43 lines
1.3 KiB
C#
43 lines
1.3 KiB
C#
using System;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using Orchard.DisplayManagement;
|
|
using Orchard.DisplayManagement.Descriptors;
|
|
using Orchard.Localization;
|
|
using Orchard.Mvc.Html;
|
|
|
|
namespace Orchard.Core.Common {
|
|
public class Shapes : IShapeTableProvider {
|
|
public Shapes() {
|
|
T = NullLocalizer.Instance;
|
|
}
|
|
|
|
public Localizer T { get; set; }
|
|
|
|
public void Discover(ShapeTableBuilder builder) {
|
|
builder.Describe("Body_Editor")
|
|
.OnDisplaying(displaying => {
|
|
string flavor = displaying.Shape.EditorFlavor;
|
|
displaying.ShapeMetadata.Alternates.Add("Body_Editor__" + flavor);
|
|
});
|
|
}
|
|
|
|
[Shape]
|
|
public IHtmlString PublishedState(dynamic Display, DateTime createdDateTimeUtc, DateTime? publisheddateTimeUtc) {
|
|
if (!publisheddateTimeUtc.HasValue) {
|
|
return T("Draft");
|
|
}
|
|
|
|
return Display.DateTime(DateTimeUtc: createdDateTimeUtc);
|
|
}
|
|
|
|
[Shape]
|
|
public IHtmlString PublishedWhen(dynamic Display, DateTime? dateTimeUtc) {
|
|
if (dateTimeUtc == null)
|
|
return T("as a Draft");
|
|
|
|
return Display.DateTimeRelative(DateTimeUtc: dateTimeUtc);
|
|
}
|
|
}
|
|
}
|