Adding an alternate for the (Orchard.Common) text field

--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2010-10-19 15:54:52 -07:00
parent 91c3588f88
commit 7af2be445e

View File

@@ -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);
}
}
}