mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-24 18:25:04 +08:00
Merge branch 'refs/heads/1.10.x' into dev
This commit is contained in:
@@ -17,13 +17,18 @@
|
||||
|
||||
//We will use a script to find the fieldset for the field we are currently processing.
|
||||
//The fieldset contains a span of class "hint". We will add tryTranslateMsg to it.
|
||||
//We will check if the field exists in the page DOM, just in case a Placement.info suppresses it.
|
||||
string dataPartName = HttpUtility.JavaScriptStringEncode(Model.Part.PartDefinition.Name);
|
||||
string dataFieldName = HttpUtility.JavaScriptStringEncode(Model.Field.PartFieldDefinition.Name);
|
||||
}
|
||||
<input type="hidden" id="@dataPartName-@dataFieldName-tryTranslateMsg" value="@tryTranslateMsg" />
|
||||
@using (Script.Foot()) {
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
$("fieldset[data-part-name='@dataPartName'][data-field-name='@dataFieldName']").find("span.hint")[0].innerText += "@tryTranslateMsg";
|
||||
var hint = $("fieldset[data-part-name='@dataPartName'][data-field-name='@dataFieldName']").find("span.hint")[0];
|
||||
if (hint) {
|
||||
hint.innerText += " " + $("#@dataPartName-@dataFieldName-tryTranslateMsg").val();
|
||||
}
|
||||
});
|
||||
@foreach (var contentItem in Model.ContentItems) {
|
||||
var loc = contentItem.As<LocalizationPart>();
|
||||
|
||||
@@ -104,6 +104,8 @@ namespace Orchard.Projections.FilterEditors.Forms {
|
||||
f._Operator.Add(new SelectListItem { Value = Convert.ToString(DateTimeOperator.GreaterThan), Text = T("Is greater than").Text });
|
||||
f._Operator.Add(new SelectListItem { Value = Convert.ToString(DateTimeOperator.Between), Text = T("Is between").Text });
|
||||
f._Operator.Add(new SelectListItem { Value = Convert.ToString(DateTimeOperator.NotBetween), Text = T("Is not between").Text });
|
||||
f._Operator.Add(new SelectListItem { Value = Convert.ToString(DateTimeOperator.IsNull), Text = T("Is null").Text });
|
||||
f._Operator.Add(new SelectListItem { Value = Convert.ToString(DateTimeOperator.IsNotNull), Text = T("Is not null").Text });
|
||||
|
||||
foreach (var unit in new[] { f._FieldSetSingle._ValueUnit, f._FieldSetMin._MinUnit, f._FieldSetMax._MaxUnit }) {
|
||||
unit.Add(new SelectListItem { Value = Convert.ToString(DateTimeSpan.Year), Text = T("Year").Text });
|
||||
@@ -125,9 +127,15 @@ namespace Orchard.Projections.FilterEditors.Forms {
|
||||
|
||||
var op = (DateTimeOperator)Enum.Parse(typeof(DateTimeOperator), Convert.ToString(formState.Operator));
|
||||
|
||||
if (op == DateTimeOperator.IsNull)
|
||||
return y => y.IsNull(property);
|
||||
else
|
||||
if (op == DateTimeOperator.IsNotNull)
|
||||
return y => y.IsNotNull(property);
|
||||
else {
|
||||
string type = Convert.ToString(formState.ValueType);
|
||||
|
||||
DateTime min, max;
|
||||
DateTime? min, max;
|
||||
|
||||
// Are those dates or time spans
|
||||
if (type == "0") {
|
||||
@@ -150,15 +158,36 @@ namespace Orchard.Projections.FilterEditors.Forms {
|
||||
}
|
||||
}
|
||||
|
||||
min = min.ToUniversalTime();
|
||||
max = max.ToUniversalTime();
|
||||
if (min.HasValue)
|
||||
min = min.Value.ToUniversalTime();
|
||||
|
||||
object minValue = min;
|
||||
object maxValue = max;
|
||||
if (max.HasValue)
|
||||
max = max.Value.ToUniversalTime();
|
||||
|
||||
object minValue;
|
||||
|
||||
if (min.HasValue)
|
||||
minValue = min.Value;
|
||||
else
|
||||
minValue = "";
|
||||
|
||||
object maxValue;
|
||||
|
||||
if (max.HasValue)
|
||||
maxValue = max.Value;
|
||||
else
|
||||
maxValue = "";
|
||||
|
||||
if(asTicks) {
|
||||
minValue = min.Ticks;
|
||||
maxValue = max.Ticks;
|
||||
if (min.HasValue)
|
||||
minValue = min.Value.Ticks;
|
||||
else
|
||||
minValue = 0;
|
||||
|
||||
if (max.HasValue)
|
||||
maxValue = max.Value.Ticks;
|
||||
else
|
||||
maxValue = 0;
|
||||
}
|
||||
|
||||
switch (op) {
|
||||
@@ -188,12 +217,17 @@ namespace Orchard.Projections.FilterEditors.Forms {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the low bound value of a date pattern. e.g., 2011-10 will return 2011-10-01 00:00:00
|
||||
/// </summary>
|
||||
/// <remarks>DateTime is stored in UTC but entered in local</remarks>
|
||||
protected static DateTime GetLowBoundPattern(string datePattern) {
|
||||
protected static DateTime? GetLowBoundPattern(string datePattern) {
|
||||
if (string.IsNullOrEmpty(datePattern)) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
var match = _dateRegEx.Match(datePattern);
|
||||
|
||||
return DateTime.Parse(
|
||||
@@ -206,6 +240,7 @@ namespace Orchard.Projections.FilterEditors.Forms {
|
||||
match.Groups["second"].Success ? match.Groups["second"].Value : "00"),
|
||||
CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal);
|
||||
}
|
||||
}
|
||||
|
||||
protected static DateTime ApplyDelta(DateTime now, string unit, int value) {
|
||||
var span = (DateTimeSpan)Enum.Parse(typeof(DateTimeSpan), unit);
|
||||
@@ -230,6 +265,13 @@ namespace Orchard.Projections.FilterEditors.Forms {
|
||||
|
||||
public static LocalizedString DisplayFilter(string fieldName, dynamic formState, Localizer T) {
|
||||
var op = (DateTimeOperator)Enum.Parse(typeof(DateTimeOperator), Convert.ToString(formState.Operator));
|
||||
|
||||
if (op == DateTimeOperator.IsNull)
|
||||
return T("{0} is null", fieldName);
|
||||
else
|
||||
if (op == DateTimeOperator.IsNotNull)
|
||||
return T("{0} is not null", fieldName);
|
||||
else {
|
||||
string type = Convert.ToString(formState.ValueType);
|
||||
string value = Convert.ToString(formState.Value);
|
||||
string min = Convert.ToString(formState.Min);
|
||||
@@ -265,6 +307,7 @@ namespace Orchard.Projections.FilterEditors.Forms {
|
||||
case DateTimeOperator.NotBetween:
|
||||
return T("{0} is not between {1}{2} and {3}{4}", fieldName, min, T(minUnit), max, T(maxUnit));
|
||||
}
|
||||
}
|
||||
|
||||
// should never be hit, but fail safe
|
||||
return new LocalizedString(fieldName);
|
||||
@@ -274,7 +317,11 @@ namespace Orchard.Projections.FilterEditors.Forms {
|
||||
/// Returns the low bound value of a date pattern. e.g., 2011-10 will return 2011-10-01 00:00:00
|
||||
/// </summary>
|
||||
/// <remarks>DateTime is stored in UTC but entered in local</remarks>
|
||||
protected static DateTime GetHighBoundPattern(string datePattern) {
|
||||
protected static DateTime? GetHighBoundPattern(string datePattern) {
|
||||
if (string.IsNullOrEmpty(datePattern)) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
var match = _dateRegEx.Match(datePattern);
|
||||
|
||||
string year, month;
|
||||
@@ -288,6 +335,7 @@ namespace Orchard.Projections.FilterEditors.Forms {
|
||||
match.Groups["second"].Success ? match.Groups["second"].Value : "59"),
|
||||
CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -299,7 +347,9 @@ namespace Orchard.Projections.FilterEditors.Forms {
|
||||
GreaterThan,
|
||||
GreaterThanEquals,
|
||||
Between,
|
||||
NotBetween
|
||||
NotBetween,
|
||||
IsNull,
|
||||
IsNotNull
|
||||
}
|
||||
|
||||
public enum DateTimeSpan {
|
||||
|
||||
@@ -13,7 +13,13 @@ namespace Orchard.Projections.FilterEditors.Forms {
|
||||
public override void Validating(ValidatingContext context) {
|
||||
if (context.FormName == DateTimeFilterForm.FormName) {
|
||||
|
||||
var isRange = new[] {"Between", "NotBetween"}.Contains(context.ValueProvider.GetValue("Operator").AttemptedValue);
|
||||
var op = (DateTimeOperator)Enum.Parse(typeof(DateTimeOperator), Convert.ToString(context.ValueProvider.GetValue("Operator").AttemptedValue));
|
||||
|
||||
if (op == DateTimeOperator.IsNull || op == DateTimeOperator.IsNotNull) {
|
||||
// no further validation needed
|
||||
}
|
||||
else {
|
||||
var isRange = new[] {DateTimeOperator.Between, DateTimeOperator.NotBetween}.Contains(op);
|
||||
var min = context.ValueProvider.GetValue("Min");
|
||||
var max = context.ValueProvider.GetValue("Max");
|
||||
var value = context.ValueProvider.GetValue("Value");
|
||||
@@ -80,6 +86,7 @@ namespace Orchard.Projections.FilterEditors.Forms {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsToken(string value) {
|
||||
return value.StartsWith("{") && value.EndsWith("}");
|
||||
|
||||
@@ -2,6 +2,19 @@
|
||||
// show/hide Min/Max fields
|
||||
$("#operator option:selected").each(function () {
|
||||
var val = $(this).val();
|
||||
|
||||
if (val == 'IsNull' || val == 'IsNotNull') {
|
||||
$('#value-type-date').closest('div').hide();
|
||||
$('#value-type-timespan').closest('div').hide();
|
||||
|
||||
$('#fieldset-single').hide();
|
||||
$('#fieldset-min').hide();
|
||||
$('#fieldset-max').hide();
|
||||
}
|
||||
else {
|
||||
$('#value-type-date').closest('div').show();
|
||||
$('#value-type-timespan').closest('div').show();
|
||||
|
||||
if (val == 'Between' || val == 'NotBetween') {
|
||||
$('#fieldset-single').hide();
|
||||
$('#fieldset-min').show();
|
||||
@@ -12,6 +25,7 @@
|
||||
$('#fieldset-min').hide();
|
||||
$('#fieldset-max').hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// show/hide unit selectors
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Orchard.Tokens.Providers {
|
||||
|
||||
FeedItem<ContentItem> item = feedItem;
|
||||
context.Response.Contextualize(requestContext => {
|
||||
author.Value = _tokenizer.Replace(settings.Title, new { Content = item.Item, Text = author.Value });
|
||||
author.Value = _tokenizer.Replace(settings.Author, new { Content = item.Item, Text = author.Value });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user