diff --git a/src/Umbraco.Core/ApplicationContext.cs b/src/Umbraco.Core/ApplicationContext.cs index 0aa861a87d..b90f3f3e94 100644 --- a/src/Umbraco.Core/ApplicationContext.cs +++ b/src/Umbraco.Core/ApplicationContext.cs @@ -107,25 +107,6 @@ namespace Umbraco.Core } } - public UmbracoConfiguration UmbracoConfiguration - { - get - { - if (_umbracoConfiguration == null) - { - var umbracoSettings = ConfigurationManager.GetSection("umbracoConfiguration/settings") as IUmbracoSettings; - if (umbracoSettings == null) - { - throw new InvalidOperationException("Could not find configuration section 'umbracoConfiguration/settings' or it does not cast to " + typeof (IUmbracoSettings)); - } - - //create a new one if it is null - _umbracoConfiguration = new UmbracoConfiguration(umbracoSettings); - } - return _umbracoConfiguration; - } - } - /// /// The original/first url that the web application executes /// diff --git a/src/Umbraco.Web/BaseRest/Configuration/BaseRestSection.cs b/src/Umbraco.Core/Configuration/BaseRest/BaseRestSection.cs similarity index 71% rename from src/Umbraco.Web/BaseRest/Configuration/BaseRestSection.cs rename to src/Umbraco.Core/Configuration/BaseRest/BaseRestSection.cs index 9f0cf6e2ed..60b4c3a133 100644 --- a/src/Umbraco.Web/BaseRest/Configuration/BaseRestSection.cs +++ b/src/Umbraco.Core/Configuration/BaseRest/BaseRestSection.cs @@ -1,43 +1,45 @@ -using System.Configuration; -using Umbraco.Core.Configuration; - -namespace Umbraco.Web.BaseRest.Configuration -{ - // note: the name should be "BaseRest" but we keep it "BaseRestSection" for compat. reasons. - - [ConfigurationKey("BaseRestExtensions")] - internal class BaseRestSection : UmbracoConfigurationSection - { - private const string KeyEnabled = "enabled"; - - private bool? _enabled; - - internal protected override void ResetSection() - { - base.ResetSection(); - - _enabled = null; - } - - [ConfigurationProperty("", IsKey = false, IsRequired = false, IsDefaultCollection = true)] - public ExtensionElementCollection Items - { - get { return (ExtensionElementCollection)base[""]; } - } - - /// - /// Gets or sets a value indicating whether base rest extensions are enabled. - /// - [ConfigurationProperty(KeyEnabled, DefaultValue = true, IsRequired = false)] - public bool Enabled - { - get - { - return _enabled ?? (IsPresent - ? (bool)this[KeyEnabled] - : true); - } - internal set { _enabled = value; } - } - } -} +using System.Collections.Generic; +using System.Configuration; + +namespace Umbraco.Core.Configuration.BaseRest +{ + [ConfigurationKey("BaseRestExtensions")] + internal class BaseRestSection : UmbracoConfigurationSection, IBaseRest + { + private const string KeyEnabled = "enabled"; + + private bool? _enabled; + + internal protected override void ResetSection() + { + base.ResetSection(); + + _enabled = null; + } + + [ConfigurationProperty("", IsKey = false, IsRequired = false, IsDefaultCollection = true)] + public ExtensionElementCollection Items + { + get { return (ExtensionElementCollection)base[""]; } + } + + /// + /// Gets or sets a value indicating whether base rest extensions are enabled. + /// + [ConfigurationProperty(KeyEnabled, DefaultValue = true, IsRequired = false)] + public bool Enabled + { + get + { + return _enabled ?? (IsPresent == false || (bool)this[KeyEnabled]); + } + internal set { _enabled = value; } + } + + IExtensionsCollection IBaseRest.Items + { + get { return Items; } + } + + } +} diff --git a/src/Umbraco.Web/BaseRest/Configuration/ExtensionElement.cs b/src/Umbraco.Core/Configuration/BaseRest/ExtensionElement.cs similarity index 62% rename from src/Umbraco.Web/BaseRest/Configuration/ExtensionElement.cs rename to src/Umbraco.Core/Configuration/BaseRest/ExtensionElement.cs index 17edf92edc..5f0a5540ae 100644 --- a/src/Umbraco.Web/BaseRest/Configuration/ExtensionElement.cs +++ b/src/Umbraco.Core/Configuration/BaseRest/ExtensionElement.cs @@ -1,63 +1,81 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Configuration; - -namespace Umbraco.Web.BaseRest.Configuration -{ - [ConfigurationCollection(typeof(ExtensionElement), CollectionType = ConfigurationElementCollectionType.BasicMapAlternate)] - public class ExtensionElement : ConfigurationElementCollection - { - const string KeyAlias = "alias"; - const string KeyType = "type"; - const string KeyMethod = "method"; - - [ConfigurationProperty(KeyAlias, IsKey = true, IsRequired = true)] - public string Alias - { - get { return (string)base[KeyAlias]; } - } - - [ConfigurationProperty(KeyType, IsKey = false, IsRequired = true)] - public string Type - { - get { return (string)base[KeyType]; } - } - - public override ConfigurationElementCollectionType CollectionType - { - get { return ConfigurationElementCollectionType.BasicMapAlternate; } - } - - protected override string ElementName - { - get { return KeyMethod; } - } - - protected override bool IsElementName(string elementName) - { - return elementName.Equals(KeyMethod, StringComparison.InvariantCultureIgnoreCase); - } - - protected override ConfigurationElement CreateNewElement() - { - return new MethodElement(); - } - - protected override object GetElementKey(ConfigurationElement element) - { - return ((MethodElement)element).Name; - } - - public override bool IsReadOnly() - { - return false; - } - - new public MethodElement this[string index] - { - get { return (MethodElement)BaseGet(index); } - } - } -} +using System; +using System.Collections.Generic; +using System.Configuration; + +namespace Umbraco.Core.Configuration.BaseRest +{ + + [ConfigurationCollection(typeof(ExtensionElement), CollectionType = ConfigurationElementCollectionType.BasicMapAlternate)] + internal class ExtensionElement : ConfigurationElementCollection, IEnumerable, IExtension + { + const string KeyAlias = "alias"; + const string KeyType = "type"; + const string KeyMethod = "method"; + + [ConfigurationProperty(KeyAlias, IsKey = true, IsRequired = true)] + public string Alias + { + get { return (string)base[KeyAlias]; } + } + + [ConfigurationProperty(KeyType, IsKey = false, IsRequired = true)] + public string Type + { + get { return (string)base[KeyType]; } + } + + public override ConfigurationElementCollectionType CollectionType + { + get { return ConfigurationElementCollectionType.BasicMapAlternate; } + } + + protected override string ElementName + { + get { return KeyMethod; } + } + + protected override bool IsElementName(string elementName) + { + return elementName.Equals(KeyMethod, StringComparison.InvariantCultureIgnoreCase); + } + + protected override ConfigurationElement CreateNewElement() + { + return new MethodElement(); + } + + protected override object GetElementKey(ConfigurationElement element) + { + return ((MethodElement)element).Name; + } + + public override bool IsReadOnly() + { + return false; + } + + new public MethodElement this[string index] + { + get { return (MethodElement)BaseGet(index); } + } + + IEnumerator IEnumerable.GetEnumerator() + { + for (var i = 0; i < Count; i++) + { + yield return BaseGet(i) as IMethod; + } + } + + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + IMethod IExtension.this[string index] + { + get { return this[index]; } + } + + } +} diff --git a/src/Umbraco.Web/BaseRest/Configuration/ExtensionElementCollection.cs b/src/Umbraco.Core/Configuration/BaseRest/ExtensionElementCollection.cs similarity index 57% rename from src/Umbraco.Web/BaseRest/Configuration/ExtensionElementCollection.cs rename to src/Umbraco.Core/Configuration/BaseRest/ExtensionElementCollection.cs index 5413d57bff..0e9691606d 100644 --- a/src/Umbraco.Web/BaseRest/Configuration/ExtensionElementCollection.cs +++ b/src/Umbraco.Core/Configuration/BaseRest/ExtensionElementCollection.cs @@ -1,49 +1,70 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Configuration; - -namespace Umbraco.Web.BaseRest.Configuration -{ - [ConfigurationCollection(typeof(ExtensionElement), CollectionType = ConfigurationElementCollectionType.BasicMapAlternate)] - public class ExtensionElementCollection : ConfigurationElementCollection - { - const string KeyExtension = "extension"; - - public override ConfigurationElementCollectionType CollectionType - { - get { return ConfigurationElementCollectionType.BasicMapAlternate; } - } - - protected override string ElementName - { - get { return KeyExtension; } - } - - protected override bool IsElementName(string elementName) - { - return elementName.Equals(KeyExtension, StringComparison.InvariantCultureIgnoreCase); - } - - protected override ConfigurationElement CreateNewElement() - { - return new ExtensionElement(); - } - - protected override object GetElementKey(ConfigurationElement element) - { - return ((ExtensionElement)element).Alias; - } - - public override bool IsReadOnly() - { - return false; - } - - new public ExtensionElement this[string index] - { - get { return (ExtensionElement)BaseGet(index); } - } - } -} +using System; +using System.Collections.Generic; +using System.Configuration; + +namespace Umbraco.Core.Configuration.BaseRest +{ + public interface IExtensionsCollection : IEnumerable + { + IExtension this[string index] { get; } + } + + [ConfigurationCollection(typeof(ExtensionElement), CollectionType = ConfigurationElementCollectionType.BasicMapAlternate)] + internal class ExtensionElementCollection : ConfigurationElementCollection, IExtensionsCollection + { + const string KeyExtension = "extension"; + + public override ConfigurationElementCollectionType CollectionType + { + get { return ConfigurationElementCollectionType.BasicMapAlternate; } + } + + protected override string ElementName + { + get { return KeyExtension; } + } + + protected override bool IsElementName(string elementName) + { + return elementName.Equals(KeyExtension, StringComparison.InvariantCultureIgnoreCase); + } + + protected override ConfigurationElement CreateNewElement() + { + return new ExtensionElement(); + } + + protected override object GetElementKey(ConfigurationElement element) + { + return ((ExtensionElement)element).Alias; + } + + public override bool IsReadOnly() + { + return false; + } + + new public ExtensionElement this[string index] + { + get { return (ExtensionElement)BaseGet(index); } + } + + IEnumerator IEnumerable.GetEnumerator() + { + for (var i = 0; i < Count; i++) + { + yield return BaseGet(i) as IExtension; + } + } + + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + IExtension IExtensionsCollection.this[string index] + { + get { return this[index]; } + } + } +} diff --git a/src/Umbraco.Core/Configuration/BaseRest/IBaseRest.cs b/src/Umbraco.Core/Configuration/BaseRest/IBaseRest.cs new file mode 100644 index 0000000000..00e72a54a3 --- /dev/null +++ b/src/Umbraco.Core/Configuration/BaseRest/IBaseRest.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; + +namespace Umbraco.Core.Configuration.BaseRest +{ + public interface IBaseRest + { + IExtensionsCollection Items { get; } + + /// + /// Gets a value indicating whether base rest extensions are enabled. + /// + bool Enabled { get; } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Configuration/BaseRest/IExtension.cs b/src/Umbraco.Core/Configuration/BaseRest/IExtension.cs new file mode 100644 index 0000000000..a40c83422b --- /dev/null +++ b/src/Umbraco.Core/Configuration/BaseRest/IExtension.cs @@ -0,0 +1,11 @@ +namespace Umbraco.Core.Configuration.BaseRest +{ + public interface IExtension + { + string Alias { get; } + + string Type { get; } + + IMethod this[string index] { get; } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Configuration/BaseRest/IMethod.cs b/src/Umbraco.Core/Configuration/BaseRest/IMethod.cs new file mode 100644 index 0000000000..c1e9f00357 --- /dev/null +++ b/src/Umbraco.Core/Configuration/BaseRest/IMethod.cs @@ -0,0 +1,17 @@ +namespace Umbraco.Core.Configuration.BaseRest +{ + public interface IMethod + { + string Name { get; } + + bool AllowAll { get; } + + string AllowGroup { get; } + + string AllowType { get; } + + string AllowMember { get; } + + bool ReturnXml { get; } + } +} \ No newline at end of file diff --git a/src/Umbraco.Web/BaseRest/Configuration/MethodElement.cs b/src/Umbraco.Core/Configuration/BaseRest/MethodElement.cs similarity index 89% rename from src/Umbraco.Web/BaseRest/Configuration/MethodElement.cs rename to src/Umbraco.Core/Configuration/BaseRest/MethodElement.cs index 79ad52e182..c9a06006ea 100644 --- a/src/Umbraco.Web/BaseRest/Configuration/MethodElement.cs +++ b/src/Umbraco.Core/Configuration/BaseRest/MethodElement.cs @@ -1,50 +1,50 @@ -using System.Configuration; - -namespace Umbraco.Web.BaseRest.Configuration -{ - public class MethodElement : ConfigurationElement - { - const string KeyName = "name"; - const string KeyAllowAll = "allowAll"; - const string KeyAllowGroup = "allowGroup"; - const string KeyAllowType = "allowType"; - const string KeyAllowMember = "allowMember"; - const string KeyReturnXml = "returnXml"; - - [ConfigurationProperty(KeyName, IsKey = true, IsRequired = true)] - public string Name - { - get { return (string)base[KeyName]; } - } - - [ConfigurationProperty(KeyAllowAll, IsKey = false, IsRequired = false, DefaultValue = false)] - public bool AllowAll - { - get { return (bool)base[KeyAllowAll]; } - } - - [ConfigurationProperty(KeyAllowGroup, IsKey = false, IsRequired = false, DefaultValue = null)] - public string AllowGroup - { - get { return (string)base[KeyAllowGroup]; } - } - - [ConfigurationProperty(KeyAllowType, IsKey = false, IsRequired = false, DefaultValue = null)] - public string AllowType - { - get { return (string)base[KeyAllowType]; } - } - - [ConfigurationProperty(KeyAllowMember, IsKey = false, IsRequired = false, DefaultValue = null)] - public string AllowMember - { - get { return (string)base[KeyAllowMember]; } - } - - [ConfigurationProperty(KeyReturnXml, IsKey = false, IsRequired = false, DefaultValue = true)] - public bool ReturnXml - { - get { return (bool)base[KeyReturnXml]; } - } - } -} +using System.Configuration; + +namespace Umbraco.Core.Configuration.BaseRest +{ + internal class MethodElement : ConfigurationElement, IMethod + { + const string KeyName = "name"; + const string KeyAllowAll = "allowAll"; + const string KeyAllowGroup = "allowGroup"; + const string KeyAllowType = "allowType"; + const string KeyAllowMember = "allowMember"; + const string KeyReturnXml = "returnXml"; + + [ConfigurationProperty(KeyName, IsKey = true, IsRequired = true)] + public string Name + { + get { return (string)base[KeyName]; } + } + + [ConfigurationProperty(KeyAllowAll, IsKey = false, IsRequired = false, DefaultValue = false)] + public bool AllowAll + { + get { return (bool)base[KeyAllowAll]; } + } + + [ConfigurationProperty(KeyAllowGroup, IsKey = false, IsRequired = false, DefaultValue = null)] + public string AllowGroup + { + get { return (string)base[KeyAllowGroup]; } + } + + [ConfigurationProperty(KeyAllowType, IsKey = false, IsRequired = false, DefaultValue = null)] + public string AllowType + { + get { return (string)base[KeyAllowType]; } + } + + [ConfigurationProperty(KeyAllowMember, IsKey = false, IsRequired = false, DefaultValue = null)] + public string AllowMember + { + get { return (string)base[KeyAllowMember]; } + } + + [ConfigurationProperty(KeyReturnXml, IsKey = false, IsRequired = false, DefaultValue = true)] + public bool ReturnXml + { + get { return (bool)base[KeyReturnXml]; } + } + } +} diff --git a/src/Umbraco.Core/Configuration/LegacyUmbracoSettings.cs b/src/Umbraco.Core/Configuration/LegacyUmbracoSettings.cs deleted file mode 100644 index c9b1c2347c..0000000000 --- a/src/Umbraco.Core/Configuration/LegacyUmbracoSettings.cs +++ /dev/null @@ -1,1428 +0,0 @@ -using System; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Threading; -using System.Web; -using System.Web.Caching; -using System.Web.Security; -using System.Xml; -using System.Configuration; - -using System.Collections.Generic; -using Umbraco.Core.Logging; -using Umbraco.Core.CodeAnnotations; - - -namespace Umbraco.Core.Configuration -{ - //NOTE: Do not expose this class ever until we cleanup all configuration including removal of static classes, etc... - // we have this two tasks logged: - // http://issues.umbraco.org/issue/U4-58 - // http://issues.umbraco.org/issue/U4-115 - - //TODO: Re-enable logging !!!! - - //TODO: We need to convert this to a real section, it's currently using HttpRuntime.Cache to detect cahnges, this is real poor, especially in a console app - - /// - /// The UmbracoSettings Class contains general settings information for the entire Umbraco instance based on information from the /config/umbracoSettings.config file - /// - internal class LegacyUmbracoSettings - { - private static bool GetKeyValue(string key, bool defaultValue) - { - bool value; - string stringValue = GetKey(key); - - if (string.IsNullOrWhiteSpace(stringValue)) - return defaultValue; - if (bool.TryParse(stringValue, out value)) - return value; - return defaultValue; - } - - private static int GetKeyValue(string key, int defaultValue) - { - int value; - string stringValue = GetKey(key); - - if (string.IsNullOrWhiteSpace(stringValue)) - return defaultValue; - if (int.TryParse(stringValue, out value)) - return value; - return defaultValue; - } - - /// - /// Used in unit testing to reset all config items that were set with property setters (i.e. did not come from config) - /// - private static void ResetInternal() - { - _addTrailingSlash = null; - _forceSafeAliases = null; - _useLegacySchema = null; - _useDomainPrefixes = null; - _umbracoLibraryCacheDuration = null; - SettingsFilePath = null; - } - - internal const string TempFriendlyXmlChildContainerNodename = ""; // "children"; - - /// - /// Gets the umbraco settings document. - /// - /// The _umbraco settings. - internal static XmlDocument UmbracoSettingsXmlDoc - { - get - { - var us = (XmlDocument)HttpRuntime.Cache["umbracoSettingsFile"] ?? EnsureSettingsDocument(); - return us; - } - } - - private static string _path; - - /// - /// Gets/sets the settings file path, the setter can be used in unit tests - /// - internal static string SettingsFilePath - { - get { return _path ?? (_path = GlobalSettings.FullpathToRoot + Path.DirectorySeparatorChar + "config" + Path.DirectorySeparatorChar); } - set { _path = value; } - } - - internal const string Filename = "umbracoSettings.config"; - - internal static XmlDocument EnsureSettingsDocument() - { - var settingsFile = HttpRuntime.Cache["umbracoSettingsFile"]; - - // Check for language file in cache - if (settingsFile == null) - { - var temp = new XmlDocument(); - var settingsReader = new XmlTextReader(SettingsFilePath + Filename); - try - { - temp.Load(settingsReader); - HttpRuntime.Cache.Insert("umbracoSettingsFile", temp, - new CacheDependency(SettingsFilePath + Filename)); - } - catch (XmlException e) - { - throw new XmlException("Your umbracoSettings.config file fails to pass as valid XML. Refer to the InnerException for more information", e); - } - catch (Exception e) - { - LogHelper.Error("Error reading umbracoSettings file: " + e.ToString(), e); - } - settingsReader.Close(); - return temp; - } - else - return (XmlDocument)settingsFile; - } - - internal static void Save() - { - UmbracoSettingsXmlDoc.Save(SettingsFilePath + Filename); - } - - - /// - /// Selects a xml node in the umbraco settings config file. - /// - /// The xpath query to the specific node. - /// If found, it returns the specific configuration xml node. - internal static XmlNode GetKeyAsNode(string key) - { - if (key == null) - throw new ArgumentException("Key cannot be null"); - EnsureSettingsDocument(); - if (UmbracoSettingsXmlDoc == null || UmbracoSettingsXmlDoc.DocumentElement == null) - return null; - return UmbracoSettingsXmlDoc.DocumentElement.SelectSingleNode(key); - } - - /// - /// Gets the value of configuration xml node with the specified key. - /// - /// The key. - /// - internal static string GetKey(string key) - { - EnsureSettingsDocument(); - - string attrName = null; - var pos = key.IndexOf('@'); - if (pos > 0) - { - attrName = key.Substring(pos + 1); - key = key.Substring(0, pos - 1); - } - - var node = UmbracoSettingsXmlDoc.DocumentElement.SelectSingleNode(key); - if (node == null) - return string.Empty; - - if (pos < 0) - { - if (node.FirstChild == null || node.FirstChild.Value == null) - return string.Empty; - return node.FirstChild.Value; - } - else - { - var attr = node.Attributes[attrName]; - if (attr == null) - return string.Empty; - return attr.Value; - } - } - - /// - /// Gets a value indicating whether the media library will create new directories in the /media directory. - /// - /// - /// true if new directories are allowed otherwise, false. - /// - internal static bool UploadAllowDirectories - { - get { return bool.Parse(GetKey("/settings/content/UploadAllowDirectories")); } - } - - /// - /// THIS IS TEMPORARY until we fix up settings all together, this setting is actually not 'settable' but is - /// here for future purposes since we check for thsi settings in the module. - /// - internal static bool EnableBaseRestHandler - { - get { return true; } - } - - /// - /// THIS IS TEMPORARY until we fix up settings all together, this setting is actually not 'settable' but is - /// here for future purposes since we check for thsi settings in the module. - /// - internal static string BootSplashPage - { - get { return "~/config/splashes/booting.aspx"; } - } - - /// - /// Gets a value indicating whether logging is enabled in umbracoSettings.config (/settings/logging/enableLogging). - /// - /// true if logging is enabled; otherwise, false. - internal static bool EnableLogging - { - get - { - // We return true if no enable logging element is present in - // umbracoSettings (to enable default behaviour when upgrading) - var enableLogging = GetKey("/settings/logging/enableLogging"); - return String.IsNullOrEmpty(enableLogging) || bool.Parse(enableLogging); - } - } - - /// - /// Gets a value indicating whether logging happens async. - /// - /// true if async logging is enabled; otherwise, false. - internal static bool EnableAsyncLogging - { - get - { - string value = GetKey("/settings/logging/enableAsyncLogging"); - bool result; - if (!string.IsNullOrEmpty(value) && bool.TryParse(value, out result)) - return result; - return false; - } - } - - /// - /// Gets the assembly of an external logger that can be used to store log items in 3rd party systems - /// - internal static string ExternalLoggerAssembly - { - get - { - var value = GetKeyAsNode("/settings/logging/externalLogger"); - return value != null ? value.Attributes["assembly"].Value : ""; - } - } - - /// - /// Gets the type of an external logger that can be used to store log items in 3rd party systems - /// - internal static string ExternalLoggerType - { - get - { - var value = GetKeyAsNode("/settings/logging/externalLogger"); - return value != null ? value.Attributes["type"].Value : ""; - } - } - - /// - /// Long Audit Trail to external log too - /// - internal static bool ExternalLoggerLogAuditTrail - { - get - { - var value = GetKeyAsNode("/settings/logging/externalLogger"); - if (value != null) - { - var logAuditTrail = value.Attributes["logAuditTrail"].Value; - bool result; - if (!string.IsNullOrEmpty(logAuditTrail) && bool.TryParse(logAuditTrail, out result)) - return result; - } - return false; - } - } - - /// - /// Keep user alive as long as they have their browser open? Default is true - /// - internal static bool KeepUserLoggedIn - { - get - { - var value = GetKey("/settings/security/keepUserLoggedIn"); - bool result; - if (!string.IsNullOrEmpty(value) && bool.TryParse(value, out result)) - return result; - return true; - } - } - - internal static string AuthCookieName - { - get - { - var value = GetKey("/settings/security/authCookieName"); - if (string.IsNullOrEmpty(value) == false) - { - return value; - } - return "UMB_UCONTEXT"; - } - } - - internal static string AuthCookieDomain - { - get - { - var value = GetKey("/settings/security/authCookieDomain"); - if (string.IsNullOrEmpty(value) == false) - { - return value; - } - return FormsAuthentication.CookieDomain; - } - } - - /// - /// Enables the experimental canvas (live) editing on the frontend of the website - /// - internal static bool EnableCanvasEditing - { - get - { - var value = GetKey("/settings/content/EnableCanvasEditing"); - bool result; - if (!string.IsNullOrEmpty(value) && bool.TryParse(value, out result)) - return result; - return true; - } - } - - /// - /// Show disabled users in the tree in the Users section in the backoffice - /// - internal static bool HideDisabledUsersInBackoffice - { - get - { - string value = GetKey("/settings/security/hideDisabledUsersInBackoffice"); - bool result; - if (!string.IsNullOrEmpty(value) && bool.TryParse(value, out result)) - return result; - return false; - } - } - - /// - /// Gets a value indicating whether the logs will be auto cleaned - /// - /// true if logs are to be automatically cleaned; otherwise, false - internal static bool AutoCleanLogs - { - get - { - string value = GetKey("/settings/logging/autoCleanLogs"); - bool result; - if (!string.IsNullOrEmpty(value) && bool.TryParse(value, out result)) - return result; - return false; - } - } - - /// - /// Gets the value indicating the log cleaning frequency (in miliseconds) - /// - internal static int CleaningMiliseconds - { - get - { - string value = GetKey("/settings/logging/cleaningMiliseconds"); - int result; - if (!string.IsNullOrEmpty(value) && int.TryParse(value, out result)) - return result; - return -1; - } - } - - internal static int MaxLogAge - { - get - { - string value = GetKey("/settings/logging/maxLogAge"); - int result; - if (!string.IsNullOrEmpty(value) && int.TryParse(value, out result)) - return result; - return -1; - } - } - - /// - /// Gets the disabled log types. - /// - /// The disabled log types. - internal static XmlNode DisabledLogTypes - { - get { return GetKeyAsNode("/settings/logging/disabledLogTypes"); } - } - - /// - /// Gets the package server url. - /// - /// The package server url. - internal static string PackageServer - { - get { return "packages.umbraco.org"; } - } - - static bool? _useDomainPrefixes = null; - - /// - /// Gets a value indicating whether umbraco will use domain prefixes. - /// - /// true if umbraco will use domain prefixes; otherwise, false. - internal static bool UseDomainPrefixes - { - get - { - // default: false - return _useDomainPrefixes ?? GetKeyValue("/settings/requestHandler/useDomainPrefixes", false); - } - /*internal*/ set - { - // for unit tests only - _useDomainPrefixes = value; - } - } - - static bool? _addTrailingSlash = null; - - /// - /// This will add a trailing slash (/) to urls when in directory url mode - /// NOTICE: This will always return false if Directory Urls in not active - /// - internal static bool AddTrailingSlash - { - get - { - // default: false - return GlobalSettings.UseDirectoryUrls - && (_addTrailingSlash ?? GetKeyValue("/settings/requestHandler/addTrailingSlash", false)); - } - /*internal*/ set - { - // for unit tests only - _addTrailingSlash = value; - } - } - - /// - /// Gets a value indicating whether umbraco will use ASP.NET MasterPages for rendering instead of its propriatary templating system. - /// - /// true if umbraco will use ASP.NET MasterPages; otherwise, false. - internal static bool UseAspNetMasterPages - { - get - { - try - { - bool result; - if (bool.TryParse(GetKey("/settings/templates/useAspNetMasterPages"), out result)) - return result; - return false; - } - catch - { - return false; - } - } - } - - /// - /// Gets a value indicating whether umbraco will attempt to load any skins to override default template files - /// - /// true if umbraco will override templates with skins if present and configured false. - internal static bool EnableTemplateFolders - { - get - { - try - { - bool result; - if (bool.TryParse(GetKey("/settings/templates/enableTemplateFolders"), out result)) - return result; - return false; - } - catch - { - return false; - } - } - } - - //TODO: I"m not sure why we need this, need to ask Gareth what the deal is, pretty sure we can remove it or change it, seems like - // massive overkill. - - /// - /// razor DynamicNode typecasting detects XML and returns DynamicXml - Root elements that won't convert to DynamicXml - /// - internal static IEnumerable NotDynamicXmlDocumentElements - { - get - { - try - { - List items = new List(); - XmlNode root = GetKeyAsNode("/settings/scripting/razor/notDynamicXmlDocumentElements"); - foreach (XmlNode element in root.SelectNodes(".//element")) - { - items.Add(element.InnerText); - } - return items; - } - catch - { - return new List() { "p", "div" }; - } - } - } - - private static IEnumerable _razorDataTypeModelStaticMapping; - private static readonly ReaderWriterLockSlim Lock = new ReaderWriterLockSlim(); - - internal static IEnumerable RazorDataTypeModelStaticMapping - { - get - { - /* - - DigibizAdvancedMediaPicker.RazorModel.ModelBinder - DigibizAdvancedMediaPicker.RazorModel.ModelBinder - - */ - - using (var l = new UpgradeableReadLock(Lock)) - { - if (_razorDataTypeModelStaticMapping == null) - { - l.UpgradeToWriteLock(); - - List items = new List(); - XmlNode root = GetKeyAsNode("/settings/scripting/razor/dataTypeModelStaticMappings"); - if (root != null) - { - foreach (XmlNode element in root.SelectNodes(".//mapping")) - { - string propertyTypeAlias = null, nodeTypeAlias = null; - Guid? dataTypeGuid = null; - if (!string.IsNullOrEmpty(element.InnerText)) - { - if (element.Attributes["dataTypeGuid"] != null) - { - dataTypeGuid = (Guid?)new Guid(element.Attributes["dataTypeGuid"].Value); - } - if (element.Attributes["propertyTypeAlias"] != null && !string.IsNullOrEmpty(element.Attributes["propertyTypeAlias"].Value)) - { - propertyTypeAlias = element.Attributes["propertyTypeAlias"].Value; - } - if (element.Attributes["nodeTypeAlias"] != null && !string.IsNullOrEmpty(element.Attributes["nodeTypeAlias"].Value)) - { - nodeTypeAlias = element.Attributes["nodeTypeAlias"].Value; - } - items.Add(new RazorDataTypeModelStaticMappingItem() - { - DataTypeGuid = dataTypeGuid, - PropertyTypeAlias = propertyTypeAlias, - NodeTypeAlias = nodeTypeAlias, - TypeName = element.InnerText, - Raw = element.OuterXml - }); - } - } - } - - _razorDataTypeModelStaticMapping = items; - } - - return _razorDataTypeModelStaticMapping; - } - } - } - - /// - /// Gets a value indicating whether umbraco will clone XML cache on publish. - /// - /// - /// true if umbraco will clone XML cache on publish; otherwise, false. - /// - internal static bool CloneXmlCacheOnPublish - { - get - { - try - { - bool result; - if (bool.TryParse(GetKey("/settings/content/cloneXmlContent"), out result)) - return result; - return false; - } - catch - { - return false; - } - } - } - - /// - /// Gets a value indicating whether rich text editor content should be parsed by tidy. - /// - /// true if content is parsed; otherwise, false. - internal static bool TidyEditorContent - { - get { return bool.Parse(GetKey("/settings/content/TidyEditorContent")); } - } - - /// - /// Gets the encoding type for the tidyied content. - /// - /// The encoding type as string. - internal static string TidyCharEncoding - { - get - { - string encoding = GetKey("/settings/content/TidyCharEncoding"); - if (String.IsNullOrEmpty(encoding)) - { - encoding = "UTF8"; - } - return encoding; - } - } - - /// - /// Gets the property context help option, this can either be 'text', 'icon' or 'none' - /// - /// The property context help option. - internal static string PropertyContextHelpOption - { - get { return GetKey("/settings/content/PropertyContextHelpOption").ToLower(); } - } - - internal static string DefaultBackofficeProvider - { - get - { - string defaultProvider = GetKey("/settings/providers/users/DefaultBackofficeProvider"); - if (String.IsNullOrEmpty(defaultProvider)) - defaultProvider = "UsersMembershipProvider"; - - return defaultProvider; - } - } - - private static bool? _forceSafeAliases; - - /// - /// Whether to force safe aliases (no spaces, no special characters) at businesslogic level on contenttypes and propertytypes - /// - internal static bool ForceSafeAliases - { - get - { - // default: true - return _forceSafeAliases ?? GetKeyValue("/settings/content/ForceSafeAliases", true); - } - /*internal*/ set - { - // used for unit testing - _forceSafeAliases = value; - } - } - - /// - /// Gets a value indicating whether to try to skip IIS custom errors. - /// - [UmbracoWillObsolete("Use UmbracoSettings.For.TrySkipIisCustomErrors instead.")] - internal static bool TrySkipIisCustomErrors - { - get { return GetKeyValue("/settings/web.routing/@trySkipIisCustomErrors", false); } - } - - /// - /// Gets a value indicating whether internal redirect preserves the template. - /// - [UmbracoWillObsolete("Use UmbracoSettings.For.InternalRedirectPerservesTemplate instead.")] - internal static bool InternalRedirectPreservesTemplate - { - get { return GetKeyValue("/settings/web.routing/@internalRedirectPreservesTemplate", false); } - } - - /// - /// File types that will not be allowed to be uploaded via the content/media upload control - /// - public static IEnumerable DisallowedUploadFiles - { - get - { - var val = GetKey("/settings/content/disallowedUploadFiles"); - return val.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries); - } - } - - /// - /// Gets the allowed image file types. - /// - /// The allowed image file types. - internal static string ImageFileTypes - { - get { return GetKey("/settings/content/imaging/imageFileTypes").ToLowerInvariant(); } - } - - /// - /// Gets the allowed script file types. - /// - /// The allowed script file types. - internal static string ScriptFileTypes - { - get { return GetKey("/settings/content/scripteditor/scriptFileTypes"); } - } - - private static int? _umbracoLibraryCacheDuration; - - /// - /// Gets the duration in seconds to cache queries to umbraco library member and media methods - /// Default is 1800 seconds (30 minutes) - /// - internal static int UmbracoLibraryCacheDuration - { - get - { - // default: 1800 - return _umbracoLibraryCacheDuration ?? GetKeyValue("/settings/content/UmbracoLibraryCacheDuration", 1800); - } - /*internal*/ set - { - // for unit tests only - _umbracoLibraryCacheDuration = value; - } - } - - /// - /// Gets the path to the scripts folder used by the script editor. - /// - /// The script folder path. - internal static string ScriptFolderPath - { - get { return GetKey("/settings/content/scripteditor/scriptFolderPath"); } - } - - /// - /// Enabled or disable the script/code editor - /// - internal static bool ScriptDisableEditor - { - get - { - string _tempValue = GetKey("/settings/content/scripteditor/scriptDisableEditor"); - if (_tempValue != String.Empty) - return bool.Parse(_tempValue); - else - return false; - } - } - - /// - /// Gets a value indicating whether umbraco will ensure unique node naming. - /// This will ensure that nodes cannot have the same url, but will add extra characters to a url. - /// ex: existingnodename.aspx would become existingnodename(1).aspx if a node with the same name is found - /// - /// true if umbraco ensures unique node naming; otherwise, false. - internal static bool EnsureUniqueNaming - { - get - { - try - { - return bool.Parse(GetKey("/settings/content/ensureUniqueNaming")); - } - catch - { - return false; - } - } - } - - /// - /// Gets the notification email sender. - /// - /// The notification email sender. - internal static string NotificationEmailSender - { - get { return GetKey("/settings/content/notifications/email"); } - } - - /// - /// Gets a value indicating whether notification-emails are HTML. - /// - /// - /// true if html notification-emails are disabled; otherwise, false. - /// - internal static bool NotificationDisableHtmlEmail - { - get - { - var tempValue = GetKey("/settings/content/notifications/disableHtmlEmail"); - return tempValue != String.Empty && bool.Parse(tempValue); - } - } - - /// - /// Gets the allowed attributes on images. - /// - /// The allowed attributes on images. - internal static string ImageAllowedAttributes - { - get { return GetKey("/settings/content/imaging/allowedAttributes"); } - } - - internal static XmlNode ImageAutoFillImageProperties - { - get { return GetKeyAsNode("/settings/content/imaging/autoFillImageProperties"); } - } - - /// - /// Gets the scheduled tasks as XML - /// - /// The scheduled tasks. - internal static XmlNode ScheduledTasks - { - get { return GetKeyAsNode("/settings/scheduledTasks"); } - } - - /// - /// Gets a list of characters that will be replaced when generating urls - /// - /// The URL replacement characters. - internal static XmlNode UrlReplaceCharacters - { - get { return GetKeyAsNode("/settings/requestHandler/urlReplacing"); } - } - - /// - /// Whether to replace double dashes from url (ie my--story----from--dash.aspx caused by multiple url replacement chars - /// - internal static bool RemoveDoubleDashesFromUrlReplacing - { - get - { - try - { - return bool.Parse(UrlReplaceCharacters.Attributes.GetNamedItem("removeDoubleDashes").Value); - } - catch - { - return false; - } - } - } - - /// - /// Gets a value indicating whether umbraco will use distributed calls. - /// This enables umbraco to share cache and content across multiple servers. - /// Used for load-balancing high-traffic sites. - /// - /// true if umbraco uses distributed calls; otherwise, false. - internal static bool UseDistributedCalls - { - get - { - try - { - return bool.Parse(GetKeyAsNode("/settings/distributedCall").Attributes.GetNamedItem("enable").Value); - } - catch - { - return false; - } - } - } - - - /// - /// Gets the ID of the user with access rights to perform the distributed calls. - /// - /// The distributed call user. - internal static int DistributedCallUser - { - get - { - try - { - return int.Parse(GetKey("/settings/distributedCall/user")); - } - catch - { - return -1; - } - } - } - - /// - /// Gets the html injected into a (x)html page if Umbraco is running in preview mode - /// - internal static string PreviewBadge - { - get - { - try - { - return GetKey("/settings/content/PreviewBadge"); - } - catch - { - return "In Preview Mode - click to end"; - } - } - } - - /// - /// Gets IP or hostnames of the distribution servers. - /// These servers will receive a call everytime content is created/deleted/removed - /// and update their content cache accordingly, ensuring a consistent cache on all servers - /// - /// The distribution servers. - internal static XmlNode DistributionServers - { - get - { - try - { - return GetKeyAsNode("/settings/distributedCall/servers"); - } - catch - { - return null; - } - } - } - - /// - /// Gets HelpPage configurations. - /// A help page configuration specify language, user type, application, application url and - /// the target help page url. - /// - internal static XmlNode HelpPages - { - get - { - try - { - return GetKeyAsNode("/settings/help"); - } - catch - { - return null; - } - } - } - - /// - /// Gets all repositories registered, and returns them as XmlNodes, containing name, alias and webservice url. - /// These repositories are used by the build-in package installer and uninstaller to install new packages and check for updates. - /// All repositories should have a unique alias. - /// All packages installed from a repository gets the repository alias included in the install information - /// - /// The repository servers. - internal static XmlNode Repositories - { - get - { - try - { - return GetKeyAsNode("/settings/repositories"); - } - catch - { - return null; - } - } - } - - /// - /// Gets a value indicating whether umbraco will use the viewstate mover module. - /// The viewstate mover will move all asp.net viewstate information to the bottom of the aspx page - /// to ensure that search engines will index text instead of javascript viewstate information. - /// - /// - /// true if umbraco will use the viewstate mover module; otherwise, false. - /// - internal static bool UseViewstateMoverModule - { - get - { - try - { - return - bool.Parse( - GetKeyAsNode("/settings/viewstateMoverModule").Attributes.GetNamedItem("enable").Value); - } - catch - { - return false; - } - } - } - - - /// - /// Tells us whether the Xml Content cache is disabled or not - /// Default is enabled - /// - internal static bool IsXmlContentCacheDisabled - { - get - { - try - { - bool xmlCacheEnabled; - string value = GetKey("/settings/content/XmlCacheEnabled"); - if (bool.TryParse(value, out xmlCacheEnabled)) - return !xmlCacheEnabled; - // Return default - return false; - } - catch - { - return false; - } - } - } - - /// - /// Check if there's changes to the umbraco.config xml file cache on disk on each request - /// Makes it possible to updates environments by syncing the umbraco.config file across instances - /// Relates to http://umbraco.codeplex.com/workitem/30722 - /// - internal static bool XmlContentCheckForDiskChanges - { - get - { - try - { - bool checkForDiskChanges; - string value = GetKey("/settings/content/XmlContentCheckForDiskChanges"); - if (bool.TryParse(value, out checkForDiskChanges)) - return checkForDiskChanges; - // Return default - return false; - } - catch - { - return false; - } - } - } - - /// - /// If this is enabled, all Umbraco objects will generate data in the preview table (cmsPreviewXml). - /// If disabled, only documents will generate data. - /// This feature is useful if anyone would like to see how data looked at a given time - /// - internal static bool EnableGlobalPreviewStorage - { - get - { - try - { - bool globalPreviewEnabled = false; - string value = GetKey("/settings/content/GlobalPreviewStorageEnabled"); - if (bool.TryParse(value, out globalPreviewEnabled)) - return !globalPreviewEnabled; - // Return default - return false; - } - catch - { - return false; - } - } - } - - private static bool? _useLegacySchema; - - /// - /// Whether to use the new 4.1 schema or the old legacy schema - /// - /// - /// true if yes, use the old node/data model; otherwise, false. - /// - internal static bool UseLegacyXmlSchema - { - get - { - // default: true - return _useLegacySchema ?? GetKeyValue("/settings/content/UseLegacyXmlSchema", false); - } - /*internal*/ set - { - // used for unit testing - _useLegacySchema = value; - } - } - - [Obsolete("This setting is not used anymore, the only file extensions that are supported are .cs and .vb files")] - internal static IEnumerable AppCodeFileExtensionsList - { - get - { - return (from XmlNode x in AppCodeFileExtensions - where !String.IsNullOrEmpty(x.InnerText) - select x.InnerText).ToList(); - } - } - - [Obsolete("This setting is not used anymore, the only file extensions that are supported are .cs and .vb files")] - internal static XmlNode AppCodeFileExtensions - { - get - { - XmlNode value = GetKeyAsNode("/settings/developer/appCodeFileExtensions"); - if (value != null) - { - return value; - } - - // default is .cs and .vb - value = UmbracoSettingsXmlDoc.CreateElement("appCodeFileExtensions"); - value.AppendChild(XmlHelper.AddTextNode(UmbracoSettingsXmlDoc, "ext", "cs")); - value.AppendChild(XmlHelper.AddTextNode(UmbracoSettingsXmlDoc, "ext", "vb")); - return value; - } - } - - /// - /// Tells us whether the Xml to always update disk cache, when changes are made to content - /// Default is enabled - /// - internal static bool ContinouslyUpdateXmlDiskCache - { - get - { - try - { - bool updateDiskCache; - string value = GetKey("/settings/content/ContinouslyUpdateXmlDiskCache"); - if (bool.TryParse(value, out updateDiskCache)) - return updateDiskCache; - // Return default - return false; - } - catch - { - return true; - } - } - } - - /// - /// Tells us whether to use a splash page while umbraco is initializing content. - /// If not, requests are queued while umbraco loads content. For very large sites (+10k nodes) it might be usefull to - /// have a splash page - /// Default is disabled - /// - internal static bool EnableSplashWhileLoading - { - get - { - try - { - bool updateDiskCache; - string value = GetKey("/settings/content/EnableSplashWhileLoading"); - if (bool.TryParse(value, out updateDiskCache)) - return updateDiskCache; - // Return default - return false; - } - catch - { - return false; - } - } - } - - private static bool? _resolveUrlsFromTextString; - internal static bool ResolveUrlsFromTextString - { - get - { - if (_resolveUrlsFromTextString == null) - { - try - { - bool enableDictionaryFallBack; - var value = GetKey("/settings/content/ResolveUrlsFromTextString"); - if (value != null) - if (bool.TryParse(value, out enableDictionaryFallBack)) - _resolveUrlsFromTextString = enableDictionaryFallBack; - } - catch (Exception ex) - { - Trace.WriteLine("Could not load /settings/content/ResolveUrlsFromTextString from umbracosettings.config:\r\n {0}", - ex.Message); - - // set url resolving to true (default (legacy) behavior) to ensure we don't keep writing to trace - _resolveUrlsFromTextString = true; - } - } - return _resolveUrlsFromTextString == true; - } - } - - - private static RenderingEngine? _defaultRenderingEngine; - - /// - /// Enables MVC, and at the same time disable webform masterpage templates. - /// This ensure views are automaticly created instead of masterpages. - /// Views are display in the tree instead of masterpages and a MVC template editor - /// is used instead of the masterpages editor - /// - /// true if umbraco defaults to using MVC views for templating, otherwise false. - internal static RenderingEngine DefaultRenderingEngine - { - get - { - if (_defaultRenderingEngine == null) - { - try - { - var engine = RenderingEngine.WebForms; - var value = GetKey("/settings/templates/defaultRenderingEngine"); - if (value != null) - { - Enum.TryParse(value, true, out engine); - } - _defaultRenderingEngine = engine; - } - catch (Exception ex) - { - LogHelper.Error("Could not load /settings/templates/defaultRenderingEngine from umbracosettings.config", ex); - _defaultRenderingEngine = RenderingEngine.WebForms; - } - } - return _defaultRenderingEngine.Value; - } - //internal set - //{ - // _defaultRenderingEngine = value; - // var node = UmbracoSettingsXmlDoc.DocumentElement.SelectSingleNode("/settings/templates/defaultRenderingEngine"); - // node.InnerText = value.ToString(); - //} - } - - private static MacroErrorBehaviour? _macroErrorBehaviour; - - /// - /// This configuration setting defines how to handle macro errors: - /// - Inline - Show error within macro as text (default and current Umbraco 'normal' behavior) - /// - Silent - Suppress error and hide macro - /// - Throw - Throw an exception and invoke the global error handler (if one is defined, if not you'll get a YSOD) - /// - /// MacroErrorBehaviour enum defining how to handle macro errors. - internal static MacroErrorBehaviour MacroErrorBehaviour - { - get - { - if (_macroErrorBehaviour == null) - { - try - { - var behaviour = MacroErrorBehaviour.Inline; - var value = GetKey("/settings/content/MacroErrors"); - if (value != null) - { - Enum.TryParse(value, true, out behaviour); - } - _macroErrorBehaviour = behaviour; - } - catch (Exception ex) - { - LogHelper.Error("Could not load /settings/content/MacroErrors from umbracosettings.config", ex); - _macroErrorBehaviour = MacroErrorBehaviour.Inline; - } - } - return _macroErrorBehaviour.Value; - } - } - - private static IconPickerBehaviour? _iconPickerBehaviour; - - /// - /// This configuration setting defines how to show icons in the document type editor. - /// - ShowDuplicates - Show duplicates in files and sprites. (default and current Umbraco 'normal' behaviour) - /// - HideSpriteDuplicates - Show files on disk and hide duplicates from the sprite - /// - HideFileDuplicates - Show files in the sprite and hide duplicates on disk - /// - /// MacroErrorBehaviour enum defining how to show icons in the document type editor. - internal static IconPickerBehaviour IconPickerBehaviour - { - get - { - if (_iconPickerBehaviour == null) - { - try - { - var behaviour = IconPickerBehaviour.ShowDuplicates; - var value = GetKey("/settings/content/DocumentTypeIconList"); - if (value != null) - { - Enum.TryParse(value, true, out behaviour); - } - _iconPickerBehaviour = behaviour; - } - catch (Exception ex) - { - LogHelper.Error("Could not load /settings/content/DocumentTypeIconList from umbracosettings.config", ex); - _iconPickerBehaviour = IconPickerBehaviour.ShowDuplicates; - } - } - return _iconPickerBehaviour.Value; - } - } - - /// - /// Gets the default document type property used when adding new properties through the back-office - /// - /// Configured text for the default document type property - /// If undefined, 'Textstring' is the default - public static string DefaultDocumentTypeProperty - { - get - { - var defaultDocumentTypeProperty = GetKey("/settings/content/defaultDocumentTypeProperty"); - if (string.IsNullOrEmpty(defaultDocumentTypeProperty)) - { - defaultDocumentTypeProperty = "Textstring"; - } - - return defaultDocumentTypeProperty; - } - } - - #region Extensible settings - - /// - /// Resets settings that were set programmatically, to their initial values. - /// - /// To be used in unit tests. - internal static void Reset() - { - ResetInternal(); - - using (new WriteLock(SectionsLock)) - { - foreach (var section in Sections.Values) - section.ResetSection(); - } - } - - private static readonly ReaderWriterLockSlim SectionsLock = new ReaderWriterLockSlim(); - private static readonly Dictionary Sections = new Dictionary(); - - /// - /// Gets the specified UmbracoConfigurationSection. - /// - /// The type of the UmbracoConfigurationSectiont. - /// The UmbracoConfigurationSection of the specified type. - public static T For() - where T : UmbracoConfigurationSection, new() - { - var sectionType = typeof (T); - using (new WriteLock(SectionsLock)) - { - if (Sections.ContainsKey(sectionType)) return Sections[sectionType] as T; - - var attr = sectionType.GetCustomAttribute(false); - if (attr == null) - throw new InvalidOperationException(string.Format("Type \"{0}\" is missing attribute ConfigurationKeyAttribute.", sectionType.FullName)); - - var sectionKey = attr.ConfigurationKey; - if (string.IsNullOrWhiteSpace(sectionKey)) - throw new InvalidOperationException(string.Format("Type \"{0}\" ConfigurationKeyAttribute value is null or empty.", sectionType.FullName)); - - var section = GetSection(sectionType, sectionKey); - - Sections[sectionType] = section; - return section as T; - } - } - - private static UmbracoConfigurationSection GetSection(Type sectionType, string key) - { - if (!sectionType.Inherits()) - throw new ArgumentException(string.Format( - "Type \"{0}\" does not inherit from UmbracoConfigurationSection.", sectionType.FullName), "sectionType"); - - var section = ConfigurationManager.GetSection(key); - - if (section != null && section.GetType() != sectionType) - throw new InvalidCastException(string.Format("Section at key \"{0}\" is of type \"{1}\" and not \"{2}\".", - key, section.GetType().FullName, sectionType.FullName)); - - if (section != null) return section as UmbracoConfigurationSection; - - section = Activator.CreateInstance(sectionType) as UmbracoConfigurationSection; - - if (section == null) - throw new NullReferenceException(string.Format( - "Activator failed to create an instance of type \"{0}\" for key\"{1}\" and returned null.", - sectionType.FullName, key)); - - return section as UmbracoConfigurationSection; - } - - #endregion - } -} \ No newline at end of file diff --git a/src/Umbraco.Core/Configuration/RazorDataTypeModelStaticMappingItem.cs b/src/Umbraco.Core/Configuration/RazorDataTypeModelStaticMappingItem.cs index b69a8d9fe0..71aa7eaa0e 100644 --- a/src/Umbraco.Core/Configuration/RazorDataTypeModelStaticMappingItem.cs +++ b/src/Umbraco.Core/Configuration/RazorDataTypeModelStaticMappingItem.cs @@ -10,6 +10,7 @@ namespace Umbraco.Core.Configuration internal class RazorDataTypeModelStaticMappingItem { + [Obsolete("This is not used whatsoever")] public string Raw { get; set; } //if all of the set (non null) properties match the property data currently being evaluated public string PropertyTypeAlias { get; set; } diff --git a/src/Umbraco.Core/Configuration/UmbracoConfiguration.cs b/src/Umbraco.Core/Configuration/UmbracoConfiguration.cs index 0116ffa394..0ac026cba0 100644 --- a/src/Umbraco.Core/Configuration/UmbracoConfiguration.cs +++ b/src/Umbraco.Core/Configuration/UmbracoConfiguration.cs @@ -1,4 +1,7 @@ -using Umbraco.Core.Configuration.UmbracoSettings; +using System; +using System.Configuration; +using Umbraco.Core.Configuration.BaseRest; +using Umbraco.Core.Configuration.UmbracoSettings; namespace Umbraco.Core.Configuration { @@ -7,13 +10,45 @@ namespace Umbraco.Core.Configuration /// public class UmbracoConfiguration { - //TODO: Add other configurations here ! + #region Singleton - public IUmbracoSettings UmbracoSettings { get; private set; } + private static readonly Lazy Lazy = new Lazy(() => new UmbracoConfiguration()); - public UmbracoConfiguration(IUmbracoSettings umbracoSettings) + public static UmbracoConfiguration Current { get { return Lazy.Value; } } + + #endregion + + /// + /// Default constructor + /// + private UmbracoConfiguration() + { + if (UmbracoSettings == null) + { + var umbracoSettings = ConfigurationManager.GetSection("umbracoConfiguration/settings") as IUmbracoSettings; + if (umbracoSettings == null) + { + throw new InvalidOperationException("Could not find configuration section 'umbracoConfiguration/settings' or it does not cast to " + typeof(IUmbracoSettings)); + } + UmbracoSettings = umbracoSettings; + } + } + + /// + /// Constructor - can be used for testing + /// + /// + /// + public UmbracoConfiguration(IUmbracoSettings umbracoSettings, IBaseRest baseRestSettings) { UmbracoSettings = umbracoSettings; + BaseRestExtensions = baseRestSettings; } + + public IUmbracoSettings UmbracoSettings { get; private set; } + + public IBaseRest BaseRestExtensions { get; private set; } + + //TODO: Add other configurations here ! } } \ No newline at end of file diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/AppCodeFileExtensionsElement.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/AppCodeFileExtensionsElement.cs index de90cada81..db260dbe66 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/AppCodeFileExtensionsElement.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/AppCodeFileExtensionsElement.cs @@ -3,7 +3,7 @@ using System.Configuration; namespace Umbraco.Core.Configuration.UmbracoSettings { - internal class AppCodeFileExtensionsElement : ConfigurationElement, IAppCodeFileExtensions + internal class AppCodeFileExtensionsElement : ConfigurationElement { [ConfigurationCollection(typeof(AppCodeFileExtensionsCollection), AddItemName = "ext")] [ConfigurationProperty("", IsDefaultCollection = true)] @@ -13,9 +13,5 @@ namespace Umbraco.Core.Configuration.UmbracoSettings set { base[""] = value; } } - IEnumerable IAppCodeFileExtensions.AppCodeFileExtensions - { - get { return AppCodeFileExtensionsCollection; } - } } } \ No newline at end of file diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/ContentElement.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/ContentElement.cs index cb57b08492..60ca65562f 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/ContentElement.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/ContentElement.cs @@ -379,12 +379,12 @@ namespace Umbraco.Core.Configuration.UmbracoSettings get { return UmbracoLibraryCacheDuration; } } - MacroErrorBehaviour IContent.MacroErrors + MacroErrorBehaviour IContent.MacroErrorBehaviour { get { return MacroErrors; } } - IconPickerBehaviour IContent.DocumentTypeIconList + IconPickerBehaviour IContent.IconPickerBehaviour { get { return DocumentTypeIconList; } } diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/DeveloperElement.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/DeveloperElement.cs index f2842b2125..4208906457 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/DeveloperElement.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/DeveloperElement.cs @@ -1,4 +1,5 @@ -using System.Configuration; +using System.Collections.Generic; +using System.Configuration; namespace Umbraco.Core.Configuration.UmbracoSettings { @@ -38,9 +39,9 @@ namespace Umbraco.Core.Configuration.UmbracoSettings } } - IAppCodeFileExtensions IDeveloper.AppCodeFileExtensions + IEnumerable IDeveloper.AppCodeFileExtensions { - get { return AppCodeFileExtensions; } + get { return AppCodeFileExtensions.AppCodeFileExtensionsCollection; } } } } \ No newline at end of file diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/DistributedCallElement.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/DistributedCallElement.cs index 5a61b64b0f..5446562084 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/DistributedCallElement.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/DistributedCallElement.cs @@ -40,7 +40,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings get { return UserId; } } - IEnumerable IDistributedCall.Servers + IEnumerable IDistributedCall.Servers { get { return Servers; } } diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/ExternalLoggerElement.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/ExternalLoggerElement.cs index 73c6a0c02e..98039f8e65 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/ExternalLoggerElement.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/ExternalLoggerElement.cs @@ -27,7 +27,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings get { return Assembly; } } - string IExternalLogger.Type + string IExternalLogger.ExternalLoggerType { get { return Type; } } diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/IAppCodeFileExtensions.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/IAppCodeFileExtensions.cs deleted file mode 100644 index 87e3c76413..0000000000 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/IAppCodeFileExtensions.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Collections.Generic; - -namespace Umbraco.Core.Configuration.UmbracoSettings -{ - public interface IAppCodeFileExtensions - { - IEnumerable AppCodeFileExtensions { get; } - } -} \ No newline at end of file diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/IContent.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/IContent.cs index 3ed58b18b9..b3a35a39d4 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/IContent.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/IContent.cs @@ -42,9 +42,9 @@ namespace Umbraco.Core.Configuration.UmbracoSettings int UmbracoLibraryCacheDuration { get; } - MacroErrorBehaviour MacroErrors { get; } + MacroErrorBehaviour MacroErrorBehaviour { get; } - IconPickerBehaviour DocumentTypeIconList { get; } + IconPickerBehaviour IconPickerBehaviour { get; } IEnumerable DisallowedUploadFiles { get; } diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/IDeveloper.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/IDeveloper.cs index c11d072e6d..dfdc3a74f5 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/IDeveloper.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/IDeveloper.cs @@ -1,7 +1,9 @@ -namespace Umbraco.Core.Configuration.UmbracoSettings +using System.Collections.Generic; + +namespace Umbraco.Core.Configuration.UmbracoSettings { public interface IDeveloper { - IAppCodeFileExtensions AppCodeFileExtensions { get; } + IEnumerable AppCodeFileExtensions { get; } } } \ No newline at end of file diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/IDistributedCall.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/IDistributedCall.cs index dde70ecc20..1acd541ce7 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/IDistributedCall.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/IDistributedCall.cs @@ -8,6 +8,6 @@ namespace Umbraco.Core.Configuration.UmbracoSettings int UserId { get; } - IEnumerable Servers { get; } + IEnumerable Servers { get; } } } \ No newline at end of file diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/IExternalLogger.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/IExternalLogger.cs index ffb7835cfd..ae2353f161 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/IExternalLogger.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/IExternalLogger.cs @@ -6,7 +6,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings { string Assembly { get; } - string Type { get; } + string ExternalLoggerType { get; } bool LogAuditTrail { get; } } diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/IRazorStaticMapping.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/IRazorStaticMapping.cs index 2566866982..471afce319 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/IRazorStaticMapping.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/IRazorStaticMapping.cs @@ -6,7 +6,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings { Guid DataTypeGuid { get; } string NodeTypeAlias { get; } - string DocumentTypeAlias { get; } + string PropertyTypeAlias { get; } string MappingName { get; } } } \ No newline at end of file diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/IRepositories.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/IRepositories.cs index 260aa39704..23f3f44149 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/IRepositories.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/IRepositories.cs @@ -2,6 +2,8 @@ namespace Umbraco.Core.Configuration.UmbracoSettings { + //TODO: Where do we put the 'package server' setting? + public interface IRepositories { IEnumerable Repositories { get; } diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/IServerElement.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/IServer.cs similarity index 83% rename from src/Umbraco.Core/Configuration/UmbracoSettings/IServerElement.cs rename to src/Umbraco.Core/Configuration/UmbracoSettings/IServer.cs index 099146f1ca..d8fd584bff 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/IServerElement.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/IServer.cs @@ -1,6 +1,6 @@ namespace Umbraco.Core.Configuration.UmbracoSettings { - public interface IServerElement + public interface IServer { string ForcePortnumber { get; } string ForceProtocol { get; } diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/IWebRouting.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/IWebRouting.cs index 7b54a022ca..6318ded60c 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/IWebRouting.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/IWebRouting.cs @@ -5,5 +5,8 @@ bool TrySkipIisCustomErrors { get; } bool InternalRedirectPreservesTemplate { get; } + + string UrlProviderMode { get; } } + } \ No newline at end of file diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/RazorStaticMappingCollection.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/RazorStaticMappingCollection.cs index 5be37f091b..d35d808f46 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/RazorStaticMappingCollection.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/RazorStaticMappingCollection.cs @@ -14,7 +14,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings { return ((RazorStaticMappingElement) element).DataTypeGuid + ((RazorStaticMappingElement) element).NodeTypeAlias - + ((RazorStaticMappingElement) element).DocumentTypeAlias; + + ((RazorStaticMappingElement) element).PropertyTypeAlias; } diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/RazorStaticMappingElement.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/RazorStaticMappingElement.cs index 28c83e94f2..917ff5e63b 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/RazorStaticMappingElement.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/RazorStaticMappingElement.cs @@ -24,13 +24,13 @@ namespace Umbraco.Core.Configuration.UmbracoSettings } } - public string DocumentTypeAlias + public string PropertyTypeAlias { get { - return RawXml.Attribute("documentTypeAlias") == null + return RawXml.Attribute("propertyTypeAlias") == null ? null - : RawXml.Attribute("documentTypeAlias").Value; + : RawXml.Attribute("propertyTypeAlias").Value; } } diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/ServerCollection.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/ServerCollection.cs index 9381170d56..2333549faa 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/ServerCollection.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/ServerCollection.cs @@ -3,7 +3,7 @@ using System.Configuration; namespace Umbraco.Core.Configuration.UmbracoSettings { - internal class ServerCollection : ConfigurationElementCollection, IEnumerable + internal class ServerCollection : ConfigurationElementCollection, IEnumerable { protected override ConfigurationElement CreateNewElement() { @@ -15,11 +15,11 @@ namespace Umbraco.Core.Configuration.UmbracoSettings return ((ServerElement)element).Value; } - IEnumerator IEnumerable.GetEnumerator() + IEnumerator IEnumerable.GetEnumerator() { for (var i = 0; i < Count; i++) { - yield return BaseGet(i) as IServerElement; + yield return BaseGet(i) as IServer; } } diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/ServerElement.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/ServerElement.cs index 8568c0f787..2374005eec 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/ServerElement.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/ServerElement.cs @@ -1,6 +1,6 @@ namespace Umbraco.Core.Configuration.UmbracoSettings { - internal class ServerElement : InnerTextConfigurationElement, IServerElement + internal class ServerElement : InnerTextConfigurationElement, IServer { public string ForcePortnumber { @@ -22,7 +22,7 @@ } } - string IServerElement.ServerAddress + string IServer.ServerAddress { get { return Value; } } diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/WebRoutingElement.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/WebRoutingElement.cs index a66f151a9a..ad3b48a070 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/WebRoutingElement.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/WebRoutingElement.cs @@ -16,5 +16,11 @@ namespace Umbraco.Core.Configuration.UmbracoSettings get { return (bool) base["internalRedirectPreservesTemplate"]; } } + [ConfigurationProperty("urlProviderMode", DefaultValue = "Auto")] + public string UrlProviderMode + { + get { return (string)base["urlProviderMode"]; } + } + } } \ No newline at end of file diff --git a/src/Umbraco.Core/IO/IOHelper.cs b/src/Umbraco.Core/IO/IOHelper.cs index d37c90f298..578dd1c859 100644 --- a/src/Umbraco.Core/IO/IOHelper.cs +++ b/src/Umbraco.Core/IO/IOHelper.cs @@ -54,7 +54,7 @@ namespace Umbraco.Core.IO [Obsolete("Use Umbraco.Web.Templates.TemplateUtilities.ResolveUrlsFromTextString instead, this method on this class will be removed in future versions")] internal static string ResolveUrlsFromTextString(string text) { - if (LegacyUmbracoSettings.ResolveUrlsFromTextString) + if (UmbracoConfiguration.Current.UmbracoSettings.Content.ResolveUrlsFromTextString) { using (var timer = DisposableTimer.DebugDuration(typeof(IOHelper), "ResolveUrlsFromTextString starting", "ResolveUrlsFromTextString complete")) { diff --git a/src/Umbraco.Core/IO/MediaFileSystem.cs b/src/Umbraco.Core/IO/MediaFileSystem.cs index 0ef1895003..4083b6d91c 100644 --- a/src/Umbraco.Core/IO/MediaFileSystem.cs +++ b/src/Umbraco.Core/IO/MediaFileSystem.cs @@ -1,7 +1,9 @@ using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Linq; using Umbraco.Core.Configuration; +using Umbraco.Core.Configuration.UmbracoSettings; namespace Umbraco.Core.IO { @@ -11,23 +13,30 @@ namespace Umbraco.Core.IO [FileSystemProvider("media")] public class MediaFileSystem : FileSystemWrapper { - public MediaFileSystem(IFileSystem wrapped) - : base(wrapped) + private readonly IContent _contentConfig; + + public MediaFileSystem(IFileSystem wrapped) + : this(wrapped, UmbracoConfiguration.Current.UmbracoSettings.Content) { } - public string GetRelativePath(int propertyId, string fileName) + public MediaFileSystem(IFileSystem wrapped, IContent contentConfig) : base(wrapped) + { + _contentConfig = contentConfig; + } + + public string GetRelativePath(int propertyId, string fileName) { - var seperator = LegacyUmbracoSettings.UploadAllowDirectories + var seperator = _contentConfig.UploadAllowDirectories ? Path.DirectorySeparatorChar : '-'; - return propertyId.ToString() + seperator + fileName; + return propertyId.ToString(CultureInfo.InvariantCulture) + seperator + fileName; } public string GetRelativePath(string subfolder, string fileName) { - var seperator = LegacyUmbracoSettings.UploadAllowDirectories + var seperator = _contentConfig.UploadAllowDirectories ? Path.DirectorySeparatorChar : '-'; diff --git a/src/Umbraco.Core/IO/UmbracoMediaFile.cs b/src/Umbraco.Core/IO/UmbracoMediaFile.cs index 819104b70f..861b1f0527 100644 --- a/src/Umbraco.Core/IO/UmbracoMediaFile.cs +++ b/src/Umbraco.Core/IO/UmbracoMediaFile.cs @@ -135,7 +135,7 @@ namespace Umbraco.Core.IO { get { - return ("," + LegacyUmbracoSettings.ImageFileTypes + ",").Contains(string.Format(",{0},", Extension)); + return UmbracoConfiguration.Current.UmbracoSettings.Content.Imaging.ImageFileTypes.InvariantContains(Extension); } } diff --git a/src/Umbraco.Core/Models/ContentExtensions.cs b/src/Umbraco.Core/Models/ContentExtensions.cs index 66045ecd3d..29b582a057 100644 --- a/src/Umbraco.Core/Models/ContentExtensions.cs +++ b/src/Umbraco.Core/Models/ContentExtensions.cs @@ -10,6 +10,7 @@ using System.Web; using System.Xml; using System.Xml.Linq; using Umbraco.Core.Configuration; +using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.IO; using Umbraco.Core.Media; using Umbraco.Core.Models.EntityBase; @@ -402,7 +403,7 @@ namespace Umbraco.Core.Models return; var numberedFolder = MediaSubfolderCounter.Current.Increment(); - var fileName = LegacyUmbracoSettings.UploadAllowDirectories + var fileName = UmbracoConfiguration.Current.UmbracoSettings.Content.UploadAllowDirectories ? Path.Combine(numberedFolder.ToString(CultureInfo.InvariantCulture), name) : numberedFolder + "-" + name; @@ -415,17 +416,17 @@ namespace Umbraco.Core.Models fs.AddFile(fileName, fileStream); //Check if file supports resizing and create thumbnails - var supportsResizing = ("," + LegacyUmbracoSettings.ImageFileTypes + ",").Contains(string.Format(",{0},", extension)); + var supportsResizing = UmbracoConfiguration.Current.UmbracoSettings.Content.Imaging.ImageFileTypes.InvariantContains(extension); //the config section used to auto-fill properties - XmlNode uploadFieldConfigNode = null; + IContentImagingAutoFillUploadField uploadFieldConfigNode = null; //Check for auto fill of additional properties - if (LegacyUmbracoSettings.ImageAutoFillImageProperties != null) + if (UmbracoConfiguration.Current.UmbracoSettings.Content.Imaging.ImageAutoFillProperties != null) { - uploadFieldConfigNode = - LegacyUmbracoSettings.ImageAutoFillImageProperties.SelectSingleNode( - string.Format("uploadField [@alias = \"{0}\"]", propertyTypeAlias)); + uploadFieldConfigNode = UmbracoConfiguration.Current.UmbracoSettings.Content.Imaging.ImageAutoFillProperties + .Single(x => x.Alias == propertyTypeAlias); + } if (supportsResizing) @@ -462,8 +463,8 @@ namespace Umbraco.Core.Models //while the image is still open, we'll check if we need to auto-populate the image properties if (uploadFieldConfigNode != null) { - SetPropertyValue(content, uploadFieldConfigNode, "widthFieldAlias", originalImage.Width.ToString(CultureInfo.InvariantCulture)); - SetPropertyValue(content, uploadFieldConfigNode, "heightFieldAlias", originalImage.Height.ToString(CultureInfo.InvariantCulture)); + content.SetValue(uploadFieldConfigNode.WidthFieldAlias, originalImage.Width.ToString(CultureInfo.InvariantCulture)); + content.SetValue(uploadFieldConfigNode.HeightFieldAlias, originalImage.Height.ToString(CultureInfo.InvariantCulture)); } } @@ -472,23 +473,14 @@ namespace Umbraco.Core.Models //if auto-fill is true, then fill the remaining, non-image properties if (uploadFieldConfigNode != null) { - SetPropertyValue(content, uploadFieldConfigNode, "lengthFieldAlias", fileSize.ToString(CultureInfo.InvariantCulture)); - SetPropertyValue(content, uploadFieldConfigNode, "extensionFieldAlias", extension); + content.SetValue(uploadFieldConfigNode.LengthFieldAlias, fileSize.ToString(CultureInfo.InvariantCulture)); + content.SetValue(uploadFieldConfigNode.ExtensionFieldAlias, extension); } //Set the value of the property to that of the uploaded file's url property.Value = fs.GetUrl(fileName); } - private static void SetPropertyValue(IContentBase content, XmlNode uploadFieldConfigNode, string propertyAlias, string propertyValue) - { - XmlNode propertyNode = uploadFieldConfigNode.SelectSingleNode(propertyAlias); - if (propertyNode != null && string.IsNullOrEmpty(propertyNode.FirstChild.Value) == false && content.HasProperty(propertyNode.FirstChild.Value)) - { - content.SetValue(propertyNode.FirstChild.Value, propertyValue); - } - } - private static ResizedImage Resize(MediaFileSystem fileSystem, string path, string extension, int maxWidthHeight, string fileNameAddition, Image originalImage) { var fileNameThumb = String.IsNullOrEmpty(fileNameAddition) diff --git a/src/Umbraco.Core/Models/PropertyExtensions.cs b/src/Umbraco.Core/Models/PropertyExtensions.cs index 914ba950fd..a0db710ae7 100644 --- a/src/Umbraco.Core/Models/PropertyExtensions.cs +++ b/src/Umbraco.Core/Models/PropertyExtensions.cs @@ -22,13 +22,13 @@ namespace Umbraco.Core.Models internal static XElement ToXml(this Property property, IDataTypeService dataTypeService) { - var nodeName = LegacyUmbracoSettings.UseLegacyXmlSchema ? "data" : property.Alias.ToSafeAlias(); + var nodeName = UmbracoConfiguration.Current.UmbracoSettings.Content.UseLegacyXmlSchema ? "data" : property.Alias.ToSafeAlias(); var xd = new XmlDocument(); var xmlNode = xd.CreateNode(XmlNodeType.Element, nodeName, ""); //Add the property alias to the legacy schema - if (LegacyUmbracoSettings.UseLegacyXmlSchema) + if (UmbracoConfiguration.Current.UmbracoSettings.Content.UseLegacyXmlSchema) { var alias = xd.CreateAttribute("alias"); alias.Value = property.Alias.ToSafeAlias(); diff --git a/src/Umbraco.Core/Models/Script.cs b/src/Umbraco.Core/Models/Script.cs index d6405477e0..49eb3982e7 100644 --- a/src/Umbraco.Core/Models/Script.cs +++ b/src/Umbraco.Core/Models/Script.cs @@ -2,6 +2,7 @@ using System.Linq; using System.Runtime.Serialization; using Umbraco.Core.Configuration; +using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.IO; namespace Umbraco.Core.Models @@ -13,8 +14,18 @@ namespace Umbraco.Core.Models [DataContract(IsReference = true)] public class Script : File { - public Script(string path) : base(path) + private readonly IContentScriptEditor _scriptEditorConfig; + + public Script(string path) + : this(path, UmbracoConfiguration.Current.UmbracoSettings.Content.ScriptEditor) { + + } + + public Script(string path, IContentScriptEditor scriptEditorConfig) + : base(path) + { + _scriptEditorConfig = scriptEditorConfig; base.Path = path; } @@ -33,7 +44,7 @@ namespace Umbraco.Core.Models //into 4 private methods. //See codeEditorSave.asmx.cs for reference. - var exts = LegacyUmbracoSettings.ScriptFileTypes.Split(',').ToList(); + var exts = _scriptEditorConfig.ScriptFileTypes.ToList(); /*if (UmbracoSettings.DefaultRenderingEngine == RenderingEngine.Mvc) { exts.Add("cshtml"); diff --git a/src/Umbraco.Core/Models/Template.cs b/src/Umbraco.Core/Models/Template.cs index 4cdb48b05d..5c30b80187 100644 --- a/src/Umbraco.Core/Models/Template.cs +++ b/src/Umbraco.Core/Models/Template.cs @@ -157,18 +157,18 @@ namespace Umbraco.Core.Models public override bool IsValid() { var exts = new List(); - if (LegacyUmbracoSettings.DefaultRenderingEngine == RenderingEngine.Mvc) + if (UmbracoConfiguration.Current.UmbracoSettings.Templates.DefaultRenderingEngine == RenderingEngine.Mvc) { exts.Add("cshtml"); exts.Add("vbhtml"); } else { - exts.Add(LegacyUmbracoSettings.UseAspNetMasterPages ? "master" : "aspx"); + exts.Add(UmbracoConfiguration.Current.UmbracoSettings.Templates.UseAspNetMasterPages ? "master" : "aspx"); } var dirs = SystemDirectories.Masterpages; - if (LegacyUmbracoSettings.DefaultRenderingEngine == RenderingEngine.Mvc) + if (UmbracoConfiguration.Current.UmbracoSettings.Templates.DefaultRenderingEngine == RenderingEngine.Mvc) dirs += "," + SystemDirectories.MvcViews; //Validate file diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs index f63eb792a5..e41f904771 100644 --- a/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs @@ -441,7 +441,7 @@ namespace Umbraco.Core.Persistence.Repositories var parentDirectory = System.IO.Path.GetDirectoryName(relativeFilePath); // don't want to delete the media folder if not using directories. - if (LegacyUmbracoSettings.UploadAllowDirectories && parentDirectory != fs.GetRelativePath("/")) + if (UmbracoConfiguration.Current.UmbracoSettings.Content.UploadAllowDirectories && parentDirectory != fs.GetRelativePath("/")) { //issue U4-771: if there is a parent directory the recursive parameter should be true fs.DeleteDirectory(parentDirectory, String.IsNullOrEmpty(parentDirectory) == false); diff --git a/src/Umbraco.Core/Persistence/Repositories/MediaRepository.cs b/src/Umbraco.Core/Persistence/Repositories/MediaRepository.cs index 63a36f2e04..f1b3324ea3 100644 --- a/src/Umbraco.Core/Persistence/Repositories/MediaRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/MediaRepository.cs @@ -342,7 +342,7 @@ namespace Umbraco.Core.Persistence.Repositories var parentDirectory = System.IO.Path.GetDirectoryName(relativeFilePath); // don't want to delete the media folder if not using directories. - if (LegacyUmbracoSettings.UploadAllowDirectories && parentDirectory != fs.GetRelativePath("/")) + if (UmbracoConfiguration.Current.UmbracoSettings.Content.UploadAllowDirectories && parentDirectory != fs.GetRelativePath("/")) { //issue U4-771: if there is a parent directory the recursive parameter should be true fs.DeleteDirectory(parentDirectory, String.IsNullOrEmpty(parentDirectory) == false); diff --git a/src/Umbraco.Core/Persistence/Repositories/MemberRepository.cs b/src/Umbraco.Core/Persistence/Repositories/MemberRepository.cs index 7ea4f6eb4d..6e1054a7a6 100644 --- a/src/Umbraco.Core/Persistence/Repositories/MemberRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/MemberRepository.cs @@ -345,7 +345,7 @@ namespace Umbraco.Core.Persistence.Repositories var parentDirectory = System.IO.Path.GetDirectoryName(relativeFilePath); // don't want to delete the media folder if not using directories. - if (LegacyUmbracoSettings.UploadAllowDirectories && parentDirectory != fs.GetRelativePath("/")) + if (UmbracoConfiguration.Current.UmbracoSettings.Content.UploadAllowDirectories && parentDirectory != fs.GetRelativePath("/")) { //issue U4-771: if there is a parent directory the recursive parameter should be true fs.DeleteDirectory(parentDirectory, String.IsNullOrEmpty(parentDirectory) == false); diff --git a/src/Umbraco.Core/Persistence/Repositories/RecycleBinRepository.cs b/src/Umbraco.Core/Persistence/Repositories/RecycleBinRepository.cs index a13ff89306..246845da0f 100644 --- a/src/Umbraco.Core/Persistence/Repositories/RecycleBinRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/RecycleBinRepository.cs @@ -132,7 +132,7 @@ namespace Umbraco.Core.Persistence.Repositories var fs = FileSystemProviderManager.Current.GetFileSystemProvider(); Parallel.ForEach(files, file => { - if (LegacyUmbracoSettings.UploadAllowDirectories) + if (UmbracoConfiguration.Current.UmbracoSettings.Content.UploadAllowDirectories) { var relativeFilePath = fs.GetRelativePath(file); var parentDirectory = System.IO.Path.GetDirectoryName(relativeFilePath); diff --git a/src/Umbraco.Core/Persistence/RepositoryFactory.cs b/src/Umbraco.Core/Persistence/RepositoryFactory.cs index c46c64a2ff..dec8b492c9 100644 --- a/src/Umbraco.Core/Persistence/RepositoryFactory.cs +++ b/src/Umbraco.Core/Persistence/RepositoryFactory.cs @@ -1,3 +1,5 @@ +using Umbraco.Core.Configuration; +using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.Persistence.Caching; using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Persistence.UnitOfWork; @@ -9,13 +11,26 @@ namespace Umbraco.Core.Persistence /// public class RepositoryFactory { + private readonly IUmbracoSettings _settings; + + public RepositoryFactory(IUmbracoSettings settings) + { + _settings = settings; + } + + public RepositoryFactory() + : this(UmbracoConfiguration.Current.UmbracoSettings) + { + + } + public virtual IContentRepository CreateContentRepository(IDatabaseUnitOfWork uow) { return new ContentRepository( uow, RuntimeCacheProvider.Current, CreateContentTypeRepository(uow), - CreateTemplateRepository(uow)) { EnsureUniqueNaming = Umbraco.Core.Configuration.LegacyUmbracoSettings.EnsureUniqueNaming }; + CreateTemplateRepository(uow)) { EnsureUniqueNaming = _settings.Content.EnsureUniqueNaming }; } public virtual IContentTypeRepository CreateContentTypeRepository(IDatabaseUnitOfWork uow) @@ -53,7 +68,7 @@ namespace Umbraco.Core.Persistence return new MediaRepository( uow, RuntimeCacheProvider.Current, - CreateMediaTypeRepository(uow)) { EnsureUniqueNaming = Umbraco.Core.Configuration.LegacyUmbracoSettings.EnsureUniqueNaming }; + CreateMediaTypeRepository(uow)) { EnsureUniqueNaming = _settings.Content.EnsureUniqueNaming }; } public virtual IMediaTypeRepository CreateMediaTypeRepository(IDatabaseUnitOfWork uow) diff --git a/src/Umbraco.Core/PublishedContentHelper.cs b/src/Umbraco.Core/PublishedContentHelper.cs index 5292a75461..41ad058a7e 100644 --- a/src/Umbraco.Core/PublishedContentHelper.cs +++ b/src/Umbraco.Core/PublishedContentHelper.cs @@ -174,8 +174,8 @@ namespace Umbraco.Core var documentElement = e.Name.LocalName; //TODO: See note against this setting, pretty sure we don't need this - if (!LegacyUmbracoSettings.NotDynamicXmlDocumentElements.Any( - tag => string.Equals(tag, documentElement, StringComparison.CurrentCultureIgnoreCase))) + if (UmbracoConfiguration.Current.UmbracoSettings.Scripting.Razor.NotDynamicXmlDocumentElements.Any( + tag => string.Equals(tag.Element, documentElement, StringComparison.CurrentCultureIgnoreCase)) == false) { return new Attempt(true, new DynamicXml(e)); } diff --git a/src/Umbraco.Core/Security/AuthenticationExtensions.cs b/src/Umbraco.Core/Security/AuthenticationExtensions.cs index 73d59bc72c..ad20b90477 100644 --- a/src/Umbraco.Core/Security/AuthenticationExtensions.cs +++ b/src/Umbraco.Core/Security/AuthenticationExtensions.cs @@ -26,7 +26,7 @@ namespace Umbraco.Core.Security /// public static void UmbracoLogout(this HttpContextBase http) { - Logout(http, LegacyUmbracoSettings.AuthCookieName); + Logout(http, UmbracoConfiguration.Current.UmbracoSettings.Security.AuthCookieName); } internal static void UmbracoLogout(this HttpContext http) @@ -42,7 +42,10 @@ namespace Umbraco.Core.Security /// public static bool RenewUmbracoAuthTicket(this HttpContextBase http, int timeoutInMinutes = 60) { - return RenewAuthTicket(http, LegacyUmbracoSettings.AuthCookieName, LegacyUmbracoSettings.AuthCookieDomain, timeoutInMinutes); + return RenewAuthTicket(http, + UmbracoConfiguration.Current.UmbracoSettings.Security.AuthCookieName, + UmbracoConfiguration.Current.UmbracoSettings.Security.AuthCookieDomain, + timeoutInMinutes); } internal static bool RenewUmbracoAuthTicket(this HttpContext http, int timeoutInMinutes = 60) @@ -65,9 +68,9 @@ namespace Umbraco.Core.Security GlobalSettings.TimeOutInMinutes, //Umbraco has always persisted it's original cookie for 1 day so we'll keep it that way 1440, - "/", - LegacyUmbracoSettings.AuthCookieName, - LegacyUmbracoSettings.AuthCookieDomain); + "/", + UmbracoConfiguration.Current.UmbracoSettings.Security.AuthCookieName, + UmbracoConfiguration.Current.UmbracoSettings.Security.AuthCookieDomain); } internal static void CreateUmbracoAuthTicket(this HttpContext http, UserData userdata) @@ -82,7 +85,7 @@ namespace Umbraco.Core.Security /// public static FormsAuthenticationTicket GetUmbracoAuthTicket(this HttpContextBase http) { - return GetAuthTicket(http, LegacyUmbracoSettings.AuthCookieName); + return GetAuthTicket(http, UmbracoConfiguration.Current.UmbracoSettings.Security.AuthCookieName); } internal static FormsAuthenticationTicket GetUmbracoAuthTicket(this HttpContext http) diff --git a/src/Umbraco.Core/Services/ContentTypeService.cs b/src/Umbraco.Core/Services/ContentTypeService.cs index a0413c619d..b54db28170 100644 --- a/src/Umbraco.Core/Services/ContentTypeService.cs +++ b/src/Umbraco.Core/Services/ContentTypeService.cs @@ -567,7 +567,7 @@ namespace Umbraco.Core.Services public string GetContentTypesDtd() { var dtd = new StringBuilder(); - if (LegacyUmbracoSettings.UseLegacyXmlSchema) + if (UmbracoConfiguration.Current.UmbracoSettings.Content.UseLegacyXmlSchema) { dtd.AppendLine(" "); } diff --git a/src/Umbraco.Core/Services/PackagingService.cs b/src/Umbraco.Core/Services/PackagingService.cs index dd99782b02..979cced5ac 100644 --- a/src/Umbraco.Core/Services/PackagingService.cs +++ b/src/Umbraco.Core/Services/PackagingService.cs @@ -108,7 +108,7 @@ namespace Umbraco.Core.Services internal XElement Export(IContent content, bool deep = false) { //nodeName should match Casing.SafeAliasWithForcingCheck(content.ContentType.Alias); - var nodeName = LegacyUmbracoSettings.UseLegacyXmlSchema ? "node" : content.ContentType.Alias.ToSafeAliasWithForcingCheck(); + var nodeName = UmbracoConfiguration.Current.UmbracoSettings.Content.UseLegacyXmlSchema ? "node" : content.ContentType.Alias.ToSafeAliasWithForcingCheck(); var xml = Export(content, nodeName); xml.Add(new XAttribute("nodeType", content.ContentType.Id)); @@ -862,7 +862,7 @@ namespace Umbraco.Core.Services internal XElement Export(IMedia media, bool deep = false) { //nodeName should match Casing.SafeAliasWithForcingCheck(content.ContentType.Alias); - var nodeName = LegacyUmbracoSettings.UseLegacyXmlSchema ? "node" : media.ContentType.Alias.ToSafeAliasWithForcingCheck(); + var nodeName = UmbracoConfiguration.Current.UmbracoSettings.Content.UseLegacyXmlSchema ? "node" : media.ContentType.Alias.ToSafeAliasWithForcingCheck(); var xml = Export(media, nodeName); xml.Add(new XAttribute("nodeType", media.ContentType.Id)); diff --git a/src/Umbraco.Core/StringExtensions.cs b/src/Umbraco.Core/StringExtensions.cs index b08ca1985d..40a71d8d25 100644 --- a/src/Umbraco.Core/StringExtensions.cs +++ b/src/Umbraco.Core/StringExtensions.cs @@ -958,7 +958,7 @@ namespace Umbraco.Core /// Checks UmbracoSettings.ForceSafeAliases to determine whether it should filter the text. public static string ToSafeAliasWithForcingCheck(this string alias) { - return LegacyUmbracoSettings.ForceSafeAliases ? alias.ToSafeAlias() : alias; + return UmbracoConfiguration.Current.UmbracoSettings.Content.ForceSafeAliases ? alias.ToSafeAlias() : alias; } /// @@ -970,7 +970,7 @@ namespace Umbraco.Core /// Checks UmbracoSettings.ForceSafeAliases to determine whether it should filter the text. public static string ToSafeAliasWithForcingCheck(this string alias, CultureInfo culture) { - return LegacyUmbracoSettings.ForceSafeAliases ? alias.ToSafeAlias(culture) : alias; + return UmbracoConfiguration.Current.UmbracoSettings.Content.ForceSafeAliases ? alias.ToSafeAlias(culture) : alias; } // note: LegacyShortStringHelper will produce a 100% backward-compatible output for ToUmbracoAlias. diff --git a/src/Umbraco.Core/Strings/DefaultShortStringHelper.cs b/src/Umbraco.Core/Strings/DefaultShortStringHelper.cs index 52d6087c75..04045f25fd 100644 --- a/src/Umbraco.Core/Strings/DefaultShortStringHelper.cs +++ b/src/Umbraco.Core/Strings/DefaultShortStringHelper.cs @@ -57,17 +57,10 @@ namespace Umbraco.Core.Strings static void InitializeLegacyUrlReplaceCharacters() { - var replaceChars = LegacyUmbracoSettings.UrlReplaceCharacters; - if (replaceChars == null) return; - var nodes = replaceChars.SelectNodes("char"); - if (nodes == null) return; - foreach (var node in nodes.Cast()) + foreach (var node in UmbracoConfiguration.Current.UmbracoSettings.RequestHandler.UrlReplacing.CharCollection) { - var attributes = node.Attributes; - if (attributes == null) continue; - var org = attributes.GetNamedItem("org"); - if (org != null && org.Value != "") - UrlReplaceCharacters[org.Value] = XmlHelper.GetNodeValue(node); + if (node.Char.IsNullOrWhiteSpace() == false) + UrlReplaceCharacters[node.Char] = node.Replacement; } } @@ -234,7 +227,7 @@ function validateSafeAlias(id, value, immediate, callback) {{ public string GetShortStringServicesJavaScript(string controllerPath) { return string.Format(SssjsFormat, - LegacyUmbracoSettings.ForceSafeAliases ? "true" : "false", controllerPath); + UmbracoConfiguration.Current.UmbracoSettings.Content.ForceSafeAliases ? "true" : "false", controllerPath); } #endregion diff --git a/src/Umbraco.Core/Strings/LegacyShortStringHelper.cs b/src/Umbraco.Core/Strings/LegacyShortStringHelper.cs index 97354c17d6..89b454348e 100644 --- a/src/Umbraco.Core/Strings/LegacyShortStringHelper.cs +++ b/src/Umbraco.Core/Strings/LegacyShortStringHelper.cs @@ -94,7 +94,7 @@ function isValidAlias(alias) {{ public string GetShortStringServicesJavaScript(string controllerPath) { return string.Format(SssjsFormat, - LegacyUmbracoSettings.ForceSafeAliases ? "true" : "false", SssjsValidCharacters, SssjsInvalidFirstCharacters); + UmbracoConfiguration.Current.UmbracoSettings.Content.ForceSafeAliases ? "true" : "false", SssjsValidCharacters, SssjsInvalidFirstCharacters); } #endregion @@ -205,11 +205,10 @@ function isValidAlias(alias) {{ var ext = filePath.Substring(filePath.LastIndexOf('.')); //Because the file usually is downloadable as well we check characters against 'UmbracoSettings.UrlReplaceCharacters' - XmlNode replaceChars = LegacyUmbracoSettings.UrlReplaceCharacters; - foreach (XmlNode n in replaceChars.SelectNodes("char")) + foreach (var n in UmbracoConfiguration.Current.UmbracoSettings.RequestHandler.UrlReplacing.CharCollection) { - if (n.Attributes.GetNamedItem("org") != null && n.Attributes.GetNamedItem("org").Value != "") - fileNamePart = fileNamePart.Replace(n.Attributes.GetNamedItem("org").Value, XmlHelper.GetNodeValue(n)); + if (n.Char.IsNullOrWhiteSpace() == false) + fileNamePart = fileNamePart.Replace(n.Char, n.Replacement); } filePath = string.Concat(fileNamePart, ext); @@ -469,15 +468,14 @@ function isValidAlias(alias) {{ public string LegacyFormatUrl(string url) { var newUrl = url.ToLowerInvariant(); - var replaceChars = LegacyUmbracoSettings.UrlReplaceCharacters; - foreach (XmlNode n in replaceChars.SelectNodes("char")) + foreach (var n in UmbracoConfiguration.Current.UmbracoSettings.RequestHandler.UrlReplacing.CharCollection) { - if (n.Attributes.GetNamedItem("org") != null && n.Attributes.GetNamedItem("org").Value != "") - newUrl = newUrl.Replace(n.Attributes.GetNamedItem("org").Value, XmlHelper.GetNodeValue(n)); + if (n.Char.IsNullOrWhiteSpace() == false) + newUrl = newUrl.Replace(n.Char, n.Replacement); } // check for double dashes - if (LegacyUmbracoSettings.RemoveDoubleDashesFromUrlReplacing) + if (UmbracoConfiguration.Current.UmbracoSettings.RequestHandler.UrlReplacing.RemoveDoubleDashes) { newUrl = Regex.Replace(newUrl, @"[-]{2,}", "-"); } diff --git a/src/Umbraco.Core/Sync/ConfigServerAddress.cs b/src/Umbraco.Core/Sync/ConfigServerAddress.cs index 71b6d8a43b..1bfa7a305e 100644 --- a/src/Umbraco.Core/Sync/ConfigServerAddress.cs +++ b/src/Umbraco.Core/Sync/ConfigServerAddress.cs @@ -1,5 +1,6 @@ using System.Xml; using Umbraco.Core.Configuration; +using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.IO; namespace Umbraco.Core.Sync @@ -10,16 +11,16 @@ namespace Umbraco.Core.Sync internal class ConfigServerAddress : IServerAddress { - public ConfigServerAddress(XmlNode n) + public ConfigServerAddress(IServer n) { var webServicesUrl = IOHelper.ResolveUrl(SystemDirectories.WebServices); var protocol = GlobalSettings.UseSSL ? "https" : "http"; - if (n.Attributes.GetNamedItem("forceProtocol") != null && !string.IsNullOrEmpty(n.Attributes.GetNamedItem("forceProtocol").Value)) - protocol = n.Attributes.GetNamedItem("forceProtocol").Value; - var domain = XmlHelper.GetNodeValue(n); - if (n.Attributes.GetNamedItem("forcePortnumber") != null && !string.IsNullOrEmpty(n.Attributes.GetNamedItem("forcePortnumber").Value)) - domain += string.Format(":{0}", n.Attributes.GetNamedItem("forcePortnumber").Value); + if (n.ForceProtocol.IsNullOrWhiteSpace() == false) + protocol = n.ForceProtocol; + var domain = n.ServerAddress; + if (n.ForcePortnumber.IsNullOrWhiteSpace() == false) + domain += string.Format(":{0}", n.ForcePortnumber); ServerAddress = string.Format("{0}://{1}{2}/cacheRefresher.asmx", protocol, domain, webServicesUrl); } diff --git a/src/Umbraco.Core/Sync/ConfigServerRegistrar.cs b/src/Umbraco.Core/Sync/ConfigServerRegistrar.cs index 3c0cfaa807..99575ab0e6 100644 --- a/src/Umbraco.Core/Sync/ConfigServerRegistrar.cs +++ b/src/Umbraco.Core/Sync/ConfigServerRegistrar.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Xml; using Umbraco.Core.Configuration; +using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.Models; namespace Umbraco.Core.Sync @@ -13,17 +14,17 @@ namespace Umbraco.Core.Sync /// internal class ConfigServerRegistrar : IServerRegistrar { - private readonly XmlNode _xmlServers; + private readonly IEnumerable _servers; public ConfigServerRegistrar() - : this(LegacyUmbracoSettings.DistributionServers) + : this(UmbracoConfiguration.Current.UmbracoSettings.DistributedCall.Servers) { } - internal ConfigServerRegistrar(XmlNode xmlServers) + internal ConfigServerRegistrar(IEnumerable servers) { - _xmlServers = xmlServers; + _servers = servers; } private List _addresses; @@ -36,16 +37,12 @@ namespace Umbraco.Core.Sync { _addresses = new List(); - if (_xmlServers != null) + if (_servers != null) { - var nodes = _xmlServers.SelectNodes("./server"); - if (nodes != null) + foreach (var n in _servers) { - foreach (XmlNode n in nodes) - { - _addresses.Add(new ConfigServerAddress(n)); - } - } + _addresses.Add(new ConfigServerAddress(n)); + } } } diff --git a/src/Umbraco.Core/Sync/DefaultServerMessenger.cs b/src/Umbraco.Core/Sync/DefaultServerMessenger.cs index 4aa8c1652c..c15ff006f1 100644 --- a/src/Umbraco.Core/Sync/DefaultServerMessenger.cs +++ b/src/Umbraco.Core/Sync/DefaultServerMessenger.cs @@ -39,7 +39,7 @@ namespace Umbraco.Core.Sync /// /// internal DefaultServerMessenger(string login, string password) - : this(login, password, LegacyUmbracoSettings.UseDistributedCalls) + : this(login, password, UmbracoConfiguration.Current.UmbracoSettings.DistributedCall.Enabled) { } @@ -226,7 +226,7 @@ namespace Umbraco.Core.Sync { Login = result.Item1; Password = result.Item2; - _useDistributedCalls = LegacyUmbracoSettings.UseDistributedCalls; + _useDistributedCalls = UmbracoConfiguration.Current.UmbracoSettings.DistributedCall.Enabled; } } catch (Exception ex) diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 3706e511f7..f8d18a42d9 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -144,9 +144,16 @@ + + + + + + + @@ -172,7 +179,6 @@ - @@ -201,7 +207,7 @@ - + @@ -804,7 +810,6 @@ - diff --git a/src/Umbraco.Core/XmlHelper.cs b/src/Umbraco.Core/XmlHelper.cs index cf76c4a032..bd488a0084 100644 --- a/src/Umbraco.Core/XmlHelper.cs +++ b/src/Umbraco.Core/XmlHelper.cs @@ -78,7 +78,7 @@ namespace Umbraco.Core if (xml == null) return false; xml = xml.Trim(); if (xml.StartsWith("<") == false || xml.EndsWith(">") == false || xml.Contains('/') == false) return false; - if (LegacyUmbracoSettings.NotDynamicXmlDocumentElements.Any(x => x.InvariantEquals(alias))) return false; + if (UmbracoConfiguration.Current.UmbracoSettings.Scripting.Razor.NotDynamicXmlDocumentElements.Any(x => x.Element.InvariantEquals(alias))) return false; return TryCreateXPathDocument(xml, out doc); } diff --git a/src/Umbraco.Tests/Configurations/UmbracoSettings/ContentElementTests.cs b/src/Umbraco.Tests/Configurations/UmbracoSettings/ContentElementTests.cs index ef7ae5c65a..e08febf5bc 100644 --- a/src/Umbraco.Tests/Configurations/UmbracoSettings/ContentElementTests.cs +++ b/src/Umbraco.Tests/Configurations/UmbracoSettings/ContentElementTests.cs @@ -104,12 +104,12 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings [Test] public void MacroErrors() { - Assert.IsTrue(Section.Content.MacroErrors == MacroErrorBehaviour.Inline); + Assert.IsTrue(Section.Content.MacroErrorBehaviour == MacroErrorBehaviour.Inline); } [Test] public void DocumentTypeIconList() { - Assert.IsTrue(Section.Content.DocumentTypeIconList == IconPickerBehaviour.HideFileDuplicates); + Assert.IsTrue(Section.Content.IconPickerBehaviour == IconPickerBehaviour.HideFileDuplicates); } [Test] public void DisallowedUploadFiles() diff --git a/src/Umbraco.Tests/Configurations/UmbracoSettings/DeveloperElementTests.cs b/src/Umbraco.Tests/Configurations/UmbracoSettings/DeveloperElementTests.cs index b21e5241de..b4cc0e84ab 100644 --- a/src/Umbraco.Tests/Configurations/UmbracoSettings/DeveloperElementTests.cs +++ b/src/Umbraco.Tests/Configurations/UmbracoSettings/DeveloperElementTests.cs @@ -9,8 +9,8 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings [Test] public void AppCodeFileExtensions() { - Assert.IsTrue(Section.Developer.AppCodeFileExtensions.AppCodeFileExtensions.Count() == 2); - Assert.IsTrue(Section.Developer.AppCodeFileExtensions.AppCodeFileExtensions.All( + Assert.IsTrue(Section.Developer.AppCodeFileExtensions.Count() == 2); + Assert.IsTrue(Section.Developer.AppCodeFileExtensions.All( x => "cs,vb".Split(',').Contains(x.Extension))); } } diff --git a/src/Umbraco.Tests/Configurations/UmbracoSettings/LoggingElementTests.cs b/src/Umbraco.Tests/Configurations/UmbracoSettings/LoggingElementTests.cs index fbb775d5b8..6247d0e81b 100644 --- a/src/Umbraco.Tests/Configurations/UmbracoSettings/LoggingElementTests.cs +++ b/src/Umbraco.Tests/Configurations/UmbracoSettings/LoggingElementTests.cs @@ -37,7 +37,7 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings [Test] public virtual void ExternalLogger_Type() { - Assert.IsTrue(Section.Logging.ExternalLogger.Type == "fully.qualified.namespace.and.type"); + Assert.IsTrue(Section.Logging.ExternalLogger.ExternalLoggerType == "fully.qualified.namespace.and.type"); } [Test] public virtual void ExternalLogger_LogAuditTrail() diff --git a/src/Umbraco.Tests/Configurations/UmbracoSettings/WebRoutingElementTests.cs b/src/Umbraco.Tests/Configurations/UmbracoSettings/WebRoutingElementTests.cs index feb308ac31..1382682981 100644 --- a/src/Umbraco.Tests/Configurations/UmbracoSettings/WebRoutingElementTests.cs +++ b/src/Umbraco.Tests/Configurations/UmbracoSettings/WebRoutingElementTests.cs @@ -16,5 +16,11 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings { Assert.IsTrue(Section.WebRouting.TrySkipIisCustomErrors == false); } + + [Test] + public void UrlProviderMode() + { + Assert.IsTrue(Section.WebRouting.UrlProviderMode == "Auto"); + } } } \ No newline at end of file diff --git a/src/Umbraco.Web.UI/install/steps/DefaultUser.ascx.cs b/src/Umbraco.Web.UI/install/steps/DefaultUser.ascx.cs index 8f90392c79..768a3ab679 100644 --- a/src/Umbraco.Web.UI/install/steps/DefaultUser.ascx.cs +++ b/src/Umbraco.Web.UI/install/steps/DefaultUser.ascx.cs @@ -22,16 +22,16 @@ namespace Umbraco.Web.UI.Install.Steps if (Page.IsValid) { var u = User.GetUser(0); - var user = Membership.Providers[LegacyUmbracoSettings.DefaultBackofficeProvider].GetUser(0, true); + var user = Membership.Providers[UmbracoConfiguration.Current.UmbracoSettings.Providers.Users.DefaultBackOfficeProvider].GetUser(0, true); user.ChangePassword(u.GetPassword(), tb_password.Text.Trim()); // Is it using the default membership provider - if (Membership.Providers[LegacyUmbracoSettings.DefaultBackofficeProvider] is UsersMembershipProvider) + if (Membership.Providers[UmbracoConfiguration.Current.UmbracoSettings.Providers.Users.DefaultBackOfficeProvider] is UsersMembershipProvider) { // Save user in membership provider var umbracoUser = user as UsersMembershipUser; umbracoUser.FullName = tb_name.Text.Trim(); - Membership.Providers[LegacyUmbracoSettings.DefaultBackofficeProvider].UpdateUser(umbracoUser); + Membership.Providers[UmbracoConfiguration.Current.UmbracoSettings.Providers.Users.DefaultBackOfficeProvider].UpdateUser(umbracoUser); // Save user details u.Email = tb_email.Text.Trim(); @@ -39,7 +39,7 @@ namespace Umbraco.Web.UI.Install.Steps else { u.Name = tb_name.Text.Trim(); - if (!(Membership.Providers[LegacyUmbracoSettings.DefaultBackofficeProvider] is ActiveDirectoryMembershipProvider)) Membership.Providers[LegacyUmbracoSettings.DefaultBackofficeProvider].UpdateUser(user); + if (!(Membership.Providers[UmbracoConfiguration.Current.UmbracoSettings.Providers.Users.DefaultBackOfficeProvider] is ActiveDirectoryMembershipProvider)) Membership.Providers[UmbracoConfiguration.Current.UmbracoSettings.Providers.Users.DefaultBackOfficeProvider].UpdateUser(user); } // we need to update the login name here as it's set to the old name when saving the user via the membership provider! diff --git a/src/Umbraco.Web.UI/web.Template.config b/src/Umbraco.Web.UI/web.Template.config index e454acc61c..7c3158d8ee 100644 --- a/src/Umbraco.Web.UI/web.Template.config +++ b/src/Umbraco.Web.UI/web.Template.config @@ -8,8 +8,7 @@
-
- +
@@ -17,12 +16,14 @@
+
+ @@ -32,7 +33,6 @@ -