Cleaned up config for Content settings

This commit is contained in:
Bjarke Berg
2020-03-12 15:30:22 +01:00
parent cb0994a929
commit c486444eda
73 changed files with 279 additions and 351 deletions
+2 -3
View File
@@ -27,8 +27,7 @@ namespace Umbraco.Core.Configuration
public ISecuritySettings SecuritySettings { get; } = new SecuritySettings();
public IUserPasswordConfiguration UserPasswordConfigurationSettings { get; } = new UserPasswordConfigurationSettings();
public IMemberPasswordConfiguration MemberPasswordConfigurationSettings { get; } = new MemberPasswordConfigurationSettings();
public IUmbracoSettingsSection UmbracoSettings { get; }
public IContentSettings ContentSettings { get; } = new ContentSettings();
public Configs Create(IIOHelper ioHelper)
{
@@ -36,7 +35,6 @@ namespace Umbraco.Core.Configuration
configs.Add<IGlobalSettings>(() => new GlobalSettings(ioHelper));
configs.Add(() => HostingSettings);
configs.Add<IUmbracoSettingsSection>("umbracoConfiguration/settings");
configs.Add<IHealthChecks>("umbracoConfiguration/HealthChecks");
configs.Add(() => CoreDebug);
@@ -60,6 +58,7 @@ namespace Umbraco.Core.Configuration
configs.Add<ISecuritySettings>(() => SecuritySettings);
configs.Add<IUserPasswordConfiguration>(() => UserPasswordConfigurationSettings);
configs.Add<IMemberPasswordConfiguration>(() => MemberPasswordConfigurationSettings);
configs.Add<IContentSettings>(() => ContentSettings);
configs.AddCoreConfigs(ioHelper);
return configs;
@@ -0,0 +1,22 @@
using System.Collections.Generic;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Macros;
namespace Umbraco.Configuration.Implementations
{
internal class ContentSettings : ConfigurationManagerConfigBase, IContentSettings
{
public string NotificationEmailAddress => UmbracoSettingsSection.Content.Notifications.NotificationEmailAddress;
public bool DisableHtmlEmail => UmbracoSettingsSection.Content.Notifications.DisableHtmlEmail;
public IEnumerable<string> ImageFileTypes => UmbracoSettingsSection.Content.Imaging.ImageFileTypes;
public IEnumerable<IImagingAutoFillUploadField> ImageAutoFillProperties => UmbracoSettingsSection.Content.Imaging.ImageAutoFillProperties;
public bool ResolveUrlsFromTextString => UmbracoSettingsSection.Content.ResolveUrlsFromTextString;
public IEnumerable<IContentErrorPage> Error404Collection => UmbracoSettingsSection.Content.Error404Collection;
public string PreviewBadge => UmbracoSettingsSection.Content.PreviewBadge;
public MacroErrorBehaviour MacroErrorBehaviour => UmbracoSettingsSection.Content.MacroErrors;
public IEnumerable<string> DisallowedUploadFiles => UmbracoSettingsSection.Content.DisallowedUploadFiles;
public IEnumerable<string> AllowedUploadFiles => UmbracoSettingsSection.Content.AllowedUploadFiles;
public bool ShowDeprecatedPropertyEditors => UmbracoSettingsSection.Content.ShowDeprecatedPropertyEditors;
public string LoginBackgroundImage => UmbracoSettingsSection.Content.LoginBackgroundImage;
}
}
@@ -4,7 +4,7 @@ using Umbraco.Core.Macros;
namespace Umbraco.Core.Configuration.UmbracoSettings
{
internal class ContentElement : UmbracoConfigurationElement, IContentSection
internal class ContentElement : UmbracoConfigurationElement, IContentSettings
{
private const string DefaultPreviewBadge = @"<div id=""umbracoPreviewBadge"" class=""umbraco-preview-badge""><span class=""umbraco-preview-badge__header"">Preview mode</span><a href=""{0}/preview/end?redir={1}"" class=""umbraco-preview-badge__end""><svg viewBox=""0 0 100 100"" xmlns=""http://www.w3.org/2000/svg""><title>Click to end</title><path d=""M5273.1 2400.1v-2c0-2.8-5-4-9.7-4s-9.7 1.3-9.7 4v2a7 7 0 002 4.9l5 4.9c.3.3.4.6.4 1v6.4c0 .4.2.7.6.8l2.9.9c.5.1 1-.2 1-.8v-7.2c0-.4.2-.7.4-1l5.1-5a7 7 0 002-4.9zm-9.7-.1c-4.8 0-7.4-1.3-7.5-1.8.1-.5 2.7-1.8 7.5-1.8s7.3 1.3 7.5 1.8c-.2.5-2.7 1.8-7.5 1.8z""/><path d=""M5268.4 2410.3c-.6 0-1 .4-1 1s.4 1 1 1h4.3c.6 0 1-.4 1-1s-.4-1-1-1h-4.3zM5272.7 2413.7h-4.3c-.6 0-1 .4-1 1s.4 1 1 1h4.3c.6 0 1-.4 1-1s-.4-1-1-1zM5272.7 2417h-4.3c-.6 0-1 .4-1 1s.4 1 1 1h4.3c.6 0 1-.4 1-1 0-.5-.4-1-1-1z""/><path d=""M78.2 13l-8.7 11.7a32.5 32.5 0 11-51.9 25.8c0-10.3 4.7-19.7 12.9-25.8L21.8 13a47 47 0 1056.4 0z""/><path d=""M42.7 2.5h14.6v49.4H42.7z""/></svg></a></div><style type=""text/css"">.umbraco-preview-badge {{position: absolute;top: 1em;right: 1em;display: inline-flex;background: #1b264f;color: #fff;padding: 1em;font-size: 12px;z-index: 99999999;justify-content: center;align-items: center;box-shadow: 0 10px 50px rgba(0, 0, 0, .1), 0 6px 20px rgba(0, 0, 0, .16);line-height: 1;}}.umbraco-preview-badge__header {{font-weight: bold;}}.umbraco-preview-badge__end {{width: 3em;padding: 1em;margin: -1em -1em -1em 2em;display: flex;flex-shrink: 0;align-items: center;align-self: stretch;}}.umbraco-preview-badge__end:hover,.umbraco-preview-badge__end:focus {{background: #f5c1bc;}}.umbraco-preview-badge__end svg {{fill: #fff;width:1em;}}</style>";
@@ -40,26 +40,26 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
[ConfigurationProperty("loginBackgroundImage")]
internal InnerTextConfigurationElement<string> LoginBackgroundImage => GetOptionalTextElement("loginBackgroundImage", string.Empty);
string IContentSection.NotificationEmailAddress => Notifications.NotificationEmailAddress;
string IContentSettings.NotificationEmailAddress => Notifications.NotificationEmailAddress;
bool IContentSection.DisableHtmlEmail => Notifications.DisableHtmlEmail;
bool IContentSettings.DisableHtmlEmail => Notifications.DisableHtmlEmail;
IEnumerable<string> IContentSection.ImageFileTypes => Imaging.ImageFileTypes;
IEnumerable<string> IContentSettings.ImageFileTypes => Imaging.ImageFileTypes;
IEnumerable<IImagingAutoFillUploadField> IContentSection.ImageAutoFillProperties => Imaging.ImageAutoFillProperties;
IEnumerable<IImagingAutoFillUploadField> IContentSettings.ImageAutoFillProperties => Imaging.ImageAutoFillProperties;
bool IContentSection.ResolveUrlsFromTextString => ResolveUrlsFromTextString;
bool IContentSettings.ResolveUrlsFromTextString => ResolveUrlsFromTextString;
string IContentSection.PreviewBadge => PreviewBadge;
string IContentSettings.PreviewBadge => PreviewBadge;
MacroErrorBehaviour IContentSection.MacroErrorBehaviour => MacroErrors;
MacroErrorBehaviour IContentSettings.MacroErrorBehaviour => MacroErrors;
IEnumerable<string> IContentSection.DisallowedUploadFiles => DisallowedUploadFiles;
IEnumerable<string> IContentSettings.DisallowedUploadFiles => DisallowedUploadFiles;
IEnumerable<string> IContentSection.AllowedUploadFiles => AllowedUploadFiles;
IEnumerable<string> IContentSettings.AllowedUploadFiles => AllowedUploadFiles;
bool IContentSection.ShowDeprecatedPropertyEditors => ShowDeprecatedPropertyEditors;
bool IContentSettings.ShowDeprecatedPropertyEditors => ShowDeprecatedPropertyEditors;
string IContentSection.LoginBackgroundImage => LoginBackgroundImage;
string IContentSettings.LoginBackgroundImage => LoginBackgroundImage;
}
}
@@ -2,7 +2,7 @@
namespace Umbraco.Core.Configuration.UmbracoSettings
{
internal class UmbracoSettingsSection : ConfigurationSection, IUmbracoSettingsSection
internal class UmbracoSettingsSection : ConfigurationSection
{
[ConfigurationProperty("backOffice")]
public BackOfficeElement BackOffice => (BackOfficeElement)this["backOffice"];
@@ -24,7 +24,5 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
[ConfigurationProperty("keepAlive")]
internal KeepAliveElement KeepAlive => (KeepAliveElement)this["keepAlive"];
IContentSection IUmbracoSettingsSection.Content => Content;
}
}
@@ -25,8 +25,8 @@ namespace Umbraco.Core
public static IConnectionStrings ConnectionStrings(this Configs configs)
=> configs.GetConfig<IConnectionStrings>();
public static IUmbracoSettingsSection Settings(this Configs configs)
=> configs.GetConfig<IUmbracoSettingsSection>();
public static IContentSettings Content(this Configs configs)
=> configs.GetConfig<IContentSettings>();
public static ISecuritySettings Security(this Configs configs)
=> configs.GetConfig<ISecuritySettings>();
@@ -11,7 +11,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
/// <param name="extension">The file extension.</param>
/// <param name="contentConfig"></param>
/// <returns>A value indicating whether the file extension corresponds to an image.</returns>
public static bool IsImageFile(this IContentSection contentConfig, string extension)
public static bool IsImageFile(this IContentSettings contentConfig, string extension)
{
if (contentConfig == null) throw new ArgumentNullException(nameof(contentConfig));
if (extension == null) return false;
@@ -24,22 +24,22 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
/// held in settings.
/// Allow upload if extension is whitelisted OR if there is no whitelist and extension is NOT blacklisted.
/// </summary>
public static bool IsFileAllowedForUpload(this IContentSection contentSection, string extension)
public static bool IsFileAllowedForUpload(this IContentSettings contentSettings, string extension)
{
return contentSection.AllowedUploadFiles.Any(x => x.InvariantEquals(extension)) ||
(contentSection.AllowedUploadFiles.Any() == false &&
contentSection.DisallowedUploadFiles.Any(x => x.InvariantEquals(extension)) == false);
return contentSettings.AllowedUploadFiles.Any(x => x.InvariantEquals(extension)) ||
(contentSettings.AllowedUploadFiles.Any() == false &&
contentSettings.DisallowedUploadFiles.Any(x => x.InvariantEquals(extension)) == false);
}
/// <summary>
/// Gets the auto-fill configuration for a specified property alias.
/// </summary>
/// <param name="contentSection"></param>
/// <param name="contentSettings"></param>
/// <param name="propertyTypeAlias">The property type alias.</param>
/// <returns>The auto-fill configuration for the specified property alias, or null.</returns>
public static IImagingAutoFillUploadField GetConfig(this IContentSection contentSection, string propertyTypeAlias)
public static IImagingAutoFillUploadField GetConfig(this IContentSettings contentSettings, string propertyTypeAlias)
{
var autoFillConfigs = contentSection.ImageAutoFillProperties;
var autoFillConfigs = contentSettings.ImageAutoFillProperties;
return autoFillConfigs?.FirstOrDefault(x => x.Alias == propertyTypeAlias);
}
}
@@ -3,7 +3,7 @@ using Umbraco.Core.Macros;
namespace Umbraco.Core.Configuration.UmbracoSettings
{
public interface IContentSection : IUmbracoConfigurationSection
public interface IContentSettings : IUmbracoConfigurationSection
{
string NotificationEmailAddress { get; }
@@ -1,9 +0,0 @@
using System;
namespace Umbraco.Core.Configuration.UmbracoSettings
{
public interface IUmbracoSettingsSection : IUmbracoConfigurationSection
{
IContentSection Content { get; }
}
}
+4 -4
View File
@@ -7,16 +7,16 @@ namespace Umbraco.Web.Templates
{
public sealed class HtmlUrlParser
{
private readonly IContentSection _contentSection;
private readonly IContentSettings _contentSettings;
private readonly IIOHelper _ioHelper;
private readonly IProfilingLogger _logger;
private static readonly Regex ResolveUrlPattern = new Regex("(=[\"\']?)(\\W?\\~(?:.(?![\"\']?\\s+(?:\\S+)=|[>\"\']))+.)[\"\']?",
RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
public HtmlUrlParser(IContentSection contentSection, IProfilingLogger logger, IIOHelper ioHelper)
public HtmlUrlParser(IContentSettings contentSettings, IProfilingLogger logger, IIOHelper ioHelper)
{
_contentSection = contentSection;
_contentSettings = contentSettings;
_ioHelper = ioHelper;
_logger = logger;
}
@@ -32,7 +32,7 @@ namespace Umbraco.Web.Templates
/// </remarks>
public string EnsureUrls(string text)
{
if (_contentSection.ResolveUrlsFromTextString == false) return text;
if (_contentSettings.ResolveUrlsFromTextString == false) return text;
using (var timer = _logger.DebugDuration(typeof(IOHelper), "ResolveUrlsFromTextString starting", "ResolveUrlsFromTextString complete"))
{
@@ -1,22 +0,0 @@
using Umbraco.Core.Configuration;
using Umbraco.Configuration;
using Umbraco.Core.Configuration.UmbracoSettings;
namespace Umbraco.Core.Composing.CompositionExtensions
{
/// <summary>
/// Compose configurations.
/// </summary>
internal static class Configuration
{
public static Composition ComposeConfiguration(this Composition composition)
{
// common configurations are already registered
// register others
composition.RegisterUnique(factory => factory.GetInstance<IUmbracoSettingsSection>().Content);
return composition;
}
}
}
@@ -18,9 +18,9 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods
private readonly IRuntimeState _runtimeState;
private readonly ILogger _logger;
private readonly IGlobalSettings _globalSettings;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
private readonly IContentSettings _contentSettings;
public EmailNotificationMethod(ILocalizedTextService textService, IRuntimeState runtimeState, ILogger logger, IGlobalSettings globalSettings, IHealthChecks healthChecks, IUmbracoSettingsSection umbracoSettingsSection) : base(healthChecks)
public EmailNotificationMethod(ILocalizedTextService textService, IRuntimeState runtimeState, ILogger logger, IGlobalSettings globalSettings, IHealthChecks healthChecks, IContentSettings contentSettings) : base(healthChecks)
{
var recipientEmail = Settings["recipientEmail"]?.Value;
if (string.IsNullOrWhiteSpace(recipientEmail))
@@ -35,7 +35,7 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods
_runtimeState = runtimeState;
_logger = logger;
_globalSettings = globalSettings;
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
_contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings));
}
public string RecipientEmail { get; }
@@ -74,7 +74,7 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods
private MailMessage CreateMailMessage(string subject, string message)
{
var to = _umbracoSettingsSection.Content.NotificationEmailAddress;
var to = _contentSettings.NotificationEmailAddress;
if (string.IsNullOrWhiteSpace(subject))
subject = "Umbraco Health Check Status";
@@ -17,13 +17,13 @@ namespace Umbraco.Web.Media
{
private readonly IMediaFileSystem _mediaFileSystem;
private readonly ILogger _logger;
private readonly IContentSection _contentSection;
private readonly IContentSettings _contentSettings;
public UploadAutoFillProperties(IMediaFileSystem mediaFileSystem, ILogger logger, IContentSection contentSection)
public UploadAutoFillProperties(IMediaFileSystem mediaFileSystem, ILogger logger, IContentSettings contentSettings)
{
_mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_contentSection = contentSection ?? throw new ArgumentNullException(nameof(contentSection));
_contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings));
}
/// <summary>
@@ -68,7 +68,7 @@ namespace Umbraco.Web.Media
using (var filestream = _mediaFileSystem.OpenFile(filepath))
{
var extension = (Path.GetExtension(filepath) ?? "").TrimStart('.');
var size = _contentSection.IsImageFile(extension) ? (Size?)ImageHelper.GetDimensions(filestream) : null;
var size = _contentSettings.IsImageFile(extension) ? (Size?)ImageHelper.GetDimensions(filestream) : null;
SetProperties(content, autoFillConfig, size, filestream.Length, extension, culture, segment);
}
}
@@ -102,7 +102,7 @@ namespace Umbraco.Web.Media
else
{
var extension = (Path.GetExtension(filepath) ?? "").TrimStart('.');
var size = _contentSection.IsImageFile(extension) ? (Size?)ImageHelper.GetDimensions(filestream) : null;
var size = _contentSettings.IsImageFile(extension) ? (Size?)ImageHelper.GetDimensions(filestream) : null;
SetProperties(content, autoFillConfig, size, filestream.Length, extension, culture, segment);
}
}
@@ -15,13 +15,13 @@ namespace Umbraco.Web.Models.Mapping
{
private readonly PropertyEditorCollection _propertyEditors;
private readonly ILogger _logger;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
private readonly IContentSettings _contentSettings;
public DataTypeMapDefinition(PropertyEditorCollection propertyEditors, ILogger logger, IUmbracoSettingsSection umbracoSettingsSection)
public DataTypeMapDefinition(PropertyEditorCollection propertyEditors, ILogger logger, IContentSettings contentSettings)
{
_propertyEditors = propertyEditors;
_logger = logger;
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
_contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings));
}
private static readonly int[] SystemIds =
@@ -128,9 +128,8 @@ namespace Umbraco.Web.Models.Mapping
private IEnumerable<PropertyEditorBasic> MapAvailableEditors(IDataType source, MapperContext context)
{
var contentSection = _umbracoSettingsSection.Content;
var properties = _propertyEditors
.Where(x => !x.IsDeprecated || contentSection.ShowDeprecatedPropertyEditors || source.EditorAlias == x.Alias)
.Where(x => !x.IsDeprecated || _contentSettings.ShowDeprecatedPropertyEditors || source.EditorAlias == x.Alias)
.OrderBy(x => x.Name);
return context.MapEnumerable<IDataEditor, PropertyEditorBasic>(properties);
}
@@ -27,9 +27,9 @@ namespace Umbraco.Core.Models
/// <summary>
/// Gets the urls of a media item.
/// </summary>
public static string[] GetUrls(this IMedia media, IContentSection contentSection, MediaUrlGeneratorCollection mediaUrlGenerators)
public static string[] GetUrls(this IMedia media, IContentSettings contentSettings, MediaUrlGeneratorCollection mediaUrlGenerators)
{
return contentSection.ImageAutoFillProperties
return contentSettings.ImageAutoFillProperties
.Select(field => media.GetUrl(field.Alias, mediaUrlGenerators))
.Where(link => string.IsNullOrWhiteSpace(link) == false)
.ToArray();
@@ -22,23 +22,21 @@ namespace Umbraco.Web.PropertyEditors
public class FileUploadPropertyEditor : DataEditor, IMediaUrlGenerator
{
private readonly IMediaFileSystem _mediaFileSystem;
private readonly IContentSection _contentSection;
private readonly IContentSettings _contentSettings;
private readonly UploadAutoFillProperties _uploadAutoFillProperties;
private readonly IDataTypeService _dataTypeService;
private readonly ILocalizationService _localizationService;
private readonly ILocalizedTextService _localizedTextService;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
public FileUploadPropertyEditor(ILogger logger, IMediaFileSystem mediaFileSystem, IContentSection contentSection, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, IUmbracoSettingsSection umbracoSettingsSection)
public FileUploadPropertyEditor(ILogger logger, IMediaFileSystem mediaFileSystem, IContentSettings contentSettings, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper)
: base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper)
{
_mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem));
_contentSection = contentSection;
_contentSettings = contentSettings;
_dataTypeService = dataTypeService;
_localizationService = localizationService;
_localizedTextService = localizedTextService;
_uploadAutoFillProperties = new UploadAutoFillProperties(_mediaFileSystem, logger, contentSection);
_umbracoSettingsSection = umbracoSettingsSection;
_uploadAutoFillProperties = new UploadAutoFillProperties(_mediaFileSystem, logger, contentSettings);
}
/// <summary>
@@ -47,8 +45,8 @@ namespace Umbraco.Web.PropertyEditors
/// <returns>The corresponding property value editor.</returns>
protected override IDataValueEditor CreateValueEditor()
{
var editor = new FileUploadPropertyValueEditor(Attribute, _mediaFileSystem, _dataTypeService, _localizationService, _localizedTextService, ShortStringHelper, _umbracoSettingsSection);
editor.Validators.Add(new UploadFileTypeValidator(_localizedTextService, _umbracoSettingsSection));
var editor = new FileUploadPropertyValueEditor(Attribute, _mediaFileSystem, _dataTypeService, _localizationService, _localizedTextService, ShortStringHelper, _contentSettings);
editor.Validators.Add(new UploadFileTypeValidator(_localizedTextService, _contentSettings));
return editor;
}
@@ -179,7 +177,7 @@ namespace Umbraco.Web.PropertyEditors
foreach (var property in properties)
{
var autoFillConfig = _contentSection.GetConfig(property.Alias);
var autoFillConfig = _contentSettings.GetConfig(property.Alias);
if (autoFillConfig == null) continue;
foreach (var pvalue in property.Values)
@@ -16,13 +16,13 @@ namespace Umbraco.Web.PropertyEditors
internal class FileUploadPropertyValueEditor : DataValueEditor
{
private readonly IMediaFileSystem _mediaFileSystem;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
private readonly IContentSettings _contentSettings;
public FileUploadPropertyValueEditor(DataEditorAttribute attribute, IMediaFileSystem mediaFileSystem, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, IUmbracoSettingsSection umbracoSettingsSection)
public FileUploadPropertyValueEditor(DataEditorAttribute attribute, IMediaFileSystem mediaFileSystem, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, IContentSettings contentSettings)
: base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute)
{
_mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem));
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
_contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings));
}
/// <summary>
@@ -101,7 +101,7 @@ namespace Umbraco.Web.PropertyEditors
{
// process the file
// no file, invalid file, reject change
if (UploadFileTypeValidator.IsValidFileExtension(file.FileName, _umbracoSettingsSection) == false)
if (UploadFileTypeValidator.IsValidFileExtension(file.FileName, _contentSettings) == false)
return null;
// get the filepath
@@ -29,17 +29,16 @@ namespace Umbraco.Web.PropertyEditors
public class ImageCropperPropertyEditor : DataEditor, IMediaUrlGenerator
{
private readonly IMediaFileSystem _mediaFileSystem;
private readonly IContentSection _contentSettings;
private readonly IContentSettings _contentSettings;
private readonly IDataTypeService _dataTypeService;
private readonly ILocalizationService _localizationService;
private readonly IIOHelper _ioHelper;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
private readonly UploadAutoFillProperties _autoFillProperties;
/// <summary>
/// Initializes a new instance of the <see cref="ImageCropperPropertyEditor"/> class.
/// </summary>
public ImageCropperPropertyEditor(ILogger logger, IMediaFileSystem mediaFileSystem, IContentSection contentSettings, IDataTypeService dataTypeService, ILocalizationService localizationService, IIOHelper ioHelper, IShortStringHelper shortStringHelper, ILocalizedTextService localizedTextService, IUmbracoSettingsSection umbracoSettingsSection)
public ImageCropperPropertyEditor(ILogger logger, IMediaFileSystem mediaFileSystem, IContentSettings contentSettings, IDataTypeService dataTypeService, ILocalizationService localizationService, IIOHelper ioHelper, IShortStringHelper shortStringHelper, ILocalizedTextService localizedTextService)
: base(logger, dataTypeService, localizationService, localizedTextService,shortStringHelper)
{
_mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem));
@@ -47,7 +46,6 @@ namespace Umbraco.Web.PropertyEditors
_dataTypeService = dataTypeService;
_localizationService = localizationService;
_ioHelper = ioHelper;
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
// TODO: inject?
_autoFillProperties = new UploadAutoFillProperties(_mediaFileSystem, logger, _contentSettings);
@@ -68,7 +66,7 @@ namespace Umbraco.Web.PropertyEditors
/// Creates the corresponding property value editor.
/// </summary>
/// <returns>The corresponding property value editor.</returns>
protected override IDataValueEditor CreateValueEditor() => new ImageCropperPropertyValueEditor(Attribute, Logger, _mediaFileSystem, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, _umbracoSettingsSection);
protected override IDataValueEditor CreateValueEditor() => new ImageCropperPropertyValueEditor(Attribute, Logger, _mediaFileSystem, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, _contentSettings);
/// <summary>
/// Creates the corresponding preValue editor.
@@ -22,14 +22,14 @@ namespace Umbraco.Web.PropertyEditors
{
private readonly ILogger _logger;
private readonly IMediaFileSystem _mediaFileSystem;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
private readonly IContentSettings _contentSettings;
public ImageCropperPropertyValueEditor(DataEditorAttribute attribute, ILogger logger, IMediaFileSystem mediaFileSystem, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, IUmbracoSettingsSection umbracoSettingsSection)
public ImageCropperPropertyValueEditor(DataEditorAttribute attribute, ILogger logger, IMediaFileSystem mediaFileSystem, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, IContentSettings contentSettings)
: base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute)
{
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem));
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
_contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings));
}
/// <summary>
@@ -146,7 +146,7 @@ namespace Umbraco.Web.PropertyEditors
{
// process the file
// no file, invalid file, reject change
if (UploadFileTypeValidator.IsValidFileExtension(file.FileName, _umbracoSettingsSection) == false)
if (UploadFileTypeValidator.IsValidFileExtension(file.FileName, _contentSettings) == false)
return null;
// get the filepath
@@ -16,12 +16,12 @@ namespace Umbraco.Web.PropertyEditors
internal class UploadFileTypeValidator : IValueValidator
{
private readonly ILocalizedTextService _localizedTextService;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
private readonly IContentSettings _contentSettings;
public UploadFileTypeValidator(ILocalizedTextService localizedTextService, IUmbracoSettingsSection umbracoSettingsSection)
public UploadFileTypeValidator(ILocalizedTextService localizedTextService, IContentSettings contentSettings)
{
_localizedTextService = localizedTextService;
_umbracoSettingsSection = umbracoSettingsSection;
_contentSettings = contentSettings;
}
public IEnumerable<ValidationResult> Validate(object value, string valueType, object dataTypeConfiguration)
@@ -46,7 +46,7 @@ namespace Umbraco.Web.PropertyEditors
foreach (string filename in fileNames)
{
if (IsValidFileExtension(filename, _umbracoSettingsSection) == false)
if (IsValidFileExtension(filename, _contentSettings) == false)
{
//we only store a single value for this editor so the 'member' or 'field'
// we'll associate this error with will simply be called 'value'
@@ -55,11 +55,11 @@ namespace Umbraco.Web.PropertyEditors
}
}
internal static bool IsValidFileExtension(string fileName, IUmbracoSettingsSection umbracoSettingsSection)
internal static bool IsValidFileExtension(string fileName, IContentSettings contentSettings)
{
if (fileName.IndexOf('.') <= 0) return false;
var extension = new FileInfo(fileName).Extension.TrimStart(".");
return umbracoSettingsSection.Content.IsFileAllowedForUpload(extension);
return contentSettings.IsFileAllowedForUpload(extension);
}
}
}
@@ -16,14 +16,14 @@ namespace Umbraco.Web.Routing
{
private readonly ILogger _logger;
private readonly IEntityService _entityService;
private readonly IContentSection _contentConfigSection;
private readonly IContentSettings _contentConfigSettings;
private readonly IExamineManager _examineManager;
public ContentFinderByConfigured404(ILogger logger, IEntityService entityService, IContentSection contentConfigSection, IExamineManager examineManager)
public ContentFinderByConfigured404(ILogger logger, IEntityService entityService, IContentSettings contentConfigSettings, IExamineManager examineManager)
{
_logger = logger;
_entityService = entityService;
_contentConfigSection = contentConfigSection;
_contentConfigSettings = contentConfigSettings;
_examineManager = examineManager;
}
@@ -63,7 +63,7 @@ namespace Umbraco.Web.Routing
}
var error404 = NotFoundHandlerHelper.GetCurrentNotFoundPageId(
_contentConfigSection.Error404Collection.ToArray(),
_contentConfigSettings.Error404Collection.ToArray(),
_entityService,
new PublishedContentQuery(frequest.UmbracoContext.PublishedSnapshot, frequest.UmbracoContext.VariationContextAccessor, _examineManager),
errorCulture);
@@ -44,7 +44,6 @@ namespace Umbraco.Core.Runtime
// composers
composition
.ComposeConfiguration()
.ComposeRepositories()
.ComposeServices()
.ComposeCoreMappingProfiles()
@@ -57,7 +57,7 @@ namespace Umbraco.Core.Runtime
// beware! must use '() => _factory.GetInstance<T>()' and NOT '_factory.GetInstance<T>'
// as the second one captures the current value (null) and therefore fails
_state = new RuntimeState(Logger,
Configs.Settings(), Configs.Global(),
Configs.Global(),
new Lazy<IMainDom>(() => mainDom),
new Lazy<IServerRegistrar>(() => _factory.GetInstance<IServerRegistrar>()),
UmbracoVersion,HostingEnvironment, BackOfficeInfo)
@@ -171,7 +171,7 @@ namespace Umbraco.Core.Runtime
// beware! must use '() => _factory.GetInstance<T>()' and NOT '_factory.GetInstance<T>'
// as the second one captures the current value (null) and therefore fails
_state = new RuntimeState(Logger,
Configs.Settings(), Configs.Global(),
Configs.Global(),
new Lazy<IMainDom>(() => _factory.GetInstance<IMainDom>()),
new Lazy<IServerRegistrar>(() => _factory.GetInstance<IServerRegistrar>()),
UmbracoVersion, HostingEnvironment, BackOfficeInfo)
+1 -3
View File
@@ -20,7 +20,6 @@ namespace Umbraco.Core
public class RuntimeState : IRuntimeState
{
private readonly ILogger _logger;
private readonly IUmbracoSettingsSection _settings;
private readonly IGlobalSettings _globalSettings;
private readonly ConcurrentHashSet<string> _applicationUrls = new ConcurrentHashSet<string>();
private readonly Lazy<IMainDom> _mainDom;
@@ -32,13 +31,12 @@ namespace Umbraco.Core
/// <summary>
/// Initializes a new instance of the <see cref="RuntimeState"/> class.
/// </summary>
public RuntimeState(ILogger logger, IUmbracoSettingsSection settings, IGlobalSettings globalSettings,
public RuntimeState(ILogger logger, IGlobalSettings globalSettings,
Lazy<IMainDom> mainDom, Lazy<IServerRegistrar> serverRegistrar, IUmbracoVersion umbracoVersion,
IHostingEnvironment hostingEnvironment,
IBackOfficeInfo backOfficeInfo)
{
_logger = logger;
_settings = settings;
_globalSettings = globalSettings;
_mainDom = mainDom;
_serverRegistrar = serverRegistrar;
@@ -28,16 +28,16 @@ namespace Umbraco.Core.Services.Implement
private readonly ILocalizationService _localizationService;
private readonly INotificationsRepository _notificationsRepository;
private readonly IGlobalSettings _globalSettings;
private readonly IContentSection _contentSection;
private readonly IContentSettings _contentSettings;
private readonly ILogger _logger;
private readonly IIOHelper _ioHelper;
public NotificationService(IScopeProvider provider, IUserService userService, IContentService contentService, ILocalizationService localizationService,
ILogger logger, IIOHelper ioHelper, INotificationsRepository notificationsRepository, IGlobalSettings globalSettings, IContentSection contentSection)
ILogger logger, IIOHelper ioHelper, INotificationsRepository notificationsRepository, IGlobalSettings globalSettings, IContentSettings contentSettings)
{
_notificationsRepository = notificationsRepository;
_globalSettings = globalSettings;
_contentSection = contentSection;
_contentSettings = contentSettings;
_uowProvider = provider ?? throw new ArgumentNullException(nameof(provider));
_userService = userService ?? throw new ArgumentNullException(nameof(userService));
_contentService = contentService ?? throw new ArgumentNullException(nameof(contentService));
@@ -302,7 +302,7 @@ namespace Umbraco.Core.Services.Implement
if (content.ContentType.VariesByNothing())
{
if (!_contentSection.DisableHtmlEmail)
if (!_contentSettings.DisableHtmlEmail)
{
//create the HTML summary for invariant content
@@ -344,7 +344,7 @@ namespace Umbraco.Core.Services.Implement
{
//it's variant, so detect what cultures have changed
if (!_contentSection.DisableHtmlEmail)
if (!_contentSettings.DisableHtmlEmail)
{
//Create the HTML based summary (ul of culture names)
@@ -406,13 +406,13 @@ namespace Umbraco.Core.Services.Implement
summary.ToString());
// create the mail message
var mail = new MailMessage(_contentSection.NotificationEmailAddress, mailingUser.Email);
var mail = new MailMessage(_contentSettings.NotificationEmailAddress, mailingUser.Email);
// populate the message
mail.Subject = createSubject((mailingUser, subjectVars));
if (_contentSection.DisableHtmlEmail)
if (_contentSettings.DisableHtmlEmail)
{
mail.IsBodyHtml = false;
mail.Body = createBody((user: mailingUser, body: bodyVars, false));
@@ -57,7 +57,6 @@ namespace Umbraco.Tests.Cache.PublishedCache
_httpContextFactory = new FakeHttpContextFactory("~/Home");
var umbracoSettings = Factory.GetInstance<IUmbracoSettingsSection>();
var globalSettings = Factory.GetInstance<IGlobalSettings>();
var umbracoContextAccessor = Factory.GetInstance<IUmbracoContextAccessor>();
@@ -14,27 +14,27 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
[Test]
public override void DisableHtmlEmail()
{
Assert.IsTrue(SettingsSection.Content.DisableHtmlEmail == false);
Assert.IsTrue(ContentSettings.DisableHtmlEmail == false);
}
[Test]
public override void Can_Set_Multiple()
{
Assert.IsTrue(SettingsSection.Content.Error404Collection.Count() == 1);
Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(0).Culture == null);
Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(0).ContentId == 1);
Assert.IsTrue(ContentSettings.Error404Collection.Count() == 1);
Assert.IsTrue(ContentSettings.Error404Collection.ElementAt(0).Culture == null);
Assert.IsTrue(ContentSettings.Error404Collection.ElementAt(0).ContentId == 1);
}
[Test]
public override void ImageAutoFillProperties()
{
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.Count() == 1);
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).Alias == "umbracoFile");
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).WidthFieldAlias == "umbracoWidth");
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).HeightFieldAlias == "umbracoHeight");
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).LengthFieldAlias == "umbracoBytes");
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).ExtensionFieldAlias == "umbracoExtension");
Assert.IsTrue(ContentSettings.ImageAutoFillProperties.Count() == 1);
Assert.IsTrue(ContentSettings.ImageAutoFillProperties.ElementAt(0).Alias == "umbracoFile");
Assert.IsTrue(ContentSettings.ImageAutoFillProperties.ElementAt(0).WidthFieldAlias == "umbracoWidth");
Assert.IsTrue(ContentSettings.ImageAutoFillProperties.ElementAt(0).HeightFieldAlias == "umbracoHeight");
Assert.IsTrue(ContentSettings.ImageAutoFillProperties.ElementAt(0).LengthFieldAlias == "umbracoBytes");
Assert.IsTrue(ContentSettings.ImageAutoFillProperties.ElementAt(0).ExtensionFieldAlias == "umbracoExtension");
}
}
}
@@ -16,80 +16,80 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
[Test]
public void EmailAddress()
{
Assert.AreEqual(SettingsSection.Content.NotificationEmailAddress, "robot@umbraco.dk");
Assert.AreEqual(ContentSettings.NotificationEmailAddress, "robot@umbraco.dk");
}
[Test]
public virtual void DisableHtmlEmail()
{
Assert.IsTrue(SettingsSection.Content.DisableHtmlEmail);
Assert.IsTrue(ContentSettings.DisableHtmlEmail);
}
[Test]
public virtual void Can_Set_Multiple()
{
Assert.AreEqual(SettingsSection.Content.Error404Collection.Count(), 3);
Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(0).Culture, "default");
Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(0).ContentId, 1047);
Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(0).HasContentId);
Assert.IsFalse(SettingsSection.Content.Error404Collection.ElementAt(0).HasContentKey);
Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(1).Culture, "en-US");
Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(1).ContentXPath, "$site/error [@name = 'error']");
Assert.IsFalse(SettingsSection.Content.Error404Collection.ElementAt(1).HasContentId);
Assert.IsFalse(SettingsSection.Content.Error404Collection.ElementAt(1).HasContentKey);
Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(2).Culture, "en-UK");
Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(2).ContentKey, new Guid("8560867F-B88F-4C74-A9A4-679D8E5B3BFC"));
Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(2).HasContentKey);
Assert.IsFalse(SettingsSection.Content.Error404Collection.ElementAt(2).HasContentId);
Assert.AreEqual(ContentSettings.Error404Collection.Count(), 3);
Assert.AreEqual(ContentSettings.Error404Collection.ElementAt(0).Culture, "default");
Assert.AreEqual(ContentSettings.Error404Collection.ElementAt(0).ContentId, 1047);
Assert.IsTrue(ContentSettings.Error404Collection.ElementAt(0).HasContentId);
Assert.IsFalse(ContentSettings.Error404Collection.ElementAt(0).HasContentKey);
Assert.AreEqual(ContentSettings.Error404Collection.ElementAt(1).Culture, "en-US");
Assert.AreEqual(ContentSettings.Error404Collection.ElementAt(1).ContentXPath, "$site/error [@name = 'error']");
Assert.IsFalse(ContentSettings.Error404Collection.ElementAt(1).HasContentId);
Assert.IsFalse(ContentSettings.Error404Collection.ElementAt(1).HasContentKey);
Assert.AreEqual(ContentSettings.Error404Collection.ElementAt(2).Culture, "en-UK");
Assert.AreEqual(ContentSettings.Error404Collection.ElementAt(2).ContentKey, new Guid("8560867F-B88F-4C74-A9A4-679D8E5B3BFC"));
Assert.IsTrue(ContentSettings.Error404Collection.ElementAt(2).HasContentKey);
Assert.IsFalse(ContentSettings.Error404Collection.ElementAt(2).HasContentId);
}
[Test]
public void ImageFileTypes()
{
Assert.IsTrue(SettingsSection.Content.ImageFileTypes.All(x => "jpeg,jpg,gif,bmp,png,tiff,tif".Split(',').Contains(x)));
Assert.IsTrue(ContentSettings.ImageFileTypes.All(x => "jpeg,jpg,gif,bmp,png,tiff,tif".Split(',').Contains(x)));
}
[Test]
public virtual void ImageAutoFillProperties()
{
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.Count(), 2);
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).Alias, "umbracoFile");
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).WidthFieldAlias, "umbracoWidth");
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).HeightFieldAlias, "umbracoHeight");
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).LengthFieldAlias, "umbracoBytes");
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).ExtensionFieldAlias, "umbracoExtension");
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).Alias, "umbracoFile2");
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).WidthFieldAlias, "umbracoWidth2");
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).HeightFieldAlias, "umbracoHeight2");
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).LengthFieldAlias, "umbracoBytes2");
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).ExtensionFieldAlias, "umbracoExtension2");
Assert.AreEqual(ContentSettings.ImageAutoFillProperties.Count(), 2);
Assert.AreEqual(ContentSettings.ImageAutoFillProperties.ElementAt(0).Alias, "umbracoFile");
Assert.AreEqual(ContentSettings.ImageAutoFillProperties.ElementAt(0).WidthFieldAlias, "umbracoWidth");
Assert.AreEqual(ContentSettings.ImageAutoFillProperties.ElementAt(0).HeightFieldAlias, "umbracoHeight");
Assert.AreEqual(ContentSettings.ImageAutoFillProperties.ElementAt(0).LengthFieldAlias, "umbracoBytes");
Assert.AreEqual(ContentSettings.ImageAutoFillProperties.ElementAt(0).ExtensionFieldAlias, "umbracoExtension");
Assert.AreEqual(ContentSettings.ImageAutoFillProperties.ElementAt(1).Alias, "umbracoFile2");
Assert.AreEqual(ContentSettings.ImageAutoFillProperties.ElementAt(1).WidthFieldAlias, "umbracoWidth2");
Assert.AreEqual(ContentSettings.ImageAutoFillProperties.ElementAt(1).HeightFieldAlias, "umbracoHeight2");
Assert.AreEqual(ContentSettings.ImageAutoFillProperties.ElementAt(1).LengthFieldAlias, "umbracoBytes2");
Assert.AreEqual(ContentSettings.ImageAutoFillProperties.ElementAt(1).ExtensionFieldAlias, "umbracoExtension2");
}
[Test]
public void PreviewBadge()
{
Assert.AreEqual(SettingsSection.Content.PreviewBadge, @"<div id=""umbracoPreviewBadge"" class=""umbraco-preview-badge""><span class=""umbraco-preview-badge__header"">Preview mode</span><a href=""{0}/preview/end?redir={1}"" class=""umbraco-preview-badge__end""><svg viewBox=""0 0 100 100"" xmlns=""http://www.w3.org/2000/svg""><title>Click to end</title><path d=""M5273.1 2400.1v-2c0-2.8-5-4-9.7-4s-9.7 1.3-9.7 4v2a7 7 0 002 4.9l5 4.9c.3.3.4.6.4 1v6.4c0 .4.2.7.6.8l2.9.9c.5.1 1-.2 1-.8v-7.2c0-.4.2-.7.4-1l5.1-5a7 7 0 002-4.9zm-9.7-.1c-4.8 0-7.4-1.3-7.5-1.8.1-.5 2.7-1.8 7.5-1.8s7.3 1.3 7.5 1.8c-.2.5-2.7 1.8-7.5 1.8z""/><path d=""M5268.4 2410.3c-.6 0-1 .4-1 1s.4 1 1 1h4.3c.6 0 1-.4 1-1s-.4-1-1-1h-4.3zM5272.7 2413.7h-4.3c-.6 0-1 .4-1 1s.4 1 1 1h4.3c.6 0 1-.4 1-1s-.4-1-1-1zM5272.7 2417h-4.3c-.6 0-1 .4-1 1s.4 1 1 1h4.3c.6 0 1-.4 1-1 0-.5-.4-1-1-1z""/><path d=""M78.2 13l-8.7 11.7a32.5 32.5 0 11-51.9 25.8c0-10.3 4.7-19.7 12.9-25.8L21.8 13a47 47 0 1056.4 0z""/><path d=""M42.7 2.5h14.6v49.4H42.7z""/></svg></a></div><style type=""text/css"">.umbraco-preview-badge {{position: absolute;top: 1em;right: 1em;display: inline-flex;background: #1b264f;color: #fff;padding: 1em;font-size: 12px;z-index: 99999999;justify-content: center;align-items: center;box-shadow: 0 10px 50px rgba(0, 0, 0, .1), 0 6px 20px rgba(0, 0, 0, .16);line-height: 1;}}.umbraco-preview-badge__header {{font-weight: bold;}}.umbraco-preview-badge__end {{width: 3em;padding: 1em;margin: -1em -1em -1em 2em;display: flex;flex-shrink: 0;align-items: center;align-self: stretch;}}.umbraco-preview-badge__end:hover,.umbraco-preview-badge__end:focus {{background: #f5c1bc;}}.umbraco-preview-badge__end svg {{fill: #fff;width:1em;}}</style>");
Assert.AreEqual(ContentSettings.PreviewBadge, @"<div id=""umbracoPreviewBadge"" class=""umbraco-preview-badge""><span class=""umbraco-preview-badge__header"">Preview mode</span><a href=""{0}/preview/end?redir={1}"" class=""umbraco-preview-badge__end""><svg viewBox=""0 0 100 100"" xmlns=""http://www.w3.org/2000/svg""><title>Click to end</title><path d=""M5273.1 2400.1v-2c0-2.8-5-4-9.7-4s-9.7 1.3-9.7 4v2a7 7 0 002 4.9l5 4.9c.3.3.4.6.4 1v6.4c0 .4.2.7.6.8l2.9.9c.5.1 1-.2 1-.8v-7.2c0-.4.2-.7.4-1l5.1-5a7 7 0 002-4.9zm-9.7-.1c-4.8 0-7.4-1.3-7.5-1.8.1-.5 2.7-1.8 7.5-1.8s7.3 1.3 7.5 1.8c-.2.5-2.7 1.8-7.5 1.8z""/><path d=""M5268.4 2410.3c-.6 0-1 .4-1 1s.4 1 1 1h4.3c.6 0 1-.4 1-1s-.4-1-1-1h-4.3zM5272.7 2413.7h-4.3c-.6 0-1 .4-1 1s.4 1 1 1h4.3c.6 0 1-.4 1-1s-.4-1-1-1zM5272.7 2417h-4.3c-.6 0-1 .4-1 1s.4 1 1 1h4.3c.6 0 1-.4 1-1 0-.5-.4-1-1-1z""/><path d=""M78.2 13l-8.7 11.7a32.5 32.5 0 11-51.9 25.8c0-10.3 4.7-19.7 12.9-25.8L21.8 13a47 47 0 1056.4 0z""/><path d=""M42.7 2.5h14.6v49.4H42.7z""/></svg></a></div><style type=""text/css"">.umbraco-preview-badge {{position: absolute;top: 1em;right: 1em;display: inline-flex;background: #1b264f;color: #fff;padding: 1em;font-size: 12px;z-index: 99999999;justify-content: center;align-items: center;box-shadow: 0 10px 50px rgba(0, 0, 0, .1), 0 6px 20px rgba(0, 0, 0, .16);line-height: 1;}}.umbraco-preview-badge__header {{font-weight: bold;}}.umbraco-preview-badge__end {{width: 3em;padding: 1em;margin: -1em -1em -1em 2em;display: flex;flex-shrink: 0;align-items: center;align-self: stretch;}}.umbraco-preview-badge__end:hover,.umbraco-preview-badge__end:focus {{background: #f5c1bc;}}.umbraco-preview-badge__end svg {{fill: #fff;width:1em;}}</style>");
}
[Test]
public void ResolveUrlsFromTextString()
{
Assert.IsFalse(SettingsSection.Content.ResolveUrlsFromTextString);
Assert.IsFalse(ContentSettings.ResolveUrlsFromTextString);
}
[Test]
public void MacroErrors()
{
Assert.AreEqual(SettingsSection.Content.MacroErrorBehaviour, MacroErrorBehaviour.Inline);
Assert.AreEqual(ContentSettings.MacroErrorBehaviour, MacroErrorBehaviour.Inline);
}
[Test]
public void DisallowedUploadFiles()
{
Assert.IsTrue(SettingsSection.Content.DisallowedUploadFiles.All(x => "ashx,aspx,ascx,config,cshtml,vbhtml,asmx,air,axd".Split(',').Contains(x)));
Assert.IsTrue(ContentSettings.DisallowedUploadFiles.All(x => "ashx,aspx,ascx,config,cshtml,vbhtml,asmx,air,axd".Split(',').Contains(x)));
}
[Test]
public void AllowedUploadFiles()
{
Assert.IsTrue(SettingsSection.Content.AllowedUploadFiles.All(x => "jpg,gif,png".Split(',').Contains(x)));
Assert.IsTrue(ContentSettings.AllowedUploadFiles.All(x => "jpg,gif,png".Split(',').Contains(x)));
}
[Test]
@@ -107,16 +107,16 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
TestingDefaults = false;
Debug.WriteLine("Extension being tested", extension);
Debug.WriteLine("AllowedUploadFiles: {0}", SettingsSection.Content.AllowedUploadFiles);
Debug.WriteLine("DisallowedUploadFiles: {0}", SettingsSection.Content.DisallowedUploadFiles);
Debug.WriteLine("AllowedUploadFiles: {0}", ContentSettings.AllowedUploadFiles);
Debug.WriteLine("DisallowedUploadFiles: {0}", ContentSettings.DisallowedUploadFiles);
var allowedContainsExtension = SettingsSection.Content.AllowedUploadFiles.Any(x => x.InvariantEquals(extension));
var disallowedContainsExtension = SettingsSection.Content.DisallowedUploadFiles.Any(x => x.InvariantEquals(extension));
var allowedContainsExtension = ContentSettings.AllowedUploadFiles.Any(x => x.InvariantEquals(extension));
var disallowedContainsExtension = ContentSettings.DisallowedUploadFiles.Any(x => x.InvariantEquals(extension));
Debug.WriteLine("AllowedContainsExtension: {0}", allowedContainsExtension);
Debug.WriteLine("DisallowedContainsExtension: {0}", disallowedContainsExtension);
Assert.AreEqual(SettingsSection.Content.IsFileAllowedForUpload(extension), expected);
Assert.AreEqual(ContentSettings.IsFileAllowedForUpload(extension), expected);
}
}
}
@@ -32,8 +32,6 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
Assert.IsNotNull(Settings);
}
protected IUmbracoSettingsSection SettingsSection => Settings;
private UmbracoSettingsSection Settings { get; set; }
protected ILoggingSettings LoggingSettings => Settings.Logging;
@@ -42,5 +40,6 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
protected ISecuritySettings SecuritySettings => Settings.Security;
protected IUserPasswordConfiguration UserPasswordConfiguration => Settings.Security.UserPasswordConfiguration;
protected IMemberPasswordConfiguration MemberPasswordConfiguration => Settings.Security.MemberPasswordConfiguration;
protected IContentSettings ContentSettings => Settings.Content;
}
}
+3 -3
View File
@@ -34,18 +34,18 @@ namespace Umbraco.Tests.IO
composition.Register(_ => Mock.Of<ILogger>());
composition.Register(_ => Mock.Of<IDataTypeService>());
composition.Register(_ => Mock.Of<IContentSection>());
composition.Register(_ => Mock.Of<IContentSettings>());
composition.Register(_ => TestHelper.ShortStringHelper);
composition.Register(_ => TestHelper.IOHelper);
composition.RegisterUnique<IMediaPathScheme, UniqueMediaPathScheme>();
composition.RegisterUnique(TestHelper.IOHelper);
composition.Configs.Add(SettingsForTests.GetDefaultGlobalSettings);
composition.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
composition.Configs.Add(SettingsForTests.GenerateMockContentSettings);
composition.ComposeFileSystems();
composition.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
composition.Configs.Add(SettingsForTests.GenerateMockContentSettings);
_factory = composition.CreateFactory();
@@ -29,7 +29,7 @@ namespace Umbraco.Tests.Models
Composition.ComposeFileSystems();
Composition.Register(_ => Mock.Of<IDataTypeService>());
Composition.Register(_ => Mock.Of<IContentSection>());
Composition.Register(_ => Mock.Of<IContentSettings>());
// all this is required so we can validate properties...
var editor = new TextboxPropertyEditor(Mock.Of<ILogger>(), Mock.Of<IDataTypeService>(), Mock.Of<ILocalizationService>(), IOHelper, ShortStringHelper, LocalizedTextService) { Alias = "test" };
+1 -1
View File
@@ -39,7 +39,7 @@ namespace Umbraco.Tests.Models
Composition.ComposeFileSystems();
Composition.Register(_ => Mock.Of<IDataTypeService>());
Composition.Register(_ => Mock.Of<IContentSection>());
Composition.Register(_ => Mock.Of<IContentSettings>());
// all this is required so we can validate properties...
var editor = new TextboxPropertyEditor(Mock.Of<ILogger>(), Mock.Of<IDataTypeService>(), Mock.Of<ILocalizationService>(), IOHelper, ShortStringHelper, LocalizedTextService) { Alias = "test" };
@@ -34,7 +34,7 @@ namespace Umbraco.Tests.Models.Mapping
Composition.ComposeFileSystems();
Composition.Register(_ => Mock.Of<IDataTypeService>());
Composition.Register(_ => Mock.Of<IContentSection>());
Composition.Register(_ => Mock.Of<IContentSettings>());
// all this is required so we can validate properties...
var editor = new TextboxPropertyEditor(Mock.Of<ILogger>(), Mock.Of<IDataTypeService>(), Mock.Of<ILocalizationService>(), IOHelper, ShortStringHelper, LocalizedTextService) { Alias = "test" };
+2 -5
View File
@@ -31,13 +31,10 @@ namespace Umbraco.Tests.Models
// and then, this will reset the width, height... because the file does not exist, of course ;-(
var logger = Mock.Of<ILogger>();
var scheme = Mock.Of<IMediaPathScheme>();
var config = Mock.Of<IContentSection>();
var dataTypeService = Mock.Of<IDataTypeService>();
var localizationService = Mock.Of<ILocalizationService>();
var umbracoSettingsSection = TestObjects.GetUmbracoSettings();
var config = Mock.Of<IContentSettings>();
var mediaFileSystem = new MediaFileSystem(Mock.Of<IFileSystem>(), scheme, logger, ShortStringHelper);
var ignored = new FileUploadPropertyEditor(Mock.Of<ILogger>(), mediaFileSystem, config, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, umbracoSettingsSection);
var ignored = new FileUploadPropertyEditor(Mock.Of<ILogger>(), mediaFileSystem, config, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper);
var media = MockedMedia.CreateMediaImage(mediaType, -1);
media.WriterId = -1; // else it's zero and that's not a user and it breaks the tests
+1 -1
View File
@@ -35,7 +35,7 @@ namespace Umbraco.Tests.Models
var configs = TestHelper.GetConfigs();
configs.Add(SettingsForTests.GetDefaultGlobalSettings);
configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
configs.Add(SettingsForTests.GenerateMockContentSettings);
_factory = Mock.Of<IFactory>();
@@ -85,10 +85,8 @@ namespace Umbraco.Tests.PropertyEditors
var mediaFileSystem = new MediaFileSystem(Mock.Of<IFileSystem>(), scheme, logger, shortStringHelper);
var umbracoSettingsSection = Mock.Of<IUmbracoSettingsSection>();
var dataTypeService = new TestObjects.TestDataTypeService(
new DataType(new ImageCropperPropertyEditor(Mock.Of<ILogger>(), mediaFileSystem, Mock.Of<IContentSection>(), Mock.Of<IDataTypeService>(), Mock.Of<ILocalizationService>(), TestHelper.IOHelper, TestHelper.ShortStringHelper, Mock.Of<ILocalizedTextService>(), umbracoSettingsSection)) { Id = 1 });
new DataType(new ImageCropperPropertyEditor(Mock.Of<ILogger>(), mediaFileSystem, Mock.Of<IContentSettings>(), Mock.Of<IDataTypeService>(), Mock.Of<ILocalizationService>(), TestHelper.IOHelper, TestHelper.ShortStringHelper, Mock.Of<ILocalizedTextService>())) { Id = 1 });
var factory = new PublishedContentTypeFactory(Mock.Of<IPublishedModelFactory>(), new PropertyValueConverterCollection(Array.Empty<IPropertyValueConverter>()), dataTypeService);
@@ -63,7 +63,7 @@ namespace Umbraco.Tests.PublishedContent
Mock.Get(factory).Setup(x => x.GetInstance(typeof(Configs))).Returns(configs);
var globalSettings = new GlobalSettings(TestHelper.IOHelper);
var hostingEnvironment = Mock.Of<IHostingEnvironment>();
configs.Add(SettingsForTests.GenerateMockUmbracoSettings);
configs.Add(SettingsForTests.GenerateMockContentSettings);
configs.Add<IGlobalSettings>(() => globalSettings);
Mock.Get(factory).Setup(x => x.GetInstance(typeof(IPublishedModelFactory))).Returns(PublishedModelFactory);
@@ -55,7 +55,7 @@ namespace Umbraco.Tests.PublishedContent
var configs = TestHelper.GetConfigs();
Mock.Get(factory).Setup(x => x.GetInstance(typeof(Configs))).Returns(configs);
var globalSettings = new GlobalSettings(TestHelper.IOHelper);
configs.Add(SettingsForTests.GenerateMockUmbracoSettings);
configs.Add(SettingsForTests.GenerateMockContentSettings);
configs.Add<IGlobalSettings>(() => globalSettings);
var publishedModelFactory = new NoopPublishedModelFactory();
@@ -34,14 +34,12 @@ namespace Umbraco.Tests.Routing
var logger = Mock.Of<ILogger>();
var mediaFileSystemMock = Mock.Of<IMediaFileSystem>();
var contentSection = Mock.Of<IContentSection>();
var contentSection = Mock.Of<IContentSettings>();
var dataTypeService = Mock.Of<IDataTypeService>();
var umbracoSettingsSection = TestObjects.GetUmbracoSettings();
var propertyEditors = new MediaUrlGeneratorCollection(new IMediaUrlGenerator[]
{
new FileUploadPropertyEditor(logger, mediaFileSystemMock, contentSection, dataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, umbracoSettingsSection),
new ImageCropperPropertyEditor(logger, mediaFileSystemMock, contentSection, dataTypeService, LocalizationService, IOHelper, ShortStringHelper, LocalizedTextService, umbracoSettingsSection),
new FileUploadPropertyEditor(logger, mediaFileSystemMock, contentSection, dataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper),
new ImageCropperPropertyEditor(logger, mediaFileSystemMock, contentSection, dataTypeService, LocalizationService, IOHelper, ShortStringHelper, LocalizedTextService),
});
_mediaUrlProvider = new DefaultMediaUrlProvider(propertyEditors, UriUtility);
}
@@ -32,7 +32,7 @@ namespace Umbraco.Tests.Routing
//create the module
var logger = Mock.Of<ILogger>();
var globalSettings = TestObjects.GetGlobalSettings();
var runtime = new RuntimeState(logger, Mock.Of<IUmbracoSettingsSection>(), globalSettings,
var runtime = new RuntimeState(logger, globalSettings,
new Lazy<IMainDom>(), new Lazy<IServerRegistrar>(), UmbracoVersion, HostingEnvironment, BackOfficeInfo);
_module = new UmbracoInjectedModule
@@ -34,7 +34,7 @@ namespace Umbraco.Tests.Routing
protected override void ComposeSettings()
{
Composition.Configs.Add(SettingsForTests.GenerateMockUmbracoSettings);
Composition.Configs.Add(SettingsForTests.GenerateMockContentSettings);
Composition.Configs.Add(SettingsForTests.GenerateMockGlobalSettings);
}
@@ -98,7 +98,7 @@ namespace Umbraco.Tests.Runtimes
{
var configs = new ConfigsFactory().Create(_ioHelper);
configs.Add(SettingsForTests.GetDefaultGlobalSettings);
configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
configs.Add(SettingsForTests.GenerateMockContentSettings);
configs.Add(SettingsForTests.GetDefaultHostingSettings);
return configs;
}
@@ -208,7 +208,7 @@ namespace Umbraco.Tests.Runtimes
public void Compose(Composition composition)
{
composition.Register(factory => SettingsForTests.GetDefaultUmbracoSettings());
composition.Register(factory => SettingsForTests.GenerateMockContentSettings());
composition.RegisterUnique<IExamineManager, TestExamineManager>();
composition.Components().Append<TestComponent>();
@@ -70,7 +70,7 @@ namespace Umbraco.Tests.Runtimes
var mainDom = new SimpleMainDom();
var umbracoVersion = TestHelper.GetUmbracoVersion();
var backOfficeInfo = TestHelper.GetBackOfficeInfo();
var runtimeState = new RuntimeState(logger, null, null, new Lazy<IMainDom>(() => mainDom), new Lazy<IServerRegistrar>(() => factory.GetInstance<IServerRegistrar>()), umbracoVersion, hostingEnvironment, backOfficeInfo);
var runtimeState = new RuntimeState(logger, null, new Lazy<IMainDom>(() => mainDom), new Lazy<IServerRegistrar>(() => factory.GetInstance<IServerRegistrar>()), umbracoVersion, hostingEnvironment, backOfficeInfo);
var configs = TestHelper.GetConfigs();
var variationContextAccessor = TestHelper.VariationContextAccessor;
@@ -121,7 +121,7 @@ namespace Umbraco.Tests.Runtimes
// configure
composition.Configs.Add(SettingsForTests.GetDefaultGlobalSettings);
composition.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
composition.Configs.Add(SettingsForTests.GenerateMockContentSettings);
// create and register the factory
Current.Factory = factory = composition.CreateFactory();
@@ -42,7 +42,7 @@ namespace Umbraco.Tests.Scoping
composition.WithCollectionBuilder<MapperCollectionBuilder>();
composition.Configs.Add(SettingsForTests.GetDefaultGlobalSettings);
composition.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
composition.Configs.Add(SettingsForTests.GenerateMockContentSettings);
Current.Reset();
Current.Factory = composition.CreateFactory();
@@ -112,7 +112,7 @@ namespace Umbraco.Tests.Scoping
settings);
}
protected IUmbracoContext GetUmbracoContextNu(string url, int templateId = 1234, RouteData routeData = null, bool setSingleton = false, IUmbracoSettingsSection umbracoSettings = null, IEnumerable<IUrlProvider> urlProviders = null)
protected IUmbracoContext GetUmbracoContextNu(string url, RouteData routeData = null, bool setSingleton = false)
{
// ensure we have a PublishedSnapshotService
var service = PublishedSnapshotService as PublishedSnapshotService;
+1 -1
View File
@@ -44,7 +44,7 @@ namespace Umbraco.Tests.Scoping
protected override void ComposeSettings()
{
Composition.Configs.Add(SettingsForTests.GenerateMockUmbracoSettings);
Composition.Configs.Add(SettingsForTests.GenerateMockContentSettings);
Composition.Configs.Add(SettingsForTests.GenerateMockGlobalSettings);
}
@@ -40,20 +40,15 @@ namespace Umbraco.Tests.TestHelpers
/// Returns generated settings which can be stubbed to return whatever values necessary
/// </summary>
/// <returns></returns>
public static IUmbracoSettingsSection GenerateMockUmbracoSettings()
public static IContentSettings GenerateMockContentSettings()
{
var settings = new Mock<IUmbracoSettingsSection>();
var content = new Mock<IContentSection>();
settings.Setup(x => x.Content).Returns(content.Object);
var content = new Mock<IContentSettings>();
//Now configure some defaults - the defaults in the config section classes do NOT pertain to the mocked data!!
settings.Setup(x => x.Content.ImageAutoFillProperties).Returns(ContentImagingElement.GetDefaultImageAutoFillProperties());
settings.Setup(x => x.Content.ImageFileTypes).Returns(ContentImagingElement.GetDefaultImageFileTypes());
return settings.Object;
content.Setup(x => x.ImageAutoFillProperties).Returns(ContentImagingElement.GetDefaultImageAutoFillProperties());
content.Setup(x => x.ImageFileTypes).Returns(ContentImagingElement.GetDefaultImageFileTypes());
return content.Object;
}
//// from appSettings
@@ -105,7 +100,6 @@ namespace Umbraco.Tests.TestHelpers
_defaultGlobalSettings = null;
}
private static IUmbracoSettingsSection _defaultUmbracoSettings;
private static IGlobalSettings _defaultGlobalSettings;
private static IHostingSettings _defaultHostingSettings;
@@ -137,22 +131,6 @@ namespace Umbraco.Tests.TestHelpers
return config;
}
internal static IUmbracoSettingsSection GetDefaultUmbracoSettings()
{
if (_defaultUmbracoSettings == null)
{
// TODO: Just make this mocks instead of reading from the config
var config = new FileInfo(TestHelper.MapPathForTest("~/Configurations/UmbracoSettings/web.config"));
var fileMap = new ExeConfigurationFileMap { ExeConfigFilename = config.FullName };
var configuration = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
_defaultUmbracoSettings = configuration.GetSection("umbracoConfiguration/defaultSettings") as UmbracoSettingsSection;
}
return _defaultUmbracoSettings;
}
public static IWebRoutingSettings GenerateMockWebRoutingSettings()
{
var mock = new Mock<IWebRoutingSettings>();
@@ -56,7 +56,6 @@ namespace Umbraco.Tests.TestHelpers
{
return new RuntimeState(
Mock.Of<ILogger>(),
Mock.Of<IUmbracoSettingsSection>(),
Mock.Of<IGlobalSettings>(),
new Lazy<IMainDom>(),
new Lazy<IServerRegistrar>(),
@@ -140,17 +140,6 @@ namespace Umbraco.Tests.TestHelpers
return umbracoContextFactory.EnsureUmbracoContext().UmbracoContext;
}
public IUmbracoSettingsSection GetUmbracoSettings()
{
// FIXME: Why not use the SettingsForTest.GenerateMock ... ?
// FIXME: Shouldn't we use the default ones so they are the same instance for each test?
var umbracoSettingsMock = new Mock<IUmbracoSettingsSection>();
var webRoutingSectionMock = new Mock<IWebRoutingSettings>();
webRoutingSectionMock.Setup(x => x.UrlProviderMode).Returns(UrlMode.Auto.ToString());
return umbracoSettingsMock.Object;
}
public IGlobalSettings GetGlobalSettings()
{
return SettingsForTests.GetDefaultGlobalSettings();
+2 -2
View File
@@ -95,7 +95,7 @@ namespace Umbraco.Tests.TestHelpers
ILogger logger,
IIOHelper ioHelper,
IGlobalSettings globalSettings,
IUmbracoSettingsSection umbracoSettings,
IContentSettings contentSettings,
IEventMessagesFactory eventMessagesFactory,
UrlSegmentProviderCollection urlSegmentProviders,
TypeLoader typeLoader,
@@ -161,7 +161,7 @@ namespace Umbraco.Tests.TestHelpers
var dataTypeService = GetLazyService<IDataTypeService>(factory, c => new DataTypeService(scopeProvider, logger, eventMessagesFactory, GetRepo<IDataTypeRepository>(c), GetRepo<IDataTypeContainerRepository>(c), GetRepo<IAuditRepository>(c), GetRepo<IEntityRepository>(c), GetRepo<IContentTypeRepository>(c), ioHelper, localizedTextService.Value, localizationService.Value, TestHelper.ShortStringHelper));
var propertyValidationService = new Lazy<IPropertyValidationService>(() => new PropertyValidationService(propertyEditorCollection, dataTypeService.Value));
var contentService = GetLazyService<IContentService>(factory, c => new ContentService(scopeProvider, logger, eventMessagesFactory, GetRepo<IDocumentRepository>(c), GetRepo<IEntityRepository>(c), GetRepo<IAuditRepository>(c), GetRepo<IContentTypeRepository>(c), GetRepo<IDocumentBlueprintRepository>(c), GetRepo<ILanguageRepository>(c), propertyValidationService));
var notificationService = GetLazyService<INotificationService>(factory, c => new NotificationService(scopeProvider, userService.Value, contentService.Value, localizationService.Value, logger, ioHelper, GetRepo<INotificationsRepository>(c), globalSettings, umbracoSettings.Content));
var notificationService = GetLazyService<INotificationService>(factory, c => new NotificationService(scopeProvider, userService.Value, contentService.Value, localizationService.Value, logger, ioHelper, GetRepo<INotificationsRepository>(c), globalSettings, contentSettings));
var serverRegistrationService = GetLazyService<IServerRegistrationService>(factory, c => new ServerRegistrationService(scopeProvider, logger, eventMessagesFactory, GetRepo<IServerRegistrationRepository>(c), TestHelper.GetHostingEnvironment()));
var memberGroupService = GetLazyService<IMemberGroupService>(factory, c => new MemberGroupService(scopeProvider, logger, eventMessagesFactory, GetRepo<IMemberGroupRepository>(c)));
var memberService = GetLazyService<IMemberService>(factory, c => new MemberService(scopeProvider, logger, eventMessagesFactory, memberGroupService.Value, GetRepo<IMemberRepository>(c), GetRepo<IMemberTypeRepository>(c), GetRepo<IMemberGroupRepository>(c), GetRepo<IAuditRepository>(c)));
+1 -5
View File
@@ -411,7 +411,6 @@ namespace Umbraco.Tests.Testing
protected virtual void ComposeSettings()
{
Composition.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
Composition.Configs.Add(SettingsForTests.GetDefaultGlobalSettings);
Composition.Configs.Add(SettingsForTests.GetDefaultHostingSettings);
Composition.Configs.Add(SettingsForTests.GenerateMockRequestHandlerSettings);
@@ -419,6 +418,7 @@ namespace Umbraco.Tests.Testing
Composition.Configs.Add(SettingsForTests.GenerateMockSecuritySettings);
Composition.Configs.Add(SettingsForTests.GenerateMockUserPasswordConfiguration);
Composition.Configs.Add(SettingsForTests.GenerateMockMemberPasswordConfiguration);
Composition.Configs.Add(SettingsForTests.GenerateMockContentSettings);
//Composition.Configs.Add<IUserPasswordConfiguration>(() => new DefaultUserPasswordConfig());
}
@@ -432,10 +432,6 @@ namespace Umbraco.Tests.Testing
// default Datalayer/Repositories/SQL/Database/etc...
Composition.ComposeRepositories();
// register basic stuff that might need to be there for some container resolvers to work
Composition.RegisterUnique(factory => factory.GetInstance<IUmbracoSettingsSection>().Content);
Composition.RegisterUnique(factory => factory.GetInstance<IWebRoutingSettings>());
Composition.RegisterUnique<IExamineManager, ExamineManager>();
Composition.RegisterUnique<IJsonSerializer, JsonNetSerializer>();
@@ -89,7 +89,7 @@ namespace Umbraco.Tests.Web.Controllers
Factory.GetInstance<IMediaFileSystem>(),
ShortStringHelper,
Factory.GetInstance<UmbracoMapper>(),
Factory.GetInstance<IUmbracoSettingsSection>(),
Factory.GetInstance<IContentSettings>(),
Factory.GetInstance<IIOHelper>(),
Factory.GetInstance<IImageUrlGenerator>(),
Factory.GetInstance<IPublishedUrlProvider>(),
@@ -162,7 +162,7 @@ namespace Umbraco.Tests.Web.Controllers
Factory.GetInstance<IMediaFileSystem>(),
ShortStringHelper,
Factory.GetInstance<UmbracoMapper>(),
Factory.GetInstance<IUmbracoSettingsSection>(),
Factory.GetInstance<IContentSettings>(),
Factory.GetInstance<IIOHelper>(),
Factory.GetInstance<IImageUrlGenerator>(),
Factory.GetInstance<IPublishedUrlProvider>(),
@@ -205,7 +205,7 @@ namespace Umbraco.Tests.Web.Controllers
Factory.GetInstance<IMediaFileSystem>(),
ShortStringHelper,
Factory.GetInstance<UmbracoMapper>(),
Factory.GetInstance<IUmbracoSettingsSection>(),
Factory.GetInstance<IContentSettings>(),
Factory.GetInstance<IIOHelper>(),
Factory.GetInstance<IImageUrlGenerator>(),
Factory.GetInstance<IPublishedUrlProvider>(),
@@ -283,7 +283,7 @@ namespace Umbraco.Tests.Web.Controllers
Factory.GetInstance<IMediaFileSystem>(),
ShortStringHelper,
Factory.GetInstance<UmbracoMapper>(),
Factory.GetInstance<IUmbracoSettingsSection>(),
Factory.GetInstance<IContentSettings>(),
Factory.GetInstance<IIOHelper>(),
Factory.GetInstance<IImageUrlGenerator>(),
Factory.GetInstance<IPublishedUrlProvider>(),
@@ -385,11 +385,7 @@ namespace Umbraco.Tests.Web.Mvc
ViewContext GetViewContext()
{
var settings = SettingsForTests.GetDefaultUmbracoSettings();
var logger = Mock.Of<ILogger>();
var umbracoContext = GetUmbracoContext(
logger, settings,
"/dang", 0);
var umbracoContext = GetUmbracoContext("/dang", 0);
var publishedRouter = BaseWebTest.CreatePublishedRouter(SettingsForTests.GenerateMockWebRoutingSettings());
var frequest = publishedRouter.CreateRequest(umbracoContext, new Uri("http://localhost/dang"));
@@ -404,7 +400,7 @@ namespace Umbraco.Tests.Web.Mvc
return context;
}
protected IUmbracoContext GetUmbracoContext(ILogger logger, IUmbracoSettingsSection umbracoSettings, string url, int templateId, RouteData routeData = null, bool setSingleton = false)
protected IUmbracoContext GetUmbracoContext(string url, int templateId, RouteData routeData = null, bool setSingleton = false)
{
var svcCtx = GetServiceContext();
@@ -48,7 +48,7 @@
redirectUrl = Url.Action("AuthorizeUpgrade", "BackOffice")
});
}
@Html.BareMinimumServerVariablesScript(Url, externalLoginUrl, Model.Features, Model.GlobalSettings, Model.UmbracoVersion, Model.UmbracoSettingsSection, Model.IOHelper, Model.TreeCollection, Model.HttpContextAccessor, Model.HostingEnvironment, Model.RuntimeSettings, Model.SecuritySettings)
@Html.BareMinimumServerVariablesScript(Url, externalLoginUrl, Model.Features, Model.GlobalSettings, Model.UmbracoVersion, Model.ContentSettings, Model.IOHelper, Model.TreeCollection, Model.HttpContextAccessor, Model.HostingEnvironment, Model.RuntimeSettings, Model.SecuritySettings)
<script type="text/javascript">
document.angularReady = function (app) {
@@ -110,7 +110,7 @@
on-login="hideLoginScreen()">
</umb-login>
@Html.BareMinimumServerVariablesScript(Url, Url.Action("ExternalLogin", "BackOffice", new { area = ViewData.GetUmbracoPath() }), Model.Features, Model.GlobalSettings, Model.UmbracoVersion, Model.UmbracoSettingsSection, Model.IOHelper, Model.TreeCollection, Model.HttpContextAccessor, Model.HostingEnvironment, Model.RuntimeSettings, Model.SecuritySettings)
@Html.BareMinimumServerVariablesScript(Url, Url.Action("ExternalLogin", "BackOffice", new { area = ViewData.GetUmbracoPath() }), Model.Features, Model.GlobalSettings, Model.UmbracoVersion, Model.ContentSettings, Model.IOHelper, Model.TreeCollection, Model.HttpContextAccessor, Model.HostingEnvironment, Model.RuntimeSettings, Model.SecuritySettings)
<script>
@@ -48,7 +48,7 @@ namespace Umbraco.Web.Editors
private BackOfficeSignInManager _signInManager;
private readonly IUmbracoVersion _umbracoVersion;
private readonly IGridConfig _gridConfig;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
private readonly IContentSettings _contentSettings;
private readonly IIOHelper _ioHelper;
private readonly TreeCollection _treeCollection;
private readonly IHostingEnvironment _hostingEnvironment;
@@ -67,7 +67,7 @@ namespace Umbraco.Web.Editors
IRuntimeState runtimeState,
IUmbracoVersion umbracoVersion,
IGridConfig gridConfig,
IUmbracoSettingsSection umbracoSettingsSection,
IContentSettings contentSettings,
IIOHelper ioHelper,
TreeCollection treeCollection,
IHostingEnvironment hostingEnvironment,
@@ -82,7 +82,7 @@ namespace Umbraco.Web.Editors
_runtimeState = runtimeState;
_umbracoVersion = umbracoVersion;
_gridConfig = gridConfig ?? throw new ArgumentNullException(nameof(gridConfig));
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
_contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings));
_ioHelper = ioHelper ?? throw new ArgumentNullException(nameof(ioHelper));
_treeCollection = treeCollection ?? throw new ArgumentNullException(nameof(treeCollection));
_hostingEnvironment = hostingEnvironment;
@@ -104,8 +104,8 @@ namespace Umbraco.Web.Editors
public async Task<ActionResult> Default()
{
return await RenderDefaultOrProcessExternalLoginAsync(
() => View(GlobalSettings.Path.EnsureEndsWith('/') + "Views/Default.cshtml", new BackOfficeModel(_features, GlobalSettings, _umbracoVersion, _umbracoSettingsSection,_ioHelper, _treeCollection, _httpContextAccessor, _hostingEnvironment, _runtimeSettings, _securitySettings)),
() => View(GlobalSettings.Path.EnsureEndsWith('/') + "Views/Default.cshtml", new BackOfficeModel(_features, GlobalSettings, _umbracoVersion, _umbracoSettingsSection, _ioHelper, _treeCollection, _httpContextAccessor, _hostingEnvironment, _runtimeSettings, _securitySettings)));
() => View(GlobalSettings.Path.EnsureEndsWith('/') + "Views/Default.cshtml", new BackOfficeModel(_features, GlobalSettings, _umbracoVersion, _contentSettings,_ioHelper, _treeCollection, _httpContextAccessor, _hostingEnvironment, _runtimeSettings, _securitySettings)),
() => View(GlobalSettings.Path.EnsureEndsWith('/') + "Views/Default.cshtml", new BackOfficeModel(_features, GlobalSettings, _umbracoVersion, _contentSettings, _ioHelper, _treeCollection, _httpContextAccessor, _hostingEnvironment, _runtimeSettings, _securitySettings)));
}
[HttpGet]
@@ -188,7 +188,7 @@ namespace Umbraco.Web.Editors
{
return await RenderDefaultOrProcessExternalLoginAsync(
//The default view to render when there is no external login info or errors
() => View(GlobalSettings.Path.EnsureEndsWith('/') + "Views/AuthorizeUpgrade.cshtml", new BackOfficeModel(_features, GlobalSettings, _umbracoVersion, _umbracoSettingsSection, _ioHelper, _treeCollection, _httpContextAccessor, _hostingEnvironment, _runtimeSettings, _securitySettings)),
() => View(GlobalSettings.Path.EnsureEndsWith('/') + "Views/AuthorizeUpgrade.cshtml", new BackOfficeModel(_features, GlobalSettings, _umbracoVersion, _contentSettings, _ioHelper, _treeCollection, _httpContextAccessor, _hostingEnvironment, _runtimeSettings, _securitySettings)),
//The ActionResult to perform if external login is successful
() => Redirect("/"));
}
@@ -295,7 +295,7 @@ namespace Umbraco.Web.Editors
[MinifyJavaScriptResult(Order = 1)]
public JavaScriptResult ServerVariables()
{
var serverVars = new BackOfficeServerVariables(Url, _runtimeState, _features, GlobalSettings, _umbracoVersion, _umbracoSettingsSection, _ioHelper, _treeCollection, _httpContextAccessor, _hostingEnvironment, _runtimeSettings, _securitySettings);
var serverVars = new BackOfficeServerVariables(Url, _runtimeState, _features, GlobalSettings, _umbracoVersion, _contentSettings, _ioHelper, _treeCollection, _httpContextAccessor, _hostingEnvironment, _runtimeSettings, _securitySettings);
//cache the result if debugging is disabled
var result = _hostingEnvironment.IsDebugMode
+3 -3
View File
@@ -11,14 +11,14 @@ namespace Umbraco.Web.Editors
public class BackOfficeModel
{
public BackOfficeModel(UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion,
IUmbracoSettingsSection umbracoSettingsSection, IIOHelper ioHelper, TreeCollection treeCollection,
IContentSettings contentSettings, IIOHelper ioHelper, TreeCollection treeCollection,
IHttpContextAccessor httpContextAccessor, IHostingEnvironment hostingEnvironment,
IRuntimeSettings runtimeSettings, ISecuritySettings securitySettings)
{
Features = features;
GlobalSettings = globalSettings;
UmbracoVersion = umbracoVersion;
UmbracoSettingsSection = umbracoSettingsSection;
ContentSettings = contentSettings;
IOHelper = ioHelper;
TreeCollection = treeCollection;
HttpContextAccessor = httpContextAccessor;
@@ -30,7 +30,7 @@ namespace Umbraco.Web.Editors
public UmbracoFeatures Features { get; }
public IGlobalSettings GlobalSettings { get; }
public IUmbracoVersion UmbracoVersion { get; }
public IUmbracoSettingsSection UmbracoSettingsSection { get; }
public IContentSettings ContentSettings { get; }
public IIOHelper IOHelper { get; }
public TreeCollection TreeCollection { get; }
public IHttpContextAccessor HttpContextAccessor { get; }
@@ -14,8 +14,8 @@ namespace Umbraco.Web.Editors
private readonly UmbracoFeatures _features;
public IEnumerable<ILanguage> Languages { get; }
public BackOfficePreviewModel(UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion, IEnumerable<ILanguage> languages, IUmbracoSettingsSection umbracoSettingsSection, IIOHelper ioHelper, TreeCollection treeCollection, IHttpContextAccessor httpContextAccessor, IHostingEnvironment hostingEnvironment, IRuntimeSettings runtimeSettings, ISecuritySettings securitySettings)
: base(features, globalSettings, umbracoVersion, umbracoSettingsSection, ioHelper, treeCollection, httpContextAccessor, hostingEnvironment, runtimeSettings, securitySettings)
public BackOfficePreviewModel(UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion, IEnumerable<ILanguage> languages, IContentSettings contentSettings, IIOHelper ioHelper, TreeCollection treeCollection, IHttpContextAccessor httpContextAccessor, IHostingEnvironment hostingEnvironment, IRuntimeSettings runtimeSettings, ISecuritySettings securitySettings)
: base(features, globalSettings, umbracoVersion, contentSettings, ioHelper, treeCollection, httpContextAccessor, hostingEnvironment, runtimeSettings, securitySettings)
{
_features = features;
Languages = languages;
@@ -33,7 +33,7 @@ namespace Umbraco.Web.Editors
private readonly UmbracoFeatures _features;
private readonly IGlobalSettings _globalSettings;
private readonly IUmbracoVersion _umbracoVersion;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
private readonly IContentSettings _contentSettings;
private readonly IIOHelper _ioHelper;
private readonly TreeCollection _treeCollection;
private readonly IHttpContextAccessor _httpContextAccessor;
@@ -47,7 +47,7 @@ namespace Umbraco.Web.Editors
UmbracoFeatures features,
IGlobalSettings globalSettings,
IUmbracoVersion umbracoVersion,
IUmbracoSettingsSection umbracoSettingsSection,
IContentSettings contentSettings,
IIOHelper ioHelper,
TreeCollection treeCollection,
IHttpContextAccessor httpContextAccessor,
@@ -60,7 +60,7 @@ namespace Umbraco.Web.Editors
_features = features;
_globalSettings = globalSettings;
_umbracoVersion = umbracoVersion;
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
_contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings));
_ioHelper = ioHelper ?? throw new ArgumentNullException(nameof(ioHelper));
_treeCollection = treeCollection ?? throw new ArgumentNullException(nameof(treeCollection));
_httpContextAccessor = httpContextAccessor;
@@ -349,15 +349,15 @@ namespace Umbraco.Web.Editors
{"appPluginsPath", _ioHelper.ResolveUrl(Constants.SystemDirectories.AppPlugins).TrimEnd('/')},
{
"imageFileTypes",
string.Join(",", _umbracoSettingsSection.Content.ImageFileTypes)
string.Join(",", _contentSettings.ImageFileTypes)
},
{
"disallowedUploadFiles",
string.Join(",", _umbracoSettingsSection.Content.DisallowedUploadFiles)
string.Join(",", _contentSettings.DisallowedUploadFiles)
},
{
"allowedUploadFiles",
string.Join(",", _umbracoSettingsSection.Content.AllowedUploadFiles)
string.Join(",", _contentSettings.AllowedUploadFiles)
},
{
"maxFileSize",
@@ -367,7 +367,7 @@ namespace Umbraco.Web.Editors
{"usernameIsEmail", _securitySettings.UsernameIsEmail},
{"cssPath", _ioHelper.ResolveUrl(globalSettings.UmbracoCssPath).TrimEnd('/')},
{"allowPasswordReset", _securitySettings.AllowPasswordReset},
{"loginBackgroundImage", _umbracoSettingsSection.Content.LoginBackgroundImage},
{"loginBackgroundImage", _contentSettings.LoginBackgroundImage},
{"showUserInvite", EmailSender.CanSendRequiredEmail(globalSettings)},
{"canSendRequiredEmail", EmailSender.CanSendRequiredEmail(globalSettings)},
}
@@ -34,7 +34,7 @@ namespace Umbraco.Web.Editors
public class CurrentUserController : UmbracoAuthorizedJsonController
{
private readonly IMediaFileSystem _mediaFileSystem;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
private readonly IContentSettings _contentSettings;
private readonly IIOHelper _ioHelper;
private readonly IImageUrlGenerator _imageUrlGenerator;
@@ -49,14 +49,14 @@ namespace Umbraco.Web.Editors
IMediaFileSystem mediaFileSystem,
IShortStringHelper shortStringHelper,
UmbracoMapper umbracoMapper,
IUmbracoSettingsSection umbracoSettingsSection,
IContentSettings contentSettings,
IIOHelper ioHelper,
IImageUrlGenerator imageUrlGenerator,
IPublishedUrlProvider publishedUrlProvider)
: base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, shortStringHelper, umbracoMapper, publishedUrlProvider)
{
_mediaFileSystem = mediaFileSystem;
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
_contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings));
_ioHelper = ioHelper ?? throw new ArgumentNullException(nameof(ioHelper));
_imageUrlGenerator = imageUrlGenerator;
}
@@ -192,7 +192,7 @@ namespace Umbraco.Web.Editors
public async Task<HttpResponseMessage> PostSetAvatar()
{
//borrow the logic from the user controller
return await UsersController.PostSetAvatarInternal(Request, Services.UserService, AppCaches.RuntimeCache, _mediaFileSystem, ShortStringHelper, _umbracoSettingsSection, _ioHelper, _imageUrlGenerator, Security.GetUserId().ResultOr(0));
return await UsersController.PostSetAvatarInternal(Request, Services.UserService, AppCaches.RuntimeCache, _mediaFileSystem, ShortStringHelper, _contentSettings, _ioHelper, _imageUrlGenerator, Security.GetUserId().ResultOr(0));
}
/// <summary>
@@ -43,7 +43,7 @@ namespace Umbraco.Web.Editors
public class DataTypeController : BackOfficeNotificationsController
{
private readonly PropertyEditorCollection _propertyEditors;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
private readonly IContentSettings _contentSettings;
public DataTypeController(
PropertyEditorCollection propertyEditors,
@@ -56,12 +56,12 @@ namespace Umbraco.Web.Editors
IRuntimeState runtimeState,
IShortStringHelper shortStringHelper,
UmbracoMapper umbracoMapper,
IUmbracoSettingsSection umbracoSettingsSection,
IContentSettings contentSettings,
IPublishedUrlProvider publishedUrlProvider)
: base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, shortStringHelper, umbracoMapper, publishedUrlProvider)
{
_propertyEditors = propertyEditors;
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
_contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings));
}
/// <summary>
@@ -468,7 +468,7 @@ namespace Umbraco.Web.Editors
public IDictionary<string, IEnumerable<DataTypeBasic>> GetGroupedPropertyEditors()
{
var datatypes = new List<DataTypeBasic>();
var showDeprecatedPropertyEditors = _umbracoSettingsSection.Content.ShowDeprecatedPropertyEditors;
var showDeprecatedPropertyEditors = _contentSettings.ShowDeprecatedPropertyEditors;
var propertyEditors = Current.PropertyEditors
.Where(x=>x.IsDeprecated == false || showDeprecatedPropertyEditors);
+4 -4
View File
@@ -17,13 +17,13 @@ namespace Umbraco.Web.Editors
public class ImagesController : UmbracoAuthorizedApiController
{
private readonly IMediaFileSystem _mediaFileSystem;
private readonly IContentSection _contentSection;
private readonly IContentSettings _contentSettings;
private readonly IImageUrlGenerator _imageUrlGenerator;
public ImagesController(IMediaFileSystem mediaFileSystem, IContentSection contentSection, IImageUrlGenerator imageUrlGenerator)
public ImagesController(IMediaFileSystem mediaFileSystem, IContentSettings contentSettings, IImageUrlGenerator imageUrlGenerator)
{
_mediaFileSystem = mediaFileSystem;
_contentSection = contentSection;
_contentSettings = contentSettings;
_imageUrlGenerator = imageUrlGenerator;
}
@@ -56,7 +56,7 @@ namespace Umbraco.Web.Editors
var ext = Path.GetExtension(imagePath);
// we need to check if it is an image by extension
if (_contentSection.IsImageFile(ext) == false)
if (_contentSettings.IsImageFile(ext) == false)
return Request.CreateResponse(HttpStatusCode.NotFound);
//redirect to ImageProcessor thumbnail with rnd generated from last modified time of original media file
+5 -5
View File
@@ -50,7 +50,7 @@ namespace Umbraco.Web.Editors
[MediaControllerControllerConfiguration]
public class MediaController : ContentControllerBase
{
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
private readonly IContentSettings _contentSettings;
private readonly IIOHelper _ioHelper;
public MediaController(
@@ -66,14 +66,14 @@ namespace Umbraco.Web.Editors
IMediaFileSystem mediaFileSystem,
IShortStringHelper shortStringHelper,
UmbracoMapper umbracoMapper,
IUmbracoSettingsSection umbracoSettingsSection,
IContentSettings contentSettings,
IIOHelper ioHelper,
IPublishedUrlProvider publishedUrlProvider)
: base(cultureDictionary, globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, shortStringHelper, umbracoMapper, publishedUrlProvider)
{
_propertyEditors = propertyEditors ?? throw new ArgumentNullException(nameof(propertyEditors));
_mediaFileSystem = mediaFileSystem;
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
_contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings));
_ioHelper = ioHelper ?? throw new ArgumentNullException(nameof(ioHelper));
}
@@ -722,13 +722,13 @@ namespace Umbraco.Web.Editors
var safeFileName = fileName.ToSafeFileName(ShortStringHelper);
var ext = safeFileName.Substring(safeFileName.LastIndexOf('.') + 1).ToLower();
if (_umbracoSettingsSection.Content.IsFileAllowedForUpload(ext))
if (_contentSettings.IsFileAllowedForUpload(ext))
{
var mediaType = Constants.Conventions.MediaTypes.File;
if (result.FormData["contentTypeAlias"] == Constants.Conventions.MediaTypes.AutoSelect)
{
if (_umbracoSettingsSection.Content.ImageFileTypes.Contains(ext))
if (_contentSettings.ImageFileTypes.Contains(ext))
{
mediaType = Constants.Conventions.MediaTypes.Image;
}
+4 -4
View File
@@ -30,7 +30,7 @@ namespace Umbraco.Web.Editors
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
private readonly ILocalizationService _localizationService;
private readonly IUmbracoVersion _umbracoVersion;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
private readonly IContentSettings _contentSettings;
private readonly IIOHelper _ioHelper;
private readonly TreeCollection _treeCollection;
private readonly IHttpContextAccessor _httpContextAccessor;
@@ -46,7 +46,7 @@ namespace Umbraco.Web.Editors
IUmbracoContextAccessor umbracoContextAccessor,
ILocalizationService localizationService,
IUmbracoVersion umbracoVersion,
IUmbracoSettingsSection umbracoSettingsSection,
IContentSettings contentSettings,
IIOHelper ioHelper,
TreeCollection treeCollection,
IHttpContextAccessor httpContextAccessor,
@@ -61,7 +61,7 @@ namespace Umbraco.Web.Editors
_umbracoContextAccessor = umbracoContextAccessor;
_localizationService = localizationService;
_umbracoVersion = umbracoVersion;
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
_contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings));
_ioHelper = ioHelper ?? throw new ArgumentNullException(nameof(ioHelper));
_treeCollection = treeCollection;
_httpContextAccessor = httpContextAccessor;
@@ -77,7 +77,7 @@ namespace Umbraco.Web.Editors
{
var availableLanguages = _localizationService.GetAllLanguages();
var model = new BackOfficePreviewModel(_features, _globalSettings, _umbracoVersion, availableLanguages, _umbracoSettingsSection, _ioHelper, _treeCollection, _httpContextAccessor, _hostingEnvironment, _runtimeSettings, _securitySettings);
var model = new BackOfficePreviewModel(_features, _globalSettings, _umbracoVersion, availableLanguages, _contentSettings, _ioHelper, _treeCollection, _httpContextAccessor, _hostingEnvironment, _runtimeSettings, _securitySettings);
if (model.PreviewExtendedHeaderView.IsNullOrWhiteSpace() == false)
{
+4 -4
View File
@@ -32,7 +32,7 @@ namespace Umbraco.Web.Editors
{
private readonly IIOHelper _ioHelper;
private readonly IShortStringHelper _shortStringHelper;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
private readonly IContentSettings _contentSettings;
public TinyMceController(
IGlobalSettings globalSettings,
@@ -44,13 +44,13 @@ namespace Umbraco.Web.Editors
IRuntimeState runtimeState,
UmbracoMapper umbracoMapper,
IShortStringHelper shortStringHelper,
IUmbracoSettingsSection umbracoSettingsSection,
IContentSettings contentSettings,
IIOHelper ioHelper,
IPublishedUrlProvider publishedUrlProvider)
: base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoMapper, publishedUrlProvider)
{
_shortStringHelper = shortStringHelper ?? throw new ArgumentNullException(nameof(shortStringHelper));
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
_contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings));
_ioHelper = ioHelper ?? throw new ArgumentNullException(nameof(ioHelper));
}
@@ -97,7 +97,7 @@ namespace Umbraco.Web.Editors
var safeFileName = fileName.ToSafeFileName(_shortStringHelper);
var ext = safeFileName.Substring(safeFileName.LastIndexOf('.') + 1).ToLower();
if (_umbracoSettingsSection.Content.IsFileAllowedForUpload(ext) == false || _umbracoSettingsSection.Content.ImageFileTypes.Contains(ext) == false)
if (_contentSettings.IsFileAllowedForUpload(ext) == false || _contentSettings.ImageFileTypes.Contains(ext) == false)
{
// Throw some error - to say can't upload this IMG type
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "This is not an image filetype extension that is approved");
+6 -6
View File
@@ -46,7 +46,7 @@ namespace Umbraco.Web.Editors
public class UsersController : UmbracoAuthorizedJsonController
{
private readonly IMediaFileSystem _mediaFileSystem;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
private readonly IContentSettings _contentSettings;
private readonly IIOHelper _ioHelper;
private readonly ISqlContext _sqlContext;
private readonly IImageUrlGenerator _imageUrlGenerator;
@@ -63,7 +63,7 @@ namespace Umbraco.Web.Editors
IMediaFileSystem mediaFileSystem,
IShortStringHelper shortStringHelper,
UmbracoMapper umbracoMapper,
IUmbracoSettingsSection umbracoSettingsSection,
IContentSettings contentSettings,
IIOHelper ioHelper,
IImageUrlGenerator imageUrlGenerator,
IPublishedUrlProvider publishedUrlProvider,
@@ -71,7 +71,7 @@ namespace Umbraco.Web.Editors
: base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, shortStringHelper, umbracoMapper, publishedUrlProvider)
{
_mediaFileSystem = mediaFileSystem;
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
_contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings));
_ioHelper = ioHelper;
_sqlContext = sqlContext;
_imageUrlGenerator = imageUrlGenerator;
@@ -96,10 +96,10 @@ namespace Umbraco.Web.Editors
[AdminUsersAuthorize]
public async Task<HttpResponseMessage> PostSetAvatar(int id)
{
return await PostSetAvatarInternal(Request, Services.UserService, AppCaches.RuntimeCache, _mediaFileSystem, ShortStringHelper, _umbracoSettingsSection, _ioHelper, _imageUrlGenerator, id);
return await PostSetAvatarInternal(Request, Services.UserService, AppCaches.RuntimeCache, _mediaFileSystem, ShortStringHelper, _contentSettings, _ioHelper, _imageUrlGenerator, id);
}
internal static async Task<HttpResponseMessage> PostSetAvatarInternal(HttpRequestMessage request, IUserService userService, IAppCache cache, IMediaFileSystem mediaFileSystem, IShortStringHelper shortStringHelper, IUmbracoSettingsSection umbracoSettingsSection, IIOHelper ioHelper, IImageUrlGenerator imageUrlGenerator, int id)
internal static async Task<HttpResponseMessage> PostSetAvatarInternal(HttpRequestMessage request, IUserService userService, IAppCache cache, IMediaFileSystem mediaFileSystem, IShortStringHelper shortStringHelper, IContentSettings contentSettings, IIOHelper ioHelper, IImageUrlGenerator imageUrlGenerator, int id)
{
if (request.Content.IsMimeMultipartContent() == false)
{
@@ -134,7 +134,7 @@ namespace Umbraco.Web.Editors
var safeFileName = fileName.ToSafeFileName(shortStringHelper);
var ext = safeFileName.Substring(safeFileName.LastIndexOf('.') + 1).ToLower();
if (umbracoSettingsSection.Content.DisallowedUploadFiles.Contains(ext) == false)
if (contentSettings.DisallowedUploadFiles.Contains(ext) == false)
{
//generate a path of known data, we don't want this path to be guessable
user.Avatar = "UserAvatars/" + (user.Id + safeFileName).GenerateHash<SHA1>() + "." + ext;
@@ -40,9 +40,9 @@ namespace Umbraco.Web
/// These are the bare minimal server variables that are required for the application to start without being authenticated,
/// we will load the rest of the server vars after the user is authenticated.
/// </remarks>
public static IHtmlString BareMinimumServerVariablesScript(this HtmlHelper html, UrlHelper uri, string externalLoginsUrl, UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion, IUmbracoSettingsSection umbracoSettingsSection, IIOHelper ioHelper, TreeCollection treeCollection, IHttpContextAccessor httpContextAccessor, IHostingEnvironment hostingEnvironment, IRuntimeSettings settings, ISecuritySettings securitySettings)
public static IHtmlString BareMinimumServerVariablesScript(this HtmlHelper html, UrlHelper uri, string externalLoginsUrl, UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion, IContentSettings contentSettings, IIOHelper ioHelper, TreeCollection treeCollection, IHttpContextAccessor httpContextAccessor, IHostingEnvironment hostingEnvironment, IRuntimeSettings settings, ISecuritySettings securitySettings)
{
var serverVars = new BackOfficeServerVariables(uri, Current.RuntimeState, features, globalSettings, umbracoVersion, umbracoSettingsSection, ioHelper, treeCollection, httpContextAccessor, hostingEnvironment, settings, securitySettings);
var serverVars = new BackOfficeServerVariables(uri, Current.RuntimeState, features, globalSettings, umbracoVersion, contentSettings, ioHelper, treeCollection, httpContextAccessor, hostingEnvironment, settings, securitySettings);
var minVars = serverVars.BareMinimumServerVariables();
var str = @"<script type=""text/javascript"">
@@ -60,12 +60,12 @@ namespace Umbraco.Web
/// <remarks>
/// See: http://issues.umbraco.org/issue/U4-1614
/// </remarks>
public static MvcHtmlString PreviewBadge(this HtmlHelper helper, IHttpContextAccessor httpContextAccessor, IGlobalSettings globalSettings, IIOHelper ioHelper, IUmbracoSettingsSection umbracoSettingsSection)
public static MvcHtmlString PreviewBadge(this HtmlHelper helper, IHttpContextAccessor httpContextAccessor, IGlobalSettings globalSettings, IIOHelper ioHelper, IContentSettings contentSettings)
{
if (Current.UmbracoContext.InPreviewMode)
{
var htmlBadge =
String.Format(umbracoSettingsSection.Content.PreviewBadge,
String.Format(contentSettings.PreviewBadge,
ioHelper.ResolveUrl(globalSettings.UmbracoPath),
WebUtility.UrlEncode(httpContextAccessor.GetRequiredHttpContext().Request.Path),
Current.UmbracoContext.PublishedRequest.PublishedContent.Id);
+4 -4
View File
@@ -23,7 +23,7 @@ namespace Umbraco.Web.Macros
{
private readonly IProfilingLogger _plogger;
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
private readonly IContentSection _contentSection;
private readonly IContentSettings _contentSettings;
private readonly ILocalizedTextService _textService;
private readonly AppCaches _appCaches;
private readonly IMacroService _macroService;
@@ -38,7 +38,7 @@ namespace Umbraco.Web.Macros
public MacroRenderer(
IProfilingLogger plogger,
IUmbracoContextAccessor umbracoContextAccessor,
IContentSection contentSection,
IContentSettings contentSettings,
ILocalizedTextService textService,
AppCaches appCaches,
IMacroService macroService,
@@ -51,7 +51,7 @@ namespace Umbraco.Web.Macros
{
_plogger = plogger ?? throw new ArgumentNullException(nameof(plogger));
_umbracoContextAccessor = umbracoContextAccessor ?? throw new ArgumentNullException(nameof(umbracoContextAccessor));
_contentSection = contentSection ?? throw new ArgumentNullException(nameof(contentSection));
_contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings));
_textService = textService;
_appCaches = appCaches ?? throw new ArgumentNullException(nameof(appCaches));
_macroService = macroService ?? throw new ArgumentNullException(nameof(macroService));
@@ -284,7 +284,7 @@ namespace Umbraco.Web.Macros
Alias = macro.Alias,
MacroSource = macro.MacroSource,
Exception = e,
Behaviour = _contentSection.MacroErrorBehaviour
Behaviour = _contentSettings.MacroErrorBehaviour
};
switch (macroErrorEventArgs.Behaviour)
@@ -23,17 +23,17 @@ namespace Umbraco.Web.Models.Mapping
private readonly IMediaTypeService _mediaTypeService;
private readonly MediaUrlGeneratorCollection _mediaUrlGenerators;
private readonly TabsAndPropertiesMapper<IMedia> _tabsAndPropertiesMapper;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
private readonly IContentSettings _contentSettings;
public MediaMapDefinition(ICultureDictionary cultureDictionary, CommonMapper commonMapper, CommonTreeNodeMapper commonTreeNodeMapper, IMediaService mediaService, IMediaTypeService mediaTypeService,
ILocalizedTextService localizedTextService, MediaUrlGeneratorCollection mediaUrlGenerators, IUmbracoSettingsSection umbracoSettingsSection, IContentTypeBaseServiceProvider contentTypeBaseServiceProvider)
ILocalizedTextService localizedTextService, MediaUrlGeneratorCollection mediaUrlGenerators, IContentSettings contentSettings, IContentTypeBaseServiceProvider contentTypeBaseServiceProvider)
{
_commonMapper = commonMapper;
_commonTreeNodeMapper = commonTreeNodeMapper;
_mediaService = mediaService;
_mediaTypeService = mediaTypeService;
_mediaUrlGenerators = mediaUrlGenerators;
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
_contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings));
_tabsAndPropertiesMapper = new TabsAndPropertiesMapper<IMedia>(cultureDictionary, localizedTextService, contentTypeBaseServiceProvider);
}
@@ -64,7 +64,7 @@ namespace Umbraco.Web.Models.Mapping
target.Id = source.Id;
target.IsChildOfListView = DetermineIsChildOfListView(source);
target.Key = source.Key;
target.MediaLink = string.Join(",", source.GetUrls(_umbracoSettingsSection.Content, _mediaUrlGenerators));
target.MediaLink = string.Join(",", source.GetUrls(_contentSettings, _mediaUrlGenerators));
target.Name = source.Name;
target.Owner = _commonMapper.GetOwner(source, context);
target.ParentId = source.ParentId;
@@ -23,7 +23,7 @@ namespace Umbraco.Web.Mvc
public abstract class UmbracoViewPage<TModel> : WebViewPage<TModel>
{
private readonly IGlobalSettings _globalSettings;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
private readonly IContentSettings _contentSettings;
private IUmbracoContext _umbracoContext;
private UmbracoHelper _helper;
@@ -106,17 +106,17 @@ namespace Umbraco.Web.Mvc
Current.Factory.GetInstance<ServiceContext>(),
Current.Factory.GetInstance<AppCaches>(),
Current.Factory.GetInstance<IGlobalSettings>(),
Current.Factory.GetInstance<IUmbracoSettingsSection>()
Current.Factory.GetInstance<IContentSettings>()
)
{
}
protected UmbracoViewPage(ServiceContext services, AppCaches appCaches, IGlobalSettings globalSettings, IUmbracoSettingsSection umbracoSettingsSection)
protected UmbracoViewPage(ServiceContext services, AppCaches appCaches, IGlobalSettings globalSettings, IContentSettings contentSettings)
{
Services = services;
AppCaches = appCaches;
_globalSettings = globalSettings ?? throw new ArgumentNullException(nameof(globalSettings));
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
_contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings));
}
// view logic below:
@@ -214,7 +214,7 @@ namespace Umbraco.Web.Mvc
{
// creating previewBadge markup
markupToInject =
string.Format(_umbracoSettingsSection.Content.PreviewBadge,
string.Format(_contentSettings.PreviewBadge,
Current.IOHelper.ResolveUrl(_globalSettings.UmbracoPath),
Server.UrlEncode(HttpContext.Current.Request.Url?.PathAndQuery),
Current.UmbracoContext.PublishedRequest.PublishedContent.Id);
@@ -42,7 +42,7 @@ namespace Umbraco.Web.Security
public static void ConfigureUserManagerForUmbracoBackOffice(this IAppBuilder app,
ServiceContext services,
UmbracoMapper mapper,
IContentSection contentSettings,
IContentSettings contentSettings,
IGlobalSettings globalSettings,
// TODO: This could probably be optional?
IPasswordConfiguration passwordConfiguration,
@@ -81,7 +81,7 @@ namespace Umbraco.Web.Security
/// <param name="ipResolver"></param>
public static void ConfigureUserManagerForUmbracoBackOffice(this IAppBuilder app,
IRuntimeState runtimeState,
IContentSection contentSettings,
IContentSettings contentSettings,
IGlobalSettings globalSettings,
BackOfficeUserStore customUserStore,
// TODO: This could probably be optional?
@@ -154,8 +154,7 @@ namespace Umbraco.Web.Security
IGlobalSettings globalSettings,
ISecuritySettings securitySettings,
IIOHelper ioHelper,
IRequestCache requestCache,
IUmbracoSettingsSection umbracoSettingsSection)
IRequestCache requestCache)
{
return app.UseUmbracoBackOfficeCookieAuthentication(umbracoContextAccessor, runtimeState, userService, globalSettings, securitySettings, ioHelper, requestCache, PipelineStage.Authenticate);
}
@@ -27,14 +27,14 @@ namespace Umbraco.Web.Security
public BackOfficeUserManager(
IUserStore<BackOfficeIdentityUser, int> store,
IdentityFactoryOptions<BackOfficeUserManager> options,
IContentSection contentSectionConfig,
IContentSettings contentSettingsConfig,
IPasswordConfiguration passwordConfiguration,
IIpResolver ipResolver,
IGlobalSettings globalSettings)
: base(store, passwordConfiguration, ipResolver)
{
if (options == null) throw new ArgumentNullException("options");
InitUserManager(this, passwordConfiguration, options.DataProtectionProvider, contentSectionConfig, globalSettings);
InitUserManager(this, passwordConfiguration, options.DataProtectionProvider, contentSettingsConfig, globalSettings);
}
#region Static Create methods
@@ -47,7 +47,7 @@ namespace Umbraco.Web.Security
/// <param name="entityService"></param>
/// <param name="externalLoginService"></param>
/// <param name="passwordConfiguration"></param>
/// <param name="contentSectionConfig"></param>
/// <param name="contentSettingsConfig"></param>
/// <param name="globalSettings"></param>
/// <returns></returns>
public static BackOfficeUserManager Create(
@@ -56,7 +56,7 @@ namespace Umbraco.Web.Security
IEntityService entityService,
IExternalLoginService externalLoginService,
UmbracoMapper mapper,
IContentSection contentSectionConfig,
IContentSettings contentSettingsConfig,
IGlobalSettings globalSettings,
IPasswordConfiguration passwordConfiguration,
IIpResolver ipResolver)
@@ -66,7 +66,7 @@ namespace Umbraco.Web.Security
if (externalLoginService == null) throw new ArgumentNullException("externalLoginService");
var store = new BackOfficeUserStore(userService, entityService, externalLoginService, globalSettings, mapper);
var manager = new BackOfficeUserManager(store, options, contentSectionConfig, passwordConfiguration, ipResolver, globalSettings);
var manager = new BackOfficeUserManager(store, options, contentSettingsConfig, passwordConfiguration, ipResolver, globalSettings);
return manager;
}
@@ -76,17 +76,17 @@ namespace Umbraco.Web.Security
/// <param name="options"></param>
/// <param name="customUserStore"></param>
/// <param name="passwordConfiguration"></param>
/// <param name="contentSectionConfig"></param>
/// <param name="contentSettingsConfig"></param>
/// <returns></returns>
public static BackOfficeUserManager Create(
IdentityFactoryOptions<BackOfficeUserManager> options,
BackOfficeUserStore customUserStore,
IContentSection contentSectionConfig,
IContentSettings contentSettingsConfig,
IPasswordConfiguration passwordConfiguration,
IIpResolver ipResolver,
IGlobalSettings globalSettings)
{
var manager = new BackOfficeUserManager(customUserStore, options, contentSectionConfig, passwordConfiguration, ipResolver, globalSettings);
var manager = new BackOfficeUserManager(customUserStore, options, contentSettingsConfig, passwordConfiguration, ipResolver, globalSettings);
return manager;
}
#endregion
@@ -154,13 +154,13 @@ namespace Umbraco.Web.Security
/// <param name="manager"></param>
/// <param name="passwordConfig"></param>
/// <param name="dataProtectionProvider"></param>
/// <param name="contentSectionConfig"></param>
/// <param name="contentSettingsConfig"></param>
/// <returns></returns>
protected void InitUserManager(
BackOfficeUserManager<T> manager,
IPasswordConfiguration passwordConfig,
IDataProtectionProvider dataProtectionProvider,
IContentSection contentSectionConfig,
IContentSettings contentSettingsConfig,
IGlobalSettings globalSettings)
{
// Configure validation logic for usernames
@@ -195,7 +195,7 @@ namespace Umbraco.Web.Security
manager.ClaimsIdentityFactory = new BackOfficeClaimsIdentityFactory<T>();
manager.EmailService = new EmailService(
contentSectionConfig.NotificationEmailAddress,
contentSettingsConfig.NotificationEmailAddress,
new EmailSender(globalSettings));
//NOTE: Not implementing these, if people need custom 2 factor auth, they'll need to implement their own UserStore to support it
+2 -2
View File
@@ -28,7 +28,7 @@ namespace Umbraco.Web
{
protected IUmbracoContextAccessor UmbracoContextAccessor => Current.UmbracoContextAccessor;
protected IGlobalSettings GlobalSettings => Current.Configs.Global();
protected IUmbracoSettingsSection UmbracoSettings => Current.Configs.Settings();
protected IContentSettings ContentSettings => Current.Configs.Content();
protected ISecuritySettings SecuritySettings => Current.Configs.Security();
protected IUserPasswordConfiguration UserPasswordConfig => Current.Configs.UserPasswordConfiguration();
protected IRuntimeState RuntimeState => Current.RuntimeState;
@@ -90,7 +90,7 @@ namespace Umbraco.Web
app.ConfigureUserManagerForUmbracoBackOffice(
Services,
Mapper,
UmbracoSettings.Content,
ContentSettings,
GlobalSettings,
UserPasswordConfig,
IpResolver);