mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 03:25:23 +08:00
Adding an alternate for the (Orchard.Common) text field
--HG-- branch : dev
This commit is contained in:
@@ -2,17 +2,26 @@ 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 : IDependency {
|
||||
public class Shapes : IShapeTableProvider {
|
||||
public Shapes() {
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public void Discover(ShapeTableBuilder builder) {
|
||||
builder.Describe("Fields_Common_Text")
|
||||
.OnDisplaying(displaying => {
|
||||
string textFieldName = displaying.Shape.Name;
|
||||
displaying.ShapeMetadata.Alternates.Add("Fields_Common_Text__" + textFieldName);
|
||||
});
|
||||
}
|
||||
|
||||
[Shape]
|
||||
public IHtmlString PublishedState(HtmlHelper Html, DateTime? dateTimeUtc) {
|
||||
return Html.DateTime(dateTimeUtc, T("Draft"));
|
||||
@@ -20,12 +29,10 @@ namespace Orchard.Core.Common {
|
||||
|
||||
[Shape]
|
||||
public IHtmlString PublishedWhen(dynamic Display, DateTime? dateTimeUtc) {
|
||||
if (dateTimeUtc == null) {
|
||||
if (dateTimeUtc == null)
|
||||
return T("as a Draft");
|
||||
}
|
||||
else {
|
||||
return Display.DateTimeRelative(dateTimeUtc: dateTimeUtc);
|
||||
}
|
||||
|
||||
return Display.DateTimeRelative(dateTimeUtc: dateTimeUtc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user