Merge remote-tracking branch 'origin/7.4.0' into dev-v8
Conflicts: build/UmbracoVersion.txt src/Umbraco.Core/ApplicationContext.cs src/Umbraco.Core/Configuration/UmbracoConfig.cs src/Umbraco.Core/Configuration/UmbracoVersion.cs src/Umbraco.Core/CoreBootManager.cs src/Umbraco.Core/DatabaseContext.cs src/Umbraco.Core/Dictionary/CultureDictionaryFactoryResolver.cs src/Umbraco.Core/Manifest/ManifestParser.cs src/Umbraco.Core/Models/DataTypeDefinition.cs src/Umbraco.Core/ObjectResolution/ApplicationEventsResolver.cs src/Umbraco.Core/Persistence/DatabaseSchemaHelper.cs src/Umbraco.Core/Persistence/Factories/MemberTypeFactory.cs src/Umbraco.Core/Persistence/Migrations/MigrationBase.cs src/Umbraco.Core/Persistence/Migrations/MigrationExpressionBase.cs src/Umbraco.Core/Persistence/Migrations/MigrationResolver.cs src/Umbraco.Core/Persistence/Migrations/MigrationRunner.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Alter/AlterSyntaxBuilder.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Alter/Column/AlterColumnBuilder.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Alter/Expressions/AlterColumnExpression.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Alter/Expressions/AlterDefaultConstraintExpression.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Alter/Expressions/AlterTableExpression.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Alter/Table/AlterTableBuilder.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Create/Column/CreateColumnBuilder.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Create/CreateBuilder.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Create/Expressions/CreateConstraintExpression.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Create/Expressions/CreateTableExpression.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Create/Table/CreateTableBuilder.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Delete/DeleteBuilder.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Delete/Expressions/DeleteColumnExpression.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Delete/Expressions/DeleteConstraintExpression.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Delete/Expressions/DeleteDataExpression.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Delete/Expressions/DeleteDefaultConstraintExpression.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Delete/Expressions/DeleteForeignKeyExpression.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Delete/Expressions/DeleteIndexExpression.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Delete/Expressions/DeleteTableExpression.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Execute/ExecuteBuilder.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Execute/Expressions/ExecuteCodeStatementExpression.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Execute/Expressions/ExecuteSqlStatementExpression.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Expressions/CreateColumnExpression.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Expressions/CreateForeignKeyExpression.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Expressions/CreateIndexExpression.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Insert/Expressions/InsertDataExpression.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Insert/InsertBuilder.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Rename/Expressions/RenameColumnExpression.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Rename/Expressions/RenameTableExpression.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Rename/RenameBuilder.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Update/Expressions/UpdateDataExpression.cs src/Umbraco.Core/Persistence/Migrations/Syntax/Update/UpdateBuilder.cs src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSeven/AddIndexToCmsMacroTable.cs src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeZero/MigrateAndRemoveTemplateMasterColumn.cs src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs src/Umbraco.Core/Persistence/Repositories/ContentTypeRepository.cs src/Umbraco.Core/Persistence/Repositories/DataTypeDefinitionRepository.cs src/Umbraco.Core/Persistence/Repositories/DictionaryRepository.cs src/Umbraco.Core/Persistence/Repositories/DomainRepository.cs src/Umbraco.Core/Persistence/Repositories/LanguageRepository.cs src/Umbraco.Core/Persistence/Repositories/MediaRepository.cs src/Umbraco.Core/Persistence/Repositories/MediaTypeRepository.cs src/Umbraco.Core/Persistence/Repositories/MemberRepository.cs src/Umbraco.Core/Persistence/Repositories/MemberTypeRepository.cs src/Umbraco.Core/Persistence/Repositories/RecycleBinRepository.cs src/Umbraco.Core/Persistence/Repositories/ServerRegistrationRepository.cs src/Umbraco.Core/Persistence/Repositories/TagRepository.cs src/Umbraco.Core/Persistence/Repositories/TemplateRepository.cs src/Umbraco.Core/Persistence/Repositories/VersionableRepositoryBase.cs src/Umbraco.Core/Persistence/RepositoryFactory.cs src/Umbraco.Core/Persistence/UmbracoDatabase.cs src/Umbraco.Core/PropertyEditors/IPropertyEditorValueConverter.cs src/Umbraco.Core/PropertyEditors/PropertyEditor.cs src/Umbraco.Core/PropertyEditors/PropertyEditorResolver.cs src/Umbraco.Core/Services/ContentService.cs src/Umbraco.Core/Services/ContentTypeService.cs src/Umbraco.Core/Services/DataTypeService.cs src/Umbraco.Core/Services/EntityService.cs src/Umbraco.Core/Services/LocalizationService.cs src/Umbraco.Core/Services/MacroService.cs src/Umbraco.Core/Services/MediaService.cs src/Umbraco.Core/Services/MemberGroupService.cs src/Umbraco.Core/Services/MemberService.cs src/Umbraco.Core/Services/MemberTypeService.cs src/Umbraco.Core/Services/PackagingService.cs src/Umbraco.Core/Services/ServerRegistrationService.cs src/Umbraco.Core/Services/ServiceContext.cs src/Umbraco.Core/Services/TagService.cs src/Umbraco.Core/Services/UserService.cs src/Umbraco.Core/Strings/DefaultShortStringHelper.cs src/Umbraco.Core/Sync/ConfigServerRegistrar.cs src/Umbraco.Core/Sync/DatabaseServerMessenger.cs src/Umbraco.Core/Umbraco.Core.csproj src/Umbraco.Core/UmbracoApplicationBase.cs src/Umbraco.Core/packages.config src/Umbraco.Tests/BootManagers/CoreBootManagerTests.cs src/Umbraco.Tests/Macros/MacroTests.cs src/Umbraco.Tests/Manifest/ManifestParserTests.cs src/Umbraco.Tests/Migrations/FindingMigrationsTest.cs src/Umbraco.Tests/Migrations/MigrationRunnerTests.cs src/Umbraco.Tests/Migrations/Stubs/FiveZeroMigration.cs src/Umbraco.Tests/Migrations/Stubs/FourElevenMigration.cs src/Umbraco.Tests/Migrations/Stubs/SixZeroMigration1.cs src/Umbraco.Tests/Migrations/Stubs/SixZeroMigration2.cs src/Umbraco.Tests/Migrations/TargetVersionSixthMigrationsTest.cs src/Umbraco.Tests/Migrations/Upgrades/BaseUpgradeTest.cs src/Umbraco.Tests/Migrations/Upgrades/SqlCeDataUpgradeTest.cs src/Umbraco.Tests/Mvc/UmbracoViewPageTests.cs src/Umbraco.Tests/Persistence/BaseTableByTableTest.cs src/Umbraco.Tests/Persistence/DatabaseContextTests.cs src/Umbraco.Tests/Persistence/Mappers/PropertyGroupMapperTest.cs src/Umbraco.Tests/Persistence/MySqlDatabaseCreationTest.cs src/Umbraco.Tests/Persistence/Querying/ContentTypeRepositorySqlClausesTest.cs src/Umbraco.Tests/Persistence/Querying/ContentTypeSqlMappingTests.cs src/Umbraco.Tests/Persistence/Repositories/ContentRepositoryTest.cs src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs src/Umbraco.Tests/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs src/Umbraco.Tests/Persistence/Repositories/DomainRepositoryTest.cs src/Umbraco.Tests/Persistence/Repositories/MediaRepositoryTest.cs src/Umbraco.Tests/Persistence/Repositories/MemberRepositoryTest.cs src/Umbraco.Tests/Persistence/Repositories/PublicAccessRepositoryTest.cs src/Umbraco.Tests/Persistence/Repositories/ServerRegistrationRepositoryTest.cs src/Umbraco.Tests/Persistence/Repositories/TagRepositoryTest.cs src/Umbraco.Tests/Persistence/Repositories/TemplateRepositoryTest.cs src/Umbraco.Tests/Persistence/SyntaxProvider/SqlCeSyntaxProviderTests.cs src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs src/Umbraco.Tests/Services/ContentServicePerformanceTest.cs src/Umbraco.Tests/Services/ContentServiceTests.cs src/Umbraco.Tests/Services/ThreadSafetyServiceTest.cs src/Umbraco.Tests/Strings/DefaultShortStringHelperTests.cs src/Umbraco.Tests/TestHelpers/BaseDatabaseFactoryTest.cs src/Umbraco.Tests/TestHelpers/BaseDatabaseTest.cs src/Umbraco.Tests/TestHelpers/BaseUmbracoApplicationTest.cs src/Umbraco.Tests/Umbraco.Tests.csproj src/Umbraco.Web.UI/Umbraco.Web.UI.csproj src/Umbraco.Web.UI/config/ClientDependency.config src/Umbraco.Web.UI/packages.config src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx.cs src/Umbraco.Web.UI/umbraco/plugins/tinymce3/insertImage.aspx src/Umbraco.Web.UI/umbraco/settings/EditNodeTypeNew.aspx.cs src/Umbraco.Web/BatchedDatabaseServerMessenger.cs src/Umbraco.Web/Cache/CacheRefresherEventHandler.cs src/Umbraco.Web/Cache/DataTypeCacheRefresher.cs src/Umbraco.Web/Cache/DistributedCacheExtensions.cs src/Umbraco.Web/Editors/AuthenticationController.cs src/Umbraco.Web/Editors/BackOfficeController.cs src/Umbraco.Web/Install/InstallSteps/DatabaseInstallStep.cs src/Umbraco.Web/Install/InstallSteps/DatabaseUpgradeStep.cs src/Umbraco.Web/Media/ThumbnailProviders/ThumbnailProvidersResolver.cs src/Umbraco.Web/Mvc/DefaultRenderMvcControllerResolver.cs src/Umbraco.Web/PropertyEditors/FileUploadPropertyEditor.cs src/Umbraco.Web/PropertyEditors/FolderBrowserPropertyEditor.cs src/Umbraco.Web/PropertyEditors/GridPropertyEditor.cs src/Umbraco.Web/PropertyEditors/ImageCropperPropertyEditor.cs src/Umbraco.Web/Routing/NotFoundHandlerHelper.cs src/Umbraco.Web/Trees/MediaTreeController.cs src/Umbraco.Web/Trees/MemberTreeController.cs src/Umbraco.Web/Umbraco.Web.csproj src/Umbraco.Web/UmbracoApplication.cs src/Umbraco.Web/UmbracoModule.cs src/Umbraco.Web/WebBootManager.cs src/Umbraco.Web/packages.config src/Umbraco.Web/umbraco.presentation/content.cs src/Umbraco.Web/umbraco.presentation/keepAliveService.cs src/Umbraco.Web/umbraco.presentation/macro.cs src/Umbraco.Web/umbraco.presentation/umbraco/Trees/loadDictionary.cs src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentControl.cs src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs src/Umbraco.Web/umbraco.presentation/umbraco/controls/Images/ImageViewer.ascx.cs src/Umbraco.Web/umbraco.presentation/umbraco/controls/Images/UploadMediaImage.ascx.cs src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/imageViewer.aspx.cs src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/rollBack.aspx.cs src/Umbraco.Web/umbraco.presentation/umbraco/members/EditMemberType.aspx.cs src/Umbraco.Web/umbraco.presentation/umbraco/plugins/tinymce3/insertImage.aspx src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditNodeTypeNew.aspx.cs src/Umbraco.Web/umbraco.presentation/umbraco/uQuery/MediaExtensions.cs src/Umbraco.Web/umbraco.presentation/umbraco/uQuery/uQuery.cs src/Umbraco.Web/umbraco.presentation/umbraco/users/EditUser.aspx.cs src/Umbraco.Web/umbraco.presentation/umbraco/webService.asmx.cs src/Umbraco.Web/umbraco.presentation/umbraco/webservices/MediaUploader.ashx.cs src/UmbracoExamine/UmbracoContentIndexer.cs src/UmbracoExamine/UmbracoMemberIndexer.cs src/umbraco.MacroEngines/RazorCore/UmbracoCultureDictionary.cs src/umbraco.MacroEngines/RazorDynamicNode/DynamicNode.cs src/umbraco.MacroEngines/RazorDynamicNode/ExtensionMethods.cs src/umbraco.MacroEngines/app.config src/umbraco.MacroEngines/packages.config src/umbraco.MacroEngines/umbraco.MacroEngines.csproj src/umbraco.businesslogic/UmbracoSettings.cs src/umbraco.cms/businesslogic/Content.cs src/umbraco.cms/businesslogic/datatype/DataTypeDefinition.cs src/umbraco.cms/businesslogic/datatype/DefaultPreValueEditor.cs src/umbraco.cms/businesslogic/datatype/FileHandlerData.cs src/umbraco.cms/businesslogic/translation/Translation.cs src/umbraco.cms/businesslogic/web/Document.cs src/umbraco.cms/packages.config src/umbraco.editorControls/DefaultPrevalueEditor.cs src/umbraco.editorControls/MultiNodeTreePicker/MNTPResources.Designer.cs src/umbraco.editorControls/MultiNodeTreePicker/MNTPResources.resx src/umbraco.editorControls/MultiNodeTreePicker/MNTP_DataType.cs src/umbraco.editorControls/app.config src/umbraco.editorControls/macrocontainer/PrevalueEditor.cs src/umbraco.editorControls/packages.config src/umbraco.editorControls/textfieldmultiple/textfieldMultipleDataType.cs src/umbraco.editorControls/umbraco.editorControls.csproj src/umbraco.editorControls/uploadfield/uploadField.cs src/umbraco.editorControls/userControlWrapper/usercontrolPrevalueEditor.cs src/umbraco.providers/app.config
This commit is contained in:
@@ -36,7 +36,7 @@ namespace Umbraco.Core.Configuration
|
||||
//make this volatile so that we can ensure thread safety with a double check lock
|
||||
private static volatile string _reservedUrlsCache;
|
||||
private static string _reservedPathsCache;
|
||||
private static StartsWithContainer _reservedList = new StartsWithContainer();
|
||||
private static HashSet<string> _reservedList = new HashSet<string>();
|
||||
private static string _reservedPaths;
|
||||
private static string _reservedUrls;
|
||||
//ensure the built on (non-changeable) reserved paths are there at all times
|
||||
@@ -242,6 +242,7 @@ namespace Umbraco.Core.Configuration
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Move these to constants!
|
||||
public const string UmbracoConnectionName = "umbracoDbDSN";
|
||||
public const string UmbracoMigrationName = "Umbraco";
|
||||
|
||||
@@ -420,14 +421,15 @@ namespace Umbraco.Core.Configuration
|
||||
/// Gets a value indicating whether the current version of umbraco is configured.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if configured; otherwise, <c>false</c>.</value>
|
||||
public static bool Configured
|
||||
[Obsolete("Do not use this, it is no longer in use and will be removed from the codebase in future versions")]
|
||||
internal static bool Configured
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
string configStatus = ConfigurationStatus;
|
||||
string currentVersion = UmbracoVersion.Current.ToString(3);
|
||||
string currentVersion = UmbracoVersion.GetSemanticVersion().ToSemanticString();
|
||||
|
||||
|
||||
if (currentVersion != configStatus)
|
||||
@@ -594,10 +596,7 @@ namespace Umbraco.Core.Configuration
|
||||
[Obsolete("Use Umbraco.Core.Configuration.UmbracoVersion.Current instead", false)]
|
||||
public static string CurrentVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
return UmbracoVersion.Current.ToString(3);
|
||||
}
|
||||
get { return UmbracoVersion.GetSemanticVersion().ToSemanticString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -768,38 +767,31 @@ namespace Umbraco.Core.Configuration
|
||||
// store references to strings to determine changes
|
||||
_reservedPathsCache = GlobalSettings.ReservedPaths;
|
||||
_reservedUrlsCache = GlobalSettings.ReservedUrls;
|
||||
|
||||
string _root = SystemDirectories.Root.Trim().ToLower();
|
||||
|
||||
|
||||
// add URLs and paths to a new list
|
||||
StartsWithContainer _newReservedList = new StartsWithContainer();
|
||||
foreach (string reservedUrl in _reservedUrlsCache.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries))
|
||||
var newReservedList = new HashSet<string>();
|
||||
foreach (var reservedUrlTrimmed in _reservedUrlsCache
|
||||
.Split(new[] {","}, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(x => x.Trim().ToLowerInvariant())
|
||||
.Where(x => x.IsNullOrWhiteSpace() == false)
|
||||
.Select(reservedUrl => IOHelper.ResolveUrl(reservedUrl).Trim().EnsureStartsWith("/"))
|
||||
.Where(reservedUrlTrimmed => reservedUrlTrimmed.IsNullOrWhiteSpace() == false))
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(reservedUrl))
|
||||
continue;
|
||||
|
||||
|
||||
//resolves the url to support tilde chars
|
||||
string reservedUrlTrimmed = IOHelper.ResolveUrl(reservedUrl.Trim()).Trim().ToLower();
|
||||
if (reservedUrlTrimmed.Length > 0)
|
||||
_newReservedList.Add(reservedUrlTrimmed);
|
||||
newReservedList.Add(reservedUrlTrimmed);
|
||||
}
|
||||
|
||||
foreach (string reservedPath in _reservedPathsCache.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries))
|
||||
foreach (var reservedPathTrimmed in _reservedPathsCache
|
||||
.Split(new[] {","}, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(x => x.Trim().ToLowerInvariant())
|
||||
.Where(x => x.IsNullOrWhiteSpace() == false)
|
||||
.Select(reservedPath => IOHelper.ResolveUrl(reservedPath).Trim().EnsureStartsWith("/").EnsureEndsWith("/"))
|
||||
.Where(reservedPathTrimmed => reservedPathTrimmed.IsNullOrWhiteSpace() == false))
|
||||
{
|
||||
bool trimEnd = !reservedPath.EndsWith("/");
|
||||
if (string.IsNullOrWhiteSpace(reservedPath))
|
||||
continue;
|
||||
|
||||
//resolves the url to support tilde chars
|
||||
string reservedPathTrimmed = IOHelper.ResolveUrl(reservedPath.Trim()).Trim().ToLower();
|
||||
|
||||
if (reservedPathTrimmed.Length > 0)
|
||||
_newReservedList.Add(reservedPathTrimmed + (reservedPathTrimmed.EndsWith("/") ? "" : "/"));
|
||||
newReservedList.Add(reservedPathTrimmed);
|
||||
}
|
||||
|
||||
// use the new list from now on
|
||||
_reservedList = _newReservedList;
|
||||
_reservedList = newReservedList;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -807,107 +799,17 @@ namespace Umbraco.Core.Configuration
|
||||
//The url should be cleaned up before checking:
|
||||
// * If it doesn't contain an '.' in the path then we assume it is a path based URL, if that is the case we should add an trailing '/' because all of our reservedPaths use a trailing '/'
|
||||
// * We shouldn't be comparing the query at all
|
||||
var pathPart = url.Split('?')[0];
|
||||
if (!pathPart.Contains(".") && !pathPart.EndsWith("/"))
|
||||
var pathPart = url.Split(new[] {'?'}, StringSplitOptions.RemoveEmptyEntries)[0].ToLowerInvariant();
|
||||
if (pathPart.Contains(".") == false)
|
||||
{
|
||||
pathPart += "/";
|
||||
pathPart = pathPart.EnsureEndsWith('/');
|
||||
}
|
||||
|
||||
// return true if url starts with an element of the reserved list
|
||||
return _reservedList.StartsWith(pathPart.ToLowerInvariant());
|
||||
return _reservedList.Any(x => pathPart.InvariantStartsWith(x));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Structure that checks in logarithmic time
|
||||
/// if a given string starts with one of the added keys.
|
||||
/// </summary>
|
||||
private class StartsWithContainer
|
||||
{
|
||||
/// <summary>Internal sorted list of keys.</summary>
|
||||
public SortedList<string, string> _list
|
||||
= new SortedList<string, string>(StartsWithComparator.Instance);
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified new key.
|
||||
/// </summary>
|
||||
/// <param name="newKey">The new key.</param>
|
||||
public void Add(string newKey)
|
||||
{
|
||||
// if the list already contains an element that begins with newKey, return
|
||||
if (String.IsNullOrEmpty(newKey) || StartsWith(newKey))
|
||||
return;
|
||||
|
||||
// create a new collection, so the old one can still be accessed
|
||||
SortedList<string, string> newList
|
||||
= new SortedList<string, string>(_list.Count + 1, StartsWithComparator.Instance);
|
||||
|
||||
// add only keys that don't already start with newKey, others are unnecessary
|
||||
foreach (string key in _list.Keys)
|
||||
if (!key.StartsWith(newKey))
|
||||
newList.Add(key, null);
|
||||
// add the new key
|
||||
newList.Add(newKey, null);
|
||||
|
||||
// update the list (thread safe, _list was never in incomplete state)
|
||||
_list = newList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the given string starts with any of the added keys.
|
||||
/// </summary>
|
||||
/// <param name="target">The target.</param>
|
||||
/// <returns>true if a key is found that matches the start of target</returns>
|
||||
/// <remarks>
|
||||
/// Runs in O(s*log(n)), with n the number of keys and s the length of target.
|
||||
/// </remarks>
|
||||
public bool StartsWith(string target)
|
||||
{
|
||||
return _list.ContainsKey(target);
|
||||
}
|
||||
|
||||
/// <summary>Comparator that tests if a string starts with another.</summary>
|
||||
/// <remarks>Not a real comparator, since it is not reflexive. (x==y does not imply y==x)</remarks>
|
||||
private sealed class StartsWithComparator : IComparer<string>
|
||||
{
|
||||
/// <summary>Default string comparer.</summary>
|
||||
private readonly static Comparer<string> _stringComparer = Comparer<string>.Default;
|
||||
|
||||
/// <summary>Gets an instance of the StartsWithComparator.</summary>
|
||||
public static readonly StartsWithComparator Instance = new StartsWithComparator();
|
||||
|
||||
/// <summary>
|
||||
/// Tests if whole begins with all characters of part.
|
||||
/// </summary>
|
||||
/// <param name="part">The part.</param>
|
||||
/// <param name="whole">The whole.</param>
|
||||
/// <returns>
|
||||
/// Returns 0 if whole starts with part, otherwise performs standard string comparison.
|
||||
/// </returns>
|
||||
public int Compare(string part, string whole)
|
||||
{
|
||||
// let the default string comparer deal with null or when part is not smaller then whole
|
||||
if (part == null || whole == null || part.Length >= whole.Length)
|
||||
return _stringComparer.Compare(part, whole);
|
||||
|
||||
////ensure both have a / on the end
|
||||
//part = part.EndsWith("/") ? part : part + "/";
|
||||
//whole = whole.EndsWith("/") ? whole : whole + "/";
|
||||
//if (part.Length >= whole.Length)
|
||||
// return _stringComparer.Compare(part, whole);
|
||||
|
||||
// loop through all characters that part and whole have in common
|
||||
int pos = 0;
|
||||
bool match;
|
||||
do
|
||||
{
|
||||
match = (part[pos] == whole[pos]);
|
||||
} while (match && ++pos < part.Length);
|
||||
|
||||
// return result of last comparison
|
||||
return match ? 0 : (part[pos] < whole[pos] ? -1 : 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
16
src/Umbraco.Core/Configuration/Grid/GridConfig.cs
Normal file
16
src/Umbraco.Core/Configuration/Grid/GridConfig.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.IO;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Logging;
|
||||
|
||||
namespace Umbraco.Core.Configuration.Grid
|
||||
{
|
||||
class GridConfig : IGridConfig
|
||||
{
|
||||
public GridConfig(ILogger logger, IRuntimeCacheProvider runtimeCache, DirectoryInfo appPlugins, DirectoryInfo configFolder, bool isDebug)
|
||||
{
|
||||
EditorsConfig = new GridEditorsConfig(logger, runtimeCache, appPlugins, configFolder, isDebug);
|
||||
}
|
||||
|
||||
public IGridEditorsConfig EditorsConfig { get; private set; }
|
||||
}
|
||||
}
|
||||
78
src/Umbraco.Core/Configuration/Grid/GridEditorsConfig.cs
Normal file
78
src/Umbraco.Core/Configuration/Grid/GridEditorsConfig.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Manifest;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
|
||||
namespace Umbraco.Core.Configuration.Grid
|
||||
{
|
||||
class GridEditorsConfig : IGridEditorsConfig
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IRuntimeCacheProvider _runtimeCache;
|
||||
private readonly DirectoryInfo _appPlugins;
|
||||
private readonly DirectoryInfo _configFolder;
|
||||
private readonly bool _isDebug;
|
||||
|
||||
public GridEditorsConfig(ILogger logger, IRuntimeCacheProvider runtimeCache, DirectoryInfo appPlugins, DirectoryInfo configFolder, bool isDebug)
|
||||
{
|
||||
_logger = logger;
|
||||
_runtimeCache = runtimeCache;
|
||||
_appPlugins = appPlugins;
|
||||
_configFolder = configFolder;
|
||||
_isDebug = isDebug;
|
||||
}
|
||||
|
||||
public IEnumerable<IGridEditorConfig> Editors
|
||||
{
|
||||
get
|
||||
{
|
||||
Func<List<GridEditor>> getResult = () =>
|
||||
{
|
||||
var editors = new List<GridEditor>();
|
||||
var gridConfig = Path.Combine(_configFolder.FullName, "grid.editors.config.js");
|
||||
if (File.Exists(gridConfig))
|
||||
{
|
||||
try
|
||||
{
|
||||
var arr = JArray.Parse(File.ReadAllText(gridConfig));
|
||||
//ensure the contents parse correctly to objects
|
||||
var parsed = ManifestParser.GetGridEditors(arr);
|
||||
editors.AddRange(parsed);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error<GridEditorsConfig>("Could not parse the contents of grid.editors.config.js into a JSON array", ex);
|
||||
}
|
||||
}
|
||||
|
||||
var parser = new ManifestParser(_appPlugins, _runtimeCache);
|
||||
var builder = new ManifestBuilder(_runtimeCache, parser);
|
||||
foreach (var gridEditor in builder.GridEditors)
|
||||
{
|
||||
//no duplicates! (based on alias)
|
||||
if (editors.Contains(gridEditor) == false)
|
||||
{
|
||||
editors.Add(gridEditor);
|
||||
}
|
||||
}
|
||||
return editors;
|
||||
};
|
||||
|
||||
//cache the result if debugging is disabled
|
||||
var result = _isDebug
|
||||
? getResult()
|
||||
: _runtimeCache.GetCacheItem<List<GridEditor>>(
|
||||
typeof(GridEditorsConfig) + "Editors",
|
||||
() => getResult(),
|
||||
TimeSpan.FromMinutes(10));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
14
src/Umbraco.Core/Configuration/Grid/IGridConfig.cs
Normal file
14
src/Umbraco.Core/Configuration/Grid/IGridConfig.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Umbraco.Core.Configuration.Grid
|
||||
{
|
||||
public interface IGridConfig
|
||||
{
|
||||
|
||||
IGridEditorsConfig EditorsConfig { get; }
|
||||
|
||||
}
|
||||
}
|
||||
15
src/Umbraco.Core/Configuration/Grid/IGridEditorConfig.cs
Normal file
15
src/Umbraco.Core/Configuration/Grid/IGridEditorConfig.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Umbraco.Core.Configuration.Grid
|
||||
{
|
||||
public interface IGridEditorConfig
|
||||
{
|
||||
string Name { get; }
|
||||
string Alias { get; }
|
||||
string View { get; }
|
||||
string Render { get; }
|
||||
string Icon { get; }
|
||||
IDictionary<string, object> Config { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Umbraco.Core.Configuration.Grid
|
||||
{
|
||||
public interface IGridEditorsConfig
|
||||
{
|
||||
IEnumerable<IGridEditorConfig> Editors { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Configuration.Dashboard;
|
||||
using Umbraco.Core.Configuration.Grid;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Logging;
|
||||
|
||||
@@ -53,6 +56,7 @@ namespace Umbraco.Core.Configuration
|
||||
|
||||
private IDashboardSection _dashboardSection;
|
||||
private IUmbracoSettingsSection _umbracoSettings;
|
||||
private IGridConfig _gridConfig;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the IDashboardSection
|
||||
@@ -103,6 +107,28 @@ namespace Umbraco.Core.Configuration
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Only for testing
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public void SetGridConfig(IGridConfig value)
|
||||
{
|
||||
_gridConfig = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the IGridConfig
|
||||
/// </summary>
|
||||
public IGridConfig GridConfig(ILogger logger, IRuntimeCacheProvider runtimeCache, DirectoryInfo appPlugins, DirectoryInfo configFolder, bool isDebug)
|
||||
{
|
||||
if (_gridConfig == null)
|
||||
{
|
||||
_gridConfig = new GridConfig(logger, runtimeCache, appPlugins, configFolder, isDebug);
|
||||
}
|
||||
|
||||
return _gridConfig;
|
||||
|
||||
//TODO: Add other configurations here !
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
bool DisableFindContentByIdPath { get; }
|
||||
|
||||
string UrlProviderMode { get; }
|
||||
|
||||
string UmbracoApplicationUrl { get; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,8 +30,13 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
|
||||
[ConfigurationProperty("urlProviderMode", DefaultValue = "AutoLegacy")]
|
||||
public string UrlProviderMode
|
||||
{
|
||||
get { return (string)base["urlProviderMode"]; }
|
||||
get { return (string) base["urlProviderMode"]; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty("umbracoApplicationUrl", DefaultValue = null)]
|
||||
public string UmbracoApplicationUrl
|
||||
{
|
||||
get { return (string)base["umbracoApplicationUrl"]; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using Semver;
|
||||
|
||||
namespace Umbraco.Core.Configuration
|
||||
{
|
||||
@@ -23,10 +24,20 @@ namespace Umbraco.Core.Configuration
|
||||
/// Gets the version comment (like beta or RC).
|
||||
/// </summary>
|
||||
/// <value>The version comment.</value>
|
||||
public static string CurrentComment { get { return ""; } }
|
||||
public static string CurrentComment { get { return "beta"; } }
|
||||
|
||||
// Get the version of the umbraco.dll by looking at a class in that dll
|
||||
// Had to do it like this due to medium trust issues, see: http://haacked.com/archive/2010/11/04/assembly-location-and-medium-trust.aspx
|
||||
public static string AssemblyVersion { get { return new AssemblyName(typeof(ActionsResolver).Assembly.FullName).Version.ToString(); } }
|
||||
|
||||
public static SemVersion GetSemanticVersion()
|
||||
{
|
||||
return new SemVersion(
|
||||
Current.Major,
|
||||
Current.Minor,
|
||||
Current.Build,
|
||||
CurrentComment.IsNullOrWhiteSpace() ? null : CurrentComment,
|
||||
Current.Revision > 0 ? Current.Revision.ToInvariantString() : null);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user