This commit is contained in:
Søren Gregersen
2019-11-18 19:46:32 +01:00
296 changed files with 4044 additions and 3630 deletions
@@ -47,8 +47,7 @@ namespace Umbraco.Core.Collections
var newList = new DeepCloneableList<T>(ListCloneBehavior.None);
foreach (var item in this)
{
var dc = item as IDeepCloneable;
if (dc != null)
if (item is IDeepCloneable dc)
{
newList.Add((T)dc.DeepClone());
}
@@ -66,8 +65,7 @@ namespace Umbraco.Core.Collections
var newList2 = new DeepCloneableList<T>(ListCloneBehavior.Always);
foreach (var item in this)
{
var dc = item as IDeepCloneable;
if (dc != null)
if (item is IDeepCloneable dc)
{
newList2.Add((T)dc.DeepClone());
}
@@ -121,6 +119,16 @@ namespace Umbraco.Core.Collections
}
}
public void DisableChangeTracking()
{
// noop
}
public void EnableChangeTracking()
{
// noop
}
public void ResetWereDirtyProperties()
{
foreach (var dc in this.OfType<IRememberBeingDirty>())
@@ -1,7 +1,7 @@
namespace Umbraco.Core.Configuration
{
/// <summary>
/// Contains general settings information for the entire Umbraco instance based on information from web.config appsettings
/// Contains general settings information for the entire Umbraco instance based on information from web.config appsettings
/// </summary>
public interface IGlobalSettings
{
@@ -21,7 +21,7 @@
/// Gets the path to umbraco's root directory (/umbraco by default).
/// </summary>
string Path { get; }
/// <summary>
/// Gets or sets the configuration status. This will return the version number of the currently installed umbraco instance.
/// </summary>
@@ -67,5 +67,10 @@
/// Gets the location of temporary files.
/// </summary>
string LocalTempPath { get; }
string UmbracoPath { get; }
string UmbracoCssPath { get; }
string UmbracoScriptsPath { get; }
string UmbracoMediaPath { get; }
}
}
@@ -46,6 +46,26 @@ namespace Umbraco.Core
/// </summary>
public const string ReservedUrls = "Umbraco.Core.ReservedUrls";
/// <summary>
/// The path of backoffice.
/// </summary>
public const string UmbracoPath = "umbracoPath";
/// <summary>
/// The path of the stylesheet folder.
/// </summary>
public const string UmbracoCssPath = "umbracoCssPath";
/// <summary>
/// The path of script folder.
/// </summary>
public const string UmbracoScriptsPath = "umbracoScriptsPath";
/// <summary>
/// The path of media folder.
/// </summary>
public const string UmbracoMediaPath = "umbracoMediaPath";
/// <summary>
/// The reserved paths from web.config
/// </summary>
@@ -0,0 +1,36 @@
namespace Umbraco.Core
{
public static partial class Constants
{
public static class SystemDirectories
{
public const string Bin = "~/bin";
public const string Config = "~/config";
public const string Data = "~/App_Data";
public const string TempData = Data + "/TEMP";
public const string TempFileUploads = TempData + "/FileUploads";
public const string TempImageUploads = TempFileUploads + "/rte";
public const string Install = "~/install";
public const string AppCode = "~/App_Code";
public const string AppPlugins = "~/App_Plugins";
public const string MvcViews = "~/Views";
public const string PartialViews = MvcViews + "/Partials/";
public const string MacroPartials = MvcViews + "/MacroPartials/";
public const string Packages = Data + "/packages";
public const string Preview = Data + "/preview";
}
}
}
+10 -3
View File
@@ -5,7 +5,7 @@ namespace Umbraco.Core.IO
public interface IIOHelper
{
bool ForceNotHosted { get; set; }
/// <summary>
/// Gets a value indicating whether Umbraco is hosted.
/// </summary>
@@ -18,8 +18,6 @@ namespace Umbraco.Core.IO
Attempt<string> TryResolveUrl(string virtualPath);
string MapPath(string path, bool useHttpContext);
string MapPath(string path);
string ReturnPath(string settingsKey, string standardPath, bool useTilde);
string ReturnPath(string settingsKey, string standardPath);
/// <summary>
/// Verifies that the current filepath matches a directory where the user is allowed to edit a file.
@@ -80,5 +78,14 @@ namespace Umbraco.Core.IO
/// <param name="path"></param>
/// <returns></returns>
string GetRelativePath(string path);
/// <summary>
/// Gets the root path of the application
/// </summary>
string Root
{
get;
set; //Only required for unit tests
}
}
}
@@ -1,5 +1,6 @@
using System.Collections.Generic;
namespace Umbraco.Core.Manifest
{
/// <summary>
@@ -0,0 +1,23 @@
using System.Collections.Generic;
using Umbraco.Core.PropertyEditors;
namespace Umbraco.Core.Manifest
{
public interface IManifestParser
{
string Path { get; set; }
/// <summary>
/// Gets all manifests, merged into a single manifest object.
/// </summary>
/// <returns></returns>
PackageManifest Manifest { get; }
/// <summary>
/// Parses a manifest.
/// </summary>
PackageManifest ParseManifest(string text);
IEnumerable<GridEditor> ParseGridEditors(string text);
}
}
@@ -1,7 +1,5 @@
using System;
using System.Runtime.Serialization;
using Umbraco.Core.Composing;
using Umbraco.Core.IO;
namespace Umbraco.Core.Manifest
{
@@ -65,11 +63,7 @@ namespace Umbraco.Core.Manifest
/// Gets or sets the view for rendering the content app.
/// </summary>
[DataMember(Name = "view")]
public string View
{
get => _view;
set => _view = Current.IOHelper.ResolveVirtualUrl(value);
}
public string View { get; set; }
/// <summary>
/// Gets or sets the list of 'show' conditions for the content app.
@@ -0,0 +1,26 @@
using System;
using System.ComponentModel;
using System.Runtime.Serialization;
using Umbraco.Core.Dashboards;
namespace Umbraco.Core.Manifest
{
[DataContract]
public class ManifestDashboard : IDashboard
{
[DataMember(Name = "alias", IsRequired = true)]
public string Alias { get; set; }
[DataMember(Name = "weight")]
public int Weight { get; set; } = 100;
[DataMember(Name = "view", IsRequired = true)]
public string View { get; set; }
[DataMember(Name = "sections")]
public string[] Sections { get; set; } = Array.Empty<string>();
[DataMember(Name = "access")]
public IAccessRule[] AccessRules { get; set; } = Array.Empty<IAccessRule>();
}
}
@@ -1,70 +1,71 @@
using System;
using Newtonsoft.Json;
using Umbraco.Core.PropertyEditors;
namespace Umbraco.Core.Manifest
{
/// <summary>
/// Represents the content of a package manifest.
/// </summary>
public class PackageManifest
{
/// <summary>
/// Gets the source path of the manifest.
/// </summary>
/// <remarks>
/// <para>Gets the full absolute file path of the manifest,
/// using system directory separators.</para>
/// </remarks>
[JsonIgnore]
public string Source { get; set; }
/// <summary>
/// Gets or sets the scripts listed in the manifest.
/// </summary>
[JsonProperty("javascript")]
public string[] Scripts { get; set; } = Array.Empty<string>();
/// <summary>
/// Gets or sets the stylesheets listed in the manifest.
/// </summary>
[JsonProperty("css")]
public string[] Stylesheets { get; set; } = Array.Empty<string>();
/// <summary>
/// Gets or sets the property editors listed in the manifest.
/// </summary>
[JsonProperty("propertyEditors")]
public IDataEditor[] PropertyEditors { get; set; } = Array.Empty<IDataEditor>();
/// <summary>
/// Gets or sets the parameter editors listed in the manifest.
/// </summary>
[JsonProperty("parameterEditors")]
public IDataEditor[] ParameterEditors { get; set; } = Array.Empty<IDataEditor>();
/// <summary>
/// Gets or sets the grid editors listed in the manifest.
/// </summary>
[JsonProperty("gridEditors")]
public GridEditor[] GridEditors { get; set; } = Array.Empty<GridEditor>();
/// <summary>
/// Gets or sets the content apps listed in the manifest.
/// </summary>
[JsonProperty("contentApps")]
public ManifestContentAppDefinition[] ContentApps { get; set; } = Array.Empty<ManifestContentAppDefinition>();
/// <summary>
/// Gets or sets the dashboards listed in the manifest.
/// </summary>
[JsonProperty("dashboards")]
public ManifestDashboard[] Dashboards { get; set; } = Array.Empty<ManifestDashboard>();
/// <summary>
/// Gets or sets the sections listed in the manifest.
/// </summary>
[JsonProperty("sections")]
public ManifestSection[] Sections { get; set; } = Array.Empty<ManifestSection>();
}
}
using System;
using System.Runtime.Serialization;
using Umbraco.Core.PropertyEditors;
namespace Umbraco.Core.Manifest
{
/// <summary>
/// Represents the content of a package manifest.
/// </summary>
[DataContract]
public class PackageManifest
{
/// <summary>
/// Gets the source path of the manifest.
/// </summary>
/// <remarks>
/// <para>Gets the full absolute file path of the manifest,
/// using system directory separators.</para>
/// </remarks>
[IgnoreDataMember]
public string Source { get; set; }
/// <summary>
/// Gets or sets the scripts listed in the manifest.
/// </summary>
[DataMember(Name = "javascript")]
public string[] Scripts { get; set; } = Array.Empty<string>();
/// <summary>
/// Gets or sets the stylesheets listed in the manifest.
/// </summary>
[DataMember(Name = "css")]
public string[] Stylesheets { get; set; } = Array.Empty<string>();
/// <summary>
/// Gets or sets the property editors listed in the manifest.
/// </summary>
[DataMember(Name = "propertyEditors")]
public IDataEditor[] PropertyEditors { get; set; } = Array.Empty<IDataEditor>();
/// <summary>
/// Gets or sets the parameter editors listed in the manifest.
/// </summary>
[DataMember(Name = "parameterEditors")]
public IDataEditor[] ParameterEditors { get; set; } = Array.Empty<IDataEditor>();
/// <summary>
/// Gets or sets the grid editors listed in the manifest.
/// </summary>
[DataMember(Name = "gridEditors")]
public GridEditor[] GridEditors { get; set; } = Array.Empty<GridEditor>();
/// <summary>
/// Gets or sets the content apps listed in the manifest.
/// </summary>
[DataMember(Name = "contentApps")]
public ManifestContentAppDefinition[] ContentApps { get; set; } = Array.Empty<ManifestContentAppDefinition>();
/// <summary>
/// Gets or sets the dashboards listed in the manifest.
/// </summary>
[DataMember(Name = "dashboards")]
public ManifestDashboard[] Dashboards { get; set; } = Array.Empty<ManifestDashboard>();
/// <summary>
/// Gets or sets the sections listed in the manifest.
/// </summary>
[DataMember(Name = "sections")]
public ManifestSection[] Sections { get; set; } = Array.Empty<ManifestSection>();
}
}
@@ -1,9 +1,7 @@
namespace Umbraco.Core.Models.ContentEditing
using System.Runtime.Serialization;
namespace Umbraco.Core.Models.ContentEditing
{
using System.Runtime.Serialization;
using Umbraco.Core.Events;
/// <summary>
/// Represents a content app badge
/// </summary>
@@ -0,0 +1,25 @@
using System.Runtime.Serialization;
namespace Umbraco.Core.Models.ContentEditing
{
// TODO: This was marked with `[StringEnumConverter]` to inform the serializer
// to serialize the values to string instead of INT (which is the default)
// so we need to either invent our own attribute and make the implementation aware of it
// or ... something else?
/// <summary>
/// Represent the content app badge types
/// </summary>
[DataContract(Name = "contentAppBadgeType")]
public enum ContentAppBadgeType
{
[EnumMember(Value = "default")]
Default = 0,
[EnumMember(Value = "warning")]
Warning = 1,
[EnumMember(Value = "alert")]
Alert = 2
}
}
@@ -36,7 +36,7 @@ namespace Umbraco.Core.Models
/// Gets the unique identifier of the document targeted by the scheduled action.
/// </summary>
[DataMember]
public Guid Id { get; internal set; }
public Guid Id { get; set; }
/// <summary>
/// Gets the culture of the scheduled action.
@@ -11,7 +11,7 @@ namespace Umbraco.Core.Models
[DataContract(IsReference = true)]
public class DictionaryTranslation : EntityBase, IDictionaryTranslation
{
internal Func<int, ILanguage> GetLanguage { get; set; }
public Func<int, ILanguage> GetLanguage { get; set; }
private ILanguage _language;
private string _value;
@@ -35,13 +35,13 @@ namespace Umbraco.Core.Models
Key = uniqueId;
}
internal DictionaryTranslation(int languageId, string value)
public DictionaryTranslation(int languageId, string value)
{
_languageId = languageId;
_value = value;
}
internal DictionaryTranslation(int languageId, string value, Guid uniqueId)
public DictionaryTranslation(int languageId, string value, Guid uniqueId)
{
_languageId = languageId;
_value = value;
@@ -80,37 +80,7 @@ namespace Umbraco.Core.Models.Entities
_id = default;
_key = Guid.Empty;
_hasIdentity = false;
}
/// <summary>
/// Updates the entity when it is being saved for the first time.
/// </summary>
internal virtual void AddingEntity()
{
var now = DateTime.Now;
// set the create and update dates, if not already set
if (IsPropertyDirty("CreateDate") == false || _createDate == default)
CreateDate = now;
if (IsPropertyDirty("UpdateDate") == false || _updateDate == default)
UpdateDate = now;
}
/// <summary>
/// Updates the entity when it is being saved.
/// </summary>
internal virtual void UpdatingEntity()
{
var now = DateTime.Now;
// just in case
if (_createDate == default)
CreateDate = now;
// set the update date if not already set
if (IsPropertyDirty("UpdateDate") == false || _updateDate == default)
UpdateDate = now;
}
}
public virtual bool Equals(EntityBase other)
{
@@ -2,12 +2,12 @@
namespace Umbraco.Core.Models.Entities
{
internal static class EntityExtensions
public static class EntityExtensions
{
/// <summary>
/// Updates the entity when it is being saved.
/// </summary>
internal static void UpdatingEntity(this IEntity entity)
public static void UpdatingEntity(this IEntity entity)
{
var now = DateTime.Now;
@@ -27,7 +27,7 @@ namespace Umbraco.Core.Models.Entities
/// <summary>
/// Updates the entity when it is being saved for the first time.
/// </summary>
internal static void AddingEntity(this IEntity entity)
public static void AddingEntity(this IEntity entity)
{
var now = DateTime.Now;
var canBeDirty = entity as ICanBeDirty;
@@ -146,6 +146,16 @@ namespace Umbraco.Core.Models.Entities
throw new WontImplementException();
}
public void DisableChangeTracking()
{
// noop
}
public void EnableChangeTracking()
{
// noop
}
public bool WasDirty()
{
throw new WontImplementException();
@@ -26,5 +26,15 @@ namespace Umbraco.Core.Models.Entities
/// Resets dirty properties.
/// </summary>
void ResetDirtyProperties();
/// <summary>
/// Disables change tracking.
/// </summary>
void DisableChangeTracking();
/// <summary>
/// Enables change tracking.
/// </summary>
void EnableChangeTracking();
}
}
@@ -98,7 +98,7 @@ namespace Umbraco.Core.Models
/// List of properties, which make up all the data available for this Content object
/// </summary>
/// <remarks>Properties are loaded as part of the Content object graph</remarks>
PropertyCollection Properties { get; set; }
IPropertyCollection Properties { get; set; }
/// <summary>
/// Gets a value indicating whether the content entity has a property with the supplied alias.
@@ -3,7 +3,6 @@ using System.ComponentModel.DataAnnotations;
using System.Xml.Linq;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Editors;
using Umbraco.Core.Services;
namespace Umbraco.Core.PropertyEditors
{
@@ -59,12 +58,12 @@ namespace Umbraco.Core.PropertyEditors
/// <summary>
/// Converts a property value to a value for the editor.
/// </summary>
object ToEditor(Property property, IDataTypeService dataTypeService, string culture = null, string segment = null);
object ToEditor(IProperty property, string culture = null, string segment = null);
// TODO: / deal with this when unplugging the xml cache
// why property vs propertyType? services should be injected! etc...
IEnumerable<XElement> ConvertDbToXml(Property property, IDataTypeService dataTypeService, ILocalizationService localizationService, bool published);
XNode ConvertDbToXml(PropertyType propertyType, object value, IDataTypeService dataTypeService);
string ConvertDbToString(PropertyType propertyType, object value, IDataTypeService dataTypeService);
IEnumerable<XElement> ConvertDbToXml(IProperty property, bool published);
XNode ConvertDbToXml(IPropertyType propertyType, object value);
string ConvertDbToString(IPropertyType propertyType, object value);
}
}
@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using Umbraco.Core.Models.Entities;
namespace Umbraco.Core.Models
{
public interface IProperty : IEntity, IRememberBeingDirty
{
ValueStorageType ValueStorageType { get; }
/// <summary>
/// Returns the PropertyType, which this Property is based on
/// </summary>
IPropertyType PropertyType { get; }
/// <summary>
/// Gets the list of values.
/// </summary>
IReadOnlyCollection<IPropertyValue> Values { get; set; }
/// <summary>
/// Returns the Alias of the PropertyType, which this Property is based on
/// </summary>
string Alias { get; }
/// <summary>
/// Gets the value.
/// </summary>
object GetValue(string culture = null, string segment = null, bool published = false);
/// <summary>
/// Sets a value.
/// </summary>
void SetValue(object value, string culture = null, string segment = null);
/// <summary>
/// Resets the entity identity.
/// </summary>
void ResetIdentity();
int PropertyTypeId { get; }
void PublishValues(string culture = "*", string segment = "*");
void UnpublishValues(string culture = "*", string segment = "*");
}
}
@@ -0,0 +1,38 @@
using System.Collections.Generic;
using System.Collections.Specialized;
namespace Umbraco.Core.Models
{
public interface IPropertyCollection : IEnumerable<IProperty>, IDeepCloneable, INotifyCollectionChanged
{
bool TryGetValue(string propertyTypeAlias, out IProperty property);
bool Contains(string key);
/// <summary>
/// Ensures that the collection contains properties for the specified property types.
/// </summary>
void EnsurePropertyTypes(IEnumerable<IPropertyType> propertyTypes);
/// <summary>
/// Ensures that the collection does not contain properties not in the specified property types.
/// </summary>
void EnsureCleanPropertyTypes(IEnumerable<IPropertyType> propertyTypes);
/// <summary>
/// Gets the property with the specified alias.
/// </summary>
IProperty this[string name] { get; }
/// <summary>
/// Gets the property at the specified index.
/// </summary>
IProperty this[int index] { get; }
/// <summary>
/// Adds or updates a property.
/// </summary>
void Add(IProperty property);
int Count { get; }
}
}
@@ -0,0 +1,87 @@
using System;
using System.Runtime.Serialization;
using Umbraco.Core.Models.Entities;
namespace Umbraco.Core.Models
{
public interface IPropertyType : IEntity, IRememberBeingDirty
{
/// <summary>
/// Gets of sets the name of the property type.
/// </summary>
string Name { get; }
/// <summary>
/// Gets of sets the alias of the property type.
/// </summary>
string Alias { get; }
/// <summary>
/// Gets of sets the description of the property type.
/// </summary>
string Description { get; }
/// <summary>
/// Gets or sets the identifier of the datatype for this property type.
/// </summary>
int DataTypeId { get; }
Guid DataTypeKey { get; }
/// <summary>
/// Gets or sets the alias of the property editor for this property type.
/// </summary>
string PropertyEditorAlias { get; }
/// <summary>
/// Gets or sets the database type for storing value for this property type.
/// </summary>
ValueStorageType ValueStorageType { get; }
/// <summary>
/// Gets or sets the identifier of the property group this property type belongs to.
/// </summary>
/// <remarks>For generic properties, the value is <c>null</c>.</remarks>
Lazy<int> PropertyGroupId { get; }
/// <summary>
/// Gets of sets a value indicating whether a value for this property type is required.
/// </summary>
bool Mandatory { get; }
/// <summary>
/// Gets of sets the sort order of the property type.
/// </summary>
int SortOrder { get; }
/// <summary>
/// Gets or sets the regular expression validating the property values.
/// </summary>
string ValidationRegExp { get; }
bool SupportsPublishing { get; }
/// <summary>
/// Gets or sets the content variation of the property type.
/// </summary>
ContentVariation Variations { get; }
/// <summary>
/// Determines whether the property type supports a combination of culture and segment.
/// </summary>
/// <param name="culture">The culture.</param>
/// <param name="segment">The segment.</param>
/// <param name="wildcards">A value indicating whether wildcards are valid.</param>
bool SupportsVariation(string culture, string segment, bool wildcards = false);
/// <summary>
/// Converts a value assigned to a property.
/// </summary>
/// <remarks>
/// <para>The input value can be pretty much anything, and is converted to the actual CLR type
/// expected by the property (eg an integer if the property values are integers).</para>
/// <para>Throws if the value cannot be converted.</para>
/// </remarks>
object ConvertAssignedValue(object value);
}
}
@@ -0,0 +1,34 @@
namespace Umbraco.Core.Models
{
public interface IPropertyValue
{
/// <summary>
/// Gets or sets the culture of the property.
/// </summary>
/// <remarks>The culture is either null (invariant) or a non-empty string. If the property is
/// set with an empty or whitespace value, its value is converted to null.</remarks>
string Culture { get; set; }
/// <summary>
/// Gets or sets the segment of the property.
/// </summary>
/// <remarks>The segment is either null (neutral) or a non-empty string. If the property is
/// set with an empty or whitespace value, its value is converted to null.</remarks>
string Segment { get; set; }
/// <summary>
/// Gets or sets the edited value of the property.
/// </summary>
object EditedValue { get; set; }
/// <summary>
/// Gets or sets the published value of the property.
/// </summary>
object PublishedValue { get; set; }
/// <summary>
/// Clones the property value.
/// </summary>
IPropertyValue Clone();
}
}
@@ -41,7 +41,7 @@ namespace Umbraco.Core.Models
/// <param name="name"></param>
/// <param name="sortOrder"></param>
/// <param name="editorAlias"></param>
internal MacroProperty(int id, Guid key, string @alias, string name, int sortOrder, string editorAlias)
public MacroProperty(int id, Guid key, string @alias, string name, int sortOrder, string editorAlias)
{
_id = id;
_alias = alias;
@@ -3,7 +3,7 @@
/// <summary>
/// Used to track the property types that are visible/editable on member profiles
/// </summary>
internal class MemberTypePropertyProfileAccess
public class MemberTypePropertyProfileAccess
{
public MemberTypePropertyProfileAccess(bool isVisible, bool isEditable, bool isSenstive)
{
@@ -6,6 +6,8 @@
/// </summary>
public enum MembershipScenario
{
//TODO: This will become obsolete when we get asp.net identity members in place
/// <summary>
/// The member is based on the native Umbraco members (IMember + Umbraco membership provider)
/// </summary>
@@ -77,7 +77,7 @@ namespace Umbraco.Core.Models
}
}
internal IEnumerable<Guid> RemovedRules => _removedRules;
public IEnumerable<Guid> RemovedRules => _removedRules;
public IEnumerable<PublicAccessRule> Rules => _ruleCollection;
@@ -7,7 +7,7 @@ namespace Umbraco.Core.Models.PublishedContent
/// Provides a base class for <c>IPublishedProperty</c> implementations which converts and caches
/// the value source to the actual value to use when rendering content.
/// </summary>
internal abstract class PublishedPropertyBase : IPublishedProperty
public abstract class PublishedPropertyBase : IPublishedProperty
{
/// <summary>
/// Initializes a new instance of the <see cref="PublishedPropertyBase"/> class.
@@ -14,7 +14,7 @@ namespace Umbraco.Core.Models.PublishedContent
/// <para>Does not support variations: the ctor throws if the property type
/// supports variations.</para>
/// </remarks>
internal class RawValueProperty : PublishedPropertyBase
public class RawValueProperty : PublishedPropertyBase
{
private readonly object _sourceValue; //the value in the db
private readonly Lazy<object> _objectValue;
@@ -49,6 +49,6 @@ namespace Umbraco.Core.Models
/// <summary>
/// Readonly value of the language ISO code for the domain
/// </summary>
public string LanguageIsoCode { get; internal set; }
public string LanguageIsoCode { get; set; }
}
}
@@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using Umbraco.Core.Configuration;
using Umbraco.Core.Models.Membership;
using Umbraco.Core.Services;
namespace Umbraco.Core.Models
{
public static class UmbracoUserExtensions
{
public static IEnumerable<string> GetPermissions(this IUser user, string path, IUserService userService)
{
return userService.GetPermissionsForPath(user, path).GetAllPermissions();
}
public static bool HasSectionAccess(this IUser user, string app)
{
var apps = user.AllowedSections;
return apps.Any(uApp => uApp.InvariantEquals(app));
}
/// <summary>
/// Determines whether this user is the 'super' user.
/// </summary>
public static bool IsSuper(this IUser user)
{
if (user == null) throw new ArgumentNullException(nameof(user));
return user.Id == Constants.Security.SuperUserId;
}
/// <summary>
/// Determines whether this user belongs to the administrators group.
/// </summary>
/// <remarks>The 'super' user does not automatically belongs to the administrators group.</remarks>
public static bool IsAdmin(this IUser user)
{
if (user == null) throw new ArgumentNullException(nameof(user));
return user.Groups != null && user.Groups.Any(x => x.Alias == Constants.Security.AdminGroupAlias);
}
/// <summary>
/// Returns the culture info associated with this user, based on the language they're assigned to in the back office
/// </summary>
/// <param name="user"></param>
/// <param name="textService"></param>
/// <param name="globalSettings"></param>
/// <returns></returns>
public static CultureInfo GetUserCulture(this IUser user, ILocalizedTextService textService, IGlobalSettings globalSettings)
{
if (user == null) throw new ArgumentNullException(nameof(user));
if (textService == null) throw new ArgumentNullException(nameof(textService));
return GetUserCulture(user.Language, textService, globalSettings);
}
public static CultureInfo GetUserCulture(string userLanguage, ILocalizedTextService textService, IGlobalSettings globalSettings)
{
try
{
var culture = CultureInfo.GetCultureInfo(userLanguage.Replace("_", "-"));
// TODO: This is a hack because we store the user language as 2 chars instead of the full culture
// which is actually stored in the language files (which are also named with 2 chars!) so we need to attempt
// to convert to a supported full culture
var result = textService.ConvertToSupportedCultureWithRegionCode(culture);
return result;
}
catch (CultureNotFoundException)
{
//return the default one
return CultureInfo.GetCultureInfo(globalSettings.DefaultUILanguage);
}
}
}
}
@@ -19,7 +19,7 @@ namespace Umbraco.Core.Models.Validation
/// <summary>
/// Determines whether an object has all required values for persistence.
/// </summary>
internal static bool HasRequiredValuesForPersistence(object model)
public static bool HasRequiredValuesForPersistence(object model)
{
return model.GetType().GetProperties().All(x =>
{
@@ -2,7 +2,7 @@
namespace Umbraco.Core.PackageActions
{
internal class PackageActionCollectionBuilder : LazyCollectionBuilderBase<PackageActionCollectionBuilder, PackageActionCollection, IPackageAction>
public class PackageActionCollectionBuilder : LazyCollectionBuilderBase<PackageActionCollectionBuilder, PackageActionCollection, IPackageAction>
{
protected override PackageActionCollectionBuilder This => this;
}
@@ -7,7 +7,7 @@ using Umbraco.Core.Services;
namespace Umbraco.Core.Packaging
{
internal class ConflictingPackageData
public class ConflictingPackageData
{
private readonly IMacroService _macroService;
private readonly IFileService _fileService;
@@ -9,7 +9,7 @@ namespace Umbraco.Core.Packaging
/// <summary>
/// Package actions are executed on package install / uninstall.
/// </summary>
internal class PackageActionRunner : IPackageActionRunner
public class PackageActionRunner : IPackageActionRunner
{
private readonly ILogger _logger;
private readonly PackageActionCollection _packageActions;
@@ -6,7 +6,7 @@ using System.IO.Compression;
namespace Umbraco.Core.Packaging
{
internal class PackageExtraction
public class PackageExtraction
{
public string ReadTextFileFromArchive(FileInfo packageFile, string fileToRead, out string directoryInPackage)
{
@@ -1,15 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using Umbraco.Core.Composing;
using Umbraco.Core.IO;
using System.Reflection;
using System.Runtime.Serialization;
namespace Umbraco.Core.PropertyEditors
{
/// <summary>
/// Represents a datatype configuration field for editing.
/// </summary>
[DataContract]
public class ConfigurationField
{
private string _view;
@@ -50,37 +50,35 @@ namespace Umbraco.Core.PropertyEditors
/// <summary>
/// Gets or sets the key of the field.
/// </summary>
[JsonProperty("key", Required = Required.Always)]
[DataMember(Name = "key", IsRequired = true)]
public string Key { get; set; }
/// <summary>
/// Gets or sets the name of the field.
/// </summary>
[JsonProperty("label", Required = Required.Always)]
[DataMember(Name = "label", IsRequired = true)]
public string Name { get; set; }
/// <summary>
/// Gets or sets the property name of the field.
/// </summary>
[JsonIgnore]
public string PropertyName { get; set; }
/// <summary>
/// Gets or sets the property CLR type of the field.
/// </summary>
[JsonIgnore]
public Type PropertyType { get; set; }
/// <summary>
/// Gets or sets the description of the field.
/// </summary>
[JsonProperty("description")]
[DataMember(Name = "description")]
public string Description { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to hide the label of the field.
/// </summary>
[JsonProperty("hideLabel")]
[DataMember(Name = "hideLabel")]
public bool HideLabel { get; set; }
/// <summary>
@@ -90,23 +88,19 @@ namespace Umbraco.Core.PropertyEditors
/// <para>Can be the full virtual path, or the relative path to the Umbraco folder,
/// or a simple view name which will map to ~/Views/PreValueEditors/{view}.html.</para>
/// </remarks>
[JsonProperty("view", Required = Required.Always)]
public string View
{
get => _view;
set => _view = Current.Factory.GetInstance<IIOHelper>().ResolveVirtualUrl(value);
}
[DataMember(Name = "view", IsRequired = true)]
public string View { get; set; }
/// <summary>
/// Gets the validators of the field.
/// </summary>
[JsonProperty("validation")]
[DataMember(Name = "validation")]
public List<IValueValidator> Validators { get; }
/// <summary>
/// Gets or sets extra configuration properties for the editor.
/// </summary>
[JsonProperty("config")]
[DataMember(Name = "config")]
public IDictionary<string, object> Config { get; set; }
}
}
@@ -1,50 +1,38 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using Umbraco.Core.Composing;
using System.Runtime.Serialization;
using Umbraco.Core.Configuration.Grid;
using Umbraco.Core.IO;
namespace Umbraco.Core.PropertyEditors
{
[DataContract]
public class GridEditor : IGridEditorConfig
{
private readonly IIOHelper _ioHelper;
private string _view;
private string _render;
public GridEditor(IIOHelper ioHelper)
public GridEditor()
{
_ioHelper = ioHelper;
Config = new Dictionary<string, object>();
}
[JsonProperty("name", Required = Required.Always)]
[DataMember(Name = "name", IsRequired = true)]
public string Name { get; set; }
[JsonProperty("nameTemplate")]
[DataMember(Name = "nameTemplate")]
public string NameTemplate { get; set; }
[JsonProperty("alias", Required = Required.Always)]
[DataMember(Name = "alias", IsRequired = true)]
public string Alias { get; set; }
[JsonProperty("view", Required = Required.Always)]
public string View
{
get => _view;
set => _view = _ioHelper.ResolveVirtualUrl(value);
}
[DataMember(Name = "view", IsRequired = true)]
public string View{ get; set; }
[JsonProperty("render")]
public string Render
{
get => _render;
set => _render = _ioHelper.ResolveVirtualUrl(value);
}
[DataMember(Name = "render")]
public string Render { get; set; }
[JsonProperty("icon", Required = Required.Always)]
[DataMember(Name = "icon", IsRequired = true)]
public string Icon { get; set; }
[JsonProperty("config")]
[DataMember(Name = "config")]
public IDictionary<string, object> Config { get; set; }
protected bool Equals(GridEditor other)
@@ -19,6 +19,6 @@ namespace Umbraco.Core.PropertyEditors
/// values. By default, there would be only one object: the property value. But some implementations may return
/// more than one value for a given field.</para>
/// </remarks>
IEnumerable<KeyValuePair<string, IEnumerable<object>>> GetIndexValues(Property property, string culture, string segment, bool published);
IEnumerable<KeyValuePair<string, IEnumerable<object>>> GetIndexValues(IProperty property, string culture, string segment, bool published);
}
}
@@ -0,0 +1,9 @@
using Umbraco.Core.Composing;
namespace Umbraco.Core.PropertyEditors
{
public class ManifestValueValidatorCollectionBuilder : LazyCollectionBuilderBase<ManifestValueValidatorCollectionBuilder, ManifestValueValidatorCollection, IManifestValueValidator>
{
protected override ManifestValueValidatorCollectionBuilder This => this;
}
}
@@ -6,7 +6,7 @@ namespace Umbraco.Core.PropertyEditors.Validators
/// <summary>
/// A validator that validates that the value is a valid decimal
/// </summary>
internal sealed class DecimalValidator : IManifestValueValidator
public sealed class DecimalValidator : IManifestValueValidator
{
/// <inheritdoc />
public string ValidationName => "Decimal";
@@ -6,7 +6,7 @@ namespace Umbraco.Core.PropertyEditors.Validators
/// <summary>
/// A validator that validates an email address
/// </summary>
internal sealed class EmailValidator : IManifestValueValidator
public sealed class EmailValidator : IManifestValueValidator
{
/// <inheritdoc />
public string ValidationName => "Email";
@@ -6,7 +6,7 @@ namespace Umbraco.Core.PropertyEditors.Validators
/// <summary>
/// A validator that validates that the value is a valid integer
/// </summary>
internal sealed class IntegerValidator : IManifestValueValidator
public sealed class IntegerValidator : IManifestValueValidator
{
/// <inheritdoc />
public string ValidationName => "Integer";
@@ -19,7 +19,7 @@ namespace Umbraco.Core.Services
/// Adds or updates a translation for a dictionary item and language
/// </summary>
/// <param name="item"></param>
/// <param name="language"></param>
/// <param name="language"></param
/// <param name="value"></param>
/// <returns></returns>
void AddOrUpdateDictionaryValue(IDictionaryItem item, ILanguage language, string value);
@@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Membership;
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
using Umbraco.Core.Persistence.Querying;
namespace Umbraco.Core.Services
@@ -7,6 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.ComponentModel.Annotations" Version="4.6.0" />
<PackageReference Include="System.Runtime.Caching" Version="4.6.0" />
</ItemGroup>

Some files were not shown because too many files have changed in this diff Show More