Merge remote-tracking branch 'origin/temp8' into feature/IContentType-removale-from-IContent

# Conflicts:
#	src/Umbraco.Core/ContentExtensions.cs
#	src/Umbraco.Core/Models/Content.cs
#	src/Umbraco.Tests/Models/ContentTests.cs
#	src/Umbraco.Tests/Models/Mapping/ContentWebModelMappingTests.cs
#	src/Umbraco.Tests/Models/VariationTests.cs
#	src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs
#	src/Umbraco.Tests/Services/ContentTypeServiceVariantsTests.cs
#	src/Umbraco.Tests/Web/Controllers/ContentControllerTests.cs
#	src/Umbraco.Web.UI/Umbraco/dialogs/ChangeDocType.aspx.cs
This commit is contained in:
Bjarke Berg
2019-01-11 08:29:29 +01:00
627 changed files with 10531 additions and 10745 deletions

View File

@@ -17,6 +17,7 @@ namespace Umbraco.Core.Models
{
private ISimpleContentType _contentType;
private ITemplate _template;
private int? _templateId;
private ContentScheduleCollection _schedule;
private bool _published;
private PublishedState _publishedState;
@@ -85,7 +86,7 @@ namespace Umbraco.Core.Models
// ReSharper disable once ClassNeverInstantiated.Local
private class PropertySelectors
{
public readonly PropertyInfo TemplateSelector = ExpressionHelper.GetPropertyInfo<Content, ITemplate>(x => x.Template);
public readonly PropertyInfo TemplateSelector = ExpressionHelper.GetPropertyInfo<Content, int?>(x => x.TemplateId);
public readonly PropertyInfo PublishedSelector = ExpressionHelper.GetPropertyInfo<Content, bool>(x => x.Published);
public readonly PropertyInfo ContentScheduleSelector = ExpressionHelper.GetPropertyInfo<Content, ContentScheduleCollection>(x => x.ContentSchedule);
public readonly PropertyInfo PublishCultureInfosSelector = ExpressionHelper.GetPropertyInfo<Content, IReadOnlyDictionary<string, ContentCultureInfos>>(x => x.PublishCultureInfos);
@@ -133,10 +134,10 @@ namespace Umbraco.Core.Models
/// the Default template from the ContentType will be returned.
/// </remarks>
[DataMember]
public ITemplate Template
public int? TemplateId
{
get => _template ?? _contentType.DefaultTemplate;
set => SetPropertyValueAndDetectChanges(value, ref _template, Ps.Value.TemplateSelector);
get => _templateId;
set => SetPropertyValueAndDetectChanges(value, ref _templateId, Ps.Value.TemplateSelector);
}
@@ -195,7 +196,7 @@ namespace Umbraco.Core.Models
/// <inheritdoc />
[IgnoreDataMember]
public ITemplate PublishTemplate { get; internal set; } // set by persistence
public int? PublishTemplateId { get; internal set; } // set by persistence
/// <inheritdoc />
[IgnoreDataMember]
@@ -460,9 +461,6 @@ namespace Umbraco.Core.Models
{
base.ResetDirtyProperties(rememberDirty);
if (Template != null)
Template.ResetDirtyProperties(rememberDirty);
// take care of the published state
_publishedState = _published ? PublishedState.Published : PublishedState.Unpublished;
@@ -504,8 +502,6 @@ namespace Umbraco.Core.Models
//need to manually clone this since it's not settable
clonedContent._contentType = ContentType;
//if culture infos exist then deal with event bindings
if (clonedContent._publishInfos != null)
{

View File

@@ -18,9 +18,9 @@ namespace Umbraco.Core.Models
ContentScheduleCollection ContentSchedule { get; set; }
/// <summary>
/// Gets or sets the template used to render the content.
/// Gets or sets the template id used to render the content.
/// </summary>
ITemplate Template { get; set; }
int? TemplateId { get; set; }
/// <summary>
/// Gets a value indicating whether the content is published.
@@ -45,10 +45,10 @@ namespace Umbraco.Core.Models
bool Blueprint { get; }
/// <summary>
/// Gets the template used to render the published version of the content.
/// Gets the template id used to render the published version of the content.
/// </summary>
/// <remarks>When editing the content, the template can change, but this will not until the content is published.</remarks>
ITemplate PublishTemplate { get; }
int? PublishTemplateId { get; }
/// <summary>
/// Gets the name of the published version of the content.

View File

@@ -27,11 +27,18 @@ namespace Umbraco.Core.Models
[DataMember]
DateTime CreateDateUtc { get; set; }
/// <summary>
/// Gets or sets the culture.
/// </summary>
[DataMember]
string Culture { get; set; }
/// <summary>
/// Gets or sets the redirect url route.
/// </summary>
/// <remarks>Is a proper Umbraco route eg /path/to/foo or 123/path/tofoo.</remarks>
[DataMember]
string Url { get; set; }
}
}

View File

@@ -6,6 +6,7 @@ using System.Linq;
using System.Reflection;
using System.Security.Claims;
using System.Threading.Tasks;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Models.Entities;
using Umbraco.Core.Models.Membership;
@@ -66,7 +67,7 @@ namespace Umbraco.Core.Models.Identity
_startContentIds = new int[] { };
_groups = new IReadOnlyUserGroup[] { };
_allowedSections = new string[] { };
_culture = UmbracoConfig.For.GlobalSettings().DefaultUILanguage; //fixme inject somehow?
_culture = Current.Configs.Global().DefaultUILanguage; //fixme inject somehow?
_groups = new IReadOnlyUserGroup[0];
_roles = new ObservableCollection<IdentityUserRole<string>>();
_roles.CollectionChanged += _roles_CollectionChanged;
@@ -83,7 +84,7 @@ namespace Umbraco.Core.Models.Identity
_startContentIds = new int[] { };
_groups = new IReadOnlyUserGroup[] { };
_allowedSections = new string[] { };
_culture = UmbracoConfig.For.GlobalSettings().DefaultUILanguage; //fixme inject somehow?
_culture = Current.Configs.Global().DefaultUILanguage; //fixme inject somehow?
_groups = groups.ToArray();
_roles = new ObservableCollection<IdentityUserRole<string>>(_groups.Select(x => new IdentityUserRole<string>
{
@@ -442,6 +443,6 @@ namespace Umbraco.Core.Models.Identity
groups => groups.GetHashCode());
}
}
}

View File

@@ -88,7 +88,7 @@ namespace Umbraco.Core.Models
try
{
var globalSettings = (IGlobalSettings) Composing.Current.Container.GetInstance(typeof(IGlobalSettings));
var globalSettings = (IGlobalSettings) Composing.Current.Factory.GetInstance(typeof(IGlobalSettings));
var defaultUiCulture = CultureInfo.GetCultureInfo(globalSettings.DefaultUILanguage);
Thread.CurrentThread.CurrentUICulture = defaultUiCulture;

View File

@@ -27,7 +27,7 @@ namespace Umbraco.Core.Models.Membership
{
SessionTimeout = 60;
_userGroups = new HashSet<IReadOnlyUserGroup>();
_language = UmbracoConfig.For.GlobalSettings().DefaultUILanguage; //fixme inject somehow?
_language = Current.Configs.Global().DefaultUILanguage; //fixme inject somehow?
_isApproved = true;
_isLockedOut = false;
_startContentIds = new int[] { };
@@ -453,7 +453,7 @@ namespace Umbraco.Core.Models.Membership
base.PerformDeepClone(clone);
var clonedEntity = (User)clone;
//manually clone the start node props
clonedEntity._startContentIds = _startContentIds.ToArray();
clonedEntity._startMediaIds = _startMediaIds.ToArray();
@@ -483,7 +483,7 @@ namespace Umbraco.Core.Models.Membership
//need to create new collections otherwise they'll get copied by ref
clonedEntity._userGroups = new HashSet<IReadOnlyUserGroup>(_userGroups);
clonedEntity._allowedSections = _allowedSections != null ? new List<string>(_allowedSections) : null;
}
/// <summary>

View File

@@ -62,7 +62,7 @@ namespace Umbraco.Core.Models.PublishedContent
/// <summary>
/// Gets the identifier of the template to use to render the content item.
/// </summary>
int TemplateId { get; }
int? TemplateId { get; }
/// <summary>
/// Gets the identifier of the user who created the content item.

View File

@@ -21,7 +21,7 @@ namespace Umbraco.Core.Models.PublishedContent
// in order to provide a nice, "fluent" experience, this extension method
// needs to access Current, which is not always initialized in tests - not
// very elegant, but works
if (!Current.HasContainer) return content;
if (!Current.HasFactory) return content;
// get model
// if factory returns nothing, throw

View File

@@ -73,7 +73,7 @@ namespace Umbraco.Core.Models.PublishedContent
public virtual string Path => _content.Path;
/// <inheritdoc />
public virtual int TemplateId => _content.TemplateId;
public virtual int? TemplateId => _content.TemplateId;
/// <inheritdoc />
public virtual int CreatorId => _content.CreatorId;

View File

@@ -112,7 +112,7 @@ namespace Umbraco.Core.Models.PublishedContent
if (ctor != null) return ctor();
var listType = typeof(List<>).MakeGenericType(modelInfo.ModelType);
ctor = modelInfo.ListCtor = ReflectionUtilities.EmitConstuctor<Func<IList>>(declaring: listType);
ctor = modelInfo.ListCtor = ReflectionUtilities.EmitConstructor<Func<IList>>(declaring: listType);
return ctor();
}

View File

@@ -28,12 +28,14 @@ namespace Umbraco.Core.Models
public readonly PropertyInfo ContentIdSelector = ExpressionHelper.GetPropertyInfo<RedirectUrl, int>(x => x.ContentId);
public readonly PropertyInfo ContentKeySelector = ExpressionHelper.GetPropertyInfo<RedirectUrl, Guid>(x => x.ContentKey);
public readonly PropertyInfo CreateDateUtcSelector = ExpressionHelper.GetPropertyInfo<RedirectUrl, DateTime>(x => x.CreateDateUtc);
public readonly PropertyInfo CultureSelector = ExpressionHelper.GetPropertyInfo<RedirectUrl, string>(x => x.Culture);
public readonly PropertyInfo UrlSelector = ExpressionHelper.GetPropertyInfo<RedirectUrl, string>(x => x.Url);
}
private int _contentId;
private Guid _contentKey;
private DateTime _createDateUtc;
private string _culture;
private string _url;
/// <inheritdoc />
@@ -57,6 +59,13 @@ namespace Umbraco.Core.Models
set { SetPropertyValueAndDetectChanges(value, ref _createDateUtc, Ps.Value.CreateDateUtcSelector); }
}
/// <inheritdoc />
public string Culture
{
get { return _culture; }
set { SetPropertyValueAndDetectChanges(value, ref _culture, Ps.Value.CultureSelector); }
}
/// <inheritdoc />
public string Url
{

View File

@@ -105,7 +105,7 @@ namespace Umbraco.Core.Models
}
//use the custom avatar
var avatarUrl = Current.FileSystems.MediaFileSystem.GetUrl(user.Avatar);
var avatarUrl = Current.MediaFileSystem.GetUrl(user.Avatar);
return new[]
{
avatarUrl + "?width=30&height=30&mode=crop",