Merge branch temp8 into temp8-11502

This commit is contained in:
Stephan
2018-08-27 09:57:41 +02:00
539 changed files with 12060 additions and 18064 deletions

View File

@@ -213,17 +213,23 @@ namespace Umbraco.Core.Models
[IgnoreDataMember]
public IEnumerable<string> PublishedCultures => _publishInfos?.Keys ?? Enumerable.Empty<string>();
//fixme should this return false if ID == 0?
//fixme should this return false if IsCultureAvailable(culture) is false?
/// <inheritdoc />
public bool IsCulturePublished(string culture)
=> _publishInfos != null && _publishInfos.ContainsKey(culture);
=> _publishInfos != null && _publishInfos.ContainsKey(culture);
//fixme should this return false if ID == 0?
//fixme should this return false if IsCultureAvailable(culture) is false?
/// <inheritdoc />
public bool WasCulturePublished(string culture)
=> _publishInfosOrig != null && _publishInfosOrig.ContainsKey(culture);
=> _publishInfosOrig != null && _publishInfosOrig.ContainsKey(culture);
//fixme should this return false if ID == 0?
//fixme should this return false if IsCultureAvailable(culture) is false?
/// <inheritdoc />
public bool IsCultureEdited(string culture)
=> !IsCulturePublished(culture) || (_editedCultures != null && _editedCultures.Contains(culture));
=> !IsCulturePublished(culture) || (_editedCultures != null && _editedCultures.Contains(culture));
/// <inheritdoc/>
[IgnoreDataMember]

View File

@@ -376,30 +376,7 @@ namespace Umbraco.Core.Models
#endregion
#region Validation
/// <inheritdoc />
public bool IsValid(string culture = "*")
{
culture = culture.NullOrWhiteSpaceAsNull();
if (culture == null)
{
if (Name.IsNullOrWhiteSpace()) return false;
return ValidateProperties(null).Length == 0;
}
if (culture != "*")
{
var name = GetCultureName(culture);
if (name.IsNullOrWhiteSpace()) return false;
return ValidateProperties(culture).Length == 0;
}
// 'all cultures'
// those that have a name are ok, those without a name... we don't validate
return AvailableCultures.All(c => ValidateProperties(c).Length == 0);
}
/// <inheritdoc />
public virtual Property[] ValidateProperties(string culture = "*")
{

View File

@@ -10,6 +10,20 @@
/// </summary>
public string PropertyAlias { get; set; }
/// <summary>
/// When dealing with content variants, this is the culture for the variant
/// </summary>
public string Culture { get; set; }
/// <summary>
/// An array of metadata that is parsed out from the file info posted to the server which is set on the client.
/// </summary>
/// <remarks>
/// This can be used for property types like Nested Content that need to have special unique identifiers for each file since there might be multiple files
/// per property.
/// </remarks>
public string[] Metadata { get; set; }
/// <summary>
/// Gets or sets the name of the file.
/// </summary>

View File

@@ -137,14 +137,7 @@ namespace Umbraco.Core.Models
void CopyFrom(IContent other, string culture = "*");
// fixme validate published cultures?
/// <summary>
/// Checks if the content and property values are valid in order to be persisted.
/// </summary>
/// <para>If the content type is variant, then culture can be either '*' or an actual culture, but neither 'null' nor
/// 'empty'. If the content type is invariant, then culture can be either '*' or null or empty.</para>
bool IsValid(string culture = "*");
/// <summary>
/// Validates the content item's properties.
/// </summary>

View File

@@ -343,6 +343,8 @@ namespace Umbraco.Core.Models
/// </summary>
internal bool IsValid(string culture = "*", string segment = "*")
{
//fixme - validating values shouldn't be done here, this calls in to IsValidValue
culture = culture.NullOrWhiteSpaceAsNull();
segment = segment.NullOrWhiteSpaceAsNull();
@@ -382,6 +384,7 @@ namespace Umbraco.Core.Models
/// <returns>True is property value is valid, otherwise false</returns>
private bool IsValidValue(object value)
{
//fixme this shouldn't exist here, the model itself shouldn't be responsible for it's own validation and this requires singleton access
return PropertyType.IsPropertyValueValid(value);
}

View File

@@ -378,11 +378,11 @@ namespace Umbraco.Core.Models
}
//fixme - perhaps this and other validation methods should be a service level (not a model) thing?
//fixme - this and other value validation methods should be a service level (not a model) thing. Changing this to internal for now
/// <summary>
/// Determines whether a value is valid for this property type.
/// </summary>
public bool IsPropertyValueValid(object value)
internal bool IsPropertyValueValid(object value)
{
var editor = Current.PropertyEditors[_propertyEditorAlias]; // fixme inject?
var configuration = Current.Services.DataTypeService.GetDataType(_dataTypeId).Configuration; // fixme inject?