diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings.cs b/src/Umbraco.Core/Configuration/UmbracoSettings.cs index f1e5cfe78d..2b5ef086fb 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings.cs @@ -20,124 +20,124 @@ namespace Umbraco.Core.Configuration //TODO: Re-enable logging !!!! - /// - /// The UmbracoSettings Class contains general settings information for the entire Umbraco instance based on information from the /config/umbracoSettings.config file - /// - internal class UmbracoSettings - { - internal const string TempFriendlyXmlChildContainerNodename = ""; // "children"; + /// + /// The UmbracoSettings Class contains general settings information for the entire Umbraco instance based on information from the /config/umbracoSettings.config file + /// + internal class UmbracoSettings + { + internal const string TempFriendlyXmlChildContainerNodename = ""; // "children"; - /// - /// Gets the umbraco settings document. - /// - /// The _umbraco settings. + /// + /// Gets the umbraco settings document. + /// + /// The _umbraco settings. internal static XmlDocument UmbracoSettingsXmlDoc - { - get - { - var us = (XmlDocument)HttpRuntime.Cache["umbracoSettingsFile"] ?? EnsureSettingsDocument(); - return us; - } - } + { + get + { + var us = (XmlDocument)HttpRuntime.Cache["umbracoSettingsFile"] ?? EnsureSettingsDocument(); + return us; + } + } - private static string _path; + 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); } + { + get { return _path ?? (_path = GlobalSettings.FullpathToRoot + Path.DirectorySeparatorChar + "config" + Path.DirectorySeparatorChar); } set { _path = value; } - } + } - internal const string Filename = "umbracoSettings.config"; + internal const string Filename = "umbracoSettings.config"; - internal static XmlDocument EnsureSettingsDocument() - { - var settingsFile = HttpRuntime.Cache["umbracoSettingsFile"]; + 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) - { + // 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; - } + } + settingsReader.Close(); + return temp; + } + else + return (XmlDocument)settingsFile; + } - internal static void Save() - { - UmbracoSettingsXmlDoc.Save(SettingsFilePath + Filename); - } + 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. - public 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); - } + /// + /// 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. + public 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. - /// - public static string GetKey(string key) - { - EnsureSettingsDocument(); + /// + /// Gets the value of configuration xml node with the specified key. + /// + /// The key. + /// + public static string GetKey(string key) + { + EnsureSettingsDocument(); - var node = UmbracoSettingsXmlDoc.DocumentElement.SelectSingleNode(key); - if (node == null || node.FirstChild == null || node.FirstChild.Value == null) - return string.Empty; - return node.FirstChild.Value; - } + var node = UmbracoSettingsXmlDoc.DocumentElement.SelectSingleNode(key); + if (node == null || node.FirstChild == null || node.FirstChild.Value == null) + return string.Empty; + return node.FirstChild.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. - /// - public static bool UploadAllowDirectories - { - get { return bool.Parse(GetKey("/settings/content/UploadAllowDirectories")); } - } + /// + /// Gets a value indicating whether the media library will create new directories in the /media directory. + /// + /// + /// true if new directories are allowed otherwise, false. + /// + public 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; } - } + 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 @@ -145,321 +145,321 @@ namespace Umbraco.Core.Configuration /// internal static string BootSplashPage { - get { return "~/config/splashes/booting.aspx"; } + 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. + /// + /// Gets a value indicating whether logging is enabled in umbracoSettings.config (/settings/logging/enableLogging). + /// + /// true if logging is enabled; otherwise, false. public 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); - } - } + { + 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. - public 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 a value indicating whether logging happens async. + /// + /// true if async logging is enabled; otherwise, false. + public 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 - /// - public 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 - /// - public static string ExternalLoggerType - { - get - { - var value = GetKeyAsNode("/settings/logging/externalLogger"); - return value != null ? value.Attributes["type"].Value : ""; - } - } + /// + /// Gets the assembly of an external logger that can be used to store log items in 3rd party systems + /// + public 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 + /// + public static string ExternalLoggerType + { + get + { + var value = GetKeyAsNode("/settings/logging/externalLogger"); + return value != null ? value.Attributes["type"].Value : ""; + } + } - /// - /// Long Audit Trail to external log too - /// - public 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; - } - } + /// + /// Long Audit Trail to external log too + /// + public 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 - /// - public 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; - } - } + /// + /// Keep user alive as long as they have their browser open? Default is true + /// + public 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; + } + } - /// - /// Show disabled users in the tree in the Users section in the backoffice - /// - public 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; - } - } + /// + /// Show disabled users in the tree in the Users section in the backoffice + /// + public 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 - public 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 a value indicating whether the logs will be auto cleaned + /// + /// true if logs are to be automatically cleaned; otherwise, false + public 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) - /// - public 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; - } - } + /// + /// Gets the value indicating the log cleaning frequency (in miliseconds) + /// + public 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; + } + } - public 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; - } - } + public 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. - public static XmlNode DisabledLogTypes - { - get { return GetKeyAsNode("/settings/logging/disabledLogTypes"); } - } + /// + /// Gets the disabled log types. + /// + /// The disabled log types. + public static XmlNode DisabledLogTypes + { + get { return GetKeyAsNode("/settings/logging/disabledLogTypes"); } + } - /// - /// Gets the package server url. - /// - /// The package server url. - public static string PackageServer - { - get { return "packages.umbraco.org"; } - } + /// + /// Gets the package server url. + /// + /// The package server url. + public 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. + /// + /// Gets a value indicating whether umbraco will use domain prefixes. + /// + /// true if umbraco will use domain prefixes; otherwise, false. // TODO rename as EnforceAbsoluteUrls - public static bool UseDomainPrefixes - { - get - { - try - { + public static bool UseDomainPrefixes + { + get + { + try + { if (_useDomainPrefixes.HasValue) return _useDomainPrefixes.Value; - bool result; - if (bool.TryParse(GetKey("/settings/requestHandler/useDomainPrefixes"), out result)) - return result; - return false; - } - catch - { - return false; - } - } + bool result; + if (bool.TryParse(GetKey("/settings/requestHandler/useDomainPrefixes"), out result)) + return result; + return false; + } + catch + { + return false; + } + } // for unit tests only internal set { _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 - /// - public static bool AddTrailingSlash - { - get - { - try - { - if (GlobalSettings.UseDirectoryUrls) - { + /// + /// 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 + /// + public static bool AddTrailingSlash + { + get + { + try + { + if (GlobalSettings.UseDirectoryUrls) + { if (_addTrailingSlash.HasValue) return _addTrailingSlash.Value; - bool result; - if (bool.TryParse(GetKey("/settings/requestHandler/addTrailingSlash"), out result)) - return result; - return false; - } - else - { - return false; - } - } - catch - { - return false; - } - } + bool result; + if (bool.TryParse(GetKey("/settings/requestHandler/addTrailingSlash"), out result)) + return result; + return false; + } + else + { + return false; + } + } + catch + { + return false; + } + } // for unit tests only internal set { _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. - public 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 use ASP.NET MasterPages for rendering instead of its propriatary templating system. + /// + /// true if umbraco will use ASP.NET MasterPages; otherwise, false. + public 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. - public static bool EnableTemplateFolders - { - get - { - try - { - bool result; - if (bool.TryParse(GetKey("/settings/templates/enableTemplateFolders"), 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. + public 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 - /// + /// + /// razor DynamicNode typecasting detects XML and returns DynamicXml - Root elements that won't convert to DynamicXml + /// public 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" }; - } - } - } + { + 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(); + private static IEnumerable _razorDataTypeModelStaticMapping; + private static readonly ReaderWriterLockSlim Lock = new ReaderWriterLockSlim(); public static IEnumerable RazorDataTypeModelStaticMapping - { - get - { + { + get + { /* DigibizAdvancedMediaPicker.RazorModel.ModelBinder @@ -472,7 +472,7 @@ namespace Umbraco.Core.Configuration if (_razorDataTypeModelStaticMapping == null) { l.UpgradeToWriteLock(); - + List items = new List(); XmlNode root = GetKeyAsNode("/settings/scripting/razor/dataTypeModelStaticMappings"); if (root != null) @@ -510,505 +510,505 @@ namespace Umbraco.Core.Configuration _razorDataTypeModelStaticMapping = items; } - return _razorDataTypeModelStaticMapping; - } - } - } + 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. - /// - public 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 umbraco will clone XML cache on publish. + /// + /// + /// true if umbraco will clone XML cache on publish; otherwise, false. + /// + public 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. - public static bool TidyEditorContent - { - get { return bool.Parse(GetKey("/settings/content/TidyEditorContent")); } - } + /// + /// Gets a value indicating whether rich text editor content should be parsed by tidy. + /// + /// true if content is parsed; otherwise, false. + public static bool TidyEditorContent + { + get { return bool.Parse(GetKey("/settings/content/TidyEditorContent")); } + } - /// - /// Gets the encoding type for the tidyied content. - /// - /// The encoding type as string. - public static string TidyCharEncoding - { - get - { - string encoding = GetKey("/settings/content/TidyCharEncoding"); - if (String.IsNullOrEmpty(encoding)) - { - encoding = "UTF8"; - } - return encoding; - } - } + /// + /// Gets the encoding type for the tidyied content. + /// + /// The encoding type as string. + public 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. - public static string PropertyContextHelpOption - { - get { return GetKey("/settings/content/PropertyContextHelpOption").ToLower(); } - } + /// + /// Gets the property context help option, this can either be 'text', 'icon' or 'none' + /// + /// The property context help option. + public static string PropertyContextHelpOption + { + get { return GetKey("/settings/content/PropertyContextHelpOption").ToLower(); } + } - public static string DefaultBackofficeProvider - { - get - { - string defaultProvider = GetKey("/settings/providers/users/DefaultBackofficeProvider"); - if (String.IsNullOrEmpty(defaultProvider)) - defaultProvider = "UsersMembershipProvider"; + public static string DefaultBackofficeProvider + { + get + { + string defaultProvider = GetKey("/settings/providers/users/DefaultBackofficeProvider"); + if (String.IsNullOrEmpty(defaultProvider)) + defaultProvider = "UsersMembershipProvider"; - return defaultProvider; - } - } + return defaultProvider; + } + } - /// - /// Whether to force safe aliases (no spaces, no special characters) at businesslogic level on contenttypes and propertytypes - /// - public static bool ForceSafeAliases - { - get - { - string forceSafeAlias = GetKey("/settings/content/ForceSafeAliases"); - if (String.IsNullOrEmpty(forceSafeAlias)) - return true; - else - { - try - { - return bool.Parse(forceSafeAlias); - } - catch - { - return true; - } - } + /// + /// Whether to force safe aliases (no spaces, no special characters) at businesslogic level on contenttypes and propertytypes + /// + public static bool ForceSafeAliases + { + get + { + string forceSafeAlias = GetKey("/settings/content/ForceSafeAliases"); + if (String.IsNullOrEmpty(forceSafeAlias)) + return true; + else + { + try + { + return bool.Parse(forceSafeAlias); + } + catch + { + return true; + } + } - } - } + } + } - /// - /// Gets the allowed image file types. - /// - /// The allowed image file types. - public static string ImageFileTypes - { - get { return GetKey("/settings/content/imaging/imageFileTypes").ToLowerInvariant(); } - } + /// + /// Gets the allowed image file types. + /// + /// The allowed image file types. + public static string ImageFileTypes + { + get { return GetKey("/settings/content/imaging/imageFileTypes").ToLowerInvariant(); } + } - /// - /// Gets the allowed script file types. - /// - /// The allowed script file types. - public static string ScriptFileTypes - { - get { return GetKey("/settings/content/scripteditor/scriptFileTypes"); } - } + /// + /// Gets the allowed script file types. + /// + /// The allowed script file types. + public static string ScriptFileTypes + { + get { return GetKey("/settings/content/scripteditor/scriptFileTypes"); } + } - /// - /// Gets the duration in seconds to cache queries to umbraco library member and media methods - /// Default is 1800 seconds (30 minutes) - /// - public static int UmbracoLibraryCacheDuration - { - get - { - string libraryCacheDuration = GetKey("/settings/content/UmbracoLibraryCacheDuration"); - if (String.IsNullOrEmpty(libraryCacheDuration)) - return 1800; - else - { - try - { - return int.Parse(libraryCacheDuration); - } - catch - { - return 1800; - } - } + /// + /// Gets the duration in seconds to cache queries to umbraco library member and media methods + /// Default is 1800 seconds (30 minutes) + /// + public static int UmbracoLibraryCacheDuration + { + get + { + string libraryCacheDuration = GetKey("/settings/content/UmbracoLibraryCacheDuration"); + if (String.IsNullOrEmpty(libraryCacheDuration)) + return 1800; + else + { + try + { + return int.Parse(libraryCacheDuration); + } + catch + { + return 1800; + } + } - } - } + } + } - /// - /// Gets the path to the scripts folder used by the script editor. - /// - /// The script folder path. - public static string ScriptFolderPath - { - get { return GetKey("/settings/content/scripteditor/scriptFolderPath"); } - } + /// + /// Gets the path to the scripts folder used by the script editor. + /// + /// The script folder path. + public static string ScriptFolderPath + { + get { return GetKey("/settings/content/scripteditor/scriptFolderPath"); } + } - /// - /// Enabled or disable the script/code editor - /// - public 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. - public static bool EnsureUniqueNaming - { - get - { - try - { - return bool.Parse(GetKey("/settings/content/ensureUniqueNaming")); - } - catch - { - return false; - } - } - } + /// + /// Enabled or disable the script/code editor + /// + public static bool ScriptDisableEditor + { + get + { + string _tempValue = GetKey("/settings/content/scripteditor/scriptDisableEditor"); + if (_tempValue != String.Empty) + return bool.Parse(_tempValue); + else + return false; + } + } - /// - /// Gets the notification email sender. - /// - /// The notification email sender. - public static string NotificationEmailSender - { - get { return GetKey("/settings/content/notifications/email"); } - } + /// + /// 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. + public static bool EnsureUniqueNaming + { + get + { + try + { + return bool.Parse(GetKey("/settings/content/ensureUniqueNaming")); + } + catch + { + return false; + } + } + } - /// - /// Gets a value indicating whether notification-emails are HTML. - /// - /// - /// true if html notification-emails are disabled; otherwise, false. - /// - public static bool NotificationDisableHtmlEmail - { - get - { - var tempValue = GetKey("/settings/content/notifications/disableHtmlEmail"); - return tempValue != String.Empty && bool.Parse(tempValue); - } - } + /// + /// Gets the notification email sender. + /// + /// The notification email sender. + public static string NotificationEmailSender + { + get { return GetKey("/settings/content/notifications/email"); } + } - /// - /// Gets the allowed attributes on images. - /// - /// The allowed attributes on images. - public static string ImageAllowedAttributes - { - get { return GetKey("/settings/content/imaging/allowedAttributes"); } - } + /// + /// Gets a value indicating whether notification-emails are HTML. + /// + /// + /// true if html notification-emails are disabled; otherwise, false. + /// + public static bool NotificationDisableHtmlEmail + { + get + { + var tempValue = GetKey("/settings/content/notifications/disableHtmlEmail"); + return tempValue != String.Empty && bool.Parse(tempValue); + } + } - public static XmlNode ImageAutoFillImageProperties - { - get { return GetKeyAsNode("/settings/content/imaging/autoFillImageProperties"); } - } + /// + /// Gets the allowed attributes on images. + /// + /// The allowed attributes on images. + public static string ImageAllowedAttributes + { + get { return GetKey("/settings/content/imaging/allowedAttributes"); } + } - /// - /// Gets the scheduled tasks as XML - /// - /// The scheduled tasks. - public static XmlNode ScheduledTasks - { - get { return GetKeyAsNode("/settings/scheduledTasks"); } - } + public static XmlNode ImageAutoFillImageProperties + { + get { return GetKeyAsNode("/settings/content/imaging/autoFillImageProperties"); } + } - /// - /// Gets a list of characters that will be replaced when generating urls - /// - /// The URL replacement characters. - public static XmlNode UrlReplaceCharacters - { - get { return GetKeyAsNode("/settings/requestHandler/urlReplacing"); } - } + /// + /// Gets the scheduled tasks as XML + /// + /// The scheduled tasks. + public static XmlNode ScheduledTasks + { + get { return GetKeyAsNode("/settings/scheduledTasks"); } + } - /// - /// Whether to replace double dashes from url (ie my--story----from--dash.aspx caused by multiple url replacement chars - /// - public static bool RemoveDoubleDashesFromUrlReplacing - { - get - { - try - { - return bool.Parse(UrlReplaceCharacters.Attributes.GetNamedItem("removeDoubleDashes").Value); - } - catch - { - return false; - } - } - } + /// + /// Gets a list of characters that will be replaced when generating urls + /// + /// The URL replacement characters. + public static XmlNode UrlReplaceCharacters + { + get { return GetKeyAsNode("/settings/requestHandler/urlReplacing"); } + } - /// - /// 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. - public static bool UseDistributedCalls - { - get - { - try - { - return bool.Parse(GetKeyAsNode("/settings/distributedCall").Attributes.GetNamedItem("enable").Value); - } - catch - { - return false; - } - } - } + /// + /// Whether to replace double dashes from url (ie my--story----from--dash.aspx caused by multiple url replacement chars + /// + public 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. + public 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. - public static int DistributedCallUser - { - get - { - try - { - return int.Parse(GetKey("/settings/distributedCall/user")); - } - catch - { - return -1; - } - } - } + /// + /// Gets the ID of the user with access rights to perform the distributed calls. + /// + /// The distributed call user. + public 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 - /// - public static string PreviewBadge - { - get - { - try - { - return GetKey("/settings/content/PreviewBadge"); - } - catch - { - return "In Preview Mode - click to end"; - } - } - } + /// + /// Gets the html injected into a (x)html page if Umbraco is running in preview mode + /// + public 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. - public static XmlNode DistributionServers - { - get - { - try - { - return GetKeyAsNode("/settings/distributedCall/servers"); - } - catch - { - return null; - } - } - } + /// + /// 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. + public 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. - /// - public static XmlNode HelpPages - { - get - { - try - { - return GetKeyAsNode("/settings/help"); - } - catch - { - return null; - } - } - } + /// + /// Gets HelpPage configurations. + /// A help page configuration specify language, user type, application, application url and + /// the target help page url. + /// + public 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. - public static XmlNode Repositories - { - get - { - try - { - return GetKeyAsNode("/settings/repositories"); - } - 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. + public 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. - /// - public static bool UseViewstateMoverModule - { - get - { - try - { - return - bool.Parse( - GetKeyAsNode("/settings/viewstateMoverModule").Attributes.GetNamedItem("enable").Value); - } - catch - { - return false; - } - } - } + /// + /// 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. + /// + public 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 - /// - public 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; - } - } - } + /// + /// Tells us whether the Xml Content cache is disabled or not + /// Default is enabled + /// + public 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 - /// - public 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; - } - } - } + /// + /// 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 + /// + public 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 - /// - public 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; - } - } - } + /// + /// 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 + /// + public 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; + 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. - /// - public static bool UseLegacyXmlSchema - { - get - { + /// + /// Whether to use the new 4.1 schema or the old legacy schema + /// + /// + /// true if yes, use the old node/data model; otherwise, false. + /// + public static bool UseLegacyXmlSchema + { + get + { try { if (_useLegacySchema.HasValue) @@ -1024,341 +1024,344 @@ namespace Umbraco.Core.Configuration { //default. TODO: When we change this to a real config section we won't have to worry about parse errors // and should handle defaults with unit tests properly. - return false; + return 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")] - public static IEnumerable AppCodeFileExtensionsList - { - get - { - return (from XmlNode x in AppCodeFileExtensions + public 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")] - public static XmlNode AppCodeFileExtensions - { - get - { - XmlNode value = GetKeyAsNode("/settings/developer/appCodeFileExtensions"); - if (value != null) - { - return value; - } + public 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; - } - } + // 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 - /// - public 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 the Xml to always update disk cache, when changes are made to content + /// Default is enabled + /// + public 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 - /// - public 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; - } - } - } + /// + /// 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 + /// + public 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; - public 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); + private static bool? _resolveUrlsFromTextString; + public 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; - } - } - - /// - /// 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. - - private static bool? _enableMvc; - public static bool EnableMvcSupport - { - get - { - if (_enableMvc == null) - { - try - { - bool enableMvc = false; - string value = GetKey("/settings/templates/enableMvcSupport"); - if (value != null) - if (bool.TryParse(value, out enableMvc)) - _enableMvc = enableMvc; - } - catch (Exception ex) - { - LogHelper.Error("Could not load /settings/templates/enableMvcSupport from umbracosettings.config", ex); - _enableMvc = false; - } - } - return _enableMvc == true; - } - } + // set url resolving to true (default (legacy) behavior) to ensure we don't keep writing to trace + _resolveUrlsFromTextString = true; + } + } + return _resolveUrlsFromTextString == true; + } + } - /// - /// Configuration regarding webservices - /// - /// Put in seperate class for more logik/seperation - internal class WebServices - { - /// - /// Gets a value indicating whether this is enabled. - /// - /// true if enabled; otherwise, false. - public static bool Enabled - { - get - { - try - { - return - bool.Parse(GetKeyAsNode("/settings/webservices").Attributes.GetNamedItem("enabled").Value); - } - catch - { - return false; - } - } - } + private static RenderingEngine? _defaultRenderingEngine; - #region "Webservice configuration" - - /// - /// Gets the document service users who have access to use the document web service - /// - /// The document service users. - public static string[] DocumentServiceUsers - { - get - { - try - { - return GetKey("/settings/webservices/documentServiceUsers").Split(','); - } - catch - { - return new string[0]; - } - } - } - - /// - /// Gets the file service users who have access to use the file web service - /// - /// The file service users. - public static string[] FileServiceUsers - { - get - { - try - { - return GetKey("/settings/webservices/fileServiceUsers").Split(','); - } - catch - { - return new string[0]; - } - } - } + /// + /// 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. + public 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; + } + } - /// - /// Gets the folders used by the file web service - /// - /// The file service folders. - public static string[] FileServiceFolders - { - get - { - try - { - return GetKey("/settings/webservices/fileServiceFolders").Split(','); - } - catch - { - return new string[0]; - } - } - } + /// + /// Configuration regarding webservices + /// + /// Put in seperate class for more logik/seperation + internal class WebServices + { + /// + /// Gets a value indicating whether this is enabled. + /// + /// true if enabled; otherwise, false. + public static bool Enabled + { + get + { + try + { + return + bool.Parse(GetKeyAsNode("/settings/webservices").Attributes.GetNamedItem("enabled").Value); + } + catch + { + return false; + } + } + } - /// - /// Gets the member service users who have access to use the member web service - /// - /// The member service users. - public static string[] MemberServiceUsers - { - get - { - try - { - return GetKey("/settings/webservices/memberServiceUsers").Split(','); - } - catch - { - return new string[0]; - } - } - } + #region "Webservice configuration" - /// - /// Gets the stylesheet service users who have access to use the stylesheet web service - /// - /// The stylesheet service users. - public static string[] StylesheetServiceUsers - { - get - { - try - { - return GetKey("/settings/webservices/stylesheetServiceUsers").Split(','); - } - catch - { - return new string[0]; - } - } - } + /// + /// Gets the document service users who have access to use the document web service + /// + /// The document service users. + public static string[] DocumentServiceUsers + { + get + { + try + { + return GetKey("/settings/webservices/documentServiceUsers").Split(','); + } + catch + { + return new string[0]; + } + } + } - /// - /// Gets the template service users who have access to use the template web service - /// - /// The template service users. - public static string[] TemplateServiceUsers - { - get - { - try - { - return GetKey("/settings/webservices/templateServiceUsers").Split(','); - } - catch - { - return new string[0]; - } - } - } - - /// - /// Gets the media service users who have access to use the media web service - /// - /// The media service users. - public static string[] MediaServiceUsers - { - get - { - try - { - return GetKey("/settings/webservices/mediaServiceUsers").Split(','); - } - catch - { - return new string[0]; - } - } - } + /// + /// Gets the file service users who have access to use the file web service + /// + /// The file service users. + public static string[] FileServiceUsers + { + get + { + try + { + return GetKey("/settings/webservices/fileServiceUsers").Split(','); + } + catch + { + return new string[0]; + } + } + } - /// - /// Gets the maintenance service users who have access to use the maintance web service - /// - /// The maintenance service users. - public static string[] MaintenanceServiceUsers - { - get - { - try - { - return GetKey("/settings/webservices/maintenanceServiceUsers").Split(','); - } - catch - { - return new string[0]; - } - } - } + /// + /// Gets the folders used by the file web service + /// + /// The file service folders. + public static string[] FileServiceFolders + { + get + { + try + { + return GetKey("/settings/webservices/fileServiceFolders").Split(','); + } + catch + { + return new string[0]; + } + } + } - #endregion - } - } + /// + /// Gets the member service users who have access to use the member web service + /// + /// The member service users. + public static string[] MemberServiceUsers + { + get + { + try + { + return GetKey("/settings/webservices/memberServiceUsers").Split(','); + } + catch + { + return new string[0]; + } + } + } + + /// + /// Gets the stylesheet service users who have access to use the stylesheet web service + /// + /// The stylesheet service users. + public static string[] StylesheetServiceUsers + { + get + { + try + { + return GetKey("/settings/webservices/stylesheetServiceUsers").Split(','); + } + catch + { + return new string[0]; + } + } + } + + /// + /// Gets the template service users who have access to use the template web service + /// + /// The template service users. + public static string[] TemplateServiceUsers + { + get + { + try + { + return GetKey("/settings/webservices/templateServiceUsers").Split(','); + } + catch + { + return new string[0]; + } + } + } + + /// + /// Gets the media service users who have access to use the media web service + /// + /// The media service users. + public static string[] MediaServiceUsers + { + get + { + try + { + return GetKey("/settings/webservices/mediaServiceUsers").Split(','); + } + catch + { + return new string[0]; + } + } + } + + + /// + /// Gets the maintenance service users who have access to use the maintance web service + /// + /// The maintenance service users. + public static string[] MaintenanceServiceUsers + { + get + { + try + { + return GetKey("/settings/webservices/maintenanceServiceUsers").Split(','); + } + catch + { + return new string[0]; + } + } + } + + #endregion + } + } } \ No newline at end of file diff --git a/src/Umbraco.Core/Enum.cs b/src/Umbraco.Core/Enum.cs new file mode 100644 index 0000000000..eb29dd644e --- /dev/null +++ b/src/Umbraco.Core/Enum.cs @@ -0,0 +1,108 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Umbraco.Core +{ + /// + /// A very useful class for parsing, enumerating and querying Enum objects + /// + /// + /// + /// Taken from http://damieng.com/blog/2010/10/17/enums-better-syntax-improved-performance-and-tryparse-in-net-3-5 + /// + internal static class Enum where T : struct + { + private static readonly IEnumerable All = Enum.GetValues(typeof(T)).Cast(); + private static readonly Dictionary InsensitiveNames = All.ToDictionary(k => Enum.GetName(typeof(T), k).ToLowerInvariant()); + private static readonly Dictionary SensitiveNames = All.ToDictionary(k => Enum.GetName(typeof(T), k)); + private static readonly Dictionary Values = All.ToDictionary(k => Convert.ToInt32(k)); + private static readonly Dictionary Names = All.ToDictionary(k => k, v => v.ToString()); + + public static bool IsDefined(T value) + { + return Names.Keys.Contains(value); + } + + public static bool IsDefined(string value) + { + return SensitiveNames.Keys.Contains(value); + } + + public static bool IsDefined(int value) + { + return Values.Keys.Contains(value); + } + + public static IEnumerable GetValues() + { + return All; + } + + public static string[] GetNames() + { + return Names.Values.ToArray(); + } + + public static string GetName(T value) + { + string name; + Names.TryGetValue(value, out name); + return name; + } + + public static T Parse(string value) + { + T parsed = default(T); + if (!SensitiveNames.TryGetValue(value, out parsed)) + throw new ArgumentException("Value is not one of the named constants defined for the enumeration", "value"); + return parsed; + } + + public static T Parse(string value, bool ignoreCase) + { + if (!ignoreCase) + return Parse(value); + + T parsed = default(T); + if (!InsensitiveNames.TryGetValue(value.ToLowerInvariant(), out parsed)) + throw new ArgumentException("Value is not one of the named constants defined for the enumeration", "value"); + return parsed; + } + + public static bool TryParse(string value, out T returnValue) + { + return SensitiveNames.TryGetValue(value, out returnValue); + } + + public static bool TryParse(string value, bool ignoreCase, out T returnValue) + { + if (!ignoreCase) + return TryParse(value, out returnValue); + + return InsensitiveNames.TryGetValue(value.ToLowerInvariant(), out returnValue); + } + + public static T? ParseOrNull(string value) + { + if (String.IsNullOrEmpty(value)) + return null; + + T foundValue; + if (InsensitiveNames.TryGetValue(value.ToLowerInvariant(), out foundValue)) + return foundValue; + + return null; + } + + public static T? CastOrNull(int value) + { + T foundValue; + if (Values.TryGetValue(value, out foundValue)) + return foundValue; + + return null; + } + } +} diff --git a/src/Umbraco.Core/RenderingEngine.cs b/src/Umbraco.Core/RenderingEngine.cs new file mode 100644 index 0000000000..fddf9147e6 --- /dev/null +++ b/src/Umbraco.Core/RenderingEngine.cs @@ -0,0 +1,8 @@ +namespace Umbraco.Core +{ + public enum RenderingEngine + { + Mvc, + WebForms + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 10f23b9c08..02ac725951 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -61,6 +61,7 @@ + @@ -119,6 +120,7 @@ + diff --git a/src/Umbraco.Web.UI/config/umbracoSettings.config b/src/Umbraco.Web.UI/config/umbracoSettings.config index f614615947..fe496e18df 100644 --- a/src/Umbraco.Web.UI/config/umbracoSettings.config +++ b/src/Umbraco.Web.UI/config/umbracoSettings.config @@ -116,7 +116,7 @@ true true - true + Mvc diff --git a/src/Umbraco.Web/Routing/RenderingEngine.cs b/src/Umbraco.Web/Routing/RenderingEngine.cs deleted file mode 100644 index 5f83c3dec3..0000000000 --- a/src/Umbraco.Web/Routing/RenderingEngine.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Umbraco.Web.Routing -{ - internal enum RenderingEngine - { - Mvc, - WebForms - } -} \ No newline at end of file diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 193a712cd0..06831b3b47 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -310,7 +310,6 @@ - ASPXCodeBehind diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/loadTemplates.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/loadTemplates.cs index f5e7ac9642..d8336963d2 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/loadTemplates.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/loadTemplates.cs @@ -7,6 +7,7 @@ using System.Text; using System.Web; using System.Xml; using System.Configuration; +using Umbraco.Core; using umbraco.BasePages; using umbraco.BusinessLogic; using umbraco.businesslogic; @@ -193,7 +194,7 @@ namespace umbraco xNode.Source = GetTreeServiceUrl(t.Id); xNode.HasChildren = t.HasChildren; - if (UmbracoSettings.EnableMvcSupport && Template.HasView(t)) + if (Umbraco.Core.Configuration.UmbracoSettings.DefaultRenderingEngine == RenderingEngine.Mvc && Template.HasView(t)) { xNode.Action = "javascript:openView(" + t.Id + ");"; xNode.Icon = "settingView.gif"; diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/create/templateTasks.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/create/templateTasks.cs index 78e6025d27..03887b2cce 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/create/templateTasks.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/create/templateTasks.cs @@ -1,6 +1,7 @@ using System; using System.Data; using System.Web.Security; +using Umbraco.Core; using umbraco.BusinessLogic; using umbraco.DataLayer; using umbraco.BasePages; @@ -46,7 +47,7 @@ namespace umbraco BusinessLogic.Log.Add(LogTypes.Debug, -1, "tp id:" + masterId.ToString()); var editor = "settings/editTemplate.aspx"; - if(UmbracoSettings.EnableMvcSupport) + if(Umbraco.Core.Configuration.UmbracoSettings.DefaultRenderingEngine == RenderingEngine.Mvc) editor = "settings/views/editView.aspx"; if (masterId > 0) diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/settings/scripts/editScript.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/settings/scripts/editScript.aspx.cs index a489c11f5a..213e4b6a4f 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/settings/scripts/editScript.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/settings/scripts/editScript.aspx.cs @@ -10,6 +10,7 @@ using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.IO; +using Umbraco.Core; using umbraco.cms.presentation.Trees; using umbraco.IO; using System.Linq; @@ -44,34 +45,34 @@ namespace umbraco.cms.presentation.settings.scripts string path = ""; if (file.StartsWith("~/")) - path = IOHelper.ResolveUrl(file); + path = Umbraco.Core.IO.IOHelper.ResolveUrl(file); else - path = IOHelper.ResolveUrl(SystemDirectories.Scripts + "/" + file); + path = Umbraco.Core.IO.IOHelper.ResolveUrl(Umbraco.Core.IO.SystemDirectories.Scripts + "/" + file); lttPath.Text = "" + path + ""; var exts = UmbracoSettings.ScriptFileTypes.Split(',').ToList(); - if (UmbracoSettings.EnableMvcSupport) + if (Umbraco.Core.Configuration.UmbracoSettings.DefaultRenderingEngine == RenderingEngine.Mvc) { exts.Add("cshtml"); exts.Add("vbhtml"); } var dirs = Umbraco.Core.IO.SystemDirectories.Scripts; - if (UmbracoSettings.EnableMvcSupport) + if (Umbraco.Core.Configuration.UmbracoSettings.DefaultRenderingEngine == RenderingEngine.Mvc) dirs += "," + Umbraco.Core.IO.SystemDirectories.MvcViews; // validate file - IOHelper.ValidateEditPath(IOHelper.MapPath(path), dirs.Split(',')); + Umbraco.Core.IO.IOHelper.ValidateEditPath(Umbraco.Core.IO.IOHelper.MapPath(path), dirs.Split(',')); // validate extension - IOHelper.ValidateFileExtension(IOHelper.MapPath(path), exts); + Umbraco.Core.IO.IOHelper.ValidateFileExtension(Umbraco.Core.IO.IOHelper.MapPath(path), exts); StreamReader SR; string S; - SR = File.OpenText(IOHelper.MapPath(path)); + SR = File.OpenText(Umbraco.Core.IO.IOHelper.MapPath(path)); S = SR.ReadToEnd(); SR.Close(); diff --git a/src/umbraco.businesslogic/IO/IOHelper.cs b/src/umbraco.businesslogic/IO/IOHelper.cs index 3679e1cdfa..eb99389fcc 100644 --- a/src/umbraco.businesslogic/IO/IOHelper.cs +++ b/src/umbraco.businesslogic/IO/IOHelper.cs @@ -77,11 +77,6 @@ namespace umbraco.IO return Umbraco.Core.IO.IOHelper.ValidateEditPath(filePath, validDir); } - public static bool ValidateEditPath(string filePath, string[] validDirs) - { - return Umbraco.Core.IO.IOHelper.ValidateEditPath(filePath, validDirs); - } - public static bool ValidateFileExtension(string filePath, List validFileExtensions) { return Umbraco.Core.IO.IOHelper.ValidateFileExtension(filePath, validFileExtensions); diff --git a/src/umbraco.businesslogic/UmbracoSettings.cs b/src/umbraco.businesslogic/UmbracoSettings.cs index bd070fb659..6e30200699 100644 --- a/src/umbraco.businesslogic/UmbracoSettings.cs +++ b/src/umbraco.businesslogic/UmbracoSettings.cs @@ -546,19 +546,6 @@ namespace umbraco get { return Umbraco.Core.Configuration.UmbracoSettings.ResolveUrlsFromTextString; } } - - /// - /// 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. - public static bool EnableMvcSupport - { - get { return Umbraco.Core.Configuration.UmbracoSettings.EnableMvcSupport; } - } - /// /// Configuration regarding webservices /// diff --git a/src/umbraco.cms/businesslogic/template/Template.cs b/src/umbraco.cms/businesslogic/template/Template.cs index f8a00f842e..bc49fee581 100644 --- a/src/umbraco.cms/businesslogic/template/Template.cs +++ b/src/umbraco.cms/businesslogic/template/Template.cs @@ -2,6 +2,7 @@ using System; using System.Linq; using System.Collections; using System.Xml; +using Umbraco.Core; using umbraco.DataLayer; using System.Text.RegularExpressions; using System.IO; @@ -132,8 +133,8 @@ namespace umbraco.cms.businesslogic.template _mastertemplate = dr.IsNull("master") ? 0 : dr.GetInt("master"); } dr.Close(); - - if (UmbracoSettings.EnableMvcSupport && Template.HasView(this)) + + if (Umbraco.Core.Configuration.UmbracoSettings.DefaultRenderingEngine == RenderingEngine.Mvc && Template.HasView(this)) _design = ViewHelper.GetViewFile(this); else _design = MasterpageHelper.GetMasterpageFile(this); @@ -254,7 +255,7 @@ namespace umbraco.cms.businesslogic.template //we only switch to MVC View editing if the template has a view file, and MVC editing is enabled - if (UmbracoSettings.EnableMvcSupport && !isMasterPageSyntax(_design)) + if (Umbraco.Core.Configuration.UmbracoSettings.DefaultRenderingEngine == RenderingEngine.Mvc && !isMasterPageSyntax(_design)) _design = ViewHelper.UpdateViewFile(this); else if (UmbracoSettings.UseAspNetMasterPages) _design = MasterpageHelper.UpdateMasterpageFile(this, _oldAlias); @@ -321,7 +322,7 @@ namespace umbraco.cms.businesslogic.template Template t = MakeNew(Name, u); t.MasterTemplate = master.Id; - if (UmbracoSettings.EnableMvcSupport) + if (Umbraco.Core.Configuration.UmbracoSettings.DefaultRenderingEngine == RenderingEngine.Mvc) ViewHelper.CreateViewFile(t, true); else MasterpageHelper.CreateMasterpageFile(t, true); @@ -373,7 +374,7 @@ namespace umbraco.cms.businesslogic.template NewEventArgs e = new NewEventArgs(); t.OnNew(e); - if (UmbracoSettings.EnableMvcSupport) + if (Umbraco.Core.Configuration.UmbracoSettings.DefaultRenderingEngine == RenderingEngine.Mvc) t._design = ViewHelper.CreateViewFile(t); else t._design = MasterpageHelper.CreateMasterpageFile(t);