mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 11:44:58 +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;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using Orchard.DisplayManagement;
|
using Orchard.DisplayManagement;
|
||||||
|
using Orchard.DisplayManagement.Descriptors;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
using Orchard.Mvc.Html;
|
using Orchard.Mvc.Html;
|
||||||
|
|
||||||
namespace Orchard.Core.Common {
|
namespace Orchard.Core.Common {
|
||||||
public class Shapes : IDependency {
|
public class Shapes : IShapeTableProvider {
|
||||||
public Shapes() {
|
public Shapes() {
|
||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Localizer T { get; set; }
|
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]
|
[Shape]
|
||||||
public IHtmlString PublishedState(HtmlHelper Html, DateTime? dateTimeUtc) {
|
public IHtmlString PublishedState(HtmlHelper Html, DateTime? dateTimeUtc) {
|
||||||
return Html.DateTime(dateTimeUtc, T("Draft"));
|
return Html.DateTime(dateTimeUtc, T("Draft"));
|
||||||
@@ -20,12 +29,10 @@ namespace Orchard.Core.Common {
|
|||||||
|
|
||||||
[Shape]
|
[Shape]
|
||||||
public IHtmlString PublishedWhen(dynamic Display, DateTime? dateTimeUtc) {
|
public IHtmlString PublishedWhen(dynamic Display, DateTime? dateTimeUtc) {
|
||||||
if (dateTimeUtc == null) {
|
if (dateTimeUtc == null)
|
||||||
return T("as a Draft");
|
return T("as a Draft");
|
||||||
}
|
|
||||||
else {
|
return Display.DateTimeRelative(dateTimeUtc: dateTimeUtc);
|
||||||
return Display.DateTimeRelative(dateTimeUtc: dateTimeUtc);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user