U4-8710 - from Umbraco.Field, GetPropertyValue to Value
This commit is contained in:
@@ -151,7 +151,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
public void Position()
|
||||
{
|
||||
var items = UmbracoContext.Current.ContentCache.GetAtRoot()
|
||||
.Where(x => x.GetPropertyValue<int>("prop1") == 1234)
|
||||
.Where(x => x.Value<int>("prop1") == 1234)
|
||||
.ToIndexedArray();
|
||||
|
||||
Assert.IsTrue(items.First().IsFirst());
|
||||
|
||||
@@ -259,7 +259,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
|
||||
#endregion
|
||||
|
||||
public int Prop1 => this.GetPropertyValue<int>("prop1");
|
||||
public int Prop1 => this.Value<int>("prop1");
|
||||
}
|
||||
|
||||
[PublishedContentModel("ContentType2Sub")]
|
||||
@@ -280,7 +280,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
: base(content)
|
||||
{ }
|
||||
|
||||
public int StrongValue => this.GetPropertyValue<int>("strongValue");
|
||||
public int StrongValue => this.Value<int>("strongValue");
|
||||
}
|
||||
|
||||
class PublishedContentStrong1Sub : PublishedContentStrong1
|
||||
@@ -289,7 +289,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
: base(content)
|
||||
{ }
|
||||
|
||||
public int AnotherValue => this.GetPropertyValue<int>("anotherValue");
|
||||
public int AnotherValue => this.Value<int>("anotherValue");
|
||||
}
|
||||
|
||||
class PublishedContentStrong2 : PublishedContentModel
|
||||
@@ -298,7 +298,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
: base(content)
|
||||
{ }
|
||||
|
||||
public int StrongValue => this.GetPropertyValue<int>("strongValue");
|
||||
public int StrongValue => this.Value<int>("strongValue");
|
||||
}
|
||||
|
||||
class AutoPublishedContentType : PublishedContentType
|
||||
|
||||
@@ -292,8 +292,8 @@ namespace Umbraco.Tests.PublishedContent
|
||||
public void GetPropertyValueRecursiveTest()
|
||||
{
|
||||
var doc = GetNode(1174);
|
||||
var rVal = doc.GetPropertyValue("testRecursive", true);
|
||||
var nullVal = doc.GetPropertyValue("DoNotFindThis", true);
|
||||
var rVal = doc.Value("testRecursive", true);
|
||||
var nullVal = doc.Value("DoNotFindThis", true);
|
||||
Assert.AreEqual("This is the recursive val", rVal);
|
||||
Assert.AreEqual(null, nullVal);
|
||||
}
|
||||
@@ -303,15 +303,15 @@ namespace Umbraco.Tests.PublishedContent
|
||||
{
|
||||
var doc = GetNode(1173);
|
||||
|
||||
var propVal = doc.GetPropertyValue("content");
|
||||
var propVal = doc.Value("content");
|
||||
Assert.IsInstanceOf(typeof(IHtmlString), propVal);
|
||||
Assert.AreEqual("<div>This is some content</div>", propVal.ToString());
|
||||
|
||||
var propVal2 = doc.GetPropertyValue<IHtmlString>("content");
|
||||
var propVal2 = doc.Value<IHtmlString>("content");
|
||||
Assert.IsInstanceOf(typeof(IHtmlString), propVal2);
|
||||
Assert.AreEqual("<div>This is some content</div>", propVal2.ToString());
|
||||
|
||||
var propVal3 = doc.GetPropertyValue("Content");
|
||||
var propVal3 = doc.Value("Content");
|
||||
Assert.IsInstanceOf(typeof(IHtmlString), propVal3);
|
||||
Assert.AreEqual("<div>This is some content</div>", propVal3.ToString());
|
||||
}
|
||||
@@ -324,7 +324,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
var result = doc.Ancestors().OrderBy(x => x.Level)
|
||||
.Single()
|
||||
.Descendants()
|
||||
.FirstOrDefault(x => x.GetPropertyValue<string>("selectedNodes", "").Split(',').Contains("1173"));
|
||||
.FirstOrDefault(x => x.Value<string>("selectedNodes", "").Split(',').Contains("1173"));
|
||||
|
||||
Assert.IsNotNull(result);
|
||||
}
|
||||
@@ -581,11 +581,11 @@ namespace Umbraco.Tests.PublishedContent
|
||||
{ }
|
||||
|
||||
|
||||
public string Legend => this.GetPropertyValue<string>("legend");
|
||||
public string Legend => this.Value<string>("legend");
|
||||
|
||||
public IPublishedContent Image => this.GetPropertyValue<IPublishedContent>("image");
|
||||
public IPublishedContent Image => this.Value<IPublishedContent>("image");
|
||||
|
||||
public int Size => this.GetPropertyValue<int>("size");
|
||||
public int Size => this.Value<int>("size");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,15 +92,15 @@ namespace Umbraco.Tests.PublishedContent
|
||||
|
||||
var publishedMedia = GetNode(media.Id);
|
||||
|
||||
var propVal = publishedMedia.GetPropertyValue("content");
|
||||
var propVal = publishedMedia.Value("content");
|
||||
Assert.IsInstanceOf<IHtmlString>(propVal);
|
||||
Assert.AreEqual("<div>This is some content</div>", propVal.ToString());
|
||||
|
||||
var propVal2 = publishedMedia.GetPropertyValue<IHtmlString>("content");
|
||||
var propVal2 = publishedMedia.Value<IHtmlString>("content");
|
||||
Assert.IsInstanceOf<IHtmlString>(propVal2);
|
||||
Assert.AreEqual("<div>This is some content</div>", propVal2.ToString());
|
||||
|
||||
var propVal3 = publishedMedia.GetPropertyValue("Content");
|
||||
var propVal3 = publishedMedia.Value("Content");
|
||||
Assert.IsInstanceOf<IHtmlString>(propVal3);
|
||||
Assert.AreEqual("<div>This is some content</div>", propVal3.ToString());
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Web;
|
||||
|
||||
@@ -48,7 +47,7 @@ namespace Umbraco.Tests.PublishedContent.StronglyTypedModels
|
||||
|
||||
protected T Resolve<T>(string propertyTypeAlias)
|
||||
{
|
||||
return Content.GetPropertyValue<T>(propertyTypeAlias);
|
||||
return Content.Value<T>(propertyTypeAlias);
|
||||
}
|
||||
|
||||
protected T Resolve<T>(MethodBase methodBase, T ifCannotConvert)
|
||||
@@ -59,7 +58,7 @@ namespace Umbraco.Tests.PublishedContent.StronglyTypedModels
|
||||
|
||||
protected T Resolve<T>(string propertyTypeAlias, T ifCannotConvert)
|
||||
{
|
||||
return Content.GetPropertyValue<T>(propertyTypeAlias, false, ifCannotConvert);
|
||||
return Content.Value<T>(propertyTypeAlias, false, ifCannotConvert);
|
||||
}
|
||||
|
||||
protected T Resolve<T>(MethodBase methodBase, bool recursive, T ifCannotConvert)
|
||||
@@ -70,7 +69,7 @@ namespace Umbraco.Tests.PublishedContent.StronglyTypedModels
|
||||
|
||||
protected T Resolve<T>(string propertyTypeAlias, bool recursive, T ifCannotConvert)
|
||||
{
|
||||
return Content.GetPropertyValue<T>(propertyTypeAlias, recursive, ifCannotConvert);
|
||||
return Content.Value<T>(propertyTypeAlias, recursive, ifCannotConvert);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
|
||||
namespace Umbraco.Web
|
||||
@@ -40,33 +39,5 @@ namespace Umbraco.Web
|
||||
/// <param name="parameters">The parameters.</param>
|
||||
/// <returns></returns>
|
||||
IHtmlString RenderMacro(string alias, IDictionary<string, object> parameters);
|
||||
|
||||
/// <summary>
|
||||
/// Renders an field to the template
|
||||
/// </summary>
|
||||
/// <param name="currentPage"></param>
|
||||
/// <param name="fieldAlias"></param>
|
||||
/// <param name="altFieldAlias"></param>
|
||||
/// <param name="altText"></param>
|
||||
/// <param name="insertBefore"></param>
|
||||
/// <param name="insertAfter"></param>
|
||||
/// <param name="recursive"></param>
|
||||
/// <param name="convertLineBreaks"></param>
|
||||
/// <param name="removeParagraphTags"></param>
|
||||
/// <param name="casing"></param>
|
||||
/// <param name="encoding"></param>
|
||||
/// <param name="formatAsDate"></param>
|
||||
/// <param name="formatAsDateWithTime"></param>
|
||||
/// <param name="formatAsDateWithTimeSeparator"></param>
|
||||
//// <param name="formatString"></param>
|
||||
/// <returns></returns>
|
||||
IHtmlString Field(IPublishedContent currentPage, string fieldAlias,
|
||||
string altFieldAlias = "", string altText = "", string insertBefore = "", string insertAfter = "",
|
||||
bool recursive = false, bool convertLineBreaks = false, bool removeParagraphTags = false,
|
||||
RenderFieldCaseType casing = RenderFieldCaseType.Unchanged,
|
||||
RenderFieldEncodingType encoding = RenderFieldEncodingType.Unchanged,
|
||||
bool formatAsDate = false,
|
||||
bool formatAsDateWithTime = false,
|
||||
string formatAsDateWithTimeSeparator = "");
|
||||
}
|
||||
}
|
||||
39
src/Umbraco.Web/IUmbracoComponentRendererWithField.cs
Normal file
39
src/Umbraco.Web/IUmbracoComponentRendererWithField.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System.Web;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
|
||||
namespace Umbraco.Web
|
||||
{
|
||||
/// <summary>
|
||||
/// Methods used to render umbraco components as HTML in templates
|
||||
/// </summary>
|
||||
public interface IUmbracoComponentRendererWithField : IUmbracoComponentRenderer
|
||||
{
|
||||
/// <summary>
|
||||
/// Renders an field to the template
|
||||
/// </summary>
|
||||
/// <param name="currentPage"></param>
|
||||
/// <param name="fieldAlias"></param>
|
||||
/// <param name="altFieldAlias"></param>
|
||||
/// <param name="altText"></param>
|
||||
/// <param name="insertBefore"></param>
|
||||
/// <param name="insertAfter"></param>
|
||||
/// <param name="recursive"></param>
|
||||
/// <param name="convertLineBreaks"></param>
|
||||
/// <param name="removeParagraphTags"></param>
|
||||
/// <param name="casing"></param>
|
||||
/// <param name="encoding"></param>
|
||||
/// <param name="formatAsDate"></param>
|
||||
/// <param name="formatAsDateWithTime"></param>
|
||||
/// <param name="formatAsDateWithTimeSeparator"></param>
|
||||
//// <param name="formatString"></param>
|
||||
/// <returns></returns>
|
||||
IHtmlString Field(IPublishedContent currentPage, string fieldAlias,
|
||||
string altFieldAlias = "", string altText = "", string insertBefore = "", string insertAfter = "",
|
||||
bool recursive = false, bool convertLineBreaks = false, bool removeParagraphTags = false,
|
||||
RenderFieldCaseType casing = RenderFieldCaseType.Unchanged,
|
||||
RenderFieldEncodingType encoding = RenderFieldEncodingType.Unchanged,
|
||||
bool formatAsDate = false,
|
||||
bool formatAsDateWithTime = false,
|
||||
string formatAsDateWithTimeSeparator = "");
|
||||
}
|
||||
}
|
||||
@@ -123,7 +123,7 @@ namespace Umbraco.Web
|
||||
return string.Empty;
|
||||
|
||||
//get the default obj from the value converter
|
||||
var cropperValue = mediaItem.GetPropertyValue(propertyAlias);
|
||||
var cropperValue = mediaItem.Value(propertyAlias);
|
||||
|
||||
//is it strongly typed?
|
||||
var stronglyTyped = cropperValue as ImageCropDataSet;
|
||||
|
||||
@@ -553,7 +553,7 @@ namespace Umbraco.Web.Macros
|
||||
{
|
||||
var content = cache.GetById(int.Parse(splitpath[i]));
|
||||
if (content == null) continue;
|
||||
value = content.GetPropertyValue(name)?.ToString();
|
||||
value = content.Value(name)?.ToString();
|
||||
if (string.IsNullOrEmpty(value) == false) break;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Umbraco.Web.Media
|
||||
else
|
||||
{
|
||||
var p = UmbracoContext.Current.ContentCache.GetById(nodeId.GetValueOrDefault());
|
||||
var v = p.GetPropertyValue(field);
|
||||
var v = p.Value(field);
|
||||
fieldValue = v == null ? string.Empty : v.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace Umbraco.Web
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetPropertyValue
|
||||
#region Value
|
||||
|
||||
/// <summary>
|
||||
/// Recursively gets the value of a content's property identified by its alias.
|
||||
@@ -134,7 +134,7 @@ namespace Umbraco.Web
|
||||
/// <para>If eg a numeric property wants to default to 0 when value source is empty, this has to be done in the converter.</para>
|
||||
/// <para>The alias is case-insensitive.</para>
|
||||
/// </remarks>
|
||||
public static object GetPropertyValue(this IPublishedContent content, string alias, bool recurse)
|
||||
public static object Value(this IPublishedContent content, string alias, bool recurse)
|
||||
{
|
||||
var property = content.GetProperty(alias, recurse);
|
||||
return property?.Value;
|
||||
@@ -155,7 +155,7 @@ namespace Umbraco.Web
|
||||
/// <para>If eg a numeric property wants to default to 0 when value source is empty, this has to be done in the converter.</para>
|
||||
/// <para>The alias is case-insensitive.</para>
|
||||
/// </remarks>
|
||||
public static object GetPropertyValue(this IPublishedContent content, string alias, bool recurse, object defaultValue)
|
||||
public static object Value(this IPublishedContent content, string alias, bool recurse, object defaultValue)
|
||||
{
|
||||
var property = content.GetProperty(alias, recurse);
|
||||
return property == null || property.HasValue == false ? defaultValue : property.Value;
|
||||
@@ -163,7 +163,7 @@ namespace Umbraco.Web
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetPropertyValue<T>
|
||||
#region Value<T>
|
||||
|
||||
/// <summary>
|
||||
/// Recursively gets the value of a content's property identified by its alias, converted to a specified type.
|
||||
@@ -180,9 +180,9 @@ namespace Umbraco.Web
|
||||
/// <para>If eg a numeric property wants to default to 0 when value source is empty, this has to be done in the converter.</para>
|
||||
/// <para>The alias is case-insensitive.</para>
|
||||
/// </remarks>
|
||||
public static T GetPropertyValue<T>(this IPublishedContent content, string alias, bool recurse)
|
||||
public static T Value<T>(this IPublishedContent content, string alias, bool recurse)
|
||||
{
|
||||
return content.GetPropertyValue(alias, recurse, false, default(T));
|
||||
return content.Value(alias, recurse, false, default(T));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -201,17 +201,17 @@ namespace Umbraco.Web
|
||||
/// <para>If eg a numeric property wants to default to 0 when value source is empty, this has to be done in the converter.</para>
|
||||
/// <para>The alias is case-insensitive.</para>
|
||||
/// </remarks>
|
||||
public static T GetPropertyValue<T>(this IPublishedContent content, string alias, bool recurse, T defaultValue)
|
||||
public static T Value<T>(this IPublishedContent content, string alias, bool recurse, T defaultValue)
|
||||
{
|
||||
return content.GetPropertyValue(alias, recurse, true, defaultValue);
|
||||
return content.Value(alias, recurse, true, defaultValue);
|
||||
}
|
||||
|
||||
internal static T GetPropertyValue<T>(this IPublishedContent content, string alias, bool recurse, bool withDefaultValue, T defaultValue)
|
||||
internal static T Value<T>(this IPublishedContent content, string alias, bool recurse, bool withDefaultValue, T defaultValue)
|
||||
{
|
||||
var property = content.GetProperty(alias, recurse);
|
||||
if (property == null) return defaultValue;
|
||||
|
||||
return property.GetValue(withDefaultValue, defaultValue);
|
||||
return property.Value(withDefaultValue, defaultValue);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -283,7 +283,7 @@ namespace Umbraco.Web
|
||||
|
||||
// rely on the property converter - will return default bool value, ie false, if property
|
||||
// is not defined, or has no value, else will return its value.
|
||||
return content.GetPropertyValue<bool>(Constants.Conventions.Content.NaviHide) == false;
|
||||
return content.Value<bool>(Constants.Conventions.Content.NaviHide) == false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -10,19 +10,19 @@ namespace Umbraco.Web
|
||||
/// </summary>
|
||||
public static class PublishedPropertyExtension
|
||||
{
|
||||
#region GetValue<T>
|
||||
#region Value<T>
|
||||
|
||||
public static T GetValue<T>(this IPublishedProperty property)
|
||||
public static T Value<T>(this IPublishedProperty property)
|
||||
{
|
||||
return property.GetValue(false, default(T));
|
||||
return property.Value(false, default(T));
|
||||
}
|
||||
|
||||
public static T GetValue<T>(this IPublishedProperty property, T defaultValue)
|
||||
public static T Value<T>(this IPublishedProperty property, T defaultValue)
|
||||
{
|
||||
return property.GetValue(true, defaultValue);
|
||||
return property.Value(true, defaultValue);
|
||||
}
|
||||
|
||||
internal static T GetValue<T>(this IPublishedProperty property, bool withDefaultValue, T defaultValue)
|
||||
internal static T Value<T>(this IPublishedProperty property, bool withDefaultValue, T defaultValue)
|
||||
{
|
||||
if (property.HasValue == false && withDefaultValue) return defaultValue;
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace Umbraco.Web
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetPropertyValue
|
||||
#region Value
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value of a content's property identified by its alias.
|
||||
@@ -89,7 +89,7 @@ namespace Umbraco.Web
|
||||
/// <para>If eg a numeric property wants to default to 0 when value source is empty, this has to be done in the converter.</para>
|
||||
/// <para>The alias is case-insensitive.</para>
|
||||
/// </remarks>
|
||||
public static object GetPropertyValue(this IPublishedFragment content, string alias)
|
||||
public static object Value(this IPublishedFragment content, string alias)
|
||||
{
|
||||
var property = content.GetProperty(alias);
|
||||
return property?.Value;
|
||||
@@ -108,7 +108,7 @@ namespace Umbraco.Web
|
||||
/// <para>If eg a numeric property wants to default to 0 when value source is empty, this has to be done in the converter.</para>
|
||||
/// <para>The alias is case-insensitive.</para>
|
||||
/// </remarks>
|
||||
public static object GetPropertyValue(this IPublishedFragment content, string alias, string defaultValue)
|
||||
public static object Value(this IPublishedFragment content, string alias, string defaultValue)
|
||||
{
|
||||
var property = content.GetProperty(alias);
|
||||
return property == null || property.HasValue == false ? defaultValue : property.Value;
|
||||
@@ -127,7 +127,7 @@ namespace Umbraco.Web
|
||||
/// <para>If eg a numeric property wants to default to 0 when value source is empty, this has to be done in the converter.</para>
|
||||
/// <para>The alias is case-insensitive.</para>
|
||||
/// </remarks>
|
||||
public static object GetPropertyValue(this IPublishedFragment content, string alias, object defaultValue)
|
||||
public static object Value(this IPublishedFragment content, string alias, object defaultValue)
|
||||
{
|
||||
var property = content.GetProperty(alias);
|
||||
return property == null || property.HasValue == false ? defaultValue : property.Value;
|
||||
@@ -135,7 +135,7 @@ namespace Umbraco.Web
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetPropertyValue<T>
|
||||
#region Value<T>
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value of a content's property identified by its alias, converted to a specified type.
|
||||
@@ -150,9 +150,9 @@ namespace Umbraco.Web
|
||||
/// <para>If eg a numeric property wants to default to 0 when value source is empty, this has to be done in the converter.</para>
|
||||
/// <para>The alias is case-insensitive.</para>
|
||||
/// </remarks>
|
||||
public static T GetPropertyValue<T>(this IPublishedFragment content, string alias)
|
||||
public static T Value<T>(this IPublishedFragment content, string alias)
|
||||
{
|
||||
return content.GetPropertyValue(alias, false, default(T));
|
||||
return content.Value(alias, false, default(T));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -169,21 +169,39 @@ namespace Umbraco.Web
|
||||
/// <para>If eg a numeric property wants to default to 0 when value source is empty, this has to be done in the converter.</para>
|
||||
/// <para>The alias is case-insensitive.</para>
|
||||
/// </remarks>
|
||||
public static T GetPropertyValue<T>(this IPublishedFragment content, string alias, T defaultValue)
|
||||
public static T Value<T>(this IPublishedFragment content, string alias, T defaultValue)
|
||||
{
|
||||
return content.GetPropertyValue(alias, true, defaultValue);
|
||||
return content.Value(alias, true, defaultValue);
|
||||
}
|
||||
|
||||
internal static T GetPropertyValue<T>(this IPublishedFragment content, string alias, bool withDefaultValue, T defaultValue)
|
||||
internal static T Value<T>(this IPublishedFragment content, string alias, bool withDefaultValue, T defaultValue)
|
||||
{
|
||||
var property = content.GetProperty(alias);
|
||||
if (property == null) return defaultValue;
|
||||
|
||||
return property.GetValue(withDefaultValue, defaultValue);
|
||||
return property.Value(withDefaultValue, defaultValue);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Value
|
||||
|
||||
// trying to reproduce Umbraco.Field so we can get rid of it
|
||||
//
|
||||
// what we want:
|
||||
// - alt aliases
|
||||
// - recursion
|
||||
// - default value
|
||||
// - before & after (if value)
|
||||
//
|
||||
// convertLineBreaks: should be an extension string.ConvertLineBreaks()
|
||||
// stripParagraphs: should be an extension string.StripParagraphs()
|
||||
// format: should use the standard .ToString(format)
|
||||
//
|
||||
// see UmbracoComponentRenderer.Field - which is ugly ;-(
|
||||
|
||||
#endregion
|
||||
|
||||
#region ToIndexedArray
|
||||
|
||||
public static IndexedArrayItem<TContent>[] ToIndexedArray<TContent>(this IEnumerable<TContent> source)
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Umbraco.Web.Routing
|
||||
var node = umbracoContext.ContentCache.GetById(id);
|
||||
string umbracoUrlName = null;
|
||||
if (node.HasProperty(Constants.Conventions.Content.UrlAlias))
|
||||
umbracoUrlName = node.GetPropertyValue<string>(Constants.Conventions.Content.UrlAlias);
|
||||
umbracoUrlName = node.Value<string>(Constants.Conventions.Content.UrlAlias);
|
||||
if (string.IsNullOrWhiteSpace(umbracoUrlName))
|
||||
return Enumerable.Empty<string>();
|
||||
|
||||
|
||||
@@ -485,7 +485,7 @@ namespace Umbraco.Web.Routing
|
||||
throw new InvalidOperationException("There is no PublishedContent.");
|
||||
|
||||
var redirect = false;
|
||||
var internalRedirect = _pcr.PublishedContent.GetPropertyValue<string>(Constants.Conventions.Content.InternalRedirectId);
|
||||
var internalRedirect = _pcr.PublishedContent.Value<string>(Constants.Conventions.Content.InternalRedirectId);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(internalRedirect))
|
||||
return false;
|
||||
@@ -685,7 +685,7 @@ namespace Umbraco.Web.Routing
|
||||
{
|
||||
if (_pcr.HasPublishedContent == false) return;
|
||||
|
||||
var redirectId = _pcr.PublishedContent.GetPropertyValue(Constants.Conventions.Content.Redirect, -1);
|
||||
var redirectId = _pcr.PublishedContent.Value(Constants.Conventions.Content.Redirect, -1);
|
||||
var redirectUrl = "#";
|
||||
if (redirectId > 0)
|
||||
redirectUrl = _routingContext.UrlProvider.GetUrl(redirectId);
|
||||
|
||||
@@ -171,6 +171,7 @@
|
||||
<Compile Include="Editors\BackOfficeNotificationsController.cs" />
|
||||
<Compile Include="IPublishedContentQuery.cs" />
|
||||
<Compile Include="Editors\MemberGroupController.cs" />
|
||||
<Compile Include="IUmbracoComponentRendererWithField.cs" />
|
||||
<Compile Include="LightInjectExtensions.cs" />
|
||||
<Compile Include="Editors\EditorValidationResolver.cs" />
|
||||
<Compile Include="Editors\EditorValidator.cs" />
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Umbraco.Web
|
||||
/// <remarks>
|
||||
/// Used by UmbracoHelper
|
||||
/// </remarks>
|
||||
internal class UmbracoComponentRenderer : IUmbracoComponentRenderer
|
||||
internal class UmbracoComponentRenderer : IUmbracoComponentRendererWithField
|
||||
{
|
||||
private readonly UmbracoContext _umbracoContext;
|
||||
|
||||
|
||||
@@ -241,75 +241,6 @@ namespace Umbraco.Web
|
||||
|
||||
#endregion
|
||||
|
||||
#region Field
|
||||
|
||||
/// <summary>
|
||||
/// Renders an field to the template
|
||||
/// </summary>
|
||||
/// <param name="fieldAlias"></param>
|
||||
/// <param name="altFieldAlias"></param>
|
||||
/// <param name="altText"></param>
|
||||
/// <param name="insertBefore"></param>
|
||||
/// <param name="insertAfter"></param>
|
||||
/// <param name="recursive"></param>
|
||||
/// <param name="convertLineBreaks"></param>
|
||||
/// <param name="removeParagraphTags"></param>
|
||||
/// <param name="casing"></param>
|
||||
/// <param name="encoding"></param>
|
||||
/// <param name="formatAsDate"></param>
|
||||
/// <param name="formatAsDateWithTime"></param>
|
||||
/// <param name="formatAsDateWithTimeSeparator"></param>
|
||||
//// <param name="formatString"></param>
|
||||
/// <returns></returns>
|
||||
public IHtmlString Field(string fieldAlias,
|
||||
string altFieldAlias = "", string altText = "", string insertBefore = "", string insertAfter = "",
|
||||
bool recursive = false, bool convertLineBreaks = false, bool removeParagraphTags = false,
|
||||
RenderFieldCaseType casing = RenderFieldCaseType.Unchanged,
|
||||
RenderFieldEncodingType encoding = RenderFieldEncodingType.Unchanged,
|
||||
bool formatAsDate = false,
|
||||
bool formatAsDateWithTime = false,
|
||||
string formatAsDateWithTimeSeparator = "")
|
||||
{
|
||||
return UmbracoComponentRenderer.Field(AssignedContentItem, fieldAlias, altFieldAlias,
|
||||
altText, insertBefore, insertAfter, recursive, convertLineBreaks, removeParagraphTags,
|
||||
casing, encoding, formatAsDate, formatAsDateWithTime, formatAsDateWithTimeSeparator);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders an field to the template
|
||||
/// </summary>
|
||||
/// <param name="currentPage"></param>
|
||||
/// <param name="fieldAlias"></param>
|
||||
/// <param name="altFieldAlias"></param>
|
||||
/// <param name="altText"></param>
|
||||
/// <param name="insertBefore"></param>
|
||||
/// <param name="insertAfter"></param>
|
||||
/// <param name="recursive"></param>
|
||||
/// <param name="convertLineBreaks"></param>
|
||||
/// <param name="removeParagraphTags"></param>
|
||||
/// <param name="casing"></param>
|
||||
/// <param name="encoding"></param>
|
||||
/// <param name="formatAsDate"></param>
|
||||
/// <param name="formatAsDateWithTime"></param>
|
||||
/// <param name="formatAsDateWithTimeSeparator"></param>
|
||||
//// <param name="formatString"></param>
|
||||
/// <returns></returns>
|
||||
public IHtmlString Field(IPublishedContent currentPage, string fieldAlias,
|
||||
string altFieldAlias = "", string altText = "", string insertBefore = "", string insertAfter = "",
|
||||
bool recursive = false, bool convertLineBreaks = false, bool removeParagraphTags = false,
|
||||
RenderFieldCaseType casing = RenderFieldCaseType.Unchanged,
|
||||
RenderFieldEncodingType encoding = RenderFieldEncodingType.Unchanged,
|
||||
bool formatAsDate = false,
|
||||
bool formatAsDateWithTime = false,
|
||||
string formatAsDateWithTimeSeparator = "")
|
||||
{
|
||||
return UmbracoComponentRenderer.Field(currentPage, fieldAlias, altFieldAlias,
|
||||
altText, insertBefore, insertAfter, recursive, convertLineBreaks, removeParagraphTags,
|
||||
casing, encoding, formatAsDate, formatAsDateWithTime, formatAsDateWithTimeSeparator);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Dictionary
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace umbraco
|
||||
//check for published content and get its value using that
|
||||
if (publishedContent != null && (publishedContent.HasProperty(_fieldName) || recursive))
|
||||
{
|
||||
var pval = publishedContent.GetPropertyValue(_fieldName, recursive);
|
||||
var pval = publishedContent.Value(_fieldName, recursive);
|
||||
var rval = pval == null ? string.Empty : pval.ToString();
|
||||
_fieldContent = rval.IsNullOrWhiteSpace() ? _fieldContent : rval;
|
||||
}
|
||||
@@ -94,7 +94,7 @@ namespace umbraco
|
||||
{
|
||||
if (publishedContent != null && (publishedContent.HasProperty(altFieldName) || recursive))
|
||||
{
|
||||
var pval = publishedContent.GetPropertyValue(altFieldName, recursive);
|
||||
var pval = publishedContent.Value(altFieldName, recursive);
|
||||
var rval = pval == null ? string.Empty : pval.ToString();
|
||||
_fieldContent = rval.IsNullOrWhiteSpace() ? _fieldContent : rval;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user