diff --git a/build/NuSpecs/UmbracoCms.nuspec b/build/NuSpecs/UmbracoCms.nuspec index fbe990f2de..565d693979 100644 --- a/build/NuSpecs/UmbracoCms.nuspec +++ b/build/NuSpecs/UmbracoCms.nuspec @@ -22,11 +22,11 @@ not want this to happen as the alpha of the next major is, really, the next major already. --> - + - - + + diff --git a/build/build.ps1 b/build/build.ps1 index ec53199251..dafae2665a 100644 --- a/build/build.ps1 +++ b/build/build.ps1 @@ -452,9 +452,22 @@ if ($this.OnError()) { return } $this.PrepareAzureGallery() if ($this.OnError()) { return } + $this.PostPackageHook() + if ($this.OnError()) { return } Write-Host "Done" }) + $ubuild.DefineMethod("PostPackageHook", + { + # run hook + if ($this.HasMethod("PostPackage")) + { + Write-Host "Run PostPackage hook" + $this.PostPackage(); + if (-not $?) { throw "Failed to run hook." } + } + }) + # ################################################################ # RUN # ################################################################ diff --git a/src/SolutionInfo.cs b/src/SolutionInfo.cs index 68d3cb4b6f..ce40bd9baa 100644 --- a/src/SolutionInfo.cs +++ b/src/SolutionInfo.cs @@ -19,4 +19,4 @@ using System.Resources; // these are FYI and changed automatically [assembly: AssemblyFileVersion("8.0.0")] -[assembly: AssemblyInformationalVersion("8.0.0-alpha.56")] +[assembly: AssemblyInformationalVersion("8.0.0-alpha.58")] diff --git a/src/Umbraco.Core/Components/AuditEventsComponent.cs b/src/Umbraco.Core/Components/AuditEventsComponent.cs index f592613e0d..08d4702afa 100644 --- a/src/Umbraco.Core/Components/AuditEventsComponent.cs +++ b/src/Umbraco.Core/Components/AuditEventsComponent.cs @@ -23,7 +23,10 @@ namespace Umbraco.Core.Components _auditService = auditService; _userService = userService; _entityService = entityService; + } + public void Initialize() + { UserService.SavedUserGroup += OnSavedUserGroupWithUsers; UserService.SavedUser += OnSavedUser; @@ -37,6 +40,9 @@ namespace Umbraco.Core.Components MemberService.Exported += OnMemberExported; } + public void Terminate() + { } + private IUser CurrentPerformingUser { get diff --git a/src/Umbraco.Core/Components/ComponentCollection.cs b/src/Umbraco.Core/Components/ComponentCollection.cs index abe493b524..4fa81b9760 100644 --- a/src/Umbraco.Core/Components/ComponentCollection.cs +++ b/src/Umbraco.Core/Components/ComponentCollection.cs @@ -20,6 +20,21 @@ namespace Umbraco.Core.Components _logger = logger; } + public void Initialize() + { + using (_logger.DebugDuration($"Initializing. (log components when >{LogThresholdMilliseconds}ms)", "Initialized.")) + { + foreach (var component in this.Reverse()) // terminate components in reverse order + { + var componentType = component.GetType(); + using (_logger.DebugDuration($"Initializing {componentType.FullName}.", $"Initialized {componentType.FullName}.", thresholdMilliseconds: LogThresholdMilliseconds)) + { + component.Initialize(); + } + } + } + } + public void Terminate() { using (_logger.DebugDuration($"Terminating. (log components when >{LogThresholdMilliseconds}ms)", "Terminated.")) @@ -29,6 +44,7 @@ namespace Umbraco.Core.Components var componentType = component.GetType(); using (_logger.DebugDuration($"Terminating {componentType.FullName}.", $"Terminated {componentType.FullName}.", thresholdMilliseconds: LogThresholdMilliseconds)) { + component.Terminate(); component.DisposeIfDisposable(); } } diff --git a/src/Umbraco.Core/Components/Composition.cs b/src/Umbraco.Core/Components/Composition.cs index 53acbdb132..dd0b83dcb3 100644 --- a/src/Umbraco.Core/Components/Composition.cs +++ b/src/Umbraco.Core/Components/Composition.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using Umbraco.Core.Composing; +using Umbraco.Core.Configuration; using Umbraco.Core.Logging; namespace Umbraco.Core.Components @@ -26,12 +27,21 @@ namespace Umbraco.Core.Components /// A type loader. /// A logger. /// The runtime state. - public Composition(IRegister register, TypeLoader typeLoader, IProfilingLogger logger, IRuntimeState runtimeState) + /// Optional configs. + public Composition(IRegister register, TypeLoader typeLoader, IProfilingLogger logger, IRuntimeState runtimeState, Configs configs = null) { _register = register; TypeLoader = typeLoader; Logger = logger; RuntimeState = runtimeState; + + if (configs == null) + { + configs = new Configs(); + configs.AddCoreConfigs(); + } + + Configs = configs; } #region Services @@ -51,6 +61,11 @@ namespace Umbraco.Core.Components /// public IRuntimeState RuntimeState { get; } + /// + /// Gets the configurations. + /// + public Configs Configs { get; } + #endregion #region IRegister @@ -94,6 +109,8 @@ namespace Umbraco.Core.Components foreach (var builder in _builders.Values) builder.RegisterWith(_register); + Configs.RegisterWith(_register); + return _register.CreateFactory(); } diff --git a/src/Umbraco.Core/Components/IComponent.cs b/src/Umbraco.Core/Components/IComponent.cs index 28ca539387..b1954d821b 100644 --- a/src/Umbraco.Core/Components/IComponent.cs +++ b/src/Umbraco.Core/Components/IComponent.cs @@ -5,11 +5,21 @@ /// /// /// Components are created by DI and therefore must have a public constructor. - /// All components which are also disposable, will be disposed in reverse - /// order, when Umbraco terminates. + /// All components are terminated in reverse order when Umbraco terminates, and + /// disposable components are disposed. /// The Dispose method may be invoked more than once, and components /// should ensure they support this. /// public interface IComponent - { } + { + /// + /// Initializes the component. + /// + void Initialize(); + + /// + /// Terminates the component. + /// + void Terminate(); + } } diff --git a/src/Umbraco.Core/Components/ManifestWatcherComponent.cs b/src/Umbraco.Core/Components/ManifestWatcherComponent.cs index a96dd516e7..2420e1d5bb 100644 --- a/src/Umbraco.Core/Components/ManifestWatcherComponent.cs +++ b/src/Umbraco.Core/Components/ManifestWatcherComponent.cs @@ -1,20 +1,28 @@ -using System; -using System.IO; +using System.IO; using Umbraco.Core.IO; using Umbraco.Core.Logging; using Umbraco.Core.Manifest; namespace Umbraco.Core.Components { - public sealed class ManifestWatcherComponent : IComponent, IDisposable + public sealed class ManifestWatcherComponent : IComponent { + private readonly IRuntimeState _runtimeState; + private readonly ILogger _logger; + // if configured and in debug mode, a ManifestWatcher watches App_Plugins folders for // package.manifest chances and restarts the application on any change private ManifestWatcher _mw; public ManifestWatcherComponent(IRuntimeState runtimeState, ILogger logger) { - if (runtimeState.Debug == false) return; + _runtimeState = runtimeState; + _logger = logger; + } + + public void Initialize() + { + if (_runtimeState.Debug == false) return; //if (ApplicationContext.Current.IsConfigured == false || GlobalSettings.DebugMode == false) // return; @@ -22,11 +30,11 @@ namespace Umbraco.Core.Components var appPlugins = IOHelper.MapPath("~/App_Plugins/"); if (Directory.Exists(appPlugins) == false) return; - _mw = new ManifestWatcher(logger); + _mw = new ManifestWatcher(_logger); _mw.Start(Directory.GetDirectories(appPlugins)); } - public void Dispose() + public void Terminate() { if (_mw == null) return; diff --git a/src/Umbraco.Core/Components/RelateOnCopyComponent.cs b/src/Umbraco.Core/Components/RelateOnCopyComponent.cs index 41ae3c70dc..404d385680 100644 --- a/src/Umbraco.Core/Components/RelateOnCopyComponent.cs +++ b/src/Umbraco.Core/Components/RelateOnCopyComponent.cs @@ -8,11 +8,14 @@ namespace Umbraco.Core.Components //TODO: This should just exist in the content service/repo! public sealed class RelateOnCopyComponent : IComponent { - public RelateOnCopyComponent() + public void Initialize() { ContentService.Copied += ContentServiceCopied; } + public void Terminate() + { } + private static void ContentServiceCopied(IContentService sender, Events.CopyEventArgs e) { if (e.RelateToOriginal == false) return; diff --git a/src/Umbraco.Core/Components/RelateOnTrashComponent.cs b/src/Umbraco.Core/Components/RelateOnTrashComponent.cs index 93803d4fae..6279bb98ba 100644 --- a/src/Umbraco.Core/Components/RelateOnTrashComponent.cs +++ b/src/Umbraco.Core/Components/RelateOnTrashComponent.cs @@ -9,7 +9,7 @@ namespace Umbraco.Core.Components { public sealed class RelateOnTrashComponent : IComponent { - public RelateOnTrashComponent() + public void Initialize() { ContentService.Moved += ContentService_Moved; ContentService.Trashed += ContentService_Trashed; @@ -17,6 +17,9 @@ namespace Umbraco.Core.Components MediaService.Trashed += MediaService_Trashed; } + public void Terminate() + { } + private static void ContentService_Moved(IContentService sender, MoveEventArgs e) { foreach (var item in e.MoveInfoCollection.Where(x => x.OriginalPath.Contains(Constants.System.RecycleBinContent.ToInvariantString()))) diff --git a/src/Umbraco.Core/Composing/Composers/ConfigurationComposer.cs b/src/Umbraco.Core/Composing/Composers/ConfigurationComposer.cs index 7217f551e9..ca86f623cc 100644 --- a/src/Umbraco.Core/Composing/Composers/ConfigurationComposer.cs +++ b/src/Umbraco.Core/Composing/Composers/ConfigurationComposer.cs @@ -5,24 +5,19 @@ using Umbraco.Core.Configuration.UmbracoSettings; namespace Umbraco.Core.Composing.Composers { /// - /// Sets up IoC container for Umbraco configuration classes + /// Compose configurations. /// public static class ConfigurationComposer { public static Composition ComposeConfiguration(this Composition composition) { - composition.RegisterUnique(); - composition.RegisterUnique(factory => factory.GetInstance().Umbraco()); + // common configurations are already registered + // register others + composition.RegisterUnique(factory => factory.GetInstance().Content); composition.RegisterUnique(factory => factory.GetInstance().Templates); composition.RegisterUnique(factory => factory.GetInstance().RequestHandler); composition.RegisterUnique(factory => factory.GetInstance().Security); - composition.RegisterUnique(factory => factory.GetInstance().Global()); - composition.RegisterUnique(factory => factory.GetInstance().Dashboards()); - composition.RegisterUnique(factory => factory.GetInstance().HealthChecks()); - composition.RegisterUnique(factory => factory.GetInstance().Grids()); - - // fixme - other sections we need to add? return composition; } diff --git a/src/Umbraco.Core/Composing/Current.cs b/src/Umbraco.Core/Composing/Current.cs index 6c093dfc2c..cf67409925 100644 --- a/src/Umbraco.Core/Composing/Current.cs +++ b/src/Umbraco.Core/Composing/Current.cs @@ -39,7 +39,7 @@ namespace Umbraco.Core.Composing private static IProfiler _profiler; private static IProfilingLogger _profilingLogger; private static IPublishedValueFallback _publishedValueFallback; - private static UmbracoConfig _config; + private static Configs _configs; /// /// Gets or sets the factory. @@ -48,25 +48,32 @@ namespace Umbraco.Core.Composing { get { - if (_factory == null) throw new Exception("No factory has been set."); + if (_factory == null) throw new InvalidOperationException("No factory has been set."); return _factory; } set { - if (_factory != null) throw new Exception("A factory has already been set."); + if (_factory != null) throw new InvalidOperationException("A factory has already been set."); + if (_configs != null) throw new InvalidOperationException("Configs are unlocked."); _factory = value; } } - internal static bool HasContainer => _factory != null; + internal static bool HasFactory => _factory != null; - // for UNIT TESTS exclusively! - // resets *everything* that is 'current' - internal static void Reset() + /// + /// Resets . Indented for testing only, and not supported in production code. + /// + /// + /// For UNIT TESTS exclusively. + /// Resets everything that is 'current'. + /// + public static void Reset() { _factory.DisposeIfDisposable(); _factory = null; + _configs = null; _shortStringHelper = null; _logger = null; _profiler = null; @@ -76,21 +83,36 @@ namespace Umbraco.Core.Composing Resetted?.Invoke(null, EventArgs.Empty); } + /// + /// Unlocks . Intended for testing only, and not supported in production code. + /// + /// + /// For UNIT TESTS exclusively. + /// Unlocks so that it is possible to add configurations + /// directly to without having to wire composition. + /// + public static void UnlockConfigs() + { + if (_factory != null) + throw new InvalidOperationException("Cannot unlock configs when a factory has been set."); + _configs = new Configs(); + } + internal static event EventHandler Resetted; #region Getters public static IShortStringHelper ShortStringHelper => _shortStringHelper ?? (_shortStringHelper = _factory?.TryGetInstance() - ?? new DefaultShortStringHelper(new DefaultShortStringHelperConfig().WithDefault(Config.Umbraco()))); + ?? new DefaultShortStringHelper(new DefaultShortStringHelperConfig().WithDefault(Configs.Settings()))); public static ILogger Logger => _logger ?? (_logger = _factory?.TryGetInstance() - ?? new DebugDiagnosticsLogger()); + ?? new DebugDiagnosticsLogger()); public static IProfiler Profiler => _profiler ?? (_profiler = _factory?.TryGetInstance() - ?? new LogProfiler(Logger)); + ?? new LogProfiler(Logger)); public static IProfilingLogger ProfilingLogger => _profilingLogger ?? (_profilingLogger = _factory?.TryGetInstance()) @@ -102,9 +124,15 @@ namespace Umbraco.Core.Composing public static TypeLoader TypeLoader => Factory.GetInstance(); - public static UmbracoConfig Config - => _config ?? (_config = _factory?.TryGetInstance() - ?? new UmbracoConfig(Logger, _factory?.TryGetInstance(), _factory?.TryGetInstance())); + public static Configs Configs + { + get + { + if (_configs != null) return _configs; + if (_factory == null) throw new InvalidOperationException("Can not get Current.Config during composition. Use composition.Config."); + return _factory.GetInstance(); + } + } public static IFileSystems FileSystems => Factory.GetInstance(); diff --git a/src/Umbraco.Core/ConfigsExtensions.cs b/src/Umbraco.Core/ConfigsExtensions.cs new file mode 100644 index 0000000000..1414dbc852 --- /dev/null +++ b/src/Umbraco.Core/ConfigsExtensions.cs @@ -0,0 +1,52 @@ +using System.IO; +using Umbraco.Core.Cache; +using Umbraco.Core.Composing; +using Umbraco.Core.Configuration; +using Umbraco.Core.Configuration.Dashboard; +using Umbraco.Core.Configuration.Grid; +using Umbraco.Core.Configuration.HealthChecks; +using Umbraco.Core.Configuration.UmbracoSettings; +using Umbraco.Core.IO; +using Umbraco.Core.Logging; + +namespace Umbraco.Core +{ + /// + /// Provides extension methods for the class. + /// + public static class ConfigsExtensions + { + public static IGlobalSettings Global(this Configs configs) + => configs.GetConfig(); + + public static IUmbracoSettingsSection Settings(this Configs configs) + => configs.GetConfig(); + + public static IDashboardSection Dashboards(this Configs configs) + => configs.GetConfig(); + + public static IHealthChecks HealthChecks(this Configs configs) + => configs.GetConfig(); + + public static IGridConfig Grids(this Configs configs) + => configs.GetConfig(); + + internal static CoreDebug CoreDebug(this Configs configs) + => configs.GetConfig(); + + public static void AddCoreConfigs(this Configs configs) + { + var configDir = new DirectoryInfo(IOHelper.MapPath(SystemDirectories.Config)); + + configs.Add(() => new GlobalSettings()); + configs.Add("umbracoConfiguration/settings"); + configs.Add("umbracoConfiguration/dashBoard"); + configs.Add("umbracoConfiguration/HealthChecks"); + + configs.Add(() => new CoreDebug()); + + // GridConfig depends on runtime caches, manifest parsers... and cannot be available during composition + configs.Add(factory => new GridConfig(factory.GetInstance(), factory.GetInstance(), configDir, factory.GetInstance().Debug)); + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Configuration/Configs.cs b/src/Umbraco.Core/Configuration/Configs.cs new file mode 100644 index 0000000000..3dbbe5d4ff --- /dev/null +++ b/src/Umbraco.Core/Configuration/Configs.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using Umbraco.Core.Composing; +using Umbraco.Core.Logging; + +namespace Umbraco.Core.Configuration +{ + /// + /// Represents Umbraco configurations. + /// + /// + /// During composition, use composition.Configs. When running, either inject the required configuration, + /// or use Current.Configs. + /// + public class Configs + { + private readonly Dictionary> _configs = new Dictionary>(); + private Dictionary> _registerings = new Dictionary>(); + + /// + /// Gets a configuration. + /// + public TConfig GetConfig() + where TConfig : class + { + if (!_configs.TryGetValue(typeof(TConfig), out var configFactory)) + throw new InvalidOperationException($"No configuration of type {typeof(TConfig)} has been added."); + + return (TConfig) configFactory.Value; + } + + /// + /// Adds a configuration, provided by a factory. + /// + public void Add(Func configFactory) + where TConfig : class + { + // make sure it is not too late + if (_registerings == null) + throw new InvalidOperationException("Configurations have already been registered."); + + var typeOfConfig = typeof(TConfig); + + var lazyConfigFactory = _configs[typeOfConfig] = new Lazy(configFactory); + _registerings[typeOfConfig] = register => register.Register(_ => (TConfig) lazyConfigFactory.Value, Lifetime.Singleton); + } + + /// + /// Adds a configuration, provided by a factory. + /// + public void Add(Func configFactory) + where TConfig : class + { + // make sure it is not too late + if (_registerings == null) + throw new InvalidOperationException("Configurations have already been registered."); + + var typeOfConfig = typeof(TConfig); + + _configs[typeOfConfig] = new Lazy(() => + { + if (Current.HasFactory) return Current.Factory.GetInstance(); + throw new InvalidOperationException($"Cannot get configuration of type {typeOfConfig} during composition."); + }); + _registerings[typeOfConfig] = register => register.Register(configFactory, Lifetime.Singleton); + } + + /// + /// Adds a configuration, provided by a configuration section. + /// + public void Add(string sectionName) + where TConfig : class + { + Add(() => GetConfig(sectionName)); + } + + private static TConfig GetConfig(string sectionName) + where TConfig : class + { + // note: need to use SafeCallContext here because ConfigurationManager.GetSection ends up getting AppDomain.Evidence + // which will want to serialize the call context including anything that is in there - what a mess! + + using (new SafeCallContext()) + { + if ((ConfigurationManager.GetSection(sectionName) is TConfig config)) + return config; + var ex = new ConfigurationErrorsException($"Could not get configuration section \"{sectionName}\" from config files."); + Current.Logger.Error(ex, "Config error"); + throw ex; + } + } + + /// + /// Registers configurations in a register. + /// + public void RegisterWith(IRegister register) + { + // do it only once + if (_registerings == null) + throw new InvalidOperationException("Configurations have already been registered."); + + register.RegisterInstance(this); + + foreach (var registering in _registerings.Values) + registering(register); + + // no need to keep them around + _registerings = null; + } + } +} diff --git a/src/Umbraco.Core/Configuration/CoreDebug.cs b/src/Umbraco.Core/Configuration/CoreDebug.cs index 71d0f24941..a71b311d7c 100644 --- a/src/Umbraco.Core/Configuration/CoreDebug.cs +++ b/src/Umbraco.Core/Configuration/CoreDebug.cs @@ -2,16 +2,6 @@ namespace Umbraco.Core.Configuration { - internal static class CoreDebugExtensions - { - private static CoreDebug _coreDebug; - - public static CoreDebug CoreDebug(this UmbracoConfig config) - { - return _coreDebug ?? (_coreDebug = new CoreDebug()); - } - } - internal class CoreDebug { public CoreDebug() diff --git a/src/Umbraco.Core/Configuration/Grid/GridConfig.cs b/src/Umbraco.Core/Configuration/Grid/GridConfig.cs index beade2d6d1..6c16a5e7ef 100644 --- a/src/Umbraco.Core/Configuration/Grid/GridConfig.cs +++ b/src/Umbraco.Core/Configuration/Grid/GridConfig.cs @@ -6,11 +6,11 @@ namespace Umbraco.Core.Configuration.Grid { class GridConfig : IGridConfig { - public GridConfig(ILogger logger, IRuntimeCacheProvider runtimeCache, DirectoryInfo appPlugins, DirectoryInfo configFolder, bool isDebug) + public GridConfig(ILogger logger, IRuntimeCacheProvider runtimeCache, DirectoryInfo configFolder, bool isDebug) { - EditorsConfig = new GridEditorsConfig(logger, runtimeCache, appPlugins, configFolder, isDebug); + EditorsConfig = new GridEditorsConfig(logger, runtimeCache, configFolder, isDebug); } - public IGridEditorsConfig EditorsConfig { get; private set; } + public IGridEditorsConfig EditorsConfig { get; } } } diff --git a/src/Umbraco.Core/Configuration/Grid/GridEditorsConfig.cs b/src/Umbraco.Core/Configuration/Grid/GridEditorsConfig.cs index 708c563d9d..94249aa135 100644 --- a/src/Umbraco.Core/Configuration/Grid/GridEditorsConfig.cs +++ b/src/Umbraco.Core/Configuration/Grid/GridEditorsConfig.cs @@ -14,15 +14,13 @@ namespace Umbraco.Core.Configuration.Grid { private readonly ILogger _logger; private readonly IRuntimeCacheProvider _runtimeCache; - private readonly DirectoryInfo _appPlugins; private readonly DirectoryInfo _configFolder; private readonly bool _isDebug; - public GridEditorsConfig(ILogger logger, IRuntimeCacheProvider runtimeCache, DirectoryInfo appPlugins, DirectoryInfo configFolder, bool isDebug) + public GridEditorsConfig(ILogger logger, IRuntimeCacheProvider runtimeCache, DirectoryInfo configFolder, bool isDebug) { _logger = logger; _runtimeCache = runtimeCache; - _appPlugins = appPlugins; _configFolder = configFolder; _isDebug = isDebug; } @@ -31,7 +29,7 @@ namespace Umbraco.Core.Configuration.Grid { get { - Func> getResult = () => + List GetResult() { // fixme - should use the common one somehow! + ignoring _appPlugins here! var parser = new ManifestParser(_runtimeCache, Current.ManifestValidators, _logger); @@ -55,20 +53,16 @@ namespace Umbraco.Core.Configuration.Grid // add manifest editors, skip duplicates foreach (var gridEditor in parser.Manifest.GridEditors) { - if (editors.Contains(gridEditor) == false) - editors.Add(gridEditor); + if (editors.Contains(gridEditor) == false) editors.Add(gridEditor); } return editors; - }; + } //cache the result if debugging is disabled var result = _isDebug - ? getResult() - : _runtimeCache.GetCacheItem>( - typeof(GridEditorsConfig) + "Editors", - () => getResult(), - TimeSpan.FromMinutes(10)); + ? GetResult() + : _runtimeCache.GetCacheItem>(typeof(GridEditorsConfig) + ".Editors",GetResult, TimeSpan.FromMinutes(10)); return result; } diff --git a/src/Umbraco.Core/Configuration/UmbracoConfig.cs b/src/Umbraco.Core/Configuration/UmbracoConfig.cs deleted file mode 100644 index 0ace23dba4..0000000000 --- a/src/Umbraco.Core/Configuration/UmbracoConfig.cs +++ /dev/null @@ -1,138 +0,0 @@ -using System; -using System.Configuration; -using System.IO; -using Umbraco.Core.Cache; -using Umbraco.Core.Configuration.Dashboard; -using Umbraco.Core.Configuration.Grid; -using Umbraco.Core.Configuration.HealthChecks; -using Umbraco.Core.Configuration.UmbracoSettings; -using Umbraco.Core.Composing; -using Umbraco.Core.IO; -using Umbraco.Core.Logging; - -namespace Umbraco.Core.Configuration -{ - /// - /// The gateway to all umbraco configuration. - /// - /// This should be registered as a unique service in the container. - public class UmbracoConfig - { - private IGlobalSettings _global; - private Lazy _umbraco; - private Lazy _healthChecks; - private Lazy _dashboards; - private Lazy _grids; - - /// - /// Initializes a new instance of the class. - /// - public UmbracoConfig(ILogger logger, IRuntimeCacheProvider runtimeCache, IRuntimeState runtimeState) - { - _global = new GlobalSettings(); - - var appPluginsDir = new DirectoryInfo(IOHelper.MapPath(SystemDirectories.AppPlugins)); - var configDir = new DirectoryInfo(IOHelper.MapPath(SystemDirectories.Config)); - - _umbraco = new Lazy(() => GetConfig("umbracoConfiguration/settings")); - _dashboards = new Lazy(() =>GetConfig("umbracoConfiguration/dashBoard")); - _healthChecks = new Lazy(() => GetConfig("umbracoConfiguration/HealthChecks")); - _grids = new Lazy(() => new GridConfig(logger, runtimeCache, appPluginsDir, configDir, runtimeState.Debug)); - } - - /// - /// Gets a typed and named config section. - /// - /// The type of the configuration section. - /// The name of the configuration section. - /// The configuration section. - public static TConfig GetConfig(string sectionName) - where TConfig : class - { - // note: need to use SafeCallContext here because ConfigurationManager.GetSection ends up getting AppDomain.Evidence - // which will want to serialize the call context including anything that is in there - what a mess! - - using (new SafeCallContext()) - { - if ((ConfigurationManager.GetSection(sectionName) is TConfig config)) - return config; - var ex = new ConfigurationErrorsException($"Could not get configuration section \"{sectionName}\" from config files."); - Current.Logger.Error(ex, "Config error"); - throw ex; - } - } - - /// - /// Gets the global configuration. - /// - public IGlobalSettings Global() - => _global; - - /// - /// Gets the Umbraco configuration. - /// - public IUmbracoSettingsSection Umbraco() - => _umbraco.Value; - - /// - /// Gets the dashboards configuration. - /// - public IDashboardSection Dashboards() - => _dashboards.Value; - - /// - /// Gets the health checks configuration. - /// - public IHealthChecks HealthChecks() - => _healthChecks.Value; - - /// - /// Gets the grids configuration. - /// - public IGridConfig Grids() - => _grids.Value; - - /// - /// Sets the global configuration, for tests only. - /// - public void SetGlobalConfig(IGlobalSettings value) - { - _global = value; - } - - /// - /// Sets the Umbraco configuration, for tests only. - /// - public void SetUmbracoConfig(IUmbracoSettingsSection value) - { - _umbraco = new Lazy(() => value); - } - - /// - /// Sets the dashboards configuration, for tests only. - /// - /// - public void SetDashboardsConfig(IDashboardSection value) - { - _dashboards = new Lazy(() => value); - } - - /// - /// Sets the health checks configuration, for tests only. - /// - public void SetHealthChecksConfig(IHealthChecks value) - { - _healthChecks = new Lazy(() => value); - } - - /// - /// Sets the grids configuration, for tests only. - /// - public void SetGridsConfig(IGridConfig value) - { - _grids = new Lazy(() => value); - } - - //TODO: Add other configurations here ! - } -} diff --git a/src/Umbraco.Core/IO/FileSystemExtensions.cs b/src/Umbraco.Core/IO/FileSystemExtensions.cs index 4b73e64e80..ade2c58b38 100644 --- a/src/Umbraco.Core/IO/FileSystemExtensions.cs +++ b/src/Umbraco.Core/IO/FileSystemExtensions.cs @@ -65,5 +65,33 @@ namespace Umbraco.Core.IO } fs.DeleteFile(tempFile); } + + /// + /// Unwraps a filesystem. + /// + /// + /// A filesystem can be wrapped in a (public) or a (internal), + /// and this method deals with the various wrappers and + /// + public static IFileSystem Unwrap(this IFileSystem filesystem) + { + var unwrapping = true; + while (unwrapping) + { + switch (filesystem) + { + case FileSystemWrapper wrapper: + filesystem = wrapper.InnerFileSystem; + break; + case ShadowWrapper shadow: + filesystem = shadow.InnerFileSystem; + break; + default: + unwrapping = false; + break; + } + } + return filesystem; + } } } diff --git a/src/Umbraco.Core/IO/FileSystemWrapper.cs b/src/Umbraco.Core/IO/FileSystemWrapper.cs index a493b7166b..14d028c16d 100644 --- a/src/Umbraco.Core/IO/FileSystemWrapper.cs +++ b/src/Umbraco.Core/IO/FileSystemWrapper.cs @@ -21,7 +21,7 @@ namespace Umbraco.Core.IO InnerFileSystem = innerFileSystem; } - public IFileSystem InnerFileSystem { get; internal set; } + internal IFileSystem InnerFileSystem { get; set; } public IEnumerable GetDirectories(string path) { diff --git a/src/Umbraco.Core/IO/MediaPathSchemes/OriginalMediaPathScheme.cs b/src/Umbraco.Core/IO/MediaPathSchemes/OriginalMediaPathScheme.cs index 14f0c7602b..1948a9f662 100644 --- a/src/Umbraco.Core/IO/MediaPathSchemes/OriginalMediaPathScheme.cs +++ b/src/Umbraco.Core/IO/MediaPathSchemes/OriginalMediaPathScheme.cs @@ -31,7 +31,7 @@ namespace Umbraco.Core.IO.MediaPathSchemes // prevpath should be "/" OR "-" // and we want to reuse the "" part, so try to find it - var sep = Current.Config.Umbraco().Content.UploadAllowDirectories ? "/" : "-"; + var sep = Current.Configs.Settings().Content.UploadAllowDirectories ? "/" : "-"; var pos = previous.IndexOf(sep, StringComparison.Ordinal); var s = pos > 0 ? previous.Substring(0, pos) : null; @@ -45,7 +45,7 @@ namespace Umbraco.Core.IO.MediaPathSchemes if (directory == null) throw new InvalidOperationException("Cannot use a null directory."); - return Current.Config.Umbraco().Content.UploadAllowDirectories + return Current.Configs.Settings().Content.UploadAllowDirectories ? Path.Combine(directory, filename).Replace('\\', '/') : directory + "-" + filename; } diff --git a/src/Umbraco.Core/IO/ShadowWrapper.cs b/src/Umbraco.Core/IO/ShadowWrapper.cs index 94bd61b162..6493238391 100644 --- a/src/Umbraco.Core/IO/ShadowWrapper.cs +++ b/src/Umbraco.Core/IO/ShadowWrapper.cs @@ -75,6 +75,8 @@ namespace Umbraco.Core.IO } } + public IFileSystem InnerFileSystem => _innerFileSystem; + private IFileSystem FileSystem { get diff --git a/src/Umbraco.Core/Logging/Serilog/SerilogLogger.cs b/src/Umbraco.Core/Logging/Serilog/SerilogLogger.cs index 3fd6d18278..17d86b45e1 100644 --- a/src/Umbraco.Core/Logging/Serilog/SerilogLogger.cs +++ b/src/Umbraco.Core/Logging/Serilog/SerilogLogger.cs @@ -166,7 +166,7 @@ namespace Umbraco.Core.Logging.Serilog messageTemplate += "\r\nThe thread has been aborted, because the request has timed out."; // dump if configured, or if stacktrace contains Monitor.ReliableEnter - dump = Current.Config.CoreDebug().DumpOnTimeoutThreadAbort || IsMonitorEnterThreadAbortException(exception); + dump = Current.Configs.CoreDebug().DumpOnTimeoutThreadAbort || IsMonitorEnterThreadAbortException(exception); // dump if it is ok to dump (might have a cap on number of dump...) dump &= MiniDump.OkToDump(); @@ -217,9 +217,9 @@ namespace Umbraco.Core.Logging.Serilog /// public void Warn(Type reporting, string message) { - LoggerFor(reporting).Warning(message); + LoggerFor(reporting).Warning(message); } - + /// public void Warn(Type reporting, string message, params object[] propertyValues) { @@ -231,7 +231,7 @@ namespace Umbraco.Core.Logging.Serilog { LoggerFor(reporting).Warning(exception, message); } - + /// public void Warn(Type reporting, Exception exception, string messageTemplate, params object[] propertyValues) { @@ -255,7 +255,7 @@ namespace Umbraco.Core.Logging.Serilog { LoggerFor(reporting).Debug(message); } - + /// public void Debug(Type reporting, string messageTemplate, params object[] propertyValues) { diff --git a/src/Umbraco.Core/Models/Identity/BackOfficeIdentityUser.cs b/src/Umbraco.Core/Models/Identity/BackOfficeIdentityUser.cs index f163124c2d..dcf86a0b42 100644 --- a/src/Umbraco.Core/Models/Identity/BackOfficeIdentityUser.cs +++ b/src/Umbraco.Core/Models/Identity/BackOfficeIdentityUser.cs @@ -67,7 +67,7 @@ namespace Umbraco.Core.Models.Identity _startContentIds = new int[] { }; _groups = new IReadOnlyUserGroup[] { }; _allowedSections = new string[] { }; - _culture = Current.Config.Global().DefaultUILanguage; //fixme inject somehow? + _culture = Current.Configs.Global().DefaultUILanguage; //fixme inject somehow? _groups = new IReadOnlyUserGroup[0]; _roles = new ObservableCollection>(); _roles.CollectionChanged += _roles_CollectionChanged; @@ -84,7 +84,7 @@ namespace Umbraco.Core.Models.Identity _startContentIds = new int[] { }; _groups = new IReadOnlyUserGroup[] { }; _allowedSections = new string[] { }; - _culture = Current.Config.Global().DefaultUILanguage; //fixme inject somehow? + _culture = Current.Configs.Global().DefaultUILanguage; //fixme inject somehow? _groups = groups.ToArray(); _roles = new ObservableCollection>(_groups.Select(x => new IdentityUserRole { diff --git a/src/Umbraco.Core/Models/Membership/User.cs b/src/Umbraco.Core/Models/Membership/User.cs index 9387d3eb8f..650aa6cb29 100644 --- a/src/Umbraco.Core/Models/Membership/User.cs +++ b/src/Umbraco.Core/Models/Membership/User.cs @@ -27,7 +27,7 @@ namespace Umbraco.Core.Models.Membership { SessionTimeout = 60; _userGroups = new HashSet(); - _language = Current.Config.Global().DefaultUILanguage; //fixme inject somehow? + _language = Current.Configs.Global().DefaultUILanguage; //fixme inject somehow? _isApproved = true; _isLockedOut = false; _startContentIds = new int[] { }; diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedContentExtensionsForModels.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedContentExtensionsForModels.cs index df3213eb07..bfc65b70d6 100644 --- a/src/Umbraco.Core/Models/PublishedContent/PublishedContentExtensionsForModels.cs +++ b/src/Umbraco.Core/Models/PublishedContent/PublishedContentExtensionsForModels.cs @@ -21,7 +21,7 @@ namespace Umbraco.Core.Models.PublishedContent // in order to provide a nice, "fluent" experience, this extension method // needs to access Current, which is not always initialized in tests - not // very elegant, but works - if (!Current.HasContainer) return content; + if (!Current.HasFactory) return content; // get model // if factory returns nothing, throw diff --git a/src/Umbraco.Core/Persistence/Factories/PropertyFactory.cs b/src/Umbraco.Core/Persistence/Factories/PropertyFactory.cs index c920a18c3b..728441964a 100644 --- a/src/Umbraco.Core/Persistence/Factories/PropertyFactory.cs +++ b/src/Umbraco.Core/Persistence/Factories/PropertyFactory.cs @@ -93,18 +93,36 @@ namespace Umbraco.Core.Persistence.Factories return dto; } - public static IEnumerable BuildDtos(int currentVersionId, int publishedVersionId, IEnumerable properties, ILanguageRepository languageRepository, out bool edited, out HashSet editedCultures) + /// + /// Creates a collection of from a collection of + /// + /// + /// The of the entity containing the collection of + /// + /// + /// + /// The properties to map + /// + /// out parameter indicating that one or more properties have been edited + /// out parameter containing a collection of of edited cultures when the contentVariation varies by culture + /// + public static IEnumerable BuildDtos(ContentVariation contentVariation, int currentVersionId, int publishedVersionId, IEnumerable properties, + ILanguageRepository languageRepository, out bool edited, out HashSet editedCultures) { var propertyDataDtos = new List(); edited = false; editedCultures = null; // don't allocate unless necessary + string defaultCulture = null; //don't allocate unless necessary + + var entityVariesByCulture = contentVariation.VariesByCulture(); foreach (var property in properties) { if (property.PropertyType.IsPublishing) { - var editingCultures = property.PropertyType.VariesByCulture(); - if (editingCultures && editedCultures == null) editedCultures = new HashSet(StringComparer.OrdinalIgnoreCase); + //create the resulting hashset if it's not created and the entity varies by culture + if (entityVariesByCulture && editedCultures == null) + editedCultures = new HashSet(StringComparer.OrdinalIgnoreCase); // publishing = deal with edit and published values foreach (var propertyValue in property.Values) @@ -125,12 +143,24 @@ namespace Umbraco.Core.Persistence.Factories var sameValues = propertyValue.PublishedValue == null ? propertyValue.EditedValue == null : propertyValue.PublishedValue.Equals(propertyValue.EditedValue); edited |= !sameValues; - if (editingCultures && // cultures can be edited, ie CultureNeutral is supported - propertyValue.Culture != null && propertyValue.Segment == null && // and value is CultureNeutral - !sameValues) // and edited and published are different + if (entityVariesByCulture // cultures can be edited, ie CultureNeutral is supported + && propertyValue.Culture != null && propertyValue.Segment == null // and value is CultureNeutral + && !sameValues) // and edited and published are different { editedCultures.Add(propertyValue.Culture); // report culture as edited } + + // flag culture as edited if it contains an edited invariant property + if (propertyValue.Culture == null //invariant property + && !sameValues // and edited and published are different + && entityVariesByCulture) //only when the entity is variant + { + if (defaultCulture == null) + defaultCulture = languageRepository.GetDefaultIsoCode(); + + editedCultures.Add(defaultCulture); + } + } } else diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/DocumentRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/DocumentRepository.cs index 35496aaba7..1f24c7c414 100644 --- a/src/Umbraco.Core/Persistence/Repositories/Implement/DocumentRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/Implement/DocumentRepository.cs @@ -352,7 +352,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement } // persist the property data - var propertyDataDtos = PropertyFactory.BuildDtos(content.VersionId, content.PublishedVersionId, entity.Properties, LanguageRepository, out var edited, out var editedCultures); + var propertyDataDtos = PropertyFactory.BuildDtos(content.ContentType.Variations, content.VersionId, content.PublishedVersionId, entity.Properties, LanguageRepository, out var edited, out var editedCultures); foreach (var propertyDataDto in propertyDataDtos) Database.Insert(propertyDataDto); @@ -527,7 +527,8 @@ namespace Umbraco.Core.Persistence.Repositories.Implement Database.Execute(deletePropertyDataSql); // insert property data - var propertyDataDtos = PropertyFactory.BuildDtos(content.VersionId, publishing ? content.PublishedVersionId : 0, entity.Properties, LanguageRepository, out var edited, out var editedCultures); + var propertyDataDtos = PropertyFactory.BuildDtos(content.ContentType.Variations, content.VersionId, publishing ? content.PublishedVersionId : 0, + entity.Properties, LanguageRepository, out var edited, out var editedCultures); foreach (var propertyDataDto in propertyDataDtos) Database.Insert(propertyDataDto); diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/MediaRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/MediaRepository.cs index dbfdc8e980..3e665e321f 100644 --- a/src/Umbraco.Core/Persistence/Repositories/Implement/MediaRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/Implement/MediaRepository.cs @@ -284,7 +284,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement Database.Insert(mediaVersionDto); // persist the property data - var propertyDataDtos = PropertyFactory.BuildDtos(media.VersionId, 0, entity.Properties, LanguageRepository, out _, out _); + var propertyDataDtos = PropertyFactory.BuildDtos(media.ContentType.Variations, media.VersionId, 0, entity.Properties, LanguageRepository, out _, out _); foreach (var propertyDataDto in propertyDataDtos) Database.Insert(propertyDataDto); @@ -341,7 +341,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement // replace the property data var deletePropertyDataSql = SqlContext.Sql().Delete().Where(x => x.VersionId == media.VersionId); Database.Execute(deletePropertyDataSql); - var propertyDataDtos = PropertyFactory.BuildDtos(media.VersionId, 0, entity.Properties, LanguageRepository, out _, out _); + var propertyDataDtos = PropertyFactory.BuildDtos(media.ContentType.Variations, media.VersionId, 0, entity.Properties, LanguageRepository, out _, out _); foreach (var propertyDataDto in propertyDataDtos) Database.Insert(propertyDataDto); diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/MemberRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/MemberRepository.cs index fd79b231de..bfadebd61b 100644 --- a/src/Umbraco.Core/Persistence/Repositories/Implement/MemberRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/Implement/MemberRepository.cs @@ -310,7 +310,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement Database.Insert(dto); // persist the property data - var propertyDataDtos = PropertyFactory.BuildDtos(member.VersionId, 0, entity.Properties, LanguageRepository, out _, out _); + var propertyDataDtos = PropertyFactory.BuildDtos(member.ContentType.Variations, member.VersionId, 0, entity.Properties, LanguageRepository, out _, out _); foreach (var propertyDataDto in propertyDataDtos) Database.Insert(propertyDataDto); @@ -375,7 +375,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement // replace the property data var deletePropertyDataSql = SqlContext.Sql().Delete().Where(x => x.VersionId == member.VersionId); Database.Execute(deletePropertyDataSql); - var propertyDataDtos = PropertyFactory.BuildDtos(member.VersionId, 0, entity.Properties, LanguageRepository, out _, out _); + var propertyDataDtos = PropertyFactory.BuildDtos(member.ContentType.Variations, member.VersionId, 0, entity.Properties, LanguageRepository, out _, out _); foreach (var propertyDataDto in propertyDataDtos) Database.Insert(propertyDataDto); diff --git a/src/Umbraco.Core/Runtime/CoreRuntime.cs b/src/Umbraco.Core/Runtime/CoreRuntime.cs index 3a698dd30d..5d2359d04c 100644 --- a/src/Umbraco.Core/Runtime/CoreRuntime.cs +++ b/src/Umbraco.Core/Runtime/CoreRuntime.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Reflection; using System.Threading; @@ -106,16 +107,18 @@ namespace Umbraco.Core.Runtime // database factory var databaseFactory = GetDatabaseFactory(); + // configs + var configs = GetConfigs(); + // type loader - var globalSettings = Current.Config.Global(); - var localTempStorage = globalSettings.LocalTempStorageLocation; + var localTempStorage = configs.Global().LocalTempStorageLocation; var typeLoader = new TypeLoader(runtimeCache, localTempStorage, ProfilingLogger); // runtime state // beware! must use '() => _factory.GetInstance()' and NOT '_factory.GetInstance' // as the second one captures the current value (null) and therefore fails _state = new RuntimeState(Logger, - Current.Config.Umbraco(), Current.Config.Global(), + configs.Settings(), configs.Global(), new Lazy(() => _factory.GetInstance()), new Lazy(() => _factory.GetInstance())) { @@ -126,7 +129,7 @@ namespace Umbraco.Core.Runtime var mainDom = new MainDom(Logger); // create the composition - composition = new Composition(register, typeLoader, ProfilingLogger, _state); + composition = new Composition(register, typeLoader, ProfilingLogger, _state, configs); composition.RegisterEssentials(Logger, Profiler, ProfilingLogger, mainDom, appCaches, databaseFactory, typeLoader, _state); // register runtime-level services @@ -146,14 +149,20 @@ namespace Umbraco.Core.Runtime // create the factory _factory = Current.Factory = composition.CreateFactory(); - // create the components + // create & initialize the components _components = _factory.GetInstance(); + _components.Initialize(); } catch (Exception e) { - _state.Level = RuntimeLevel.BootFailed; var bfe = e as BootFailedException ?? new BootFailedException("Boot failed.", e); - _state.BootFailedException = bfe; + + if (_state != null) + { + _state.Level = RuntimeLevel.BootFailed; + _state.BootFailedException = bfe; + } + timer.Fail(exception: bfe); // be sure to log the exception - even if we repeat ourselves // if something goes wrong above, we may end up with no factory @@ -168,6 +177,8 @@ namespace Umbraco.Core.Runtime catch { /* yea */ } } + Debugger.Break(); + // throwing here can cause w3wp to hard-crash and we want to avoid it. // instead, we're logging the exception and setting level to BootFailed. // various parts of Umbraco such as UmbracoModule and UmbracoDefaultOwinStartup @@ -338,6 +349,16 @@ namespace Umbraco.Core.Runtime protected internal virtual IUmbracoDatabaseFactory GetDatabaseFactory() => new UmbracoDatabaseFactory(Logger, new Lazy(() => _factory.GetInstance())); + /// + /// Gets the configurations. + /// + protected virtual Configs GetConfigs() + { + var configs = new Configs(); + configs.AddCoreConfigs(); + return configs; + } + #endregion } } diff --git a/src/Umbraco.Core/Runtime/CoreRuntimeComponent.cs b/src/Umbraco.Core/Runtime/CoreRuntimeComponent.cs index 9e61feb15d..b9efdd6432 100644 --- a/src/Umbraco.Core/Runtime/CoreRuntimeComponent.cs +++ b/src/Umbraco.Core/Runtime/CoreRuntimeComponent.cs @@ -7,12 +7,19 @@ namespace Umbraco.Core.Runtime { public class CoreRuntimeComponent : IComponent { + private readonly IEnumerable _mapperProfiles; + public CoreRuntimeComponent(IEnumerable mapperProfiles) + { + _mapperProfiles = mapperProfiles; + } + + public void Initialize() { // mapper profiles have been registered & are created by the container Mapper.Initialize(configuration => { - foreach (var profile in mapperProfiles) + foreach (var profile in _mapperProfiles) configuration.AddProfile(profile); }); @@ -24,5 +31,8 @@ namespace Umbraco.Core.Runtime IOHelper.EnsurePathExists(SystemDirectories.MvcViews + "/Partials"); IOHelper.EnsurePathExists(SystemDirectories.MvcViews + "/MacroPartials"); } + + public void Terminate() + { } } } diff --git a/src/Umbraco.Core/Scoping/Scope.cs b/src/Umbraco.Core/Scoping/Scope.cs index daef4c4cd7..b8d4d7b430 100644 --- a/src/Umbraco.Core/Scoping/Scope.cs +++ b/src/Umbraco.Core/Scoping/Scope.cs @@ -492,7 +492,7 @@ namespace Umbraco.Core.Scoping // caching config // true if Umbraco.CoreDebug.LogUncompletedScope appSetting is set to "true" private static bool LogUncompletedScopes => (_logUncompletedScopes - ?? (_logUncompletedScopes = Current.Config.CoreDebug().LogUncompletedScopes)).Value; + ?? (_logUncompletedScopes = Current.Configs.CoreDebug().LogUncompletedScopes)).Value; /// public void ReadLock(params int[] lockIds) diff --git a/src/Umbraco.Core/Security/MembershipProviderExtensions.cs b/src/Umbraco.Core/Security/MembershipProviderExtensions.cs index 10f44c46e7..ff595a5d45 100644 --- a/src/Umbraco.Core/Security/MembershipProviderExtensions.cs +++ b/src/Umbraco.Core/Security/MembershipProviderExtensions.cs @@ -88,11 +88,11 @@ namespace Umbraco.Core.Security /// public static MembershipProvider GetUsersMembershipProvider() { - if (Membership.Providers[Current.Config.Umbraco().Providers.DefaultBackOfficeUserProvider] == null) + if (Membership.Providers[Current.Configs.Settings().Providers.DefaultBackOfficeUserProvider] == null) { - throw new InvalidOperationException("No membership provider found with name " + Current.Config.Umbraco().Providers.DefaultBackOfficeUserProvider); + throw new InvalidOperationException("No membership provider found with name " + Current.Configs.Settings().Providers.DefaultBackOfficeUserProvider); } - return Membership.Providers[Current.Config.Umbraco().Providers.DefaultBackOfficeUserProvider]; + return Membership.Providers[Current.Configs.Settings().Providers.DefaultBackOfficeUserProvider]; } /// diff --git a/src/Umbraco.Core/StringExtensions.cs b/src/Umbraco.Core/StringExtensions.cs index 98eaf9f4e9..90fc472e30 100644 --- a/src/Umbraco.Core/StringExtensions.cs +++ b/src/Umbraco.Core/StringExtensions.cs @@ -1114,7 +1114,7 @@ namespace Umbraco.Core /// Checks UmbracoSettings.ForceSafeAliases to determine whether it should filter the text. public static string ToSafeAliasWithForcingCheck(this string alias) { - return Current.Config.Umbraco().Content.ForceSafeAliases ? alias.ToSafeAlias() : alias; + return Current.Configs.Settings().Content.ForceSafeAliases ? alias.ToSafeAlias() : alias; } /// @@ -1126,7 +1126,7 @@ namespace Umbraco.Core /// Checks UmbracoSettings.ForceSafeAliases to determine whether it should filter the text. public static string ToSafeAliasWithForcingCheck(this string alias, string culture) { - return Current.Config.Umbraco().Content.ForceSafeAliases ? alias.ToSafeAlias(culture) : alias; + return Current.Configs.Settings().Content.ForceSafeAliases ? alias.ToSafeAlias(culture) : alias; } // the new methods to get a url segment diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index fc92bc4c55..a01bbf1746 100755 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -204,6 +204,8 @@ + + @@ -257,7 +259,6 @@ - diff --git a/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs b/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs index 7f2edac876..28e753cadc 100644 --- a/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs +++ b/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs @@ -4,6 +4,8 @@ using Moq; using NUnit.Framework; using Umbraco.Core.Cache; using Umbraco.Core.Composing; +using Umbraco.Core.Configuration; +using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Tests.TestHelpers; using Umbraco.Tests.Testing; using Umbraco.Tests.Testing.Objects.Accessors; @@ -48,16 +50,14 @@ namespace Umbraco.Tests.Cache.PublishedCache "; } - public override void SetUp() + protected override void Initialize() { - base.SetUp(); + base.Initialize(); _httpContextFactory = new FakeHttpContextFactory("~/Home"); - var umbracoSettings = SettingsForTests.GenerateMockUmbracoSettings(); - var globalSettings = SettingsForTests.GenerateMockGlobalSettings(); - SettingsForTests.ConfigureSettings(umbracoSettings); - SettingsForTests.ConfigureSettings(globalSettings); + var umbracoSettings = Factory.GetInstance(); + var globalSettings = Factory.GetInstance(); _xml = new XmlDocument(); _xml.LoadXml(GetXml()); diff --git a/src/Umbraco.Tests/Components/ComponentTests.cs b/src/Umbraco.Tests/Components/ComponentTests.cs index 903c53292c..a04636f919 100644 --- a/src/Umbraco.Tests/Components/ComponentTests.cs +++ b/src/Umbraco.Tests/Components/ComponentTests.cs @@ -18,7 +18,8 @@ namespace Umbraco.Tests.Components public class ComponentTests { private static readonly List Composed = new List(); - private static readonly List Initialized = new List(); + private static readonly List Initialized = new List(); + private static readonly List Terminated = new List(); private static IFactory MockFactory(Action> setup = null) { @@ -64,13 +65,36 @@ namespace Umbraco.Tests.Components var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown)); var types = TypeArray(); - var components = new Core.Components.Composers(composition, types, Mock.Of()); + var composers = new Composers(composition, types, Mock.Of()); Composed.Clear(); // 2 is Core and requires 4 // 3 is User - goes away with RuntimeLevel.Unknown // => reorder components accordingly - components.Compose(); + composers.Compose(); AssertTypeArray(TypeArray(), Composed); + + var factory = MockFactory(m => + { + m.Setup(x => x.TryGetInstance(It.Is(t => t == typeof(ISomeResource)))).Returns(() => new SomeResource()); + m.Setup(x => x.GetInstance(It.IsAny())).Returns((type) => + { + if (type == typeof(Composer1)) return new Composer1(); + if (type == typeof(Composer5)) return new Composer5(); + if (type == typeof(Component5)) return new Component5(new SomeResource()); + if (type == typeof(IProfilingLogger)) return new ProfilingLogger(Mock.Of(), Mock.Of()); + throw new NotSupportedException(type.FullName); + }); + }); + + var builder = composition.WithCollectionBuilder(); + builder.RegisterWith(register); + var components = builder.CreateCollection(factory); + + Assert.IsEmpty(components); + components.Initialize(); + Assert.IsEmpty(Initialized); + components.Terminate(); + Assert.IsEmpty(Terminated); } [Test] @@ -164,6 +188,10 @@ namespace Umbraco.Tests.Components [Test] public void Initialize() { + Composed.Clear(); + Initialized.Clear(); + Terminated.Clear(); + var register = MockRegister(); var factory = MockFactory(m => { @@ -181,17 +209,22 @@ namespace Umbraco.Tests.Components var types = new[] { typeof(Composer1), typeof(Composer5) }; var composers = new Composers(composition, types, Mock.Of()); - Composed.Clear(); - Initialized.Clear(); + + Assert.IsEmpty(Composed); composers.Compose(); + AssertTypeArray(TypeArray(), Composed); + var builder = composition.WithCollectionBuilder(); builder.RegisterWith(register); var components = builder.CreateCollection(factory); - Assert.AreEqual(2, Composed.Count); - Assert.AreEqual(typeof(Composer1), Composed[0]); - Assert.AreEqual(typeof(Composer5), Composed[1]); - Assert.AreEqual(1, Initialized.Count); - Assert.AreEqual("Umbraco.Tests.Components.ComponentTests+SomeResource", Initialized[0]); + + Assert.IsEmpty(Initialized); + components.Initialize(); + AssertTypeArray(TypeArray(), Initialized); + + Assert.IsEmpty(Terminated); + components.Terminate(); + AssertTypeArray(TypeArray(), Terminated); } [Test] @@ -301,9 +334,6 @@ namespace Umbraco.Tests.Components } } - public class TestComponentBase : IComponent - { } - public class Composer1 : TestComposerBase { } @@ -326,11 +356,26 @@ namespace Umbraco.Tests.Components } } - public class Component5 : IComponent + public class TestComponentBase : IComponent { + public virtual void Initialize() + { + Initialized.Add(GetType()); + } + + public virtual void Terminate() + { + Terminated.Add(GetType()); + } + } + + public class Component5 : TestComponentBase + { + private readonly ISomeResource _resource; + public Component5(ISomeResource resource) { - Initialized.Add(resource.GetType().FullName); + _resource = resource; } } diff --git a/src/Umbraco.Tests/Configurations/GlobalSettingsTests.cs b/src/Umbraco.Tests/Configurations/GlobalSettingsTests.cs index d1470756f0..8587a7b194 100644 --- a/src/Umbraco.Tests/Configurations/GlobalSettingsTests.cs +++ b/src/Umbraco.Tests/Configurations/GlobalSettingsTests.cs @@ -2,6 +2,7 @@ using System.Web.Routing; using Moq; using NUnit.Framework; +using Umbraco.Core; using Umbraco.Core.Composing; using Umbraco.Core.Configuration; using Umbraco.Core.IO; @@ -46,14 +47,13 @@ namespace Umbraco.Tests.Configurations [TestCase("~/some-wacky/nestedPath", "/MyVirtualDir/NestedVDir/", "some-wacky-nestedpath")] public void Umbraco_Mvc_Area(string path, string rootPath, string outcome) { - var globalSettingsMock = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettingsMock = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettingsMock.Setup(x => x.Path).Returns(IOHelper.ResolveUrl(path)); - SettingsForTests.ConfigureSettings(globalSettingsMock.Object); SystemDirectories.Root = rootPath; - Assert.AreEqual(outcome, Current.Config.Global().GetUmbracoMvcArea()); + Assert.AreEqual(outcome, Current.Configs.Global().GetUmbracoMvcArea()); } - + [TestCase("/umbraco/editContent.aspx")] [TestCase("/install/default.aspx")] [TestCase("/install/")] @@ -93,10 +93,9 @@ namespace Umbraco.Tests.Configurations public void Is_Reserved_By_Route(string url, bool shouldMatch) { //reset the app config, we only want to test routes not the hard coded paths - var globalSettingsMock = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettingsMock = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettingsMock.Setup(x => x.ReservedPaths).Returns(""); globalSettingsMock.Setup(x => x.ReservedUrls).Returns(""); - SettingsForTests.ConfigureSettings(globalSettingsMock.Object); var routes = new RouteCollection(); diff --git a/src/Umbraco.Tests/CoreThings/TryConvertToTests.cs b/src/Umbraco.Tests/CoreThings/TryConvertToTests.cs index c7741deb04..120a7f40c9 100644 --- a/src/Umbraco.Tests/CoreThings/TryConvertToTests.cs +++ b/src/Umbraco.Tests/CoreThings/TryConvertToTests.cs @@ -1,8 +1,9 @@ using System; using NUnit.Framework; using Umbraco.Core; +using Umbraco.Core.Composing; +using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.Strings; -using Umbraco.Tests.TestHelpers; using Umbraco.Tests.Testing; namespace Umbraco.Tests.CoreThings @@ -10,14 +11,11 @@ namespace Umbraco.Tests.CoreThings [TestFixture] public class TryConvertToTests : UmbracoTestBase { - public override void SetUp() + protected void Compose() { - base.SetUp(); + base.Compose(); - var settings = SettingsForTests.GetDefaultUmbracoSettings(); - - // fixme - base should do it! - Composition.RegisterUnique(_ => new DefaultShortStringHelper(settings)); + Composition.RegisterUnique(f => new DefaultShortStringHelper(f.GetInstance())); } [Test] diff --git a/src/Umbraco.Tests/IO/FileSystemsTests.cs b/src/Umbraco.Tests/IO/FileSystemsTests.cs index 116c53f5e4..52de1bbcfa 100644 --- a/src/Umbraco.Tests/IO/FileSystemsTests.cs +++ b/src/Umbraco.Tests/IO/FileSystemsTests.cs @@ -26,10 +26,6 @@ namespace Umbraco.Tests.IO [SetUp] public void Setup() { - //init the config singleton - var config = SettingsForTests.GetDefaultUmbracoSettings(); - SettingsForTests.ConfigureSettings(config); - _register = RegisterFactory.Create(); var composition = new Composition(_register, new TypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run)); @@ -39,10 +35,18 @@ namespace Umbraco.Tests.IO composition.Register(_ => Mock.Of()); composition.RegisterUnique(); + composition.Configs.Add(SettingsForTests.GetDefaultGlobalSettings); + composition.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings); + composition.ComposeFileSystems(); + composition.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings); + _factory = composition.CreateFactory(); + Current.Reset(); + Current.Factory = _factory; + // make sure we start clean // because some tests will create corrupt or weird filesystems FileSystems.Reset(); @@ -82,6 +86,16 @@ namespace Umbraco.Tests.IO Assert.AreSame(fileSystem1, fileSystem2); } + [Test] + public void Can_Unwrap_MediaFileSystem() + { + var fileSystem = _factory.GetInstance(); + var unwrapped = fileSystem.Unwrap(); + Assert.IsNotNull(unwrapped); + var physical = unwrapped as PhysicalFileSystem; + Assert.IsNotNull(physical); + } + [Test] public void Can_Delete_MediaFiles() { diff --git a/src/Umbraco.Tests/Macros/MacroTests.cs b/src/Umbraco.Tests/Macros/MacroTests.cs index 3ab56052e0..984fb94fab 100644 --- a/src/Umbraco.Tests/Macros/MacroTests.cs +++ b/src/Umbraco.Tests/Macros/MacroTests.cs @@ -6,6 +6,7 @@ using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Composing; using Umbraco.Core.Configuration; +using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.Models; using Umbraco.Tests.TestHelpers; using Umbraco.Web.Macros; @@ -27,7 +28,9 @@ namespace Umbraco.Tests.Macros new IsolatedRuntimeCache(type => new ObjectCacheRuntimeCacheProvider())); //Current.ApplicationContext = new ApplicationContext(cacheHelper, new ProfilingLogger(Mock.Of(), Mock.Of())); - Current.Config.SetUmbracoConfig(SettingsForTests.GetDefaultUmbracoSettings()); + Current.Reset(); + Current.UnlockConfigs(); + Current.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings); } [TestCase("123", "IntProp", typeof(int))] diff --git a/src/Umbraco.Tests/Misc/UriUtilityTests.cs b/src/Umbraco.Tests/Misc/UriUtilityTests.cs index 0bd9156f20..42c69d3967 100644 --- a/src/Umbraco.Tests/Misc/UriUtilityTests.cs +++ b/src/Umbraco.Tests/Misc/UriUtilityTests.cs @@ -90,7 +90,6 @@ namespace Umbraco.Tests.Misc var settings = SettingsForTests.GenerateMockUmbracoSettings(); var requestMock = Mock.Get(settings.RequestHandler); requestMock.Setup(x => x.AddTrailingSlash).Returns(trailingSlash); - SettingsForTests.ConfigureSettings(settings); UriUtility.SetAppDomainAppVirtualPath("/"); diff --git a/src/Umbraco.Tests/Models/ContentTests.cs b/src/Umbraco.Tests/Models/ContentTests.cs index c893b71df5..24aeb1668f 100644 --- a/src/Umbraco.Tests/Models/ContentTests.cs +++ b/src/Umbraco.Tests/Models/ContentTests.cs @@ -7,18 +7,14 @@ using System.Threading; using Moq; using Umbraco.Core; using NUnit.Framework; -using Umbraco.Core; using Umbraco.Core.Cache; -using Umbraco.Core.Composing; using Umbraco.Core.Composing.Composers; using Umbraco.Core.Configuration.UmbracoSettings; -using Umbraco.Core.IO; using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.Entities; using Umbraco.Core.Serialization; using Umbraco.Core.Services; -using Umbraco.Tests.TestHelpers; using Umbraco.Tests.TestHelpers.Entities; using Umbraco.Tests.TestHelpers.Stubs; using Umbraco.Tests.Testing; @@ -29,14 +25,6 @@ namespace Umbraco.Tests.Models [TestFixture] public class ContentTests : UmbracoTestBase { - public override void SetUp() - { - base.SetUp(); - - var config = SettingsForTests.GetDefaultUmbracoSettings(); - SettingsForTests.ConfigureSettings(config); - } - protected override void Compose() { base.Compose(); diff --git a/src/Umbraco.Tests/Models/MacroTests.cs b/src/Umbraco.Tests/Models/MacroTests.cs index b4060134bd..d980cd1d58 100644 --- a/src/Umbraco.Tests/Models/MacroTests.cs +++ b/src/Umbraco.Tests/Models/MacroTests.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using NUnit.Framework; +using Umbraco.Core.Composing; using Umbraco.Core.Models; using Umbraco.Core.Models.Entities; using Umbraco.Tests.TestHelpers; @@ -13,8 +14,9 @@ namespace Umbraco.Tests.Models [SetUp] public void Init() { - var config = SettingsForTests.GetDefaultUmbracoSettings(); - SettingsForTests.ConfigureSettings(config); + Current.Reset(); + Current.UnlockConfigs(); + Current.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings); } [Test] diff --git a/src/Umbraco.Tests/Models/MemberTests.cs b/src/Umbraco.Tests/Models/MemberTests.cs index 76ea804c57..c09f2e9460 100644 --- a/src/Umbraco.Tests/Models/MemberTests.cs +++ b/src/Umbraco.Tests/Models/MemberTests.cs @@ -2,9 +2,10 @@ using System.Diagnostics; using System.Linq; using NUnit.Framework; +using Umbraco.Core.Composing; using Umbraco.Core.Models; -using Umbraco.Core.Models.Entities; using Umbraco.Core.Serialization; +using Umbraco.Tests.TestHelpers; using Umbraco.Tests.TestHelpers.Entities; namespace Umbraco.Tests.Models @@ -12,6 +13,15 @@ namespace Umbraco.Tests.Models [TestFixture] public class MemberTests { + [SetUp] + public void Setup() + { + Current.Reset(); + Current.UnlockConfigs(); + Current.Configs.Add(SettingsForTests.GetDefaultGlobalSettings); + Current.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings); + } + [Test] public void Can_Deep_Clone() { diff --git a/src/Umbraco.Tests/Models/UserTests.cs b/src/Umbraco.Tests/Models/UserTests.cs index 5e982633d2..797b79381a 100644 --- a/src/Umbraco.Tests/Models/UserTests.cs +++ b/src/Umbraco.Tests/Models/UserTests.cs @@ -2,14 +2,24 @@ using System.Diagnostics; using System.Linq; using NUnit.Framework; +using Umbraco.Core.Composing; using Umbraco.Core.Models.Membership; using Umbraco.Core.Serialization; +using Umbraco.Tests.TestHelpers; namespace Umbraco.Tests.Models { [TestFixture] public class UserTests { + [SetUp] + public void Setup() + { + Current.Reset(); + Current.UnlockConfigs(); + Current.Configs.Add(SettingsForTests.GetDefaultGlobalSettings); + } + [Test] public void Can_Deep_Clone() { diff --git a/src/Umbraco.Tests/Models/VariationTests.cs b/src/Umbraco.Tests/Models/VariationTests.cs index f5ba7f5915..103fd35074 100644 --- a/src/Umbraco.Tests/Models/VariationTests.cs +++ b/src/Umbraco.Tests/Models/VariationTests.cs @@ -3,6 +3,7 @@ using Moq; using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.Composing; +using Umbraco.Core.Configuration; using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.PropertyEditors; @@ -26,6 +27,11 @@ namespace Umbraco.Tests.Models // need to be able to retrieve them all... Current.Reset(); + + var configs = new Configs(); + configs.Add(SettingsForTests.GetDefaultGlobalSettings); + configs.Add(SettingsForTests.GetDefaultUmbracoSettings); + var factory = Mock.Of(); Current.Factory = factory; @@ -53,12 +59,12 @@ namespace Umbraco.Tests.Models .Setup(x => x.GetInstance(It.IsAny())) .Returns(x => { + if (x == typeof(Configs)) return configs; if (x == typeof(PropertyEditorCollection)) return propertyEditors; if (x == typeof(ServiceContext)) return serviceContext; if (x == typeof(ILocalizedTextService)) return serviceContext.LocalizationService; - throw new Exception("oops"); + throw new NotSupportedException(x.FullName); }); - } [Test] @@ -429,7 +435,7 @@ namespace Umbraco.Tests.Models Assert.IsTrue(content.IsCultureAvailable(langUk)); Assert.IsFalse(content.IsCulturePublished(langUk)); Assert.IsNull(content.GetPublishName(langUk)); - Assert.IsNull(content.GetPublishDate(langUk)); // not published + Assert.IsNull(content.GetPublishDate(langUk)); // not published Assert.IsFalse(content.IsCultureAvailable(langEs)); Assert.IsFalse(content.IsCultureEdited(langEs)); // not avail, so... not edited @@ -437,7 +443,7 @@ namespace Umbraco.Tests.Models // not published! Assert.IsNull(content.GetPublishName(langEs)); - Assert.IsNull(content.GetPublishDate(langEs)); + Assert.IsNull(content.GetPublishDate(langEs)); // cannot test IsCultureEdited here - as that requires the content service and repository // see: ContentServiceTests.Can_SaveRead_Variations diff --git a/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs b/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs index d12699efb7..3ba0ef64ce 100644 --- a/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs +++ b/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs @@ -35,8 +35,11 @@ namespace Umbraco.Tests.PublishedContent // this test implements a full standalone NuCache (based upon a test IDataSource, does not // use any local db files, does not rely on any database) - and tests variations - SettingsForTests.ConfigureSettings(SettingsForTests.GenerateMockUmbracoSettings()); - var globalSettings = Current.Config.Global(); + Current.Reset(); + Current.UnlockConfigs(); + Current.Configs.Add(SettingsForTests.GenerateMockUmbracoSettings); + Current.Configs.Add(() => new GlobalSettings()); + var globalSettings = Current.Configs.Global(); // create a content node kit var kit = new ContentNodeKit diff --git a/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs index d88df766e3..88b211d0ee 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs @@ -104,7 +104,7 @@ namespace Umbraco.Tests.PublishedContent Assert.AreEqual("
This is some content
", propVal2.ToString()); var propVal3 = publishedMedia.Value("Content"); - Assert.IsInstanceOf(propVal3); + Assert.IsInstanceOf(propVal3); Assert.AreEqual("
This is some content
", propVal3.ToString()); } @@ -461,10 +461,6 @@ namespace Umbraco.Tests.PublishedContent [Test] public void Convert_From_Standard_Xml() { - var config = SettingsForTests.GenerateMockUmbracoSettings(); - - SettingsForTests.ConfigureSettings(config); - var nodeId = 2112; var xml = XElement.Parse(@" diff --git a/src/Umbraco.Tests/Routing/ContentFinderByUrlAndTemplateTests.cs b/src/Umbraco.Tests/Routing/ContentFinderByUrlAndTemplateTests.cs index dab0f15917..c40b2e5876 100644 --- a/src/Umbraco.Tests/Routing/ContentFinderByUrlAndTemplateTests.cs +++ b/src/Umbraco.Tests/Routing/ContentFinderByUrlAndTemplateTests.cs @@ -1,5 +1,7 @@ using Moq; using NUnit.Framework; +using Umbraco.Core.Composing; +using Umbraco.Core.Configuration; using Umbraco.Tests.TestHelpers; using Umbraco.Web.Routing; using Umbraco.Core.Models; @@ -27,10 +29,8 @@ namespace Umbraco.Tests.Routing [TestCase("/home/Sub1.aspx/blah")] public void Match_Document_By_Url_With_Template(string urlAsString) { - - var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); - SettingsForTests.ConfigureSettings(globalSettings.Object); var template1 = CreateTemplate("test"); var template2 = CreateTemplate("blah"); diff --git a/src/Umbraco.Tests/Routing/ContentFinderByUrlTests.cs b/src/Umbraco.Tests/Routing/ContentFinderByUrlTests.cs index e4002c0da1..fa8beea2c2 100644 --- a/src/Umbraco.Tests/Routing/ContentFinderByUrlTests.cs +++ b/src/Umbraco.Tests/Routing/ContentFinderByUrlTests.cs @@ -2,6 +2,7 @@ using System.Globalization; using Moq; using NUnit.Framework; +using Umbraco.Core; using Umbraco.Core.Composing; using Umbraco.Core.Configuration; using Umbraco.Core.Models; @@ -28,16 +29,15 @@ namespace Umbraco.Tests.Routing [TestCase("/test-page", 1172)] public void Match_Document_By_Url_Hide_Top_Level(string urlString, int expectedId) { - var globalSettingsMock = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettingsMock = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettingsMock.Setup(x => x.HideTopLevelNodeFromPath).Returns(true); - SettingsForTests.ConfigureSettings(globalSettingsMock.Object); var umbracoContext = GetUmbracoContext(urlString, globalSettings:globalSettingsMock.Object); var publishedRouter = CreatePublishedRouter(); var frequest = publishedRouter.CreateRequest(umbracoContext); var lookup = new ContentFinderByUrl(Logger); - Assert.IsTrue(Current.Config.Global().HideTopLevelNodeFromPath); + Assert.IsTrue(Current.Configs.Global().HideTopLevelNodeFromPath); // fixme debugging - going further down, the routes cache is NOT empty?! if (urlString == "/home/sub1") @@ -64,16 +64,15 @@ namespace Umbraco.Tests.Routing [TestCase("/home/Sub1.aspx", 1173)] public void Match_Document_By_Url(string urlString, int expectedId) { - var globalSettingsMock = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettingsMock = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettingsMock.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); - SettingsForTests.ConfigureSettings(globalSettingsMock.Object); var umbracoContext = GetUmbracoContext(urlString, globalSettings:globalSettingsMock.Object); var publishedRouter = CreatePublishedRouter(); var frequest = publishedRouter.CreateRequest(umbracoContext); var lookup = new ContentFinderByUrl(Logger); - Assert.IsFalse(Current.Config.Global().HideTopLevelNodeFromPath); + Assert.IsFalse(Current.Configs.Global().HideTopLevelNodeFromPath); var result = lookup.TryFindContent(frequest); @@ -90,9 +89,8 @@ namespace Umbraco.Tests.Routing [TestCase("/home/sub1/custom-sub-4-with-æøå", 1180)] public void Match_Document_By_Url_With_Special_Characters(string urlString, int expectedId) { - var globalSettingsMock = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettingsMock = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettingsMock.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); - SettingsForTests.ConfigureSettings(globalSettingsMock.Object); var umbracoContext = GetUmbracoContext(urlString, globalSettings:globalSettingsMock.Object); var publishedRouter = CreatePublishedRouter(); @@ -118,9 +116,8 @@ namespace Umbraco.Tests.Routing [TestCase("/home/sub1/custom-sub-4-with-æøå", 1180)] public void Match_Document_By_Url_With_Special_Characters_Using_Hostname(string urlString, int expectedId) { - var globalSettingsMock = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettingsMock = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettingsMock.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); - SettingsForTests.ConfigureSettings(globalSettingsMock.Object); var umbracoContext = GetUmbracoContext(urlString, globalSettings:globalSettingsMock.Object); var publishedRouter = CreatePublishedRouter(); @@ -148,9 +145,8 @@ namespace Umbraco.Tests.Routing [TestCase("/æøå/home/sub1/custom-sub-4-with-æøå", 1180)] public void Match_Document_By_Url_With_Special_Characters_In_Hostname(string urlString, int expectedId) { - var globalSettingsMock = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettingsMock = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettingsMock.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); - SettingsForTests.ConfigureSettings(globalSettingsMock.Object); var umbracoContext = GetUmbracoContext(urlString, globalSettings:globalSettingsMock.Object); var publishedRouter = CreatePublishedRouter(); diff --git a/src/Umbraco.Tests/Routing/ContentFinderByUrlWithDomainsTests.cs b/src/Umbraco.Tests/Routing/ContentFinderByUrlWithDomainsTests.cs index 92aed90168..dfbe9b0cda 100644 --- a/src/Umbraco.Tests/Routing/ContentFinderByUrlWithDomainsTests.cs +++ b/src/Umbraco.Tests/Routing/ContentFinderByUrlWithDomainsTests.cs @@ -1,5 +1,7 @@ using Moq; using NUnit.Framework; +using Umbraco.Core.Composing; +using Umbraco.Core.Configuration; using Umbraco.Core.Models; using Umbraco.Tests.TestHelpers; using Umbraco.Web.Routing; @@ -124,10 +126,9 @@ namespace Umbraco.Tests.Routing { SetDomains3(); - var globalSettingsMock = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettingsMock = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettingsMock.Setup(x => x.HideTopLevelNodeFromPath).Returns(true); - SettingsForTests.ConfigureSettings(globalSettingsMock.Object); - + var umbracoContext = GetUmbracoContext(url, globalSettings:globalSettingsMock.Object); var publishedRouter = CreatePublishedRouter(Factory); var frequest = publishedRouter.CreateRequest(umbracoContext); @@ -167,9 +168,8 @@ namespace Umbraco.Tests.Routing // defaults depend on test environment expectedCulture = expectedCulture ?? System.Threading.Thread.CurrentThread.CurrentUICulture.Name; - var globalSettingsMock = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettingsMock = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettingsMock.Setup(x => x.HideTopLevelNodeFromPath).Returns(true); - SettingsForTests.ConfigureSettings(globalSettingsMock.Object); var umbracoContext = GetUmbracoContext(url, globalSettings:globalSettingsMock.Object); var publishedRouter = CreatePublishedRouter(Factory); diff --git a/src/Umbraco.Tests/Routing/DomainsAndCulturesTests.cs b/src/Umbraco.Tests/Routing/DomainsAndCulturesTests.cs index 471fa27f82..a81f345e38 100644 --- a/src/Umbraco.Tests/Routing/DomainsAndCulturesTests.cs +++ b/src/Umbraco.Tests/Routing/DomainsAndCulturesTests.cs @@ -5,6 +5,7 @@ using Umbraco.Tests.TestHelpers; using Umbraco.Web.Routing; using Umbraco.Core; using Umbraco.Core.Composing; +using Umbraco.Core.Configuration; namespace Umbraco.Tests.Routing { @@ -265,9 +266,8 @@ namespace Umbraco.Tests.Routing { SetDomains1(); - var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); - SettingsForTests.ConfigureSettings(globalSettings.Object); var umbracoContext = GetUmbracoContext(inputUrl, globalSettings:globalSettings.Object); var publishedRouter = CreatePublishedRouter(Factory); @@ -315,9 +315,8 @@ namespace Umbraco.Tests.Routing // defaults depend on test environment expectedCulture = expectedCulture ?? System.Threading.Thread.CurrentThread.CurrentUICulture.Name; - var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); - SettingsForTests.ConfigureSettings(globalSettings.Object); var umbracoContext = GetUmbracoContext(inputUrl, globalSettings:globalSettings.Object); var publishedRouter = CreatePublishedRouter(Factory); @@ -371,9 +370,8 @@ namespace Umbraco.Tests.Routing { SetDomains3(); - var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); - SettingsForTests.ConfigureSettings(globalSettings.Object); var umbracoContext = GetUmbracoContext(inputUrl, globalSettings:globalSettings.Object); var publishedRouter = CreatePublishedRouter(Factory); var frequest = publishedRouter.CreateRequest(umbracoContext); diff --git a/src/Umbraco.Tests/Routing/GetContentUrlsTests.cs b/src/Umbraco.Tests/Routing/GetContentUrlsTests.cs index 6079369df7..8e9e52258c 100644 --- a/src/Umbraco.Tests/Routing/GetContentUrlsTests.cs +++ b/src/Umbraco.Tests/Routing/GetContentUrlsTests.cs @@ -3,10 +3,11 @@ using System.Globalization; using System.Linq; using Moq; using NUnit.Framework; -using Umbraco.Core.Configuration.UmbracoSettings; +using Umbraco.Core; +using Umbraco.Core.Composing; +using Umbraco.Core.Configuration; using Umbraco.Core.Models; using Umbraco.Core.Services; -using Umbraco.Tests.TestHelpers; using Umbraco.Tests.TestHelpers.Entities; using Umbraco.Web.Routing; @@ -15,17 +16,6 @@ namespace Umbraco.Tests.Routing [TestFixture] public class GetContentUrlsTests : UrlRoutingTestBase { - private IUmbracoSettingsSection _umbracoSettings; - - public override void SetUp() - { - base.SetUp(); - - //generate new mock settings and assign so we can configure in individual tests - _umbracoSettings = SettingsForTests.GenerateMockUmbracoSettings(); - SettingsForTests.ConfigureSettings(_umbracoSettings); - } - private ILocalizedTextService GetTextService() { var textService = Mock.Of( @@ -80,8 +70,10 @@ namespace Umbraco.Tests.Routing content.Path = "-1,1046"; content.Published = true; + var umbracoSettings = Current.Configs.Settings(); + var umbContext = GetUmbracoContext("http://localhost:8000", - urlProviders: new []{ new DefaultUrlProvider(_umbracoSettings.RequestHandler, Logger, TestObjects.GetGlobalSettings(), new SiteDomainHelper()) }); + urlProviders: new []{ new DefaultUrlProvider(umbracoSettings.RequestHandler, Logger, TestObjects.GetGlobalSettings(), new SiteDomainHelper()) }); var publishedRouter = CreatePublishedRouter(Factory, contentFinders:new ContentFinderCollection(new[]{new ContentFinderByUrl(Logger) })); var urls = content.GetContentUrls(publishedRouter, @@ -110,8 +102,10 @@ namespace Umbraco.Tests.Routing child.Path = "-1,1046,1173"; child.Published = true; + var umbracoSettings = Current.Configs.Settings(); + var umbContext = GetUmbracoContext("http://localhost:8000", - urlProviders: new[] { new DefaultUrlProvider(_umbracoSettings.RequestHandler, Logger, TestObjects.GetGlobalSettings(), new SiteDomainHelper()) }); + urlProviders: new[] { new DefaultUrlProvider(umbracoSettings.RequestHandler, Logger, TestObjects.GetGlobalSettings(), new SiteDomainHelper()) }); var publishedRouter = CreatePublishedRouter(Factory, contentFinders: new ContentFinderCollection(new[] { new ContentFinderByUrl(Logger) })); var urls = child.GetContentUrls(publishedRouter, diff --git a/src/Umbraco.Tests/Routing/UrlProviderTests.cs b/src/Umbraco.Tests/Routing/UrlProviderTests.cs index 6f29a312ae..819ea0b01c 100644 --- a/src/Umbraco.Tests/Routing/UrlProviderTests.cs +++ b/src/Umbraco.Tests/Routing/UrlProviderTests.cs @@ -6,7 +6,7 @@ using Moq; using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.Composing; -using Umbraco.Core.Configuration.UmbracoSettings; +using Umbraco.Core.Configuration; using Umbraco.Core.Models; using Umbraco.Core.Models.PublishedContent; using Umbraco.Tests.TestHelpers; @@ -28,15 +28,10 @@ namespace Umbraco.Tests.Routing Composition.Register(); } - private IUmbracoSettingsSection _umbracoSettings; - - public override void SetUp() + protected override void ComposeSettings() { - base.SetUp(); - - //generate new mock settings and assign so we can configure in individual tests - _umbracoSettings = SettingsForTests.GenerateMockUmbracoSettings(); - SettingsForTests.ConfigureSettings(_umbracoSettings); + Composition.Configs.Add(SettingsForTests.GenerateMockUmbracoSettings); + Composition.Configs.Add(SettingsForTests.GenerateMockGlobalSettings); } /// @@ -46,17 +41,18 @@ namespace Umbraco.Tests.Routing [Test] public void Ensure_Cache_Is_Correct() { - var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true); globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); - SettingsForTests.ConfigureSettings(globalSettings.Object); + + var umbracoSettings = Current.Configs.Settings(); var umbracoContext = GetUmbracoContext("/test", 1111, urlProviders: new[] { - new DefaultUrlProvider(_umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper()) + new DefaultUrlProvider(umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper()) }, globalSettings: globalSettings.Object); - var requestHandlerMock = Mock.Get(_umbracoSettings.RequestHandler); + var requestHandlerMock = Mock.Get(umbracoSettings.RequestHandler); requestHandlerMock.Setup(x => x.AddTrailingSlash).Returns(false);// (cached routes have none) var samples = new Dictionary { @@ -109,17 +105,18 @@ namespace Umbraco.Tests.Routing [TestCase(1172, "/test-page/")] public void Get_Url_Not_Hiding_Top_Level(int nodeId, string niceUrlMatch) { - var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true); globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); - SettingsForTests.ConfigureSettings(globalSettings.Object); + + var umbracoSettings = Current.Configs.Settings(); var umbracoContext = GetUmbracoContext("/test", 1111, urlProviders: new[] { - new DefaultUrlProvider(_umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper()) + new DefaultUrlProvider(umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper()) }, globalSettings: globalSettings.Object); - var requestMock = Mock.Get(_umbracoSettings.RequestHandler); + var requestMock = Mock.Get(umbracoSettings.RequestHandler); requestMock.Setup(x => x.UseDomainPrefixes).Returns(false); var result = umbracoContext.UrlProvider.GetUrl(nodeId); @@ -139,17 +136,18 @@ namespace Umbraco.Tests.Routing [TestCase(1172, "/test-page/")] // not hidden because not first root public void Get_Url_Hiding_Top_Level(int nodeId, string niceUrlMatch) { - var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true); globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(true); - SettingsForTests.ConfigureSettings(globalSettings.Object); + + var umbracoSettings = Current.Configs.Settings(); var umbracoContext = GetUmbracoContext("/test", 1111, urlProviders: new[] { - new DefaultUrlProvider(_umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper()) + new DefaultUrlProvider(umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper()) }, globalSettings: globalSettings.Object); - var requestMock = Mock.Get(_umbracoSettings.RequestHandler); + var requestMock = Mock.Get(umbracoSettings.RequestHandler); requestMock.Setup(x => x.UseDomainPrefixes).Returns(false); var result = umbracoContext.UrlProvider.GetUrl(nodeId); @@ -161,12 +159,13 @@ namespace Umbraco.Tests.Routing { const string currentUri = "http://example.us/test"; - var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true); globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); - SettingsForTests.ConfigureSettings(globalSettings.Object); - var requestMock = Mock.Get(_umbracoSettings.RequestHandler); + var umbracoSettings = Current.Configs.Settings(); + + var requestMock = Mock.Get(umbracoSettings.RequestHandler); requestMock.Setup(x => x.UseDomainPrefixes).Returns(false); var contentType = new PublishedContentType(666, "alias", PublishedItemType.Content, Enumerable.Empty(), Enumerable.Empty(), ContentVariation.Culture); @@ -188,9 +187,9 @@ namespace Umbraco.Tests.Routing snapshotService.Setup(x => x.CreatePublishedSnapshot(It.IsAny())) .Returns(snapshot); - var umbracoContext = GetUmbracoContext(currentUri, umbracoSettings: _umbracoSettings, + var umbracoContext = GetUmbracoContext(currentUri, umbracoSettings: umbracoSettings, urlProviders: new[] { - new DefaultUrlProvider(_umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper()) + new DefaultUrlProvider(umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper()) }, globalSettings: globalSettings.Object, snapshotService: snapshotService.Object); @@ -209,12 +208,13 @@ namespace Umbraco.Tests.Routing { const string currentUri = "http://example.fr/test"; - var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true); globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); - SettingsForTests.ConfigureSettings(globalSettings.Object); - var requestMock = Mock.Get(_umbracoSettings.RequestHandler); + var umbracoSettings = Current.Configs.Settings(); + + var requestMock = Mock.Get(umbracoSettings.RequestHandler); requestMock.Setup(x => x.UseDomainPrefixes).Returns(false); var contentType = new PublishedContentType(666, "alias", PublishedItemType.Content, Enumerable.Empty(), Enumerable.Empty(), ContentVariation.Culture); @@ -245,9 +245,9 @@ namespace Umbraco.Tests.Routing snapshotService.Setup(x => x.CreatePublishedSnapshot(It.IsAny())) .Returns(snapshot); - var umbracoContext = GetUmbracoContext(currentUri, umbracoSettings: _umbracoSettings, + var umbracoContext = GetUmbracoContext(currentUri, umbracoSettings: umbracoSettings, urlProviders: new[] { - new DefaultUrlProvider(_umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper()) + new DefaultUrlProvider(umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper()) }, globalSettings: globalSettings.Object, snapshotService: snapshotService.Object); @@ -266,12 +266,13 @@ namespace Umbraco.Tests.Routing { const string currentUri = "http://example.us/test"; - var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true); globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); - SettingsForTests.ConfigureSettings(globalSettings.Object); - var requestMock = Mock.Get(_umbracoSettings.RequestHandler); + var umbracoSettings = Current.Configs.Settings(); + + var requestMock = Mock.Get(umbracoSettings.RequestHandler); requestMock.Setup(x => x.UseDomainPrefixes).Returns(false); var contentType = new PublishedContentType(666, "alias", PublishedItemType.Content, Enumerable.Empty(), Enumerable.Empty(), ContentVariation.Culture); @@ -302,9 +303,9 @@ namespace Umbraco.Tests.Routing snapshotService.Setup(x => x.CreatePublishedSnapshot(It.IsAny())) .Returns(snapshot); - var umbracoContext = GetUmbracoContext(currentUri, umbracoSettings: _umbracoSettings, + var umbracoContext = GetUmbracoContext(currentUri, umbracoSettings: umbracoSettings, urlProviders: new[] { - new DefaultUrlProvider(_umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper()) + new DefaultUrlProvider(umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper()) }, globalSettings: globalSettings.Object, snapshotService: snapshotService.Object); @@ -319,17 +320,18 @@ namespace Umbraco.Tests.Routing [Test] public void Get_Url_Relative_Or_Absolute() { - var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true); globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); - SettingsForTests.ConfigureSettings(globalSettings.Object); - var requestMock = Mock.Get(_umbracoSettings.RequestHandler); + var umbracoSettings = Current.Configs.Settings(); + + var requestMock = Mock.Get(umbracoSettings.RequestHandler); requestMock.Setup(x => x.UseDomainPrefixes).Returns(false); - var umbracoContext = GetUmbracoContext("http://example.com/test", 1111, umbracoSettings: _umbracoSettings, urlProviders: new[] + var umbracoContext = GetUmbracoContext("http://example.com/test", 1111, umbracoSettings: umbracoSettings, urlProviders: new[] { - new DefaultUrlProvider(_umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper()) + new DefaultUrlProvider(umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper()) }, globalSettings: globalSettings.Object); Assert.AreEqual("/home/sub1/custom-sub-1/", umbracoContext.UrlProvider.GetUrl(1177)); @@ -345,18 +347,19 @@ namespace Umbraco.Tests.Routing [Test] public void Get_Url_Unpublished() { - var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true); globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); - SettingsForTests.ConfigureSettings(globalSettings.Object); + + var umbracoSettings = Current.Configs.Settings(); var umbracoContext = GetUmbracoContext("http://example.com/test", 1111, urlProviders: new[] { - new DefaultUrlProvider(_umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper()) + new DefaultUrlProvider(umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper()) }, globalSettings: globalSettings.Object); //mock the Umbraco settings that we need - var requestMock = Mock.Get(_umbracoSettings.RequestHandler); + var requestMock = Mock.Get(umbracoSettings.RequestHandler); requestMock.Setup(x => x.UseDomainPrefixes).Returns(false); Assert.AreEqual("#", umbracoContext.UrlProvider.GetUrl(999999)); diff --git a/src/Umbraco.Tests/Routing/UrlRoutesTests.cs b/src/Umbraco.Tests/Routing/UrlRoutesTests.cs index 9b291249c9..4928cd01dc 100644 --- a/src/Umbraco.Tests/Routing/UrlRoutesTests.cs +++ b/src/Umbraco.Tests/Routing/UrlRoutesTests.cs @@ -1,6 +1,8 @@ using System; using Moq; using NUnit.Framework; +using Umbraco.Core.Composing; +using Umbraco.Core.Configuration; using Umbraco.Core.Models; using Umbraco.Tests.TestHelpers; using Umbraco.Tests.Testing; @@ -193,9 +195,8 @@ DetermineRouteById(id): [TestCase(2006, false, "/x/b/e")] public void GetRouteByIdNoHide(int id, bool hide, string expected) { - var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(hide); - SettingsForTests.ConfigureSettings(globalSettings.Object); var umbracoContext = GetUmbracoContext("/test", 0, globalSettings: globalSettings.Object); var cache = umbracoContext.ContentCache as PublishedContentCache; @@ -218,9 +219,8 @@ DetermineRouteById(id): [TestCase(2006, true, "/b/e")] // risky! public void GetRouteByIdHide(int id, bool hide, string expected) { - var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(hide); - SettingsForTests.ConfigureSettings(globalSettings.Object); var umbracoContext = GetUmbracoContext("/test", 0, globalSettings: globalSettings.Object); var cache = umbracoContext.ContentCache as PublishedContentCache; @@ -233,14 +233,13 @@ DetermineRouteById(id): [Test] public void GetRouteByIdCache() { - var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); - SettingsForTests.ConfigureSettings(globalSettings.Object); var umbracoContext = GetUmbracoContext("/test", 0, globalSettings:globalSettings.Object); var cache = umbracoContext.ContentCache as PublishedContentCache; if (cache == null) throw new Exception("Unsupported IPublishedContentCache, only the Xml one is supported."); - + var route = cache.GetRouteById(false, 1000); Assert.AreEqual("/a", route); @@ -265,9 +264,8 @@ DetermineRouteById(id): [TestCase("/x", false, 2000)] public void GetByRouteNoHide(string route, bool hide, int expected) { - var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(hide); - SettingsForTests.ConfigureSettings(globalSettings.Object); var umbracoContext = GetUmbracoContext("/test", 0, globalSettings:globalSettings.Object); var cache = umbracoContext.ContentCache as PublishedContentCache; @@ -297,9 +295,8 @@ DetermineRouteById(id): [TestCase("/b/c", true, 1002)] // (hence the 2005 collision) public void GetByRouteHide(string route, bool hide, int expected) { - var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(hide); - SettingsForTests.ConfigureSettings(globalSettings.Object); var umbracoContext = GetUmbracoContext("/test", 0, globalSettings:globalSettings.Object); var cache = umbracoContext.ContentCache as PublishedContentCache; @@ -321,14 +318,13 @@ DetermineRouteById(id): [Test] public void GetByRouteCache() { - var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); - SettingsForTests.ConfigureSettings(globalSettings.Object); var umbracoContext = GetUmbracoContext("/test", 0, globalSettings:globalSettings.Object); var cache = umbracoContext.ContentCache as PublishedContentCache; if (cache == null) throw new Exception("Unsupported IPublishedContentCache, only the Xml one is supported."); - + var content = cache.GetByRoute(false, "/a/b/c"); Assert.IsNotNull(content); Assert.AreEqual(1002, content.Id); diff --git a/src/Umbraco.Tests/Routing/UrlsProviderWithDomainsTests.cs b/src/Umbraco.Tests/Routing/UrlsProviderWithDomainsTests.cs index e26877481a..ba646f6d94 100644 --- a/src/Umbraco.Tests/Routing/UrlsProviderWithDomainsTests.cs +++ b/src/Umbraco.Tests/Routing/UrlsProviderWithDomainsTests.cs @@ -5,6 +5,7 @@ using Moq; using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.Composing; +using Umbraco.Core.Configuration; using Umbraco.Core.Models; using Umbraco.Core.Services; using Umbraco.Tests.TestHelpers; @@ -178,10 +179,9 @@ namespace Umbraco.Tests.Routing var request = Mock.Get(settings.RequestHandler); request.Setup(x => x.UseDomainPrefixes).Returns(false); - var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true); globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); // ignored w/domains - SettingsForTests.ConfigureSettings(globalSettings.Object); var umbracoContext = GetUmbracoContext("/test", 1111, umbracoSettings: settings, urlProviders: new[] { @@ -214,10 +214,9 @@ namespace Umbraco.Tests.Routing var request = Mock.Get(settings.RequestHandler); request.Setup(x => x.UseDomainPrefixes).Returns(false); - var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true); globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); // ignored w/domains - SettingsForTests.ConfigureSettings(globalSettings.Object); var umbracoContext = GetUmbracoContext("/test", 1111, umbracoSettings: settings, urlProviders: new[] { @@ -242,10 +241,9 @@ namespace Umbraco.Tests.Routing var request = Mock.Get(settings.RequestHandler); request.Setup(x => x.UseDomainPrefixes).Returns(false); - var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true); globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); // ignored w/domains - SettingsForTests.ConfigureSettings(globalSettings.Object); var umbracoContext = GetUmbracoContext("/test", 1111, umbracoSettings: settings, urlProviders: new[] { @@ -276,10 +274,9 @@ namespace Umbraco.Tests.Routing var request = Mock.Get(settings.RequestHandler); request.Setup(x => x.UseDomainPrefixes).Returns(false); - var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true); globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); // ignored w/domains - SettingsForTests.ConfigureSettings(globalSettings.Object); var umbracoContext = GetUmbracoContext("/test", 1111, umbracoSettings: settings, urlProviders: new[] { @@ -300,10 +297,9 @@ namespace Umbraco.Tests.Routing var request = Mock.Get(settings.RequestHandler); request.Setup(x => x.UseDomainPrefixes).Returns(false); - var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true); globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); // ignored w/domains - SettingsForTests.ConfigureSettings(globalSettings.Object); var umbracoContext = GetUmbracoContext("/test", 1111, umbracoSettings: settings, urlProviders: new[] { @@ -367,10 +363,9 @@ namespace Umbraco.Tests.Routing var requestMock = Mock.Get(settings.RequestHandler); requestMock.Setup(x => x.UseDomainPrefixes).Returns(false); - var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true); globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); // ignored w/domains - SettingsForTests.ConfigureSettings(globalSettings.Object); var umbracoContext = GetUmbracoContext("http://domain1.com/test", 1111, umbracoSettings: settings, urlProviders: new[] { @@ -399,10 +394,9 @@ namespace Umbraco.Tests.Routing { var settings = SettingsForTests.GenerateMockUmbracoSettings(); - var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true); globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); // ignored w/domains - SettingsForTests.ConfigureSettings(globalSettings.Object); var umbracoContext = GetUmbracoContext("http://domain1.com/en/test", 1111, umbracoSettings: settings, urlProviders: new[] { diff --git a/src/Umbraco.Tests/Routing/UrlsWithNestedDomains.cs b/src/Umbraco.Tests/Routing/UrlsWithNestedDomains.cs index 13ec434608..e28a6485d6 100644 --- a/src/Umbraco.Tests/Routing/UrlsWithNestedDomains.cs +++ b/src/Umbraco.Tests/Routing/UrlsWithNestedDomains.cs @@ -3,6 +3,7 @@ using Moq; using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.Composing; +using Umbraco.Core.Configuration; using Umbraco.Core.Models; using Umbraco.Tests.TestHelpers; using Umbraco.Web.PublishedCache.XmlPublishedCache; @@ -29,10 +30,9 @@ namespace Umbraco.Tests.Routing [Test] public void DoNotPolluteCache() { - var globalSettings = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettings.Setup(x => x.UseDirectoryUrls).Returns(true); globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); - SettingsForTests.ConfigureSettings(globalSettings.Object); var settings = SettingsForTests.GenerateMockUmbracoSettings(); var request = Mock.Get(settings.RequestHandler); diff --git a/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs b/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs index ca70ac5b6a..c894659865 100644 --- a/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs +++ b/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs @@ -8,6 +8,7 @@ using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.Components; using Umbraco.Core.Composing; +using Umbraco.Core.Configuration; using Umbraco.Core.Events; using Umbraco.Core.Exceptions; using Umbraco.Core.Logging; @@ -27,12 +28,7 @@ namespace Umbraco.Tests.Runtimes public void SetUp() { TestComponent.Reset(); - - // cannot boot runtime without some configuration - var umbracoSettings = SettingsForTests.GenerateMockUmbracoSettings(); - var globalSettings = SettingsForTests.GenerateMockGlobalSettings(); - SettingsForTests.ConfigureSettings(umbracoSettings); - SettingsForTests.ConfigureSettings(globalSettings); + Current.Reset(); } public void TearDown() @@ -106,6 +102,14 @@ namespace Umbraco.Tests.Runtimes return mock.Object; } + protected override Configs GetConfigs() + { + var configs = new Configs(); + configs.Add(SettingsForTests.GetDefaultGlobalSettings); + configs.Add(SettingsForTests.GetDefaultUmbracoSettings); + return configs; + } + // fixme so how the f* should we do it now? /* // pretend we have the proper migration @@ -191,8 +195,7 @@ namespace Umbraco.Tests.Runtimes { // test flags public static bool Ctored; - public static bool Initialized1; - public static bool Initialized2; + public static bool Initialized; public static bool Terminated; public static IProfilingLogger ProfilingLogger; @@ -200,7 +203,7 @@ namespace Umbraco.Tests.Runtimes public static void Reset() { - Ctored = Initialized1 = Initialized2 = Terminated = false; + Ctored = Initialized = Terminated = false; ProfilingLogger = null; } @@ -210,10 +213,19 @@ namespace Umbraco.Tests.Runtimes ProfilingLogger = proflog; } + public void Initialize() + { + Initialized = true; + } + + public void Terminate() + { + Terminated = true; + } + public void Dispose() { Disposed = true; - Terminated = true; } } } diff --git a/src/Umbraco.Tests/Runtimes/StandaloneTests.cs b/src/Umbraco.Tests/Runtimes/StandaloneTests.cs index c24ca6f351..ccb7427907 100644 --- a/src/Umbraco.Tests/Runtimes/StandaloneTests.cs +++ b/src/Umbraco.Tests/Runtimes/StandaloneTests.cs @@ -107,6 +107,10 @@ namespace Umbraco.Tests.Runtimes .Clear() .Append(); + // configure + composition.Configs.Add(SettingsForTests.GetDefaultGlobalSettings); + composition.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings); + // create and register the factory Current.Factory = factory = composition.CreateFactory(); @@ -150,11 +154,6 @@ namespace Umbraco.Tests.Runtimes // done installing runtimeState.Level = RuntimeLevel.Run; - var globalSettings = SettingsForTests.GetDefaultGlobalSettings(); - SettingsForTests.ConfigureSettings(globalSettings); - var umbracoSettings = SettingsForTests.GetDefaultUmbracoSettings(); - SettingsForTests.ConfigureSettings(umbracoSettings); - // instantiate to register events // should be done by Initialize? // should we invoke Initialize? @@ -260,9 +259,9 @@ namespace Umbraco.Tests.Runtimes // get the components // all of them? var composerTypes = typeLoader.GetTypes(); - // filtered? - //var componentTypes = typeLoader.GetTypes() - // .Where(x => !x.FullName.StartsWith("Umbraco.Web")); + // filtered + composerTypes = composerTypes + .Where(x => !x.FullName.StartsWith("Umbraco.Tests")); // single? //var componentTypes = new[] { typeof(CoreRuntimeComponent) }; var composers = new Composers(composition, composerTypes, profilingLogger); diff --git a/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs b/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs index e74125adfa..4aa28b5975 100644 --- a/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs +++ b/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs @@ -3,7 +3,6 @@ using System.Linq; using Moq; using NUnit.Framework; using Umbraco.Core; -using Umbraco.Core.Cache; using Umbraco.Core.Components; using Umbraco.Core.Events; using Umbraco.Core.Models; @@ -13,7 +12,6 @@ using Umbraco.Core.Scoping; using Umbraco.Tests.TestHelpers; using Umbraco.Tests.TestHelpers.Entities; using Umbraco.Core.Composing; -using Umbraco.Core.Configuration; using Umbraco.Core.Persistence.Mappers; using Umbraco.Core.Services; using Umbraco.Tests.Components; @@ -42,6 +40,9 @@ namespace Umbraco.Tests.Scoping composition.RegisterUnique(factory => new FileSystems(factory, factory.TryGetInstance())); composition.WithCollectionBuilder(); + composition.Configs.Add(SettingsForTests.GetDefaultGlobalSettings); + composition.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings); + Current.Reset(); Current.Factory = composition.CreateFactory(); diff --git a/src/Umbraco.Tests/Scoping/ScopedXmlTests.cs b/src/Umbraco.Tests/Scoping/ScopedXmlTests.cs index 99a5c57058..568bafa4e6 100644 --- a/src/Umbraco.Tests/Scoping/ScopedXmlTests.cs +++ b/src/Umbraco.Tests/Scoping/ScopedXmlTests.cs @@ -5,6 +5,7 @@ using Moq; using NUnit.Framework; using Umbraco.Core.Cache; using Umbraco.Core.Composing; +using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.Events; using Umbraco.Core.Logging; using Umbraco.Core.Models; @@ -39,6 +40,12 @@ namespace Umbraco.Tests.Scoping .Add(() => Composition.TypeLoader.GetCacheRefreshers()); } + protected override void ComposeSettings() + { + Composition.Configs.Add(SettingsForTests.GenerateMockUmbracoSettings); + Composition.Configs.Add(SettingsForTests.GenerateMockGlobalSettings); + } + [TearDown] public void Teardown() { @@ -79,10 +86,8 @@ namespace Umbraco.Tests.Scoping Assert.AreSame(XmlStore, ((PublishedContentCache) umbracoContext.ContentCache).XmlStore); // settings - var settings = SettingsForTests.GenerateMockUmbracoSettings(); - var contentMock = Mock.Get(settings.Content); + var contentMock = Mock.Get(Factory.GetInstance().Content); contentMock.Setup(x => x.XmlCacheEnabled).Returns(false); - SettingsForTests.ConfigureSettings(settings); // create document type, document var contentType = new ContentType(-1) { Alias = "CustomDocument", Name = "Custom Document" }; @@ -200,9 +205,8 @@ namespace Umbraco.Tests.Scoping // settings var settings = SettingsForTests.GenerateMockUmbracoSettings(); - var contentMock = Mock.Get(settings.Content); + var contentMock = Mock.Get(Factory.GetInstance().Content); contentMock.Setup(x => x.XmlCacheEnabled).Returns(false); - SettingsForTests.ConfigureSettings(settings); // create document type var contentType = new ContentType(-1) { Alias = "CustomDocument", Name = "Custom Document" }; diff --git a/src/Umbraco.Tests/Services/ContentServiceTests.cs b/src/Umbraco.Tests/Services/ContentServiceTests.cs index 8fba16662c..0f48a9c99a 100644 --- a/src/Umbraco.Tests/Services/ContentServiceTests.cs +++ b/src/Umbraco.Tests/Services/ContentServiceTests.cs @@ -792,6 +792,54 @@ namespace Umbraco.Tests.Services } + [Test] + public void Pending_Invariant_Property_Changes_Affect_Default_Language_Edited_State() + { + // Arrange + + var langGB = new Language("en-GB") { IsDefault = true }; + var langFr = new Language("fr-FR"); + + ServiceContext.LocalizationService.Save(langFr); + ServiceContext.LocalizationService.Save(langGB); + + var contentType = MockedContentTypes.CreateMetaContentType(); + contentType.Variations = ContentVariation.Culture; + foreach(var prop in contentType.PropertyTypes) + prop.Variations = ContentVariation.Culture; + var keywordsProp = contentType.PropertyTypes.Single(x => x.Alias == "metakeywords"); + keywordsProp.Variations = ContentVariation.Nothing; // this one is invariant + + ServiceContext.ContentTypeService.Save(contentType); + + IContent content = new Content("content", -1, contentType); + content.SetCultureName("content-en", langGB.IsoCode); + content.SetCultureName("content-fr", langFr.IsoCode); + content.PublishCulture(langGB.IsoCode); + content.PublishCulture(langFr.IsoCode); + Assert.IsTrue(ServiceContext.ContentService.SavePublishing(content).Success); + + //re-get + content = ServiceContext.ContentService.GetById(content.Id); + Assert.AreEqual(PublishedState.Published, content.PublishedState); + Assert.IsTrue(content.IsCulturePublished(langGB.IsoCode)); + Assert.IsTrue(content.IsCulturePublished(langFr.IsoCode)); + Assert.IsFalse(content.IsCultureEdited(langGB.IsoCode)); + Assert.IsFalse(content.IsCultureEdited(langFr.IsoCode)); + + //update the invariant property and save a pending version + content.SetValue("metakeywords", "hello"); + ServiceContext.ContentService.Save(content); + + //re-get + content = ServiceContext.ContentService.GetById(content.Id); + Assert.AreEqual(PublishedState.Published, content.PublishedState); + Assert.IsTrue(content.IsCulturePublished(langGB.IsoCode)); + Assert.IsTrue(content.IsCulturePublished(langFr.IsoCode)); + Assert.IsTrue(content.IsCultureEdited(langGB.IsoCode)); + Assert.IsFalse(content.IsCultureEdited(langFr.IsoCode)); + } + [Test] public void Can_Publish_Content_Variation_And_Detect_Changed_Cultures() { diff --git a/src/Umbraco.Tests/Strings/CmsHelperCasingTests.cs b/src/Umbraco.Tests/Strings/CmsHelperCasingTests.cs index 0fb0dee68c..a4006409be 100644 --- a/src/Umbraco.Tests/Strings/CmsHelperCasingTests.cs +++ b/src/Umbraco.Tests/Strings/CmsHelperCasingTests.cs @@ -9,15 +9,6 @@ namespace Umbraco.Tests.Strings [TestFixture] public class CmsHelperCasingTests : UmbracoTestBase { - [SetUp] - public void Setup() - { - //set default config - var config = SettingsForTests.GetDefaultUmbracoSettings(); - SettingsForTests.ConfigureSettings(config); - - } - [TestCase("thisIsTheEnd", "This Is The End")] [TestCase("th", "Th")] [TestCase("t", "t")] diff --git a/src/Umbraco.Tests/Strings/DefaultShortStringHelperTests.cs b/src/Umbraco.Tests/Strings/DefaultShortStringHelperTests.cs index 0ceaffa916..0d39fcc9e5 100644 --- a/src/Umbraco.Tests/Strings/DefaultShortStringHelperTests.cs +++ b/src/Umbraco.Tests/Strings/DefaultShortStringHelperTests.cs @@ -123,7 +123,6 @@ namespace Umbraco.Tests.Strings var contentMock = Mock.Get(settings.RequestHandler); contentMock.Setup(x => x.CharCollection).Returns(Enumerable.Empty()); contentMock.Setup(x => x.ConvertUrlsToAscii).Returns(false); - SettingsForTests.ConfigureSettings(settings); const string input1 = "ÆØÅ and æøå and 中文测试 and אודות האתר and größer БбДдЖж page"; const string input2 = "ÆØÅ and æøå and größer БбДдЖж page"; diff --git a/src/Umbraco.Tests/TestHelpers/SettingsForTests.cs b/src/Umbraco.Tests/TestHelpers/SettingsForTests.cs index 5f08478658..ea40ed9c84 100644 --- a/src/Umbraco.Tests/TestHelpers/SettingsForTests.cs +++ b/src/Umbraco.Tests/TestHelpers/SettingsForTests.cs @@ -1,9 +1,7 @@ -using System.Collections.Generic; -using System.IO; +using System.IO; using System.Configuration; using Moq; using Umbraco.Core; -using Umbraco.Core.Composing; using Umbraco.Core.Configuration; using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.IO; @@ -12,22 +10,6 @@ namespace Umbraco.Tests.TestHelpers { public class SettingsForTests { - public static void ConfigureSettings(IGlobalSettings settings) - { - Current.Config.SetGlobalConfig(settings); - } - - // umbracoSettings - - /// - /// Sets the umbraco settings singleton to the object specified - /// - /// - public static void ConfigureSettings(IUmbracoSettingsSection settings) - { - Current.Config.SetUmbracoConfig(settings); - } - public static IGlobalSettings GenerateMockGlobalSettings() { var config = Mock.Of( @@ -132,8 +114,6 @@ namespace Umbraco.Tests.TestHelpers private static void ResetSettings() { _defaultGlobalSettings = null; - ConfigureSettings(GetDefaultUmbracoSettings()); - ConfigureSettings(GetDefaultGlobalSettings()); } private static IUmbracoSettingsSection _defaultUmbracoSettings; diff --git a/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs b/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs index 2daf86796b..a2a0c35c56 100644 --- a/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs +++ b/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs @@ -131,9 +131,8 @@ namespace Umbraco.Tests.TestHelpers } // ensure the configuration matches the current version for tests - var globalSettingsMock = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container + var globalSettingsMock = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container globalSettingsMock.Setup(x => x.ConfigurationStatus).Returns(UmbracoVersion.Current.ToString(3)); - SettingsForTests.ConfigureSettings(globalSettingsMock.Object); using (ProfilingLogger.TraceDuration("Initialize database.")) { diff --git a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs index 3f5240d04c..a79531af74 100644 --- a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs +++ b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs @@ -287,25 +287,25 @@ namespace Umbraco.Tests.Testing // create the schema } + protected virtual void ComposeSettings() + { + Composition.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings); + Composition.Configs.Add(SettingsForTests.GetDefaultGlobalSettings); + } + protected virtual void ComposeApplication(bool withApplication) { - if (withApplication == false) return; + ComposeSettings(); - var umbracoSettings = SettingsForTests.GetDefaultUmbracoSettings(); - var globalSettings = SettingsForTests.GetDefaultGlobalSettings(); - //apply these globally - SettingsForTests.ConfigureSettings(umbracoSettings); - SettingsForTests.ConfigureSettings(globalSettings); + if (withApplication == false) return; // 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 => umbracoSettings); - Composition.RegisterUnique(factory => globalSettings); - Composition.RegisterUnique(factory => umbracoSettings.Content); - Composition.RegisterUnique(factory => umbracoSettings.Templates); - Composition.RegisterUnique(factory => umbracoSettings.WebRouting); + Composition.RegisterUnique(factory => factory.GetInstance().Content); + Composition.RegisterUnique(factory => factory.GetInstance().Templates); + Composition.RegisterUnique(factory => factory.GetInstance().WebRouting); Composition.RegisterUnique(factory => ExamineManager.Instance); diff --git a/src/Umbraco.Tests/Web/TemplateUtilitiesTests.cs b/src/Umbraco.Tests/Web/TemplateUtilitiesTests.cs index 7b640fae95..047d0b0b8f 100644 --- a/src/Umbraco.Tests/Web/TemplateUtilitiesTests.cs +++ b/src/Umbraco.Tests/Web/TemplateUtilitiesTests.cs @@ -37,17 +37,19 @@ namespace Umbraco.Tests.Web var serviceContext = ServiceContext.CreatePartial(entityService: entityService.Object); // fixme - bad in a unit test - but Udi has a static ctor that wants it?! - var container = new Mock(); - container.Setup(x => x.GetInstance(typeof(TypeLoader))).Returns( + var factory = new Mock(); + factory.Setup(x => x.GetInstance(typeof(TypeLoader))).Returns( new TypeLoader(NullCacheProvider.Instance, LocalTempStorage.Default, new ProfilingLogger(Mock.Of(), Mock.Of()))); - container.Setup(x => x.GetInstance(typeof (ServiceContext))).Returns(serviceContext); - Current.Factory = container.Object; + factory.Setup(x => x.GetInstance(typeof (ServiceContext))).Returns(serviceContext); + + var settings = SettingsForTests.GetDefaultUmbracoSettings(); + factory.Setup(x => x.GetInstance(typeof(IUmbracoSettingsSection))).Returns(settings); + + Current.Factory = factory.Object; Umbraco.Web.Composing.Current.UmbracoContextAccessor = new TestUmbracoContextAccessor(); Udi.ResetUdiTypes(); - - Current.Config.SetUmbracoConfig(SettingsForTests.GetDefaultUmbracoSettings()); } [TearDown] diff --git a/src/Umbraco.Web.UI.Client/package-lock.json b/src/Umbraco.Web.UI.Client/package-lock.json index 8badea2b2b..7c3fe8b4f9 100644 --- a/src/Umbraco.Web.UI.Client/package-lock.json +++ b/src/Umbraco.Web.UI.Client/package-lock.json @@ -5152,14 +5152,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -5174,20 +5172,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -5304,8 +5299,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -5317,7 +5311,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -5332,7 +5325,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -5340,14 +5332,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.2.4", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -5366,7 +5356,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -5447,8 +5436,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -5460,7 +5448,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -5582,7 +5569,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/buttons/umbtoggle.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/buttons/umbtoggle.directive.js index e3c4cbf40c..c2c9ec068b 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/buttons/umbtoggle.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/buttons/umbtoggle.directive.js @@ -18,6 +18,7 @@ @param {boolean} checked Set to true or false to toggle the switch. +@param {boolean} disabled Set to true or false to disable the switch. @param {callback} onClick The function which should be called when the toggle is clicked. @param {string=} showLabels Set to true or false to show a "On" or "Off" label next to the switch. @param {string=} labelOn Set a custom label for when the switched is turned on. It will default to "On". @@ -115,6 +118,7 @@ templateUrl: 'views/components/buttons/umb-toggle.html', scope: { checked: "=", + disabled: "=", onClick: "&", labelOn: "@?", labelOff: "@?", diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js index 8564cf2c43..89c8b541d1 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js @@ -109,7 +109,7 @@ }); } })); - + } /** @@ -308,6 +308,18 @@ } } + function ensureDirtyIsSetIfAnyVariantIsDirty() { + + $scope.contentForm.$dirty = false; + + for (var i = 0; i < $scope.content.variants.length; i++) { + if($scope.content.variants[i].isDirty){ + $scope.contentForm.$dirty = true; + return; + } + } + } + // This is a helper method to reduce the amount of code repitition for actions: Save, Publish, SendToPublish function performSave(args) { @@ -331,6 +343,7 @@ eventsService.emit("content.saved", { content: $scope.content, action: args.action }); resetNestedFieldValiation(fieldsToRollback); + ensureDirtyIsSetIfAnyVariantIsDirty(); return $q.when(data); }, diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/events/events.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/events/events.directive.js index 7578ade867..6e75973ae7 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/events/events.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/events/events.directive.js @@ -136,7 +136,7 @@ angular.module('umbraco.directives') return; } - angularHelper.safeApply(scope, attrs.onOutsideClick); + scope.$apply(attrs.onOutsideClick); } diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/grid/grid.rte.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/grid/grid.rte.directive.js index 0dddada8ad..372fb472fa 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/grid/grid.rte.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/grid/grid.rte.directive.js @@ -55,7 +55,7 @@ angular.module("umbraco.directives") //initialize the standard editor functionality for Umbraco tinyMceService.initializeEditor({ editor: editor, - value: scope.value, + model: scope, currentForm: angularHelper.getCurrentForm(scope) }); @@ -67,7 +67,7 @@ angular.module("umbraco.directives") $timeout(function () { if (scope.value === null) { - editor.trigger("focus"); + editor.focus(); } }, 400); diff --git a/src/Umbraco.Web.UI.Client/src/common/filters/safehtml.filter.js b/src/Umbraco.Web.UI.Client/src/common/filters/safehtml.filter.js new file mode 100644 index 0000000000..50d8574306 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/common/filters/safehtml.filter.js @@ -0,0 +1,6 @@ +angular.module('umbraco.filters') + .filter('safe_html', ['$sce', function($sce){ + return function(text) { + return $sce.trustAsHtml(text); + }; + }]); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/common/services/tinymce.service.js b/src/Umbraco.Web.UI.Client/src/common/services/tinymce.service.js index f6c2e93182..3fc11f8225 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/tinymce.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/tinymce.service.js @@ -1194,7 +1194,7 @@ function tinyMceService($rootScope, $q, imageHelper, $locale, $http, $timeout, s .css("top", "auto") .css("margin-top", "0") .css("width", tinyMceWidth); - } + } }, @@ -1214,15 +1214,15 @@ function tinyMceService($rootScope, $q, imageHelper, $locale, $http, $timeout, s if (!args.editor) { throw "args.editor is required"; } - //if (!args.value) { - // throw "args.value is required"; + //if (!args.model.value) { + // throw "args.model.value is required"; //} var unwatch = null; //Starts a watch on the model value so that we can update TinyMCE if the model changes behind the scenes or from the server function startWatch() { - unwatch = $rootScope.$watch(() => args.value, function (newVal, oldVal) { + unwatch = $rootScope.$watch(() => args.model.value, function (newVal, oldVal) { if (newVal !== oldVal) { //update the display val again if it has changed from the server; //uses an empty string in the editor when the value is null @@ -1247,7 +1247,7 @@ function tinyMceService($rootScope, $q, imageHelper, $locale, $http, $timeout, s //stop watching before we update the value stopWatch(); angularHelper.safeApply($rootScope, function () { - args.value = args.editor.getContent(); + args.model.value = args.editor.getContent(); }); //re-watch the value startWatch(); @@ -1255,8 +1255,8 @@ function tinyMceService($rootScope, $q, imageHelper, $locale, $http, $timeout, s args.editor.on('init', function (e) { - if (args.value) { - args.editor.setContent(args.value); + if (args.model.value) { + args.editor.setContent(args.model.value); } //enable browser based spell checking args.editor.getBody().setAttribute('spellcheck', true); diff --git a/src/Umbraco.Web.UI.Client/src/less/components/buttons/umb-toggle.less b/src/Umbraco.Web.UI.Client/src/less/components/buttons/umb-toggle.less index 150963cbb2..4c30ae583c 100644 --- a/src/Umbraco.Web.UI.Client/src/less/components/buttons/umb-toggle.less +++ b/src/Umbraco.Web.UI.Client/src/less/components/buttons/umb-toggle.less @@ -28,7 +28,8 @@ .umb-toggle__toggle { cursor: pointer; - display: inline-block; + align-items: center; + display: flex; width: 48px; height: 24px; background: @gray-8; @@ -41,6 +42,11 @@ background-color: @green; } +.umb-toggle--disabled .umb-toggle__toggle { + cursor: not-allowed; + opacity: 0.8; +} + .umb-toggle--checked .umb-toggle__handler { transform: translate3d(24px, 0, 0) rotate(0); } @@ -63,7 +69,7 @@ .umb-toggle__icon { position: absolute; - top: 3px; + line-height: 1em; text-decoration: none; transition: all 0.2s ease; } diff --git a/src/Umbraco.Web.UI.Client/src/less/components/umb-editor-navigation.less b/src/Umbraco.Web.UI.Client/src/less/components/umb-editor-navigation.less index 3b49dceeb2..d8b83af67a 100644 --- a/src/Umbraco.Web.UI.Client/src/less/components/umb-editor-navigation.less +++ b/src/Umbraco.Web.UI.Client/src/less/components/umb-editor-navigation.less @@ -19,6 +19,7 @@ align-items: center; justify-content: center; height: @editorHeaderHeight; + position: relative; } .umb-sub-views-nav-item:focus { @@ -46,6 +47,33 @@ margin-bottom: 7px; } +.umb-sub-views-nav-item .badge { + position: absolute; + top: 6px; + right: 6px; + min-width: 16px; + color: @white; + background-color: @turquoise-d1; + border: 2px solid @white; + border-radius: 50%; + font-size: 10px; + font-weight: bold; + padding: 2px; + line-height: 16px; + display: block; + + &.-type-alert { + background-color: @red-l1; + } + &.-type-warning { + background-color: @yellow-d2; + } + &:empty { + height: 12px; + min-width: 12px; + } +} + .umb-sub-views-nav-item-text { font-size: 12px; line-height: 1em; @@ -80,4 +108,4 @@ grid-template-columns: 1fr 1fr 1fr; min-width: auto; margin-top: 10px; -} \ No newline at end of file +} diff --git a/src/Umbraco.Web.UI.Client/src/less/components/users/umb-permission.less b/src/Umbraco.Web.UI.Client/src/less/components/users/umb-permission.less index f5a81e3393..0d74986d65 100644 --- a/src/Umbraco.Web.UI.Client/src/less/components/users/umb-permission.less +++ b/src/Umbraco.Web.UI.Client/src/less/components/users/umb-permission.less @@ -4,10 +4,6 @@ padding: 7px 0; } -.umb-permission--disabled { - opacity: 0.8; -} - .umb-permission:last-of-type { border-bottom: none; } @@ -25,6 +21,12 @@ cursor: pointer; } +.umb-permission--disabled .umb-permission__toggle, +.umb-permission--disabled .umb-permission__content { + cursor: not-allowed; + opacity: 0.8; +} + .umb-permission__description { font-size: 13px; color: @gray-4; diff --git a/src/Umbraco.Web.UI.Client/src/views/components/buttons/umb-toggle.html b/src/Umbraco.Web.UI.Client/src/views/components/buttons/umb-toggle.html index bc5c114bb6..c8039448fd 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/buttons/umb-toggle.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/buttons/umb-toggle.html @@ -1,4 +1,4 @@ - /// This class exists for logging purposes - the one you want to use is BackgroundTaskRunner{T}. public abstract class BackgroundTaskRunner - { } + { + /// + /// Represents a MainDom hook. + /// + public class MainDomHook + { + /// + /// Initializes a new instance of the class. + /// + /// The object. + /// A method to execute when hooking into the main domain. + /// A method to execute when the main domain releases. + public MainDomHook(IMainDom mainDom, Action install, Action release) + { + MainDom = mainDom; + Install = install; + Release = release; + } + + /// + /// Gets the object. + /// + public IMainDom MainDom { get; } + + /// + /// Gets the method to execute when hooking into the main domain. + /// + public Action Install { get; } + + /// + /// Gets the method to execute when the main domain releases. + /// + public Action Release { get; } + + internal bool Register() + { + if (MainDom != null) + return MainDom.Register(Install, Release); + + // tests + Install?.Invoke(); + return true; + } + } + } /// /// Manages a queue of tasks of type and runs them in the background. @@ -55,42 +98,6 @@ namespace Umbraco.Web.Scheduling private bool _terminated; // remember we've terminated private readonly TaskCompletionSource _terminatedSource = new TaskCompletionSource(); // enable awaiting termination - // fixme - this is temp - // at the moment MainDom is internal so we have to find a way to hook into it - temp - public class MainDomHook - { - private MainDomHook(MainDom mainDom, Action install, Action release) - { - MainDom = mainDom; - Install = install; - Release = release; - } - - internal MainDom MainDom { get; } - public Action Install { get; } - public Action Release { get; } - - public static MainDomHook Create(Action install, Action release) - { - return new MainDomHook(Core.Composing.Current.Factory.GetInstance(), install, release); - } - - public static MainDomHook CreateForTest(Action install, Action release) - { - return new MainDomHook(null, install, release); - } - - public bool Register() - { - if (MainDom != null) - return MainDom.Register(Install, Release); - - // tests - Install?.Invoke(); - return true; - } - } - /// /// Initializes a new instance of the class. /// @@ -129,11 +136,9 @@ namespace Umbraco.Web.Scheduling /// An optional main domain hook. public BackgroundTaskRunner(string name, BackgroundTaskRunnerOptions options, ILogger logger, MainDomHook hook = null) { - if (options == null) throw new ArgumentNullException(nameof(options)); - if (logger == null) throw new ArgumentNullException(nameof(logger)); - _options = options; + _options = options ?? throw new ArgumentNullException(nameof(options)); + _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _logPrefix = "[" + name + "] "; - _logger = logger; if (options.Hosted) HostingEnvironment.RegisterObject(this); @@ -319,7 +324,7 @@ namespace Umbraco.Web.Scheduling } /// - /// Shuts the taks runner down. + /// Shuts the tasks runner down. /// /// True for force the runner to stop. /// True to wait until the runner has stopped. @@ -355,7 +360,7 @@ namespace Umbraco.Web.Scheduling // tasks in the queue will be executed... if (wait == false) return; - _runningTask?.Wait(); // wait for whatever is running to end... + _runningTask?.Wait(CancellationToken.None); // wait for whatever is running to end... } private async Task Pump() @@ -648,13 +653,13 @@ namespace Umbraco.Web.Scheduling #endregion /// - /// Requests a registered object to unregister. + /// Requests a registered object to un-register. /// - /// true to indicate the registered object should unregister from the hosting + /// true to indicate the registered object should un-register from the hosting /// environment before returning; otherwise, false. /// /// "When the application manager needs to stop a registered object, it will call the Stop method." - /// The application manager will call the Stop method to ask a registered object to unregister. During + /// The application manager will call the Stop method to ask a registered object to un-register. During /// processing of the Stop method, the registered object must call the HostingEnvironment.UnregisterObject method. /// public void Stop(bool immediate) diff --git a/src/Umbraco.Web/Scheduling/HealthCheckNotifier.cs b/src/Umbraco.Web/Scheduling/HealthCheckNotifier.cs index c803abc966..4f66af11bd 100644 --- a/src/Umbraco.Web/Scheduling/HealthCheckNotifier.cs +++ b/src/Umbraco.Web/Scheduling/HealthCheckNotifier.cs @@ -53,7 +53,7 @@ namespace Umbraco.Web.Scheduling using (_logger.DebugDuration("Health checks executing", "Health checks complete")) { - var healthCheckConfig = Current.Config.HealthChecks(); + var healthCheckConfig = Current.Configs.HealthChecks(); // Don't notify for any checks that are disabled, nor for any disabled // just for notifications diff --git a/src/Umbraco.Web/Scheduling/SchedulerComponent.cs b/src/Umbraco.Web/Scheduling/SchedulerComponent.cs index efd9d60fe8..e4bc74b7f2 100644 --- a/src/Umbraco.Web/Scheduling/SchedulerComponent.cs +++ b/src/Umbraco.Web/Scheduling/SchedulerComponent.cs @@ -4,6 +4,7 @@ using System.Threading; using Umbraco.Core; using Umbraco.Core.Components; using Umbraco.Core.Composing; +using Umbraco.Core.Configuration; using Umbraco.Core.Configuration.HealthChecks; using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.Logging; @@ -24,11 +25,11 @@ namespace Umbraco.Web.Scheduling private readonly HealthCheckCollection _healthChecks; private readonly HealthCheckNotificationMethodCollection _notifications; - private readonly BackgroundTaskRunner _keepAliveRunner; - private readonly BackgroundTaskRunner _publishingRunner; - private readonly BackgroundTaskRunner _tasksRunner; - private readonly BackgroundTaskRunner _scrubberRunner; - private readonly BackgroundTaskRunner _healthCheckRunner; + private BackgroundTaskRunner _keepAliveRunner; + private BackgroundTaskRunner _publishingRunner; + private BackgroundTaskRunner _tasksRunner; + private BackgroundTaskRunner _scrubberRunner; + private BackgroundTaskRunner _healthCheckRunner; private bool _started; private object _locker = new object(); @@ -47,18 +48,26 @@ namespace Umbraco.Web.Scheduling _healthChecks = healthChecks; _notifications = notifications; + } + public void Initialize() + { // backgrounds runners are web aware, if the app domain dies, these tasks will wind down correctly - _keepAliveRunner = new BackgroundTaskRunner("KeepAlive", logger); - _publishingRunner = new BackgroundTaskRunner("ScheduledPublishing", logger); - _tasksRunner = new BackgroundTaskRunner("ScheduledTasks", logger); - _scrubberRunner = new BackgroundTaskRunner("LogScrubber", logger); - _healthCheckRunner = new BackgroundTaskRunner("HealthCheckNotifier", logger); + _keepAliveRunner = new BackgroundTaskRunner("KeepAlive", _logger); + _publishingRunner = new BackgroundTaskRunner("ScheduledPublishing", _logger); + _tasksRunner = new BackgroundTaskRunner("ScheduledTasks", _logger); + _scrubberRunner = new BackgroundTaskRunner("LogScrubber", _logger); + _healthCheckRunner = new BackgroundTaskRunner("HealthCheckNotifier", _logger); // we will start the whole process when a successful request is made UmbracoModule.RouteAttempt += RegisterBackgroundTasksOnce; } + public void Terminate() + { + // the appdomain / maindom / whatever takes care of stopping background task runners + } + private void RegisterBackgroundTasksOnce(object sender, RoutableAttemptEventArgs e) { switch (e.Outcome) @@ -76,7 +85,7 @@ namespace Umbraco.Web.Scheduling LazyInitializer.EnsureInitialized(ref _tasks, ref _started, ref _locker, () => { _logger.Debug("Initializing the scheduler"); - var settings = Current.Config.Umbraco(); + var settings = Current.Configs.Settings(); var tasks = new List(); @@ -85,7 +94,7 @@ namespace Umbraco.Web.Scheduling tasks.Add(RegisterTaskRunner(settings)); tasks.Add(RegisterLogScrubber(settings)); - var healthCheckConfig = Current.Config.HealthChecks(); + var healthCheckConfig = Current.Configs.HealthChecks(); if (healthCheckConfig.NotificationSettings.Enabled) tasks.Add(RegisterHealthCheckNotifier(healthCheckConfig, _healthChecks, _notifications, _logger)); diff --git a/src/Umbraco.Web/Search/ExamineComponent.cs b/src/Umbraco.Web/Search/ExamineComponent.cs index 81543c6dcc..09d0c555da 100644 --- a/src/Umbraco.Web/Search/ExamineComponent.cs +++ b/src/Umbraco.Web/Search/ExamineComponent.cs @@ -26,7 +26,7 @@ namespace Umbraco.Web.Search { private readonly IExamineManager _examineManager; private readonly IContentValueSetBuilder _contentValueSetBuilder; - public IPublishedContentValueSetBuilder _publishedContentValueSetBuilder; + private readonly IPublishedContentValueSetBuilder _publishedContentValueSetBuilder; private readonly IValueSetBuilder _mediaValueSetBuilder; private readonly IValueSetBuilder _memberValueSetBuilder; private static bool _disableExamineIndexing = false; @@ -36,6 +36,10 @@ namespace Umbraco.Web.Search private readonly ServiceContext _services; private static BackgroundTaskRunner _rebuildOnStartupRunner; private static readonly object RebuildLocker = new object(); + private readonly IMainDom _mainDom; + private readonly IProfilingLogger _logger; + private readonly IUmbracoIndexesCreator _indexCreator; + private readonly IndexRebuilder _indexRebuilder; // the default enlist priority is 100 // enlist with a lower priority to ensure that anything "default" runs after us @@ -59,6 +63,14 @@ namespace Umbraco.Web.Search _mediaValueSetBuilder = mediaValueSetBuilder; _memberValueSetBuilder = memberValueSetBuilder; + _mainDom = mainDom; + _logger = profilingLogger; + _indexCreator = indexCreator; + _indexRebuilder = indexRebuilder; + } + + public void Initialize() + { //we want to tell examine to use a different fs lock instead of the default NativeFSFileLock which could cause problems if the appdomain //terminates and in some rare cases would only allow unlocking of the file if IIS is forcefully terminated. Instead we'll rely on the simplefslock //which simply checks the existence of the lock file @@ -69,9 +81,9 @@ namespace Umbraco.Web.Search }; //let's deal with shutting down Examine with MainDom - var examineShutdownRegistered = mainDom.Register(() => + var examineShutdownRegistered = _mainDom.Register(() => { - using (profilingLogger.TraceDuration("Examine shutting down")) + using (_logger.TraceDuration("Examine shutting down")) { _examineManager.Dispose(); } @@ -79,23 +91,23 @@ namespace Umbraco.Web.Search if (!examineShutdownRegistered) { - profilingLogger.Debug("Examine shutdown not registered, this appdomain is not the MainDom, Examine will be disabled"); + _logger.Debug("Examine shutdown not registered, this appdomain is not the MainDom, Examine will be disabled"); //if we could not register the shutdown examine ourselves, it means we are not maindom! in this case all of examine should be disabled! - Suspendable.ExamineEvents.SuspendIndexers(profilingLogger); + Suspendable.ExamineEvents.SuspendIndexers(_logger); _disableExamineIndexing = true; return; //exit, do not continue } //create the indexes and register them with the manager - foreach(var index in indexCreator.Create()) + foreach(var index in _indexCreator.Create()) _examineManager.AddIndex(index); - profilingLogger.Debug("Examine shutdown registered with MainDom"); + _logger.Debug("Examine shutdown registered with MainDom"); - var registeredIndexers = examineManager.Indexes.OfType().Count(x => x.EnableDefaultEventHandler); + var registeredIndexers = _examineManager.Indexes.OfType().Count(x => x.EnableDefaultEventHandler); - profilingLogger.Info("Adding examine event handlers for {RegisteredIndexers} index providers.", registeredIndexers); + _logger.Info("Adding examine event handlers for {RegisteredIndexers} index providers.", registeredIndexers); // don't bind event handlers if we're not suppose to listen if (registeredIndexers == 0) @@ -108,12 +120,15 @@ namespace Umbraco.Web.Search MediaCacheRefresher.CacheUpdated += MediaCacheRefresherUpdated; MemberCacheRefresher.CacheUpdated += MemberCacheRefresherUpdated; - EnsureUnlocked(profilingLogger, examineManager); + EnsureUnlocked(_logger, _examineManager); //TODO: Instead of waiting 5000 ms, we could add an event handler on to fulfilling the first request, then start? - RebuildIndexes(indexRebuilder, profilingLogger, true, 5000); + RebuildIndexes(_indexRebuilder, _logger, true, 5000); } + public void Terminate() + { } + /// /// Called to rebuild empty indexes on startup /// @@ -146,8 +161,6 @@ namespace Umbraco.Web.Search } } - - /// /// Must be called to each index is unlocked before any indexing occurs /// diff --git a/src/Umbraco.Web/Security/AppBuilderExtensions.cs b/src/Umbraco.Web/Security/AppBuilderExtensions.cs index 84636e74cc..22d87bdc14 100644 --- a/src/Umbraco.Web/Security/AppBuilderExtensions.cs +++ b/src/Umbraco.Web/Security/AppBuilderExtensions.cs @@ -211,8 +211,8 @@ namespace Umbraco.Web.Security //This is a custom middleware, we need to return the user's remaining logged in seconds app.Use( cookieAuthOptions, - Current.Config.Global(), - Current.Config.Umbraco().Security, + Current.Configs.Global(), + Current.Configs.Settings().Security, app.CreateLogger()); //This is required so that we can read the auth ticket format outside of this pipeline @@ -316,7 +316,7 @@ namespace Umbraco.Web.Security CookiePath = "/", CookieSecure = globalSettings.UseHttps ? CookieSecureOption.Always : CookieSecureOption.SameAsRequest, CookieHttpOnly = true, - CookieDomain = Current.Config.Umbraco().Security.AuthCookieDomain + CookieDomain = Current.Configs.Settings().Security.AuthCookieDomain }, stage); return app; @@ -362,7 +362,7 @@ namespace Umbraco.Web.Security if (runtimeState.Level != RuntimeLevel.Run) return app; var authOptions = app.CreateUmbracoCookieAuthOptions(umbracoContextAccessor, globalSettings, runtimeState, securitySettings); - app.Use(typeof(PreviewAuthenticationMiddleware), authOptions, Current.Config.Global()); + app.Use(typeof(PreviewAuthenticationMiddleware), authOptions, Current.Configs.Global()); // This middleware must execute at least on PostAuthentication, by default it is on Authorize // The middleware needs to execute after the RoleManagerModule executes which is during PostAuthenticate, diff --git a/src/Umbraco.Web/Security/AuthenticationExtensions.cs b/src/Umbraco.Web/Security/AuthenticationExtensions.cs index b5246051f8..66fbd8e201 100644 --- a/src/Umbraco.Web/Security/AuthenticationExtensions.cs +++ b/src/Umbraco.Web/Security/AuthenticationExtensions.cs @@ -145,7 +145,7 @@ namespace Umbraco.Web.Security public static void UmbracoLogout(this HttpContextBase http) { if (http == null) throw new ArgumentNullException("http"); - Logout(http, Current.Config.Umbraco().Security.AuthCookieName); + Logout(http, Current.Configs.Settings().Security.AuthCookieName); } /// @@ -215,7 +215,7 @@ namespace Umbraco.Web.Security public static AuthenticationTicket GetUmbracoAuthTicket(this HttpContextBase http) { if (http == null) throw new ArgumentNullException(nameof(http)); - return GetAuthTicket(http, Current.Config.Umbraco().Security.AuthCookieName); + return GetAuthTicket(http, Current.Configs.Settings().Security.AuthCookieName); } internal static AuthenticationTicket GetUmbracoAuthTicket(this HttpContext http) @@ -227,7 +227,7 @@ namespace Umbraco.Web.Security public static AuthenticationTicket GetUmbracoAuthTicket(this IOwinContext ctx) { if (ctx == null) throw new ArgumentNullException(nameof(ctx)); - return GetAuthTicket(ctx, Current.Config.Umbraco().Security.AuthCookieName); + return GetAuthTicket(ctx, Current.Configs.Settings().Security.AuthCookieName); } /// diff --git a/src/Umbraco.Web/Security/BackOfficeCookieAuthenticationProvider.cs b/src/Umbraco.Web/Security/BackOfficeCookieAuthenticationProvider.cs index 4c3df092b8..bf22e82bbc 100644 --- a/src/Umbraco.Web/Security/BackOfficeCookieAuthenticationProvider.cs +++ b/src/Umbraco.Web/Security/BackOfficeCookieAuthenticationProvider.cs @@ -67,7 +67,7 @@ namespace Umbraco.Web.Security Expires = DateTime.Now.AddYears(-1), Path = "/" }); - context.Response.Cookies.Append(Current.Config.Umbraco().Security.AuthCookieName, "", new CookieOptions + context.Response.Cookies.Append(Current.Configs.Settings().Security.AuthCookieName, "", new CookieOptions { Expires = DateTime.Now.AddYears(-1), Path = "/" diff --git a/src/Umbraco.Web/Security/ExternalSignInAutoLinkOptions.cs b/src/Umbraco.Web/Security/ExternalSignInAutoLinkOptions.cs index fffa2ed30e..44fbdda6c7 100644 --- a/src/Umbraco.Web/Security/ExternalSignInAutoLinkOptions.cs +++ b/src/Umbraco.Web/Security/ExternalSignInAutoLinkOptions.cs @@ -1,5 +1,6 @@ using System; using Microsoft.AspNet.Identity.Owin; +using Umbraco.Core; using Umbraco.Core.Composing; using Umbraco.Core.Configuration; using Umbraco.Core.Models.Identity; @@ -24,7 +25,7 @@ namespace Umbraco.Web.Security { _defaultUserGroups = defaultUserGroups ?? new[] { "editor" }; _autoLinkExternalAccount = autoLinkExternalAccount; - _defaultCulture = defaultCulture ?? Current.Config.Global().DefaultUILanguage; + _defaultCulture = defaultCulture ?? Current.Configs.Global().DefaultUILanguage; } private readonly string[] _defaultUserGroups; diff --git a/src/Umbraco.Web/Security/Providers/UsersMembershipProvider.cs b/src/Umbraco.Web/Security/Providers/UsersMembershipProvider.cs index c5403f10d7..f5002cdcd3 100644 --- a/src/Umbraco.Web/Security/Providers/UsersMembershipProvider.cs +++ b/src/Umbraco.Web/Security/Providers/UsersMembershipProvider.cs @@ -38,7 +38,7 @@ namespace Umbraco.Web.Security.Providers public override string ProviderName { - get { return Current.Config.Umbraco().Providers.DefaultBackOfficeUserProvider; } + get { return Current.Configs.Settings().Providers.DefaultBackOfficeUserProvider; } } protected override MembershipUser ConvertToMembershipUser(IUser entity) diff --git a/src/Umbraco.Web/SignalR/PreviewHubComponent.cs b/src/Umbraco.Web/SignalR/PreviewHubComponent.cs index 1ca8ad0176..328f5a06ed 100644 --- a/src/Umbraco.Web/SignalR/PreviewHubComponent.cs +++ b/src/Umbraco.Web/SignalR/PreviewHubComponent.cs @@ -1,5 +1,6 @@ using System; using Microsoft.AspNet.SignalR; +using Umbraco.Core.Cache; using Umbraco.Core.Components; using Umbraco.Core.Sync; using Umbraco.Web.Cache; @@ -8,31 +9,39 @@ namespace Umbraco.Web.SignalR { public class PreviewHubComponent : IComponent { + private readonly Lazy> _hubContext; + // using a lazy arg here means that we won't create the hub until necessary // and therefore we won't have too bad an impact on boot time public PreviewHubComponent(Lazy> hubContext) { - // ContentService.Saved is too soon - the content cache is not ready yet - // try using the content cache refresher event, because when it triggers - // the cache has already been notified of the changes - //ContentService.Saved += (sender, args) => - //{ - // var entity = args.SavedEntities.FirstOrDefault(); - // if (entity != null) - // _previewHub.Clients.All.refreshed(entity.Id); - //}; + _hubContext = hubContext; + } - ContentCacheRefresher.CacheUpdated += (sender, args) => + public void Initialize() + { + // ContentService.Saved is too soon - the content cache is not ready yet, + // so use the content cache refresher event, because when it triggers + // the cache has already been notified of the changes + + ContentCacheRefresher.CacheUpdated += HandleCacheUpdated; + } + + public void Terminate() + { + ContentCacheRefresher.CacheUpdated -= HandleCacheUpdated; + } + + private void HandleCacheUpdated(ContentCacheRefresher sender, CacheRefresherEventArgs args) + { + if (args.MessageType != MessageType.RefreshByPayload) return; + var payloads = (ContentCacheRefresher.JsonPayload[])args.MessageObject; + var hubContextInstance = _hubContext.Value; + foreach (var payload in payloads) { - if (args.MessageType != MessageType.RefreshByPayload) return; - var payloads = (ContentCacheRefresher.JsonPayload[])args.MessageObject; - var hubContextInstance = hubContext.Value; - foreach (var payload in payloads) - { - var id = payload.Id; // keep it simple for now, ignore ChangeTypes - hubContextInstance.Clients.All.refreshed(id); - } - }; + var id = payload.Id; // keep it simple for now, ignore ChangeTypes + hubContextInstance.Clients.All.refreshed(id); + } } } } diff --git a/src/Umbraco.Web/Templates/TemplateRenderer.cs b/src/Umbraco.Web/Templates/TemplateRenderer.cs index b0f4c6efc3..7281874dd2 100644 --- a/src/Umbraco.Web/Templates/TemplateRenderer.cs +++ b/src/Umbraco.Web/Templates/TemplateRenderer.cs @@ -86,7 +86,7 @@ namespace Umbraco.Web.Templates //set the doc that was found by id contentRequest.PublishedContent = doc; //set the template, either based on the AltTemplate found or the standard template of the doc - contentRequest.TemplateModel = Current.Config.Umbraco().WebRouting.DisableAlternativeTemplates || AltTemplate.HasValue == false + contentRequest.TemplateModel = Current.Configs.Settings().WebRouting.DisableAlternativeTemplates || AltTemplate.HasValue == false ? FileService.GetTemplate(doc.TemplateId) : FileService.GetTemplate(AltTemplate.Value); diff --git a/src/Umbraco.Web/Templates/TemplateUtilities.cs b/src/Umbraco.Web/Templates/TemplateUtilities.cs index 4b13da15af..6da133413d 100644 --- a/src/Umbraco.Web/Templates/TemplateUtilities.cs +++ b/src/Umbraco.Web/Templates/TemplateUtilities.cs @@ -86,7 +86,7 @@ namespace Umbraco.Web.Templates /// public static string ResolveUrlsFromTextString(string text) { - if (Current.Config.Umbraco().Content.ResolveUrlsFromTextString == false) return text; + if (Current.Configs.Settings().Content.ResolveUrlsFromTextString == false) return text; using (var timer = Current.ProfilingLogger.DebugDuration(typeof(IOHelper), "ResolveUrlsFromTextString starting", "ResolveUrlsFromTextString complete")) { diff --git a/src/Umbraco.Web/Trees/ApplicationTreeController.cs b/src/Umbraco.Web/Trees/ApplicationTreeController.cs index d824f32f4b..0454155772 100644 --- a/src/Umbraco.Web/Trees/ApplicationTreeController.cs +++ b/src/Umbraco.Web/Trees/ApplicationTreeController.cs @@ -9,7 +9,6 @@ using System.Web.Http; using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.Services; -using Umbraco.Web.Composing; using Umbraco.Web.Models.Trees; using Umbraco.Web.Mvc; using Umbraco.Web.WebApi; diff --git a/src/Umbraco.Web/Trees/ApplicationTreeExtensions.cs b/src/Umbraco.Web/Trees/ApplicationTreeExtensions.cs index c688491ebb..2c43cbd5dc 100644 --- a/src/Umbraco.Web/Trees/ApplicationTreeExtensions.cs +++ b/src/Umbraco.Web/Trees/ApplicationTreeExtensions.cs @@ -14,7 +14,6 @@ using Umbraco.Web.Models.Trees; using Umbraco.Web.Mvc; using Umbraco.Web.WebApi; using Umbraco.Core.Composing; -using Umbraco.Core.Services; using Current = Umbraco.Web.Composing.Current; using ApplicationTree = Umbraco.Core.Models.ApplicationTree; diff --git a/src/Umbraco.Web/Trees/ContentBlueprintTreeController.cs b/src/Umbraco.Web/Trees/ContentBlueprintTreeController.cs index 365308a8f2..cce40eb047 100644 --- a/src/Umbraco.Web/Trees/ContentBlueprintTreeController.cs +++ b/src/Umbraco.Web/Trees/ContentBlueprintTreeController.cs @@ -1,14 +1,12 @@ using System.Linq; using System.Net.Http.Formatting; using Umbraco.Core; -using Umbraco.Core.Services; using Umbraco.Core.Models; using Umbraco.Core.Models.Entities; using Umbraco.Web.Actions; using Umbraco.Web.Models.Trees; using Umbraco.Web.Mvc; using Umbraco.Web.WebApi.Filters; - using Constants = Umbraco.Core.Constants; namespace Umbraco.Web.Trees @@ -117,6 +115,5 @@ namespace Umbraco.Web.Trees return menu; } - } } diff --git a/src/Umbraco.Web/Trees/ContentTreeController.cs b/src/Umbraco.Web/Trees/ContentTreeController.cs index 0fa4718766..3da8540fe3 100644 --- a/src/Umbraco.Web/Trees/ContentTreeController.cs +++ b/src/Umbraco.Web/Trees/ContentTreeController.cs @@ -9,11 +9,9 @@ using Umbraco.Core.Models; using Umbraco.Core.Models.Entities; using Umbraco.Core.Services; using Umbraco.Web.Actions; -using Umbraco.Web.Composing; using Umbraco.Web.Models.Trees; using Umbraco.Web.Mvc; using Umbraco.Web.WebApi.Filters; - using Umbraco.Web.Models.ContentEditing; using Umbraco.Web.Search; using Constants = Umbraco.Core.Constants; @@ -143,8 +141,6 @@ namespace Umbraco.Web.Trees } // add default actions for *all* users - // fixme - temp disable RePublish as the page itself (republish.aspx) has been temp disabled - //menu.Items.Add(Services.TextService.Localize("actions", ActionRePublish.Instance.Alias)).ConvertLegacyMenuItem(null, "content", "content"); menu.Items.Add(new RefreshNode(Services.TextService, true)); return menu; diff --git a/src/Umbraco.Web/Trees/ContentTreeControllerBase.cs b/src/Umbraco.Web/Trees/ContentTreeControllerBase.cs index e98f723501..ae62f800e9 100644 --- a/src/Umbraco.Web/Trees/ContentTreeControllerBase.cs +++ b/src/Umbraco.Web/Trees/ContentTreeControllerBase.cs @@ -14,7 +14,6 @@ using Umbraco.Web.Models.Trees; using Umbraco.Web.WebApi.Filters; using System.Globalization; using Umbraco.Core.Models.Entities; -using Umbraco.Core.Services; using Umbraco.Web.Actions; using Umbraco.Web.Composing; diff --git a/src/Umbraco.Web/Trees/ContentTypeTreeController.cs b/src/Umbraco.Web/Trees/ContentTypeTreeController.cs index 1e0bd8b619..a4c820ae25 100644 --- a/src/Umbraco.Web/Trees/ContentTypeTreeController.cs +++ b/src/Umbraco.Web/Trees/ContentTypeTreeController.cs @@ -5,12 +5,9 @@ using System.Linq; using System.Net.Http.Formatting; using Umbraco.Core; using Umbraco.Core.Composing; -using Umbraco.Core.Configuration; using Umbraco.Core.Models; using Umbraco.Core.Models.Entities; -using Umbraco.Core.Services; using Umbraco.Web.Actions; - using Umbraco.Web.Models.ContentEditing; using Umbraco.Web.Models.Trees; using Umbraco.Web.WebApi.Filters; @@ -75,7 +72,7 @@ namespace Umbraco.Web.Trees { var menu = new MenuItemCollection(); - var enableInheritedDocumentTypes = Current.Config.Umbraco().Content.EnableInheritedDocumentTypes; + var enableInheritedDocumentTypes = Current.Configs.Settings().Content.EnableInheritedDocumentTypes; if (id == Constants.System.Root.ToInvariantString()) { diff --git a/src/Umbraco.Web/Trees/DataTypeTreeController.cs b/src/Umbraco.Web/Trees/DataTypeTreeController.cs index b8e77f981d..8b38bee865 100644 --- a/src/Umbraco.Web/Trees/DataTypeTreeController.cs +++ b/src/Umbraco.Web/Trees/DataTypeTreeController.cs @@ -12,8 +12,6 @@ using Umbraco.Web.WebApi.Filters; using Umbraco.Core.Services; using Umbraco.Web.Actions; using Umbraco.Web.Models.ContentEditing; -using Umbraco.Web.Search; - using Constants = Umbraco.Core.Constants; namespace Umbraco.Web.Trees @@ -91,7 +89,6 @@ namespace Umbraco.Web.Trees Constants.DataTypes.DefaultContentListView, Constants.DataTypes.DefaultMediaListView, Constants.DataTypes.DefaultMembersListView - }; } diff --git a/src/Umbraco.Web/Trees/DictionaryTreeController.cs b/src/Umbraco.Web/Trees/DictionaryTreeController.cs index cac2e7f435..49bed23ed9 100644 --- a/src/Umbraco.Web/Trees/DictionaryTreeController.cs +++ b/src/Umbraco.Web/Trees/DictionaryTreeController.cs @@ -3,9 +3,7 @@ using System.Linq; using System.Net.Http.Formatting; using Umbraco.Core; using Umbraco.Core.Models; -using Umbraco.Core.Services; using Umbraco.Web.Actions; - using Umbraco.Web.Models.Trees; using Umbraco.Web.WebApi.Filters; diff --git a/src/Umbraco.Web/Trees/FileSystemTreeController.cs b/src/Umbraco.Web/Trees/FileSystemTreeController.cs index 9babb656fe..9b7d078e13 100644 --- a/src/Umbraco.Web/Trees/FileSystemTreeController.cs +++ b/src/Umbraco.Web/Trees/FileSystemTreeController.cs @@ -1,12 +1,10 @@ using System; -using System.Collections.Generic; using System.IO; using System.Linq; using System.Net.Http.Formatting; using System.Web; using Umbraco.Core; using Umbraco.Core.IO; -using Umbraco.Core.Services; using Umbraco.Web.Actions; using Umbraco.Web.Models.Trees; diff --git a/src/Umbraco.Web/Trees/LegacyTreeDataConverter.cs b/src/Umbraco.Web/Trees/LegacyTreeDataConverter.cs index 2bba17a729..f271d276c6 100644 --- a/src/Umbraco.Web/Trees/LegacyTreeDataConverter.cs +++ b/src/Umbraco.Web/Trees/LegacyTreeDataConverter.cs @@ -1,15 +1,9 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Http.Formatting; -using System.Web.Http.Routing; using Umbraco.Core; -using Umbraco.Core.Configuration; using Umbraco.Core.Services; using Umbraco.Web.Actions; using Umbraco.Web.Composing; -using Umbraco.Web.Models.Trees; namespace Umbraco.Web.Trees { @@ -31,7 +25,7 @@ namespace Umbraco.Web.Trees { case ActionDelete actionDelete: return Attempt.Succeed( - Current.Config.Global().Path.EnsureEndsWith('/') + "views/common/dialogs/legacydelete.html"); + Current.Configs.Global().Path.EnsureEndsWith('/') + "views/common/dialogs/legacydelete.html"); } return Attempt.Fail(); @@ -78,6 +72,5 @@ namespace Umbraco.Web.Trees public ActionUrlMethod ActionMethod { get; private set; } public string DialogTitle { get; private set; } } - } } diff --git a/src/Umbraco.Web/Trees/MacrosTreeController.cs b/src/Umbraco.Web/Trees/MacrosTreeController.cs index 3f925eef8d..5576c09704 100644 --- a/src/Umbraco.Web/Trees/MacrosTreeController.cs +++ b/src/Umbraco.Web/Trees/MacrosTreeController.cs @@ -2,14 +2,11 @@ using System.Linq; using System.Net.Http.Formatting; using Umbraco.Core; -using Umbraco.Core.Models; using Umbraco.Core.Models.Entities; using Umbraco.Web.Models.Trees; using Umbraco.Web.Mvc; using Umbraco.Web.WebApi.Filters; -using Umbraco.Core.Services; using Umbraco.Web.Actions; - using Constants = Umbraco.Core.Constants; namespace Umbraco.Web.Trees @@ -70,7 +67,6 @@ namespace Umbraco.Web.Trees return menu; } - var macro = Services.MacroService.GetById(int.Parse(id)); if (macro == null) return new MenuItemCollection(); diff --git a/src/Umbraco.Web/Trees/MediaTreeController.cs b/src/Umbraco.Web/Trees/MediaTreeController.cs index d88b2b9402..5797dd930d 100644 --- a/src/Umbraco.Web/Trees/MediaTreeController.cs +++ b/src/Umbraco.Web/Trees/MediaTreeController.cs @@ -9,11 +9,9 @@ using Umbraco.Core.Models; using Umbraco.Core.Models.Entities; using Umbraco.Core.Services; using Umbraco.Web.Actions; -using Umbraco.Web.Composing; using Umbraco.Web.Models.Trees; using Umbraco.Web.Mvc; using Umbraco.Web.WebApi.Filters; - using Umbraco.Web.Models.ContentEditing; using Umbraco.Web.Search; using Constants = Umbraco.Core.Constants; diff --git a/src/Umbraco.Web/Trees/MediaTypeTreeController.cs b/src/Umbraco.Web/Trees/MediaTypeTreeController.cs index ff87819fa2..b93c1ac9e3 100644 --- a/src/Umbraco.Web/Trees/MediaTypeTreeController.cs +++ b/src/Umbraco.Web/Trees/MediaTypeTreeController.cs @@ -5,18 +5,14 @@ using System.Net.Http.Formatting; using AutoMapper; using Umbraco.Core; using Umbraco.Core.Composing; -using Umbraco.Core.Configuration; using Umbraco.Core.Models; using Umbraco.Core.Models.Entities; -using Umbraco.Core.Persistence.Querying; using Umbraco.Web.Models.Trees; using Umbraco.Web.WebApi.Filters; using Umbraco.Core.Services; using Umbraco.Web.Actions; using Umbraco.Web.Models.ContentEditing; -using Umbraco.Web.Search; - namespace Umbraco.Web.Trees { [UmbracoTreeAuthorize(Constants.Trees.MediaTypes)] @@ -69,7 +65,7 @@ namespace Umbraco.Web.Trees { var menu = new MenuItemCollection(); - var enableInheritedMediaTypes = Current.Config.Umbraco().Content.EnableInheritedMediaTypes; + var enableInheritedMediaTypes = Current.Configs.Settings().Content.EnableInheritedMediaTypes; if (id == Constants.System.Root.ToInvariantString()) { diff --git a/src/Umbraco.Web/Trees/MemberTreeController.cs b/src/Umbraco.Web/Trees/MemberTreeController.cs index 39568e2efa..d1219da466 100644 --- a/src/Umbraco.Web/Trees/MemberTreeController.cs +++ b/src/Umbraco.Web/Trees/MemberTreeController.cs @@ -14,7 +14,6 @@ using Umbraco.Web.Actions; using Umbraco.Web.Models.Trees; using Umbraco.Web.Mvc; using Umbraco.Web.WebApi.Filters; - using Umbraco.Web.Models.ContentEditing; using Umbraco.Web.Search; using Constants = Umbraco.Core.Constants; @@ -116,8 +115,6 @@ namespace Umbraco.Web.Trees return node; } - - } protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings) @@ -188,7 +185,6 @@ namespace Umbraco.Web.Trees menu.Items.Add(new ExportMember(Services.TextService)); } - return menu; } diff --git a/src/Umbraco.Web/Trees/MemberTypeAndGroupTreeControllerBase.cs b/src/Umbraco.Web/Trees/MemberTypeAndGroupTreeControllerBase.cs index 9ea5908891..d3f9ee77c9 100644 --- a/src/Umbraco.Web/Trees/MemberTypeAndGroupTreeControllerBase.cs +++ b/src/Umbraco.Web/Trees/MemberTypeAndGroupTreeControllerBase.cs @@ -1,9 +1,7 @@ using System.Collections.Generic; using System.Net.Http.Formatting; using Umbraco.Core; -using Umbraco.Core.Services; using Umbraco.Web.Actions; - using Umbraco.Web.Models.Trees; namespace Umbraco.Web.Trees diff --git a/src/Umbraco.Web/Trees/PackagesTreeController.cs b/src/Umbraco.Web/Trees/PackagesTreeController.cs index 8158b47985..c56ed716a1 100644 --- a/src/Umbraco.Web/Trees/PackagesTreeController.cs +++ b/src/Umbraco.Web/Trees/PackagesTreeController.cs @@ -1,15 +1,12 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Net.Http.Formatting; using Umbraco.Web.Models.Trees; using Umbraco.Web.Mvc; using Umbraco.Web.WebApi.Filters; -using umbraco; -using umbraco.cms.businesslogic.packager; using Umbraco.Core.Services; using Umbraco.Web.Actions; - +using Umbraco.Web._Legacy.Packager.PackageInstance; using Constants = Umbraco.Core.Constants; namespace Umbraco.Web.Trees @@ -27,13 +24,11 @@ namespace Umbraco.Web.Trees protected override TreeNode CreateRootNode(FormDataCollection queryStrings) { var root = base.CreateRootNode(queryStrings); - root.RoutePath = $"{Constants.Applications.Packages}/{Constants.Trees.Packages}/overview"; - root.Icon = "icon-box"; - return root; } + protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings) { var nodes = new TreeNodeCollection(); @@ -47,7 +42,8 @@ namespace Umbraco.Web.Trees .OrderBy(entity => entity.Data.Name) .Select(dt => { - var node = CreateTreeNode(dt.Data.Id.ToString(), id, queryStrings, dt.Data.Name, "icon-inbox", false, + var node = CreateTreeNode(dt.Data.Id.ToString(), id, queryStrings, dt.Data.Name, + "icon-inbox", false, $"/{queryStrings.GetValue("application")}/framed/{Uri.EscapeDataString("developer/Packages/EditPackage.aspx?id=" + dt.Data.Id)}"); return node; })); @@ -64,16 +60,12 @@ namespace Umbraco.Web.Trees createdPackages.Count > 0, string.Empty); - - //TODO: This isn't the best way to ensure a noop process for clicking a node but it works for now. node.AdditionalData["jsClickCallback"] = "javascript:void(0);"; nodes.Add(node); } - - return nodes; } @@ -85,12 +77,14 @@ namespace Umbraco.Web.Trees if (id == "-1") { menu.Items.Add(Services.TextService, opensDialog: true) - .ConvertLegacyMenuItem(null, Constants.Trees.Packages, queryStrings.GetValue("application")); + .ConvertLegacyMenuItem(null, Constants.Trees.Packages, + queryStrings.GetValue("application")); } else if (id == "created") { menu.Items.Add(Services.TextService, opensDialog: true) - .ConvertLegacyMenuItem(null, Constants.Trees.Packages, queryStrings.GetValue("application")); + .ConvertLegacyMenuItem(null, Constants.Trees.Packages, + queryStrings.GetValue("application")); menu.Items.Add(new RefreshNode(Services.TextService, true)); } diff --git a/src/Umbraco.Web/Trees/PartialViewsTreeController.cs b/src/Umbraco.Web/Trees/PartialViewsTreeController.cs index 6a65f5dd3e..a7aa8f134e 100644 --- a/src/Umbraco.Web/Trees/PartialViewsTreeController.cs +++ b/src/Umbraco.Web/Trees/PartialViewsTreeController.cs @@ -1,5 +1,4 @@ -using umbraco; -using Umbraco.Core.IO; +using Umbraco.Core.IO; using Umbraco.Web.Composing; using Umbraco.Web.Models.Trees; using Umbraco.Web.Mvc; diff --git a/src/Umbraco.Web/Trees/RelationTypeTreeController.cs b/src/Umbraco.Web/Trees/RelationTypeTreeController.cs index 1ce319b6ac..1888044d8d 100644 --- a/src/Umbraco.Web/Trees/RelationTypeTreeController.cs +++ b/src/Umbraco.Web/Trees/RelationTypeTreeController.cs @@ -44,9 +44,10 @@ namespace Umbraco.Web.Trees if (id == Constants.System.Root.ToInvariantString()) { nodes.AddRange(Services.RelationService.GetAllRelationTypes() - .Select(rt => CreateTreeNode(rt.Id.ToString(), id, queryStrings, rt.Name, - "icon-trafic", false))); + .Select(rt => CreateTreeNode(rt.Id.ToString(), id, queryStrings, rt.Name, + "icon-trafic", false))); } + return nodes; } } diff --git a/src/Umbraco.Web/Trees/ScriptsTreeController.cs b/src/Umbraco.Web/Trees/ScriptsTreeController.cs index 08a03ac912..cd56cc4790 100644 --- a/src/Umbraco.Web/Trees/ScriptsTreeController.cs +++ b/src/Umbraco.Web/Trees/ScriptsTreeController.cs @@ -1,5 +1,4 @@ -using System; -using Umbraco.Core; +using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Web.Composing; using Umbraco.Web.Models.Trees; diff --git a/src/Umbraco.Web/Trees/TemplatesTreeController.cs b/src/Umbraco.Web/Trees/TemplatesTreeController.cs index fce51e2435..d9493063e2 100644 --- a/src/Umbraco.Web/Trees/TemplatesTreeController.cs +++ b/src/Umbraco.Web/Trees/TemplatesTreeController.cs @@ -5,16 +5,13 @@ using System.Linq; using System.Net.Http.Formatting; using AutoMapper; using Umbraco.Core; -using Umbraco.Core.Services; using Umbraco.Core.Models; using Umbraco.Core.Models.Entities; using Umbraco.Web.Actions; using Umbraco.Web.Models.ContentEditing; using Umbraco.Web.Models.Trees; using Umbraco.Web.Mvc; -using Umbraco.Web.Search; using Umbraco.Web.WebApi.Filters; - using Constants = Umbraco.Core.Constants; namespace Umbraco.Web.Trees diff --git a/src/Umbraco.Web/Trees/TreeAttribute.cs b/src/Umbraco.Web/Trees/TreeAttribute.cs index b214698721..1cf23c549f 100644 --- a/src/Umbraco.Web/Trees/TreeAttribute.cs +++ b/src/Umbraco.Web/Trees/TreeAttribute.cs @@ -48,8 +48,6 @@ namespace Umbraco.Web.Trees IsSingleNodeTree = isSingleNodeTree; } - - public string ApplicationAlias { get; private set; } public string Alias { get; private set; } public string Title { get; private set; } diff --git a/src/Umbraco.Web/Trees/TreeController.cs b/src/Umbraco.Web/Trees/TreeController.cs index b5708ff57d..1c37307db5 100644 --- a/src/Umbraco.Web/Trees/TreeController.cs +++ b/src/Umbraco.Web/Trees/TreeController.cs @@ -1,8 +1,4 @@ -using System; -using System.Linq; -using Umbraco.Core.Services; - -namespace Umbraco.Web.Trees +namespace Umbraco.Web.Trees { /// /// The base controller for all tree requests @@ -22,8 +18,8 @@ namespace Umbraco.Web.Trees /// public override string RootNodeDisplayName => _rootNodeDisplayName - ?? (_rootNodeDisplayName = Services.ApplicationTreeService.GetByAlias(_attribute.Alias) - ?.GetRootNodeDisplayName(Services.TextService)); + ?? (_rootNodeDisplayName = Services.ApplicationTreeService.GetByAlias(_attribute.Alias) + ?.GetRootNodeDisplayName(Services.TextService)); /// /// Gets the current tree alias from the attribute assigned to it. diff --git a/src/Umbraco.Web/Trees/TreeControllerBase.cs b/src/Umbraco.Web/Trees/TreeControllerBase.cs index ebf2f74e07..ffdcac4479 100644 --- a/src/Umbraco.Web/Trees/TreeControllerBase.cs +++ b/src/Umbraco.Web/Trees/TreeControllerBase.cs @@ -10,7 +10,6 @@ using Umbraco.Core.Models.Entities; using Umbraco.Web.Models.Trees; using Umbraco.Web.WebApi; using Umbraco.Web.WebApi.Filters; -using Umbraco.Web.Search; namespace Umbraco.Web.Trees { diff --git a/src/Umbraco.Web/Trees/UserPermissionsTreeController.cs b/src/Umbraco.Web/Trees/UserPermissionsTreeController.cs index 479cc20083..5473fee7bb 100644 --- a/src/Umbraco.Web/Trees/UserPermissionsTreeController.cs +++ b/src/Umbraco.Web/Trees/UserPermissionsTreeController.cs @@ -2,8 +2,6 @@ using System.Linq; using System.Net.Http.Formatting; using Umbraco.Core; -using Umbraco.Core.Services; -using Umbraco.Web.Actions; using Umbraco.Web.Models.Trees; using Umbraco.Web.Mvc; using Umbraco.Web.WebApi.Filters; diff --git a/src/Umbraco.Web/Trees/UserTreeController.cs b/src/Umbraco.Web/Trees/UserTreeController.cs index f029a929de..95f041cac5 100644 --- a/src/Umbraco.Web/Trees/UserTreeController.cs +++ b/src/Umbraco.Web/Trees/UserTreeController.cs @@ -1,10 +1,7 @@ using System.Net.Http.Formatting; -using Umbraco.Core; -using Umbraco.Core.Services; using Umbraco.Web.Models.Trees; using Umbraco.Web.Mvc; using Umbraco.Web.WebApi.Filters; - using Constants = Umbraco.Core.Constants; namespace Umbraco.Web.Trees diff --git a/src/Umbraco.Web/UI/Pages/BasePage.cs b/src/Umbraco.Web/UI/Pages/BasePage.cs index 089f98d874..a8fbc92722 100644 --- a/src/Umbraco.Web/UI/Pages/BasePage.cs +++ b/src/Umbraco.Web/UI/Pages/BasePage.cs @@ -6,6 +6,7 @@ using Umbraco.Core.Logging; using Umbraco.Core.Services; using Umbraco.Web.Security; using System.Web.UI; +using Umbraco.Core; using Umbraco.Web.Composing; namespace Umbraco.Web.UI.Pages @@ -72,7 +73,7 @@ namespace Umbraco.Web.UI.Pages { base.OnLoad(e); - if (Request.IsSecureConnection || Current.Config.Global().UseHttps == false) return; + if (Request.IsSecureConnection || Current.Configs.Global().UseHttps == false) return; var serverName = HttpUtility.UrlEncode(Request.ServerVariables["SERVER_NAME"]); Response.Redirect($"https://{serverName}{Request.FilePath}"); diff --git a/src/Umbraco.Web/UI/Pages/UmbracoEnsuredPage.cs b/src/Umbraco.Web/UI/Pages/UmbracoEnsuredPage.cs index 27b92488db..bb9ce3c421 100644 --- a/src/Umbraco.Web/UI/Pages/UmbracoEnsuredPage.cs +++ b/src/Umbraco.Web/UI/Pages/UmbracoEnsuredPage.cs @@ -90,7 +90,7 @@ namespace Umbraco.Web.UI.Pages //If this is not a back office request, then the module won't have authenticated it, in this case we // need to do the auth manually and since this is an UmbracoEnsuredPage, this is the anticipated behavior // TODO: When we implement Identity, this process might not work anymore, will be an interesting challenge - if (Context.Request.Url.IsBackOfficeRequest(HttpRuntime.AppDomainAppVirtualPath, Current.Config.Global()) == false) + if (Context.Request.Url.IsBackOfficeRequest(HttpRuntime.AppDomainAppVirtualPath, Current.Configs.Global()) == false) { var http = new HttpContextWrapper(Context); var ticket = http.GetUmbracoAuthTicket(); diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 7a695ff4ef..fa1b620152 100755 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -1124,27 +1124,16 @@ - - - - - - - - - - - @@ -1183,9 +1172,6 @@ ASPXCodeBehind - - ASPXCodeBehind - ASPXCodeBehind @@ -1242,7 +1228,6 @@ Code - @@ -1252,26 +1237,6 @@ FeedProxy.aspx - - insertMasterpageContent.aspx - ASPXCodeBehind - - - insertMasterpageContent.aspx - - - insertMasterpagePlaceholder.aspx - ASPXCodeBehind - - - insertMasterpagePlaceholder.aspx - - - republish.aspx - - - republish.aspx - editPackage.aspx ASPXCodeBehind @@ -1324,15 +1289,6 @@ - - ASPXCodeBehind - - - ASPXCodeBehind - - - ASPXCodeBehind - ASPXCodeBehind diff --git a/src/Umbraco.Web/UmbracoContext.cs b/src/Umbraco.Web/UmbracoContext.cs index 01d862729b..a4de900e7c 100644 --- a/src/Umbraco.Web/UmbracoContext.cs +++ b/src/Umbraco.Web/UmbracoContext.cs @@ -111,10 +111,10 @@ namespace Umbraco.Web Composing.Current.UmbracoContextAccessor, httpContext, Composing.Current.PublishedSnapshotService, - new WebSecurity(httpContext, Composing.Current.Services.UserService, Composing.Current.Config.Global()), - Composing.Current.Config.Umbraco(), + new WebSecurity(httpContext, Composing.Current.Services.UserService, Composing.Current.Configs.Global()), + Composing.Current.Configs.Settings(), Composing.Current.UrlProviders, - Composing.Current.Config.Global(), + Composing.Current.Configs.Global(), Composing.Current.Factory.GetInstance(), true); diff --git a/src/Umbraco.Web/UmbracoDefaultOwinStartup.cs b/src/Umbraco.Web/UmbracoDefaultOwinStartup.cs index de6192acb3..2651167a6b 100644 --- a/src/Umbraco.Web/UmbracoDefaultOwinStartup.cs +++ b/src/Umbraco.Web/UmbracoDefaultOwinStartup.cs @@ -24,8 +24,8 @@ namespace Umbraco.Web public class UmbracoDefaultOwinStartup { protected IUmbracoContextAccessor UmbracoContextAccessor => Current.UmbracoContextAccessor; - protected IGlobalSettings GlobalSettings => Current.Config.Global(); - protected IUmbracoSettingsSection UmbracoSettings => Current.Config.Umbraco(); + protected IGlobalSettings GlobalSettings => Current.Configs.Global(); + protected IUmbracoSettingsSection UmbracoSettings => Current.Configs.Settings(); protected IRuntimeState RuntimeState => Core.Composing.Current.RuntimeState; protected ServiceContext Services => Current.Services; diff --git a/src/Umbraco.Web/UmbracoInjectedModule.cs b/src/Umbraco.Web/UmbracoInjectedModule.cs index de05671fa1..eb6fc54fbb 100644 --- a/src/Umbraco.Web/UmbracoInjectedModule.cs +++ b/src/Umbraco.Web/UmbracoInjectedModule.cs @@ -99,7 +99,7 @@ namespace Umbraco.Web httpContext, _publishedSnapshotService, new WebSecurity(httpContext, _userService, _globalSettings), - Current.Config.Umbraco(), + Current.Configs.Settings(), _urlProviders, _globalSettings, _variationContextAccessor, @@ -270,7 +270,7 @@ namespace Umbraco.Web ReportRuntime(level, "Umbraco is booting."); // let requests pile up and wait for 10s then show the splash anyway - if (Current.Config.Umbraco().Content.EnableSplashWhileLoading == false + if (Current.Configs.Settings().Content.EnableSplashWhileLoading == false && ((RuntimeState) _runtime).WaitForRunLevel(TimeSpan.FromSeconds(10))) return true; // redirect to booting page diff --git a/src/Umbraco.Web/UmbracoModule.cs b/src/Umbraco.Web/UmbracoModule.cs index e2cbcd260e..332c955506 100644 --- a/src/Umbraco.Web/UmbracoModule.cs +++ b/src/Umbraco.Web/UmbracoModule.cs @@ -1,5 +1,6 @@ using System; using System.Web; +using Umbraco.Core; using Umbraco.Core.Collections; using Umbraco.Core.Configuration; using Umbraco.Core.Logging; @@ -77,7 +78,7 @@ namespace Umbraco.Web else if (pcr.Is404) { response.StatusCode = 404; - response.TrySkipIisCustomErrors = Current.Config.Umbraco().WebRouting.TrySkipIisCustomErrors; + response.TrySkipIisCustomErrors = Current.Configs.Settings().WebRouting.TrySkipIisCustomErrors; if (response.TrySkipIisCustomErrors == false) logger.Warn("Status code is 404 yet TrySkipIisCustomErrors is false - IIS will take over."); diff --git a/src/Umbraco.Web/UmbracoWebService.cs b/src/Umbraco.Web/UmbracoWebService.cs index 852e0df470..b970a0e8c2 100644 --- a/src/Umbraco.Web/UmbracoWebService.cs +++ b/src/Umbraco.Web/UmbracoWebService.cs @@ -29,7 +29,7 @@ namespace Umbraco.Web Logger = Current.Logger; ProfilingLogger = Current.ProfilingLogger; Services = Current.Services; - GlobalSettings = Current.Config.Global(); + GlobalSettings = Current.Configs.Global(); } /// diff --git a/src/Umbraco.Web/WebApi/Filters/CheckIfUserTicketDataIsStaleAttribute.cs b/src/Umbraco.Web/WebApi/Filters/CheckIfUserTicketDataIsStaleAttribute.cs index a1158126ea..84481868e4 100644 --- a/src/Umbraco.Web/WebApi/Filters/CheckIfUserTicketDataIsStaleAttribute.cs +++ b/src/Umbraco.Web/WebApi/Filters/CheckIfUserTicketDataIsStaleAttribute.cs @@ -76,7 +76,7 @@ namespace Umbraco.Web.WebApi.Filters () => user.Username != identity.Username, () => { - var culture = UserExtensions.GetUserCulture(user, Current.Services.TextService, Current.Config.Global()); + var culture = UserExtensions.GetUserCulture(user, Current.Services.TextService, Current.Configs.Global()); return culture != null && culture.ToString() != identity.Culture; }, () => user.AllowedSections.UnsortedSequenceEqual(identity.AllowedApplications) == false, diff --git a/src/Umbraco.Web/WebApi/Filters/SetAngularAntiForgeryTokensAttribute.cs b/src/Umbraco.Web/WebApi/Filters/SetAngularAntiForgeryTokensAttribute.cs index c75e223e1b..b8cad1f26e 100644 --- a/src/Umbraco.Web/WebApi/Filters/SetAngularAntiForgeryTokensAttribute.cs +++ b/src/Umbraco.Web/WebApi/Filters/SetAngularAntiForgeryTokensAttribute.cs @@ -4,6 +4,7 @@ using System.Net.Http; using System.Net.Http.Headers; using System.Web.Helpers; using System.Web.Http.Filters; +using Umbraco.Core; using Umbraco.Core.Composing; using Umbraco.Core.Configuration; @@ -44,14 +45,14 @@ namespace Umbraco.Web.WebApi.Filters Path = "/", //must be js readable HttpOnly = false, - Secure = Current.Config.Global().UseHttps + Secure = Current.Configs.Global().UseHttps }; var validationCookie = new CookieHeaderValue(AngularAntiForgeryHelper.CsrfValidationCookieName, cookieToken) { Path = "/", HttpOnly = true, - Secure = Current.Config.Global().UseHttps + Secure = Current.Configs.Global().UseHttps }; context.Response.Headers.AddCookies(new[] { angularCookie, validationCookie }); diff --git a/src/Umbraco.Web/WebApi/Filters/UmbracoWebApiRequireHttpsAttribute.cs b/src/Umbraco.Web/WebApi/Filters/UmbracoWebApiRequireHttpsAttribute.cs index e1278b0b9f..50d997f40d 100644 --- a/src/Umbraco.Web/WebApi/Filters/UmbracoWebApiRequireHttpsAttribute.cs +++ b/src/Umbraco.Web/WebApi/Filters/UmbracoWebApiRequireHttpsAttribute.cs @@ -4,6 +4,7 @@ using System.Net.Http; using System.Text; using System.Web.Http.Controllers; using System.Web.Http.Filters; +using Umbraco.Core; using Umbraco.Core.Composing; using Umbraco.Core.Configuration; @@ -24,7 +25,7 @@ namespace Umbraco.Web.WebApi.Filters public override void OnAuthorization(HttpActionContext actionContext) { var request = actionContext.Request; - if (Current.Config.Global().UseHttps && request.RequestUri.Scheme != Uri.UriSchemeHttps) + if (Current.Configs.Global().UseHttps && request.RequestUri.Scheme != Uri.UriSchemeHttps) { HttpResponseMessage response; var uri = new UriBuilder(request.RequestUri) diff --git a/src/Umbraco.Web/_Legacy/Controls/DataAttributes.cs b/src/Umbraco.Web/_Legacy/Controls/DataAttributes.cs deleted file mode 100644 index 0f83ecd53e..0000000000 --- a/src/Umbraco.Web/_Legacy/Controls/DataAttributes.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Collections.Generic; -using System.Web.UI.WebControls; - -namespace Umbraco.Web._Legacy.Controls -{ - internal class DataAttributes : Dictionary - { - - public void AppendTo(WebControl c) - { - foreach (var keyval in this) - c.Attributes.Add("data-" + keyval.Key, keyval.Value); - } - } -} diff --git a/src/Umbraco.Web/_Legacy/Controls/FieldDropDownList.cs b/src/Umbraco.Web/_Legacy/Controls/FieldDropDownList.cs deleted file mode 100644 index cf85b107e0..0000000000 --- a/src/Umbraco.Web/_Legacy/Controls/FieldDropDownList.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System.Web; -using System.Web.UI; -using System.Web.UI.WebControls; - -namespace Umbraco.Web._Legacy.Controls -{ - public class FieldDropDownList : DropDownList - { - private bool _customOptionsStarted; - private bool _standardOptionsStarted; - - public string CustomPropertiesLabel { get; set; } - public string StandardPropertiesLabel { get; set; } - public string ChooseText { get; set; } - - protected override void RenderContents(HtmlTextWriter writer) - { - if (Items.Count > 0 && Items[0].Text.StartsWith("#")) - { - Items.Insert(0, new ListItem(ChooseText, "")); - SelectedIndex = 0; - - base.RenderContents(writer); - return; - } - - writer.Write("", ChooseText); - - foreach (ListItem item in Items) - { - if (!_customOptionsStarted) - { - RenderOptionGroupBeginTag(CustomPropertiesLabel, writer); - _customOptionsStarted = true; - } - else if (item.Text.StartsWith("@") && !_standardOptionsStarted) - { - _standardOptionsStarted = true; - RenderOptionGroupEndTag(writer); - RenderOptionGroupBeginTag(StandardPropertiesLabel, writer); - } - - writer.WriteBeginTag("option"); - writer.WriteAttribute("value", item.Value, true); - - foreach (string key in item.Attributes.Keys) - writer.WriteAttribute(key, item.Attributes[key]); - - writer.Write(HtmlTextWriter.TagRightChar); - HttpUtility.HtmlEncode(item.Text.Replace("@", ""), writer); - writer.WriteEndTag("option"); - writer.WriteLine(); - } - - RenderOptionGroupEndTag(writer); - } - - private void RenderOptionGroupBeginTag(string name, HtmlTextWriter writer) - { - writer.WriteBeginTag("optgroup"); - writer.WriteAttribute("label", name); - writer.Write(HtmlTextWriter.TagRightChar); - writer.WriteLine(); - } - - private void RenderOptionGroupEndTag(HtmlTextWriter writer) - { - writer.WriteEndTag("optgroup"); - writer.WriteLine(); - } - } -} diff --git a/src/Umbraco.Web/_Legacy/Controls/MenuButton.cs b/src/Umbraco.Web/_Legacy/Controls/MenuButton.cs deleted file mode 100644 index bf44f3a379..0000000000 --- a/src/Umbraco.Web/_Legacy/Controls/MenuButton.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System; -using Umbraco.Core.IO; - -namespace Umbraco.Web._Legacy.Controls -{ - public class MenuButton : System.Web.UI.WebControls.LinkButton - { - public MenuButtonType ButtonType { get; set; } - internal DataAttributes Data { get; private set; } - public string Hotkey { get; set; } - - public string Icon { get; set; } - - public MenuButton() - { - Data = new DataAttributes(); - CssClass = "btn"; - } - - - protected override void Render(System.Web.UI.HtmlTextWriter writer) - { - //setup a hotkey if present - if (ButtonType == MenuButtonType.Primary && String.IsNullOrEmpty(Hotkey)) - Data.Add("hotkey", "ctrl+" + this.Text.ToLower()[0]); - else if (!string.IsNullOrEmpty(Hotkey)) - Data.Add("shortcut", Hotkey); - - Data.AppendTo(this); - - string cssClass = "btn"; - - if (Icon != null) - { - cssClass = "btn editorIcon"; - var i = Icon.Trim('.'); - - if (!string.IsNullOrEmpty(i)) - { - this.ToolTip = this.Text; - - if (i.Contains(".")) - this.Text = "" + this.ToolTip + " " + this.ToolTip; - else - this.Text = " " + this.ToolTip; - } - } - - cssClass += " btn-" + Enum.GetName(ButtonType.GetType(), ButtonType).ToLower() + " " + CssClass; - this.CssClass = cssClass.Trim(); - - - base.Render(writer); - } - - } - - - public enum MenuButtonType - { - Default, - Primary, - Info, - Success, - Warning, - Danger, - Inverse, - Link - } -} diff --git a/src/Umbraco.Web/_Legacy/Controls/MenuButtonI.cs b/src/Umbraco.Web/_Legacy/Controls/MenuButtonI.cs deleted file mode 100644 index 28ae95557a..0000000000 --- a/src/Umbraco.Web/_Legacy/Controls/MenuButtonI.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; -using System.Collections; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Web; -using System.Web.SessionState; -using System.Web.UI; -using System.Web.UI.WebControls; -using System.Web.UI.HtmlControls; -using ClientDependency.Core; - -namespace Umbraco.Web._Legacy.Controls -{ - - public class MenuImageButton : System.Web.UI.WebControls.ImageButton, MenuIconI { - private string _OnClickCommand = ""; - - public string AltText { - get { return this.AlternateText; } - set { - this.AlternateText = value; - this.Attributes.Add("title", value); - } - } - public int IconWidth { - get { return (int)this.Width.Value; } - set { this.Width = value; } - } - public int IconHeight { - get { return (int)this.Height.Value; } - set { this.Height = value; } - } - - - public string ImageURL { - get { return base.ImageUrl; } - set { base.ImageUrl = value; } - } - - public string OnClickCommand { - get { return _OnClickCommand; } - set { _OnClickCommand = value; } - } - - protected override void CreateChildControls() - { - this.Width = Unit.Pixel(20); - this.Height = Unit.Pixel(20); - this.Style.Clear(); - this.Attributes.Add("class", "btn btn-default editorIcon"); - - - if (_OnClickCommand != "") - { - this.Attributes.Add("onClick", OnClickCommand); - } - base.CreateChildControls(); - } - } -} diff --git a/src/Umbraco.Web/_Legacy/Controls/MenuIcon.cs b/src/Umbraco.Web/_Legacy/Controls/MenuIcon.cs deleted file mode 100644 index fe8b654b8a..0000000000 --- a/src/Umbraco.Web/_Legacy/Controls/MenuIcon.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System.ComponentModel; -using System.Web.UI; -using ClientDependency.Core; - -namespace Umbraco.Web._Legacy.Controls -{ - - [ClientDependency(ClientDependencyType.Css, "menuicon/style.css", "UmbracoClient")] - internal class MenuIcon : System.Web.UI.WebControls.Image, MenuIconI - { - private string _OnClickCommand = ""; - private string _AltText = "init"; - - public string AltText { - get { return this.AlternateText; } - set { - _AltText = value; - this.AlternateText = value; - this.Attributes.Add("title", value); - } - } - public int IconWidth { - get { return (int)this.Width.Value; } - set { this.Width = value; } - } - public int IconHeight { - get { return (int)this.Height.Value; } - set { this.Height = value; } - } - - public string ImageURL { - get { return this.ImageUrl; } - set { this.ImageUrl = value; } - } - - public string OnClickCommand { - get { return _OnClickCommand; } - set { _OnClickCommand = value; } - } - - protected override void OnLoad(System.EventArgs EventArguments) { - - - // NH 17-01-2007. Trying to avoid inline styling soup - // Me.Width = WebControls.Unit.Pixel(22) - // Me.Height = WebControls.Unit.Pixel(23) - //Me.Style.Add("border", "0px") - this.Attributes.Add("class", "editorIcon"); - this.Attributes.Add("onMouseover", "this.className='editorIconOver'"); - string holder = ""; -// if (this.ID != "") { - //holder = this.ID.Substring(0, this.ID.LastIndexOf("_")) + "_menu"; - this.Attributes.Add("onMouseout", "hoverIconOut('" + holder + "','" + this.ID + "');"); - this.Attributes.Add("onMouseup", "hoverIconOut('" + holder + "','" + this.ID + "');"); -// } else { - this.Attributes.Add("onMouseout", "this.className='editorIcon'"); - this.Attributes.Add("onMouseup", "this.className='editorIcon'"); -// } - this.Attributes.Add("onMouseDown", "this.className='editorIconDown'; return false;"); - this.AlternateText = _AltText; - this.Attributes.Add("title", _AltText); - - if (_OnClickCommand != "") { - this.Attributes.Add("onClick", OnClickCommand); - } - } - - - } -} diff --git a/src/Umbraco.Web/_Legacy/Controls/MenuIconI.cs b/src/Umbraco.Web/_Legacy/Controls/MenuIconI.cs deleted file mode 100644 index 06716c6cb1..0000000000 --- a/src/Umbraco.Web/_Legacy/Controls/MenuIconI.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace Umbraco.Web._Legacy.Controls -{ - public interface MenuIconI { - string ImageURL { - get; - set; - } - string ID { - get; - set; - } - string OnClickCommand { - get; - set; - } - string AltText { - get; - set; - } - int IconWidth { - get; - set; - } - int IconHeight { - get; - set; - } - } -} diff --git a/src/Umbraco.Web/_Legacy/Controls/ProgressBar.cs b/src/Umbraco.Web/_Legacy/Controls/ProgressBar.cs deleted file mode 100644 index 7a30a5cbb1..0000000000 --- a/src/Umbraco.Web/_Legacy/Controls/ProgressBar.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using Umbraco.Core; -using Umbraco.Core.Composing; -using Umbraco.Core.Services; - -namespace Umbraco.Web._Legacy.Controls -{ - [Obsolete("Use Umbraco.Web.UI.Controls.ProgressBar")] - public class ProgressBar : System.Web.UI.WebControls.Panel - { - private string _title = Current.Services.TextService.Localize("publish/inProgress"); - public string Title { get; set; } - - protected override void Render(System.Web.UI.HtmlTextWriter writer) - { - if(!string.IsNullOrEmpty(Title)) - _title = Title; - - base.CssClass = "umb-loader"; - - base.Render(writer); - } - } -} diff --git a/src/Umbraco.Web/_Legacy/Controls/Splitter.cs b/src/Umbraco.Web/_Legacy/Controls/Splitter.cs deleted file mode 100644 index df6ade91bc..0000000000 --- a/src/Umbraco.Web/_Legacy/Controls/Splitter.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.ComponentModel; -using System.Web.UI; -using Umbraco.Core.IO; - -namespace Umbraco.Web._Legacy.Controls -{ - internal class Splitter : System.Web.UI.WebControls.Image { - - protected override void OnLoad(System.EventArgs EventArguments) { - this.Height = System.Web.UI.WebControls.Unit.Pixel(21); - this.Style.Add("border", "0px"); - this.Attributes.Add("class", "editorIconSplit"); - this.ImageUrl = "/menuicon/images/split.gif"; - } - } -} diff --git a/src/Umbraco.Web/_Legacy/Controls/feedback.cs b/src/Umbraco.Web/_Legacy/Controls/feedback.cs deleted file mode 100644 index 4c4b5bf143..0000000000 --- a/src/Umbraco.Web/_Legacy/Controls/feedback.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using ClientDependency.Core; - -namespace Umbraco.Web._Legacy.Controls -{ - - [ClientDependency(ClientDependencyType.Css, "ui/default.css", "UmbracoClient")] - public class Feedback : System.Web.UI.WebControls.Panel - { - - public Feedback() { - - } - - protected override void OnInit(EventArgs e) { - } - - protected override void OnLoad(System.EventArgs EventArguments) { - } - - public feedbacktype type { get; set; } - - private string _text = string.Empty; - public string Text { - get { - - return _text; - - } - set { _text = value; } - } - - public enum feedbacktype{ - notice, - error, - success - } - - protected override void Render(System.Web.UI.HtmlTextWriter writer) { - if (_text != string.Empty) { - base.CreateChildControls(); - - string styleString = ""; - foreach (string key in this.Style.Keys) { - styleString += key + ":" + this.Style[key] + ";"; - } - - writer.WriteLine("

"); - writer.WriteLine(_text); - writer.WriteLine("

"); - } - } - } -} diff --git a/src/Umbraco.Web/_Legacy/PackageActions/PackageHelper.cs b/src/Umbraco.Web/_Legacy/PackageActions/PackageHelper.cs index c479b720da..55171c2643 100644 --- a/src/Umbraco.Web/_Legacy/PackageActions/PackageHelper.cs +++ b/src/Umbraco.Web/_Legacy/PackageActions/PackageHelper.cs @@ -7,7 +7,7 @@ using Umbraco.Core.Xml; namespace Umbraco.Web._Legacy.PackageActions { - public class PackageHelper + internal class PackageHelper { //Helper method to replace umbraco tags that breaks the xml format.. public static string ParseToValidXml(ITemplate templateObj, ref bool hasAspNetContentBeginning, string template, bool toValid) diff --git a/src/Umbraco.Web/_Legacy/PackageActions/addApplicationTree.cs b/src/Umbraco.Web/_Legacy/PackageActions/addApplicationTree.cs deleted file mode 100644 index b83cb964c2..0000000000 --- a/src/Umbraco.Web/_Legacy/PackageActions/addApplicationTree.cs +++ /dev/null @@ -1,83 +0,0 @@ -using System.Xml; -using Umbraco.Core; -using Umbraco.Core._Legacy.PackageActions; -using Umbraco.Web.Composing; - -namespace Umbraco.Web._Legacy.PackageActions -{ - /*Build in standard actions */ - - /// - /// This class implements the IPackageAction Interface, used to execute code when packages are installed. - /// All IPackageActions only takes a PackageName and a XmlNode as input, and executes based on the data in the xmlnode. - /// - public class addApplicationTree : IPackageAction - { - - #region IPackageAction Members - - /// - /// Executes the specified package action. - /// - /// Name of the package. - /// The XML data. - /// - /// - /// - /// - public bool Execute(string packageName, XmlNode xmlData) - { - bool initialize = bool.Parse(xmlData.Attributes["initialize"].Value); - byte sortOrder = byte.Parse(xmlData.Attributes["sortOrder"].Value); - - string applicationAlias = xmlData.Attributes["applicationAlias"].Value; - string treeAlias = xmlData.Attributes["treeAlias"].Value; - string treeTitle = xmlData.Attributes["treeTitle"].Value; - string iconOpened = xmlData.Attributes["iconOpened"].Value; - string iconClosed = xmlData.Attributes["iconClosed"].Value; - string type = xmlData.Attributes["treeHandlerType"].Value; - - Current.Services.ApplicationTreeService.MakeNew(initialize, sortOrder, applicationAlias, treeAlias, treeTitle, iconClosed, iconOpened, type); - - return true; - } - - /// - /// Undoes the action - /// - /// Name of the package. - /// The XML data. - /// - public bool Undo(string packageName, XmlNode xmlData) - { - string treeAlias = xmlData.Attributes["treeAlias"].Value; - var found = Current.Services.ApplicationTreeService.GetByAlias(treeAlias); - if (found != null) - { - Current.Services.ApplicationTreeService.DeleteTree(found); - } - return true; - } - - /// - /// Action alias. - /// - /// - public string Alias() - { - return "addApplicationTree"; - } - - #endregion - - - public XmlNode SampleXml() - { - - string sample = ""; - return PackageHelper.ParseStringToXmlNode(sample); - } - } -} diff --git a/src/Umbraco.Web/_Legacy/PackageActions/moveRootDocument.cs b/src/Umbraco.Web/_Legacy/PackageActions/moveRootDocument.cs deleted file mode 100644 index 83d9387352..0000000000 --- a/src/Umbraco.Web/_Legacy/PackageActions/moveRootDocument.cs +++ /dev/null @@ -1,102 +0,0 @@ - -//TODO: MIgrate this to core: http://issues.umbraco.org/issue/U4-5857 - -//using System; -//using System.Xml; - -//namespace umbraco.cms.businesslogic.packager.standardPackageActions -//{ -// /// -// /// This class implements the IPackageAction Interface, used to execute code when packages are installed. -// /// All IPackageActions only takes a PackageName and a XmlNode as input, and executes based on the data in the xmlnode. -// /// -// public class moveRootDocument : umbraco.interfaces.IPackageAction -// { -// #region IPackageAction Members - -// /// -// /// Executes the specified package action. -// /// -// /// Name of the package. -// /// The XML data. -// /// -// /// -// /// -// /// True if executed succesfully -// public bool Execute(string packageName, XmlNode xmlData) -// { - -// string documentName = xmlData.Attributes["documentName"].Value; -// string parentDocumentType = xmlData.Attributes["parentDocumentType"].Value; -// string parentDocumentName = ""; - -// if (xmlData.Attributes["parentDocumentName"] != null) -// parentDocumentName = xmlData.Attributes["parentDocumentName"].Value; - -// int parentDocid = 0; - -// ContentType ct = ContentType.GetByAlias(parentDocumentType); -// Content[] docs = web.Document.getContentOfContentType(ct); - -// if (docs.Length > 0) -// { -// if (String.IsNullOrEmpty(parentDocumentName)) -// parentDocid = docs[0].Id; -// else -// { -// foreach (Content doc in docs) -// { -// if (doc.Text == parentDocumentName) -// parentDocid = doc.Id; -// } -// } -// } - -// if (parentDocid > 0) -// { -// web.Document[] rootDocs = web.Document.GetRootDocuments(); - -// foreach (web.Document rootDoc in rootDocs) -// { -// if (rootDoc.Text == documentName) -// { -// rootDoc.Move(parentDocid); -// rootDoc.PublishWithSubs(new umbraco.BusinessLogic.User(0)); -// } -// } -// } - - -// return true; -// } - -// //this has no undo. -// /// -// /// This action has no undo. -// /// -// /// Name of the package. -// /// The XML data. -// /// -// public bool Undo(string packageName, XmlNode xmlData) -// { -// return true; -// } - -// /// -// /// Action alias -// /// -// /// -// public string Alias() -// { -// return "moveRootDocument"; -// } - -// #endregion - -// public XmlNode SampleXml() -// { -// throw new NotImplementedException(); -// } - -// } -//} diff --git a/src/Umbraco.Web/_Legacy/Packager/Installer.cs b/src/Umbraco.Web/_Legacy/Packager/Installer.cs index 020e34d4ce..795aa9ead7 100644 --- a/src/Umbraco.Web/_Legacy/Packager/Installer.cs +++ b/src/Umbraco.Web/_Legacy/Packager/Installer.cs @@ -1,24 +1,26 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Globalization; using System.IO; -using System.Xml; using System.Linq; +using System.Net; +using System.Xml; using ICSharpCode.SharpZipLib.Zip; using Umbraco.Core; +using Umbraco.Core.Composing; +using Umbraco.Core.Events; using Umbraco.Core.IO; using Umbraco.Core.Logging; -using System.Diagnostics; using Umbraco.Core.Models; -using Umbraco.Core.Composing; -using System.Net; -using Umbraco.Core.Events; using Umbraco.Core.Models.Packaging; using Umbraco.Core.Services.Implement; using Umbraco.Core.Xml; +using Umbraco.Web._Legacy.Packager.PackageInstance; using File = System.IO.File; +using PackageAction = Umbraco.Web._Legacy.Packager.PackageInstance.PackageAction; -namespace umbraco.cms.businesslogic.packager +namespace Umbraco.Web._Legacy.Packager { /// /// The packager is a component which enables sharing of both data and functionality components between different umbraco installations. diff --git a/src/Umbraco.Web/_Legacy/Packager/PackageInstance/CreatedPackage.cs b/src/Umbraco.Web/_Legacy/Packager/PackageInstance/CreatedPackage.cs index 5d811ed3d8..3bfcdd3f86 100644 --- a/src/Umbraco.Web/_Legacy/Packager/PackageInstance/CreatedPackage.cs +++ b/src/Umbraco.Web/_Legacy/Packager/PackageInstance/CreatedPackage.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using System.IO; using System.Xml; -using Lucene.Net.Documents; using Umbraco.Core; using Umbraco.Core.Composing; using Umbraco.Core.IO; @@ -11,7 +10,7 @@ using Umbraco.Core.Services; using File = System.IO.File; -namespace umbraco.cms.businesslogic.packager +namespace Umbraco.Web._Legacy.Packager.PackageInstance { public class CreatedPackage { diff --git a/src/Umbraco.Web/_Legacy/Packager/PackageInstance/IPackageInstance.cs b/src/Umbraco.Web/_Legacy/Packager/PackageInstance/IPackageInstance.cs index 28c7c05b6b..b920c85a9f 100644 --- a/src/Umbraco.Web/_Legacy/Packager/PackageInstance/IPackageInstance.cs +++ b/src/Umbraco.Web/_Legacy/Packager/PackageInstance/IPackageInstance.cs @@ -1,5 +1,4 @@ -using System; -namespace umbraco.cms.businesslogic.packager{ +namespace Umbraco.Web._Legacy.Packager.PackageInstance{ public interface IPackageInstance { string Actions { get; set; } string Author { get; set; } diff --git a/src/Umbraco.Web/_Legacy/Packager/PackageInstance/InstalledPackage.cs b/src/Umbraco.Web/_Legacy/Packager/PackageInstance/InstalledPackage.cs index 9e04bff636..3fca97759b 100644 --- a/src/Umbraco.Web/_Legacy/Packager/PackageInstance/InstalledPackage.cs +++ b/src/Umbraco.Web/_Legacy/Packager/PackageInstance/InstalledPackage.cs @@ -1,15 +1,15 @@ using System; using System.Collections.Generic; using System.Linq; -using Umbraco.Core; using Umbraco.Core.Composing; -using Umbraco.Core.Logging; using Umbraco.Core.IO; +using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.Packaging; using Umbraco.Core.Services; -namespace umbraco.cms.businesslogic.packager { +namespace Umbraco.Web._Legacy.Packager.PackageInstance +{ public class InstalledPackage { diff --git a/src/Umbraco.Web/_Legacy/Packager/PackageInstance/PackageActions.cs b/src/Umbraco.Web/_Legacy/Packager/PackageInstance/PackageActions.cs index d1df47cd44..bfd1030d85 100644 --- a/src/Umbraco.Web/_Legacy/Packager/PackageInstance/PackageActions.cs +++ b/src/Umbraco.Web/_Legacy/Packager/PackageInstance/PackageActions.cs @@ -1,12 +1,10 @@ using System; using System.Xml; -using Umbraco.Core; using Umbraco.Core.Composing; using Umbraco.Core.Logging; using Umbraco.Core._Legacy.PackageActions; - -namespace umbraco.cms.businesslogic.packager +namespace Umbraco.Web._Legacy.Packager.PackageInstance { /// diff --git a/src/Umbraco.Web/_Legacy/Packager/PackageInstance/PackageInstance.cs b/src/Umbraco.Web/_Legacy/Packager/PackageInstance/PackageInstance.cs index 8f7cb56320..fe32633ccd 100644 --- a/src/Umbraco.Web/_Legacy/Packager/PackageInstance/PackageInstance.cs +++ b/src/Umbraco.Web/_Legacy/Packager/PackageInstance/PackageInstance.cs @@ -1,10 +1,7 @@ using System; - -using System.Xml; -using System.Xml.XPath; using System.Collections.Generic; -namespace umbraco.cms.businesslogic.packager +namespace Umbraco.Web._Legacy.Packager.PackageInstance { public class PackageInstance { diff --git a/src/Umbraco.Web/_Legacy/Packager/PackageInstance/PackagerUtility.cs b/src/Umbraco.Web/_Legacy/Packager/PackageInstance/PackagerUtility.cs index 53ed58810c..d972977bad 100644 --- a/src/Umbraco.Web/_Legacy/Packager/PackageInstance/PackagerUtility.cs +++ b/src/Umbraco.Web/_Legacy/Packager/PackageInstance/PackagerUtility.cs @@ -8,7 +8,7 @@ using Umbraco.Core.Composing; using Umbraco.Core.IO; using Umbraco.Core.Services; -namespace umbraco.cms.businesslogic.packager +namespace Umbraco.Web._Legacy.Packager.PackageInstance { /// /// A utillity class for working with packager data. diff --git a/src/Umbraco.Web/_Legacy/Packager/RequirementsType.cs b/src/Umbraco.Web/_Legacy/Packager/RequirementsType.cs index ea63ff6979..ca91626128 100644 --- a/src/Umbraco.Web/_Legacy/Packager/RequirementsType.cs +++ b/src/Umbraco.Web/_Legacy/Packager/RequirementsType.cs @@ -1,4 +1,4 @@ -namespace umbraco.cms.businesslogic.packager +namespace Umbraco.Web._Legacy.Packager { public enum RequirementsType { diff --git a/src/Umbraco.Web/_Legacy/Packager/Settings.cs b/src/Umbraco.Web/_Legacy/Packager/Settings.cs index 85cfebcfee..57ab4b9ea4 100644 --- a/src/Umbraco.Web/_Legacy/Packager/Settings.cs +++ b/src/Umbraco.Web/_Legacy/Packager/Settings.cs @@ -1,16 +1,8 @@ using System; -using System.Data; -using System.Configuration; -using System.Web; -using System.Web.Security; -using System.Web.UI; -using System.Web.UI.WebControls; -using System.Web.UI.WebControls.WebParts; -using System.Web.UI.HtmlControls; using System.IO; using Umbraco.Core.IO; -namespace umbraco.cms.businesslogic.packager +namespace Umbraco.Web._Legacy.Packager { public class Settings { diff --git a/src/Umbraco.Web/_Legacy/Packager/data.cs b/src/Umbraco.Web/_Legacy/Packager/data.cs index 88cc7a4b54..962b7d5ed4 100644 --- a/src/Umbraco.Web/_Legacy/Packager/data.cs +++ b/src/Umbraco.Web/_Legacy/Packager/data.cs @@ -1,15 +1,15 @@ using System; -using System.Xml; using System.Collections.Generic; using System.IO; +using System.Xml; using Umbraco.Core; -using Umbraco.Core.Configuration; using Umbraco.Core.Composing; +using Umbraco.Core.Configuration; using Umbraco.Core.IO; using Umbraco.Core.Logging; using Umbraco.Core.Xml; -namespace umbraco.cms.businesslogic.packager +namespace Umbraco.Web._Legacy.Packager { /// /// This is the xml data for installed packages. This is not the same xml as a pckage format! @@ -85,7 +85,7 @@ namespace umbraco.cms.businesslogic.packager return Source.SelectSingleNode("/packages/package [@packageGuid = '" + guid + "']"); } - public static PackageInstance MakeNew(string Name, string dataSource) + public static PackageInstance.PackageInstance MakeNew(string Name, string dataSource) { Reload(dataSource); @@ -151,26 +151,26 @@ namespace umbraco.cms.businesslogic.packager return retVal; } - public static PackageInstance Package(int id, string datasource) + public static PackageInstance.PackageInstance Package(int id, string datasource) { return ConvertXmlToPackage(GetFromId(id, datasource, true)); } - public static PackageInstance Package(string guid, string datasource) + public static PackageInstance.PackageInstance Package(string guid, string datasource) { XmlNode node = GetFromGuid(guid, datasource, true); if (node != null) return ConvertXmlToPackage(node); else - return new PackageInstance(); + return new PackageInstance.PackageInstance(); } - public static List GetAllPackages(string dataSource) + public static List GetAllPackages(string dataSource) { Reload(dataSource); XmlNodeList nList = data.Source.SelectNodes("packages/package"); - List retVal = new List(); + List retVal = new List(); for (int i = 0; i < nList.Count; i++) { @@ -187,9 +187,9 @@ namespace umbraco.cms.businesslogic.packager return retVal; } - private static PackageInstance ConvertXmlToPackage(XmlNode n) + private static PackageInstance.PackageInstance ConvertXmlToPackage(XmlNode n) { - PackageInstance retVal = new PackageInstance(); + PackageInstance.PackageInstance retVal = new PackageInstance.PackageInstance(); if (n != null) { @@ -263,7 +263,7 @@ namespace umbraco.cms.businesslogic.packager } - public static void Save(PackageInstance package, string dataSource) + public static void Save(PackageInstance.PackageInstance package, string dataSource) { Reload(dataSource); var xmlDef = GetFromId(package.Id, dataSource, false); diff --git a/src/Umbraco.Web/umbraco.presentation/default.aspx.cs b/src/Umbraco.Web/umbraco.presentation/default.aspx.cs index c571c99ced..c7a5d9fdd2 100644 --- a/src/Umbraco.Web/umbraco.presentation/default.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/default.aspx.cs @@ -141,7 +141,7 @@ namespace umbraco if (pos > -1) { string htmlBadge = - string.Format(Current.Config.Umbraco().Content.PreviewBadge, + string.Format(Current.Configs.Settings().Content.PreviewBadge, IOHelper.ResolveUrl(SystemDirectories.Umbraco), Server.UrlEncode(UmbracoContext.Current.HttpContext.Request.Path)); diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/dualSelectBox.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/dualSelectBox.cs deleted file mode 100644 index 6e109b3327..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/dualSelectBox.cs +++ /dev/null @@ -1,153 +0,0 @@ -using System; -using System.Web.Razor; -using System.Web.UI; -using System.Web.UI.WebControls; -using System.Web.UI.HtmlControls; -using ClientDependency.Core; -using Umbraco.Core; -using Umbraco.Core.Services; -using Umbraco.Web; -using Umbraco.Web.Composing; - -namespace umbraco.controls -{ - /// - /// Summary description for dualSelectbox. - /// - [ClientDependency(ClientDependencyType.Javascript, "js/dualSelectBox.js", "UmbracoRoot")] - public class DualSelectbox : System.Web.UI.WebControls.WebControl, System.Web.UI.INamingContainer - { - private ListItemCollection _items = new ListItemCollection(); - - private ListBox _possibleValues = new ListBox(); - private ListBox _selectedValues = new ListBox(); - private HtmlInputHidden _value = new HtmlInputHidden(); - private HtmlInputButton _add = new HtmlInputButton(); - private HtmlInputButton _remove = new HtmlInputButton(); - private int _rows = 8; - - - public ListItemCollection Items - { - get - { - EnsureChildControls(); - return _items; - } - } - - public new int Width - { - set - { - _possibleValues.Width = new Unit(value); - _selectedValues.Width = new Unit(value); - } - } - - public new int Height - { - set - { - _possibleValues.Height = new Unit(value); - _selectedValues.Height = new Unit(value); - } - } - - protected override void CreateChildControls() - { - _possibleValues.ID = "posVals"; - _selectedValues.ID = "selVals"; - _possibleValues.SelectionMode = ListSelectionMode.Multiple; - _selectedValues.SelectionMode = ListSelectionMode.Multiple; - _possibleValues.CssClass = "guiInputTextStandard"; - _selectedValues.CssClass = "guiInputTextStandard"; - _possibleValues.Rows = _rows; - _selectedValues.Rows = _rows; - - _value.ID = "theValue"; - - HtmlTable table = new HtmlTable(); - table.CellPadding = 5; - table.CellSpacing = 0; - table.Border = 0; - - HtmlTableRow header = new HtmlTableRow(); - header.Controls.Add(new HtmlTableCell { InnerHtml = Current.Services.TextService.Localize("content/notmemberof") }); - header.Controls.Add(new HtmlTableCell { InnerHtml= " " }); - header.Controls.Add(new HtmlTableCell { InnerHtml = Current.Services.TextService.Localize("content/memberof") }); - table.Controls.Add(header); - - HtmlTableRow row = new HtmlTableRow(); - table.Controls.Add(row); - HtmlTableCell cFirst = new HtmlTableCell(); - cFirst.Controls.Add(_possibleValues); - row.Controls.Add(cFirst); - HtmlTableCell cButtons = new HtmlTableCell(); - _add.Value = ">>"; - _add.Attributes.Add("class", "guiInputButton"); - _remove.Value = "<<"; - _remove.Attributes.Add("class", "guiInputButton"); - cButtons.Controls.Add(_add); - cButtons.Controls.Add(new LiteralControl("

")); - cButtons.Controls.Add(_remove); - row.Controls.Add(cButtons); - HtmlTableCell cSecond = new HtmlTableCell(); - cSecond.Controls.Add(_selectedValues); - row.Controls.Add(cSecond); - - this.Controls.Add(table); - this.Controls.Add(_value); - } - - public string Value - { - get - { - return _value.Value; - } - - set - { - _value.Value = value; - } - } - - public int Rows - { - set - { - _rows = value; - } - } - - public DualSelectbox() - { - } - - - protected override void OnPreRender(EventArgs e) - { - base.OnPreRender (e); - - _selectedValues.Items.Clear(); - _possibleValues.Items.Clear(); - - foreach(ListItem li in _items) - { - if (((string) (","+ this.Value +",")).IndexOf(","+li.Value+",") > -1) - _selectedValues.Items.Add(li); - else - _possibleValues.Items.Add(li); - } - - // add js to buttons here to ensure full clientids - _add.Attributes.Add("onClick", "dualSelectBoxShift('" + this.ClientID + "');"); - _remove.Attributes.Add("onClick", "dualSelectBoxShift('" + this.ClientID + "');"); - } - - - - - } -} diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/create/CreatedPackageTasks.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/create/CreatedPackageTasks.cs index 64f2c94b0a..47980f2808 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/create/CreatedPackageTasks.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/create/CreatedPackageTasks.cs @@ -3,8 +3,8 @@ using Umbraco.Web.UI; using Umbraco.Core; using Umbraco.Web; using Umbraco.Web.Composing; +using Umbraco.Web._Legacy.Packager.PackageInstance; using Umbraco.Web._Legacy.UI; -using umbraco.cms.businesslogic.packager; namespace Umbraco.Web { diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/editPackage.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/editPackage.aspx.cs index 22a9f4292f..645aa088f2 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/editPackage.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/editPackage.aspx.cs @@ -12,6 +12,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Web.UI; using Umbraco.Web.UI.Pages; +using Umbraco.Web._Legacy.Packager.PackageInstance; namespace umbraco.presentation.developer.packages { @@ -31,14 +32,14 @@ namespace umbraco.presentation.developer.packages public Umbraco.Web._Legacy.Controls.TabPage packageActions; protected ContentPicker cp; - private cms.businesslogic.packager.PackageInstance pack; - private cms.businesslogic.packager.CreatedPackage createdPackage; + private PackageInstance pack; + private CreatedPackage createdPackage; protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["id"] != null) { - createdPackage = cms.businesslogic.packager.CreatedPackage.GetById(int.Parse(Request.QueryString["id"])); + createdPackage = CreatedPackage.GetById(int.Parse(Request.QueryString["id"])); pack = createdPackage.Data; /* CONTENT */ @@ -359,8 +360,8 @@ namespace umbraco.presentation.developer.packages if (newPath.Trim() != "") { - cms.businesslogic.packager.CreatedPackage createdPackage = cms.businesslogic.packager.CreatedPackage.GetById(int.Parse(Request.QueryString["id"])); - cms.businesslogic.packager.PackageInstance pack = createdPackage.Data; + CreatedPackage createdPackage = CreatedPackage.GetById(int.Parse(Request.QueryString["id"])); + PackageInstance pack = createdPackage.Data; pack.Files.Add(newPath); @@ -386,8 +387,8 @@ namespace umbraco.presentation.developer.packages tmpFilePathString += tmpFFFF + "�"; } - cms.businesslogic.packager.CreatedPackage createdPackage = cms.businesslogic.packager.CreatedPackage.GetById(int.Parse(Request.QueryString["id"])); - cms.businesslogic.packager.PackageInstance pack = createdPackage.Data; + CreatedPackage createdPackage = CreatedPackage.GetById(int.Parse(Request.QueryString["id"])); + PackageInstance pack = createdPackage.Data; pack.Files = new List(tmpFilePathString.Trim('�').Split('�')); pack.Files.TrimExcess(); diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/insertMasterpageContent.aspx b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/insertMasterpageContent.aspx deleted file mode 100644 index b188df39eb..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/insertMasterpageContent.aspx +++ /dev/null @@ -1,32 +0,0 @@ -<%@ Page Title="" Language="C#" MasterPageFile="../masterpages/umbracoDialog.Master" AutoEventWireup="true" CodeBehind="insertMasterpageContent.aspx.cs" Inherits="umbraco.presentation.umbraco.dialogs.insertMasterpageContent" %> -<%@ Register TagPrefix="cc1" Namespace="Umbraco.Web._Legacy.Controls" %> - - - - - - - - - -

- <%= Services.TextService.Localize("defaultdialogs/templateContentPlaceHolderHelp")%> -

-
- - - -
- - - <%=Services.TextService.Localize("general/cancel")%> - " /> - -
\ No newline at end of file diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/insertMasterpageContent.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/insertMasterpageContent.aspx.cs deleted file mode 100644 index 96b1006de5..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/insertMasterpageContent.aspx.cs +++ /dev/null @@ -1,52 +0,0 @@ -using Umbraco.Core.Services; -using System; -using System.Linq; -using System.Web.UI.WebControls; -using Umbraco.Core; -using Umbraco.Core.IO; - -namespace umbraco.presentation.umbraco.dialogs -{ - public partial class insertMasterpageContent : Umbraco.Web.UI.Pages.UmbracoEnsuredPage - { - public insertMasterpageContent() - { - CurrentApp = Constants.Applications.Settings.ToString(); - } - - protected void Page_Load(object sender, EventArgs e) - { - //labels - pp_placeholder.Text = Services.TextService.Localize("placeHolderID"); - - //Add a default Item - var li = new ListItem("Choose ID..."); - li.Selected = true; - dd_detectedAlias.Items.Add(li); - - //var t = new cms.businesslogic.template.Template(int.Parse(Request["id"])); - var t = Services.FileService.GetTemplate(int.Parse(Request["id"])); - - - //if (t.MasterTemplate > 0) - if (string.IsNullOrWhiteSpace(t.MasterTemplateAlias) != true) - { - //t = new cms.businesslogic.template.Template(t.MasterTemplate); - t = Services.FileService.GetTemplate(t.MasterTemplateAlias); - - } - - //foreach (string cpId in t.contentPlaceholderIds()) - foreach (string cpId in MasterPageHelper.GetContentPlaceholderIds(t)) - { - dd_detectedAlias.Items.Add(cpId); - } - - if (dd_detectedAlias.Items.Count == 1) - dd_detectedAlias.Items.Add("ContentPlaceHolderDefault"); - - } - - - } -} diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/insertMasterpageContent.aspx.designer.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/insertMasterpageContent.aspx.designer.cs deleted file mode 100644 index 7303e3d56b..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/insertMasterpageContent.aspx.designer.cs +++ /dev/null @@ -1,42 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace umbraco.presentation.umbraco.dialogs { - - - public partial class insertMasterpageContent { - - /// - /// pane_insert control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::Umbraco.Web._Legacy.Controls.Pane pane_insert; - - /// - /// pp_placeholder control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::Umbraco.Web._Legacy.Controls.PropertyPanel pp_placeholder; - - /// - /// dd_detectedAlias control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.DropDownList dd_detectedAlias; - } -} diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/insertMasterpagePlaceholder.aspx b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/insertMasterpagePlaceholder.aspx deleted file mode 100644 index bb6bca8042..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/insertMasterpagePlaceholder.aspx +++ /dev/null @@ -1,34 +0,0 @@ -<%@ Page Title="" Language="C#" MasterPageFile="../masterpages/umbracoDialog.Master" AutoEventWireup="true" CodeBehind="insertMasterpagePlaceholder.aspx.cs" Inherits="umbraco.presentation.umbraco.dialogs.insertMasterpagePlaceholder" %> - - - - - - - - - -

- <%= Services.TextService.Localize("defaultdialogs/templateContentAreaHelp")%> -

-
- - - - -
- - - <%=Services.TextService.Localize("general/cancel")%> - " /> - -
\ No newline at end of file diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/insertMasterpagePlaceholder.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/insertMasterpagePlaceholder.aspx.cs deleted file mode 100644 index 48073a7f4f..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/insertMasterpagePlaceholder.aspx.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Umbraco.Core.Services; -using System; -using Umbraco.Core; - -namespace umbraco.presentation.umbraco.dialogs { - public partial class insertMasterpagePlaceholder : Umbraco.Web.UI.Pages.UmbracoEnsuredPage { - - public insertMasterpagePlaceholder() - { - CurrentApp = Constants.Applications.Settings.ToString(); - } - protected void Page_Load(object sender, EventArgs e) { - //labels - pp_placeholder.Text = Services.TextService.Localize("placeHolderID"); - - } - } -} diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/insertMasterpagePlaceholder.aspx.designer.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/insertMasterpagePlaceholder.aspx.designer.cs deleted file mode 100644 index a12635e368..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/insertMasterpagePlaceholder.aspx.designer.cs +++ /dev/null @@ -1,26 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace umbraco.presentation.umbraco.dialogs { - - - public partial class insertMasterpagePlaceholder { - - /// - /// tb_alias control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.TextBox tb_alias; - - protected global::Umbraco.Web._Legacy.Controls.PropertyPanel pp_placeholder; - } -} diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/republish.aspx b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/republish.aspx deleted file mode 100644 index c58ca0d8fc..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/republish.aspx +++ /dev/null @@ -1,40 +0,0 @@ -<%@ Page Language="c#" Codebehind="republish.aspx.cs" MasterPageFile="../masterpages/umbracoDialog.Master" AutoEventWireup="True" Inherits="umbraco.cms.presentation.republish" %> -<%@ Register TagPrefix="cc1" Namespace="Umbraco.Web._Legacy.Controls" %> - - - - - - - -
-

<%= Services.TextService.Localize("defaultdialogs/siterepublishHelp")%>

-
- -
- - <%= Services.TextService.Localize("or") %> - <%=Services.TextService.Localize("cancel")%> -
- - - -
- - -
-

<%= Services.TextService.Localize("defaultdialogs/siterepublished")%>

- -
- -
-
\ No newline at end of file diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/republish.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/republish.aspx.cs deleted file mode 100644 index 4fee44eabe..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/republish.aspx.cs +++ /dev/null @@ -1,68 +0,0 @@ -//TODO: Re-create this in angular and new APIS! then remove it - -//using System; -//using System.Collections; -//using System.ComponentModel; -//using System.Data; -//using System.Drawing; -//using System.Web; -//using System.Web.SessionState; -//using System.Web.UI; -//using System.Web.UI.WebControls; -//using System.Web.UI.HtmlControls; -//using Umbraco.Web; - -//namespace umbraco.cms.presentation -//{ -// /// -// /// Summary description for republish. -// /// -// public partial class republish : Umbraco.Web.UI.Pages.UmbracoEnsuredPage -// { -// public republish() -// { -// CurrentApp = Constants.Applications.Content.ToString(); - -// } -// protected void go(object sender, EventArgs e) { -// // re-create xml -// if (Request.GetItemAsString("xml") != "") -// { -// Server.ScriptTimeout = 100000; -// Services.ContentService.RePublishAll(); -// } -// else if (Request.GetItemAsString("previews") != "") -// { -// Server.ScriptTimeout = 100000; -// umbraco.cms.businesslogic.web.Document.RegeneratePreviews(); -// } -// else if (Request.GetItemAsString("refreshNodes") != "") -// { -// Server.ScriptTimeout = 100000; -// System.Xml.XmlDocument xd = new System.Xml.XmlDocument(); - -// var doc = new cms.businesslogic.web.Document(int.Parse(Request.GetItemAsString("refreshNodes"))); - -// foreach (cms.businesslogic.web.Document d in doc.Children) -// { -// d.XmlGenerate(xd); -// Response.Write("
  • Creating xml for " + d.Text + "
  • "); -// Response.Flush(); -// } -// } - -// //PPH changed this to a general library call for load balancing support -// library.RefreshContent(); - -// p_republish.Visible = false; -// p_done.Visible = true; -// } - -// protected void Page_Load(object sender, System.EventArgs e) -// { -// bt_go.Text = Services.TextService.Localize("republish"); -// } - - -// } -//} diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/republish.aspx.designer.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/republish.aspx.designer.cs deleted file mode 100644 index a2311585a5..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/republish.aspx.designer.cs +++ /dev/null @@ -1,51 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace umbraco.cms.presentation { - - - public partial class republish { - - /// - /// p_republish control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Panel p_republish; - - /// - /// bt_go control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Button bt_go; - - /// - /// progbar control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::Umbraco.Web._Legacy.Controls.ProgressBar progbar; - - /// - /// p_done control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Panel p_done; - } -} diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/umbracoField.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/umbracoField.aspx.cs deleted file mode 100644 index 244fdeb9da..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/umbracoField.aspx.cs +++ /dev/null @@ -1,251 +0,0 @@ -using System.Linq; -using System.Web.UI.WebControls; -using Umbraco.Core.Configuration; -using Umbraco.Core; -using Umbraco.Core.Services; -using Umbraco.Web; -using Umbraco.Web.Composing; - -namespace umbraco.dialogs -{ - /// - /// Summary description for umbracoField. - /// - public partial class umbracoField : Umbraco.Web.UI.Pages.UmbracoEnsuredPage - { - string[] preValuesSource = { "@createDate", "@creatorName", "@level", "@nodeType", "@nodeTypeAlias", "@pageID", "@pageName", "@parentID", "@path", "@template", "@updateDate", "@writerID", "@writerName" }; - bool m_IsDictionaryMode = false; - - public umbracoField() - { - CurrentApp = Constants.Applications.Settings.ToString(); - } - - protected void Page_Load(object sender, System.EventArgs e) - { - - //set labels on properties... - pp_insertAltField.Text = Services.TextService.Localize("templateEditor/alternativeField"); - pp_insertAltText.Text = Services.TextService.Localize("templateEditor/alternativeText"); - pp_insertBefore.Text = Services.TextService.Localize("templateEditor/preContent"); - pp_insertAfter.Text = Services.TextService.Localize("templateEditor/postContent"); - - pp_FormatAsDate.Text = Services.TextService.Localize("templateEditor/formatAsDate"); - pp_casing.Text = Services.TextService.Localize("templateEditor/casing"); - pp_encode.Text = Services.TextService.Localize("templateEditor/encoding"); - - tagName.Value = "umbraco:Item"; - - using (var scope = Current.ScopeProvider.CreateScope()) - { - // either get page fields or dictionary items - string fieldSql = ""; - if (Request.GetItemAsString("tagName") == "UMBRACOGETDICTIONARY") - { - fieldSql = "select '#'+[key] as alias from cmsDictionary order by alias"; - m_IsDictionaryMode = true; - pp_insertField.Text = "Insert Dictionary Item"; - } - else - { - //exclude built-in memberhip properties from showing up here - var exclude = Constants.Conventions.Member.GetStandardPropertyTypeStubs() - .Select(x => Current.SqlContext.SqlSyntax.GetQuotedValue(x.Key)).ToArray(); - - fieldSql = string.Format( - "select distinct alias from cmsPropertyType where alias not in ({0}) order by alias", - string.Join(",", exclude)); - pp_insertField.Text = Services.TextService.Localize("templateEditor/chooseField"); - } - - fieldPicker.ChooseText = Services.TextService.Localize("templateEditor/chooseField"); - fieldPicker.StandardPropertiesLabel = Services.TextService.Localize("templateEditor/standardFields"); - fieldPicker.CustomPropertiesLabel = Services.TextService.Localize("templateEditor/customFields"); - - var dataTypes = scope.Database.Fetch(fieldSql); - fieldPicker.DataTextField = "alias"; - fieldPicker.DataValueField = "alias"; - fieldPicker.DataSource = dataTypes; - fieldPicker.DataBind(); - fieldPicker.Attributes.Add("onChange", "document.forms[0].field.value = document.forms[0]." + fieldPicker.ClientID + "[document.forms[0]." + fieldPicker.ClientID + ".selectedIndex].value;"); - - altFieldPicker.ChooseText = Services.TextService.Localize("templateEditor/chooseField"); - altFieldPicker.StandardPropertiesLabel = Services.TextService.Localize("templateEditor/standardFields"); - altFieldPicker.CustomPropertiesLabel = Services.TextService.Localize("templateEditor/customFields"); - - var dataTypes2 = scope.Database.Fetch(fieldSql); - altFieldPicker.DataTextField = "alias"; - altFieldPicker.DataValueField = "alias"; - altFieldPicker.DataSource = dataTypes2; - altFieldPicker.DataBind(); - altFieldPicker.Attributes.Add("onChange", "document.forms[0].useIfEmpty.value = document.forms[0]." + altFieldPicker.ClientID + "[document.forms[0]." + altFieldPicker.ClientID + ".selectedIndex].value;"); - - scope.Complete(); - } - - // Pre values - if (!m_IsDictionaryMode) - { - foreach (string s in preValuesSource) - { - fieldPicker.Items.Add(new ListItem(s, s.Replace("@", ""))); - altFieldPicker.Items.Add(new ListItem(s, s.Replace("@", ""))); - } - } - } - - - /// - /// JsInclude1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::ClientDependency.Core.Controls.JsInclude JsInclude1; - - /// - /// JsInclude2 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::ClientDependency.Core.Controls.JsInclude JsInclude2; - - /// - /// tagName control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.HtmlControls.HtmlInputHidden tagName; - - /// - /// pane_form control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::Umbraco.Web._Legacy.Controls.Pane pane_form; - - /// - /// pp_insertField control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::Umbraco.Web._Legacy.Controls.PropertyPanel pp_insertField; - - /// - /// fieldPicker control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::Umbraco.Web._Legacy.Controls.FieldDropDownList fieldPicker; - - /// - /// pp_insertAltField control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::Umbraco.Web._Legacy.Controls.PropertyPanel pp_insertAltField; - - /// - /// altFieldPicker control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::Umbraco.Web._Legacy.Controls.FieldDropDownList altFieldPicker; - - /// - /// pp_insertAltText control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::Umbraco.Web._Legacy.Controls.PropertyPanel pp_insertAltText; - - /// - /// pp_recursive control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::Umbraco.Web._Legacy.Controls.PropertyPanel pp_recursive; - - /// - /// pp_insertBefore control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::Umbraco.Web._Legacy.Controls.PropertyPanel pp_insertBefore; - - /// - /// pp_insertAfter control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::Umbraco.Web._Legacy.Controls.PropertyPanel pp_insertAfter; - - /// - /// pp_FormatAsDate control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::Umbraco.Web._Legacy.Controls.PropertyPanel pp_FormatAsDate; - - /// - /// pp_casing control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::Umbraco.Web._Legacy.Controls.PropertyPanel pp_casing; - - /// - /// pp_encode control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::Umbraco.Web._Legacy.Controls.PropertyPanel pp_encode; - - /// - /// pp_convertLineBreaks control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::Umbraco.Web._Legacy.Controls.PropertyPanel pp_convertLineBreaks; - - /// - /// pp_removePTags control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::Umbraco.Web._Legacy.Controls.PropertyPanel pp_removePTags; - } -}