diff --git a/build/NuSpecs/UmbracoCms.Core.nuspec b/build/NuSpecs/UmbracoCms.Core.nuspec index 7f4fbe3d84..8eada02e1b 100644 --- a/build/NuSpecs/UmbracoCms.Core.nuspec +++ b/build/NuSpecs/UmbracoCms.Core.nuspec @@ -33,8 +33,8 @@ - - + + @@ -104,4 +104,4 @@ - + diff --git a/src/Umbraco.Core/DatabaseContext.cs b/src/Umbraco.Core/DatabaseContext.cs index 837e59ca12..b48ab1bca4 100644 --- a/src/Umbraco.Core/DatabaseContext.cs +++ b/src/Umbraco.Core/DatabaseContext.cs @@ -110,7 +110,14 @@ namespace Umbraco.Core /// public virtual UmbracoDatabase Database { - get { return _factory.CreateDatabase(); } + get + { + if (IsDatabaseConfigured == false) + { + throw new InvalidOperationException("Cannot create a database instance, there is no available connection string"); + } + return _factory.CreateDatabase(); + } } /// @@ -202,7 +209,7 @@ namespace Umbraco.Core } else { - throw new InvalidOperationException("Can't find a connection string with the name '" + Constants.System.UmbracoConnectionName + "'"); + throw new NullReferenceException("Can't find a connection string with the name '" + Constants.System.UmbracoConnectionName + "'"); } return _providerName; } diff --git a/src/Umbraco.Core/Persistence/PetaPoco.cs b/src/Umbraco.Core/Persistence/PetaPoco.cs index b569b1c45d..ba44af2c28 100644 --- a/src/Umbraco.Core/Persistence/PetaPoco.cs +++ b/src/Umbraco.Core/Persistence/PetaPoco.cs @@ -167,12 +167,12 @@ namespace Umbraco.Core.Persistence var providerName = Constants.DatabaseProviders.SqlServer; if (ConfigurationManager.ConnectionStrings[connectionStringName] != null) { - if (!string.IsNullOrEmpty(ConfigurationManager.ConnectionStrings[connectionStringName].ProviderName)) + if (string.IsNullOrEmpty(ConfigurationManager.ConnectionStrings[connectionStringName].ProviderName) == false) providerName = ConfigurationManager.ConnectionStrings[connectionStringName].ProviderName; } else { - throw new InvalidOperationException("Can't find a connection string with the name '" + connectionStringName + "'"); + throw new NullReferenceException("Can't find a connection string with the name '" + connectionStringName + "'"); } // Store factory and connection string diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 8b0cc5a749..e134092f8c 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -49,8 +49,9 @@ ..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll - - ..\packages\ImageProcessor.2.5.1\lib\net45\ImageProcessor.dll + + ..\packages\ImageProcessor.2.5.2\lib\net45\ImageProcessor.dll + True ..\packages\log4net-mediumtrust.2.0.0\lib\log4net.dll diff --git a/src/Umbraco.Core/UmbracoApplicationBase.cs b/src/Umbraco.Core/UmbracoApplicationBase.cs index 1bf90fb154..7f1f0803f8 100644 --- a/src/Umbraco.Core/UmbracoApplicationBase.cs +++ b/src/Umbraco.Core/UmbracoApplicationBase.cs @@ -63,9 +63,12 @@ namespace Umbraco.Core // after Umbraco has started there is a database in "context" and that context is // going to stay there and never get destroyed nor reused, so we have to ensure that // the database is disposed (which will auto-remove it from context). - var database = ApplicationContext.Current.DatabaseContext.Database; - if (database != null) // never to happen... unless in weird tests - ApplicationContext.Current.DatabaseContext.Database.Dispose(); + if (ApplicationContext.Current.DatabaseContext.IsDatabaseConfigured) + { + var database = ApplicationContext.Current.DatabaseContext.Database; + if (database != null) // never to happen... unless in weird tests + ApplicationContext.Current.DatabaseContext.Database.Dispose(); + } } /// diff --git a/src/Umbraco.Core/packages.config b/src/Umbraco.Core/packages.config index 3f8e37c3dc..babf6d8759 100644 --- a/src/Umbraco.Core/packages.config +++ b/src/Umbraco.Core/packages.config @@ -2,7 +2,7 @@ - + diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index 7643ad2bb1..ca3d46a2c9 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -58,9 +58,8 @@ ..\packages\AutoMapper.3.3.1\lib\net40\AutoMapper.Net4.dll - - ..\packages\Examine.0.1.80\lib\net45\Examine.dll - True + + ..\packages\Examine.0.1.81\lib\net45\Examine.dll ..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll diff --git a/src/Umbraco.Tests/packages.config b/src/Umbraco.Tests/packages.config index cf84699a12..b2497a3015 100644 --- a/src/Umbraco.Tests/packages.config +++ b/src/Umbraco.Tests/packages.config @@ -2,7 +2,7 @@ - + diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbstickybar.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbstickybar.directive.js index cee705b8e8..91a0a41a10 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbstickybar.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbstickybar.directive.js @@ -36,119 +36,119 @@ Use this directive make an element sticky and follow the page when scrolling. @param {string} scrollableContainer Set the class (".element") or the id ("#element") of the scrollable container element. **/ -(function() { - 'use strict'; +(function () { + 'use strict'; - function StickyBarDirective($rootScope) { + function StickyBarDirective($rootScope) { - function link(scope, el, attr, ctrl) { + function link(scope, el, attr, ctrl) { - var bar = $(el); - var scrollableContainer = null; - var clonedBar = null; - var cloneIsMade = false; - var barTop = bar.context.offsetTop; + var bar = $(el); + var scrollableContainer = null; + var clonedBar = null; + var cloneIsMade = false; - function activate() { + function activate() { - if (attr.scrollableContainer) { - scrollableContainer = $(attr.scrollableContainer); - } else { - scrollableContainer = $(window); - } + if (attr.scrollableContainer) { + scrollableContainer = $(attr.scrollableContainer); + } else { + scrollableContainer = $(window); + } - scrollableContainer.on('scroll.umbStickyBar', determineVisibility).trigger("scroll"); - $(window).on('resize.umbStickyBar', determineVisibility); + scrollableContainer.on('scroll.umbStickyBar', determineVisibility).trigger("scroll"); + $(window).on('resize.umbStickyBar', determineVisibility); - scope.$on('$destroy', function() { - scrollableContainer.off('.umbStickyBar'); - $(window).off('.umbStickyBar'); - }); - - } - - function determineVisibility() { - - var scrollTop = scrollableContainer.scrollTop(); - - if (scrollTop > barTop) { - - if (!cloneIsMade) { - - createClone(); - - clonedBar.css({ - 'visibility': 'visible' - }); - - } else { - - calculateSize(); - - } - - } else { - - if (cloneIsMade) { - - //remove cloned element (switched places with original on creation) - bar.remove(); - bar = clonedBar; - clonedBar = null; - - bar.removeClass('-umb-sticky-bar'); - bar.css({ - position: 'relative', - 'width': 'auto', - 'height': 'auto', - 'z-index': 'auto', - 'visibility': 'visible' - }); - - cloneIsMade = false; - - } + scope.$on('$destroy', function () { + scrollableContainer.off('.umbStickyBar'); + $(window).off('.umbStickyBar'); + }); } - } + function determineVisibility() { - function calculateSize() { - clonedBar.css({ - width: bar.outerWidth(), - height: bar.height() - }); - } + var barTop = bar[0].offsetTop; + var scrollTop = scrollableContainer.scrollTop(); - function createClone() { - //switch place with cloned element, to keep binding intact - clonedBar = bar; - bar = clonedBar.clone(); - clonedBar.after(bar); - clonedBar.addClass('-umb-sticky-bar'); - clonedBar.css({ - 'position': 'fixed', - 'z-index': 500, - 'visibility': 'hidden' - }); + if (scrollTop > barTop) { - cloneIsMade = true; - calculateSize(); + if (!cloneIsMade) { - } + createClone(); - activate(); + clonedBar.css({ + 'visibility': 'visible' + }); - } + } else { - var directive = { - restrict: 'A', - link: link - }; + calculateSize(); - return directive; - } + } - angular.module('umbraco.directives').directive('umbStickyBar', StickyBarDirective); + } else { + + if (cloneIsMade) { + + //remove cloned element (switched places with original on creation) + bar.remove(); + bar = clonedBar; + clonedBar = null; + + bar.removeClass('-umb-sticky-bar'); + bar.css({ + position: 'relative', + 'width': 'auto', + 'height': 'auto', + 'z-index': 'auto', + 'visibility': 'visible' + }); + + cloneIsMade = false; + + } + + } + + } + + function calculateSize() { + clonedBar.css({ + width: bar.outerWidth(), + height: bar.height() + }); + } + + function createClone() { + //switch place with cloned element, to keep binding intact + clonedBar = bar; + bar = clonedBar.clone(); + clonedBar.after(bar); + clonedBar.addClass('-umb-sticky-bar'); + clonedBar.css({ + 'position': 'fixed', + 'z-index': 500, + 'visibility': 'hidden' + }); + + cloneIsMade = true; + calculateSize(); + + } + + activate(); + + } + + var directive = { + restrict: 'A', + link: link + }; + + return directive; + } + + angular.module('umbraco.directives').directive('umbStickyBar', StickyBarDirective); })(); diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/macrocontainer/macrocontainer.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/macrocontainer/macrocontainer.controller.js index b74e30004e..f0fe89b14f 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/macrocontainer/macrocontainer.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/macrocontainer/macrocontainer.controller.js @@ -3,7 +3,11 @@ angular.module('umbraco') .controller("Umbraco.PropertyEditors.MacroContainerController", function($scope, dialogService, entityResource, macroService){ + $scope.renderModel = []; + $scope.allowOpenButton = true; + $scope.allowRemoveButton = true; + $scope.sortableOptions = {}; if($scope.model.value){ var macros = $scope.model.value.split('>'); @@ -20,6 +24,7 @@ angular.module('umbraco') parsed.syntax = syntax; collectDetails(parsed); $scope.renderModel.push(parsed); + setSortingState($scope.renderModel); } }); } @@ -27,11 +32,12 @@ angular.module('umbraco') function collectDetails(macro){ macro.details = ""; + macro.icon = "icon-settings-alt"; if(macro.macroParamsDictionary){ angular.forEach((macro.macroParamsDictionary), function(value, key){ macro.details += key + ": " + value + " "; }); - } + } } function openDialog(index){ @@ -61,6 +67,8 @@ angular.module('umbraco') $scope.renderModel.push(macroObject); } + setSortingState($scope.renderModel); + $scope.macroPickerOverlay.show = false; $scope.macroPickerOverlay = null; }; @@ -90,6 +98,7 @@ angular.module('umbraco') $scope.remove =function(index){ $scope.renderModel.splice(index, 1); + setSortingState($scope.renderModel); }; $scope.clear = function() { @@ -117,4 +126,13 @@ angular.module('umbraco') return str.replace(rgxtrim, ''); } + function setSortingState(items) { + // disable sorting if the list only consist of one item + if(items.length > 1) { + $scope.sortableOptions.disabled = false; + } else { + $scope.sortableOptions.disabled = true; + } + } + }); diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/macrocontainer/macrocontainer.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/macrocontainer/macrocontainer.html index 96c74c9c55..1dec2788e2 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/macrocontainer/macrocontainer.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/macrocontainer/macrocontainer.html @@ -1,30 +1,27 @@
- - - + + Add + False ..\packages\dotless.1.4.1.0\lib\dotless.Core.dll - - ..\packages\Examine.0.1.80\lib\net45\Examine.dll - True + + ..\packages\Examine.0.1.81\lib\net45\Examine.dll False ..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll - - ..\packages\ImageProcessor.2.5.1\lib\net45\ImageProcessor.dll + + ..\packages\ImageProcessor.2.5.2\lib\net45\ImageProcessor.dll + True - - ..\packages\ImageProcessor.Web.4.8.0\lib\net45\ImageProcessor.Web.dll + + ..\packages\ImageProcessor.Web.4.8.2\lib\net45\ImageProcessor.Web.dll True @@ -168,7 +168,8 @@ - ..\packages\Microsoft.IO.RecyclableMemoryStream.1.2.0\lib\net45\Microsoft.IO.RecyclableMemoryStream.dll + ..\packages\Microsoft.IO.RecyclableMemoryStream.1.2.1\lib\net45\Microsoft.IO.RecyclableMemoryStream.dll + True ..\packages\Microsoft.Owin.3.0.1\lib\net45\Microsoft.Owin.dll diff --git a/src/Umbraco.Web.UI/packages.config b/src/Umbraco.Web.UI/packages.config index 629438762f..ce3ef29c96 100644 --- a/src/Umbraco.Web.UI/packages.config +++ b/src/Umbraco.Web.UI/packages.config @@ -4,9 +4,9 @@ - - - + + + @@ -22,7 +22,7 @@ - + diff --git a/src/Umbraco.Web/Cache/PageCacheRefresher.cs b/src/Umbraco.Web/Cache/PageCacheRefresher.cs index 75118a6748..fc6e0c8d20 100644 --- a/src/Umbraco.Web/Cache/PageCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/PageCacheRefresher.cs @@ -74,7 +74,7 @@ namespace Umbraco.Web.Cache public override void Remove(int id) { ApplicationContext.Current.ApplicationCache.ClearPartialViewCache(); - content.Instance.ClearDocumentCache(id); + content.Instance.ClearDocumentCache(id, false); DistributedCache.Instance.ClearAllMacroCacheOnCurrentServer(); DistributedCache.Instance.ClearXsltCacheOnCurrentServer(); ClearAllIsolatedCacheByEntityType(); @@ -95,7 +95,7 @@ namespace Umbraco.Web.Cache public override void Remove(IContent instance) { ApplicationContext.Current.ApplicationCache.ClearPartialViewCache(); - content.Instance.ClearDocumentCache(new Document(instance)); + content.Instance.ClearDocumentCache(new Document(instance), false); XmlPublishedContent.ClearRequest(); DistributedCache.Instance.ClearAllMacroCacheOnCurrentServer(); DistributedCache.Instance.ClearXsltCacheOnCurrentServer(); diff --git a/src/Umbraco.Web/Editors/ContentControllerBase.cs b/src/Umbraco.Web/Editors/ContentControllerBase.cs index fc112693e4..6b8d570e5f 100644 --- a/src/Umbraco.Web/Editors/ContentControllerBase.cs +++ b/src/Umbraco.Web/Editors/ContentControllerBase.cs @@ -99,23 +99,15 @@ namespace Umbraco.Web.Editors var files = contentItem.UploadedFiles.Where(x => x.PropertyAlias == property.Alias).ToArray(); if (files.Length > 0) { - dictionary.Add("files", files); - // add extra things needed to figure out where to put the files - dictionary.Add("cuid", contentItem.PersistedContent.Key); - dictionary.Add("puid", dboProperty.PropertyType.Key); + dictionary.Add("files", files); } - foreach (var file in files) file.FileName = file.FileName.ToSafeFileName(); - if (files.Length > 0) - { - dictionary.Add("files", files); - // add extra things needed to figure out where to put the files - dictionary.Add("cuid", contentItem.PersistedContent.Key); - dictionary.Add("puid", dboProperty.PropertyType.Key); - } - + // add extra things needed to figure out where to put the files + dictionary.Add("cuid", contentItem.PersistedContent.Key); + dictionary.Add("puid", dboProperty.PropertyType.Key); + var data = new ContentPropertyData(property.Value, property.PreValues, dictionary); //get the deserialized value from the property editor diff --git a/src/Umbraco.Web/Install/InstallSteps/NewInstallStep.cs b/src/Umbraco.Web/Install/InstallSteps/NewInstallStep.cs index 775fcaaf9c..7a6a54f9e7 100644 --- a/src/Umbraco.Web/Install/InstallSteps/NewInstallStep.cs +++ b/src/Umbraco.Web/Install/InstallSteps/NewInstallStep.cs @@ -81,7 +81,7 @@ namespace Umbraco.Web.Install.InstallSteps { var client = new System.Net.WebClient(); var values = new NameValueCollection { { "name", admin.Name }, { "email", admin.Email} }; - client.UploadValues("https://umbraco.com/base/Ecom/SubmitEmail/installer.aspx", values); + client.UploadValues("https://shop.umbraco.com/base/Ecom/SubmitEmail/installer.aspx", values); } catch { /* fail in silence */ } } @@ -147,4 +147,4 @@ namespace Umbraco.Web.Install.InstallSteps } } } -} \ No newline at end of file +} diff --git a/src/Umbraco.Web/PropertyEditors/MacroContainerPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/MacroContainerPropertyEditor.cs index 3ac5788dd2..6bb2cda0b0 100644 --- a/src/Umbraco.Web/PropertyEditors/MacroContainerPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/MacroContainerPropertyEditor.cs @@ -9,7 +9,7 @@ using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PropertyEditors { - [PropertyEditor(Constants.PropertyEditors.MacroContainerAlias, "Macro container", "macrocontainer", ValueType = PropertyEditorValueTypes.Text, Group="rich content", Icon="icon-settings-alt")] + [PropertyEditor(Constants.PropertyEditors.MacroContainerAlias, "Macro Picker", "macrocontainer", ValueType = PropertyEditorValueTypes.Text, Group="rich content", Icon="icon-settings-alt")] public class MacroContainerPropertyEditor : PropertyEditor { /// diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index aff6d35724..3e5172b774 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -112,9 +112,8 @@ ..\packages\dotless.1.4.1.0\lib\dotless.Core.dll - - ..\packages\Examine.0.1.80\lib\net45\Examine.dll - True + + ..\packages\Examine.0.1.81\lib\net45\Examine.dll ..\packages\HtmlAgilityPack.1.4.9\lib\Net45\HtmlAgilityPack.dll diff --git a/src/Umbraco.Web/packages.config b/src/Umbraco.Web/packages.config index 7c47f69fe1..9da3a842f5 100644 --- a/src/Umbraco.Web/packages.config +++ b/src/Umbraco.Web/packages.config @@ -3,7 +3,7 @@ - + diff --git a/src/Umbraco.Web/umbraco.presentation/content.cs b/src/Umbraco.Web/umbraco.presentation/content.cs index 00d1984d12..a7c5a75337 100644 --- a/src/Umbraco.Web/umbraco.presentation/content.cs +++ b/src/Umbraco.Web/umbraco.presentation/content.cs @@ -394,6 +394,11 @@ namespace umbraco } public virtual void ClearDocumentCache(int documentId) + { + ClearDocumentCache(documentId, true); + } + + internal virtual void ClearDocumentCache(int documentId, bool removeDbXmlEntry) { // Get the document Document d; @@ -408,7 +413,7 @@ namespace umbraco ClearDocumentXmlCache(documentId); return; } - ClearDocumentCache(d); + ClearDocumentCache(d, removeDbXmlEntry); } /// @@ -416,7 +421,8 @@ namespace umbraco /// This means the node gets unpublished from the website. /// /// The document - internal void ClearDocumentCache(Document doc) + /// + internal void ClearDocumentCache(Document doc, bool removeDbXmlEntry) { var e = new DocumentCacheEventArgs(); FireBeforeClearDocumentCache(doc, e); @@ -425,8 +431,13 @@ namespace umbraco { XmlNode x; - // remove from xml db cache - doc.XmlRemoveFromDB(); + //Hack: this is here purely for backwards compat if someone for some reason is using the + // ClearDocumentCache(int documentId) method and expecting it to remove the xml + if (removeDbXmlEntry) + { + // remove from xml db cache + doc.XmlRemoveFromDB(); + } // clear xml cache ClearDocumentXmlCache(doc.Id); diff --git a/src/UmbracoExamine/Config/IndexSetExtensions.cs b/src/UmbracoExamine/Config/IndexSetExtensions.cs index 1255f50a3c..f4bd2e24b2 100644 --- a/src/UmbracoExamine/Config/IndexSetExtensions.cs +++ b/src/UmbracoExamine/Config/IndexSetExtensions.cs @@ -14,7 +14,7 @@ namespace UmbracoExamine.Config public static class IndexSetExtensions { internal static IIndexCriteria ToIndexCriteria(this IndexSet set, IDataService svc, - IEnumerable indexFieldPolicies) + StaticFieldCollection indexFieldPolicies) { return new LazyIndexCriteria(set, svc, indexFieldPolicies); } @@ -29,7 +29,7 @@ namespace UmbracoExamine.Config /// public static IIndexCriteria ToIndexCriteria(this IndexSet set, IDataService svc) { - return set.ToIndexCriteria(svc, Enumerable.Empty()); + return set.ToIndexCriteria(svc, new StaticFieldCollection()); } } diff --git a/src/UmbracoExamine/Config/LazyIndexCriteria.cs b/src/UmbracoExamine/Config/LazyIndexCriteria.cs index 72ab3f31ba..ee58431930 100644 --- a/src/UmbracoExamine/Config/LazyIndexCriteria.cs +++ b/src/UmbracoExamine/Config/LazyIndexCriteria.cs @@ -12,7 +12,7 @@ namespace UmbracoExamine.Config public LazyIndexCriteria( IndexSet set, IDataService svc, - IEnumerable indexFieldPolicies) + StaticFieldCollection indexFieldPolicies) { if (set == null) throw new ArgumentNullException("set"); if (indexFieldPolicies == null) throw new ArgumentNullException("indexFieldPolicies"); @@ -35,8 +35,9 @@ namespace UmbracoExamine.Config foreach (var u in userProps) { var field = new IndexField() { Name = u }; - var policy = indexFieldPolicies.FirstOrDefault(x => x.Name == u); - if (policy != null) + + StaticField policy; + if (indexFieldPolicies.TryGetValue(u, out policy)) { field.Type = policy.Type; field.EnableSorting = policy.EnableSorting; @@ -55,8 +56,9 @@ namespace UmbracoExamine.Config foreach (var s in sysProps) { var field = new IndexField() { Name = s }; - var policy = indexFieldPolicies.FirstOrDefault(x => x.Name == s); - if (policy != null) + + StaticField policy; + if (indexFieldPolicies.TryGetValue(s, out policy)) { field.Type = policy.Type; field.EnableSorting = policy.EnableSorting; diff --git a/src/UmbracoExamine/StaticFieldCollection.cs b/src/UmbracoExamine/StaticFieldCollection.cs new file mode 100644 index 0000000000..909271e0b5 --- /dev/null +++ b/src/UmbracoExamine/StaticFieldCollection.cs @@ -0,0 +1,28 @@ +using System.Collections.ObjectModel; + +namespace UmbracoExamine +{ + internal class StaticFieldCollection : KeyedCollection + { + protected override string GetKeyForItem(StaticField item) + { + return item.Name; + } + + /// + /// Implements TryGetValue using the underlying dictionary + /// + /// + /// + /// + public bool TryGetValue(string key, out StaticField field) + { + if (Dictionary == null) + { + field = null; + return false; + } + return Dictionary.TryGetValue(key, out field); + } + } +} \ No newline at end of file diff --git a/src/UmbracoExamine/UmbracoContentIndexer.cs b/src/UmbracoExamine/UmbracoContentIndexer.cs index 0f3779034c..37382d2647 100644 --- a/src/UmbracoExamine/UmbracoContentIndexer.cs +++ b/src/UmbracoExamine/UmbracoContentIndexer.cs @@ -196,27 +196,27 @@ namespace UmbracoExamine /// Alot of standard umbraco fields shouldn't be tokenized or even indexed, just stored into lucene /// for retreival after searching. /// - internal static readonly List IndexFieldPolicies - = new List + internal static readonly StaticFieldCollection IndexFieldPolicies + = new StaticFieldCollection { new StaticField("id", FieldIndexTypes.NOT_ANALYZED, false, string.Empty), new StaticField("key", FieldIndexTypes.NOT_ANALYZED, false, string.Empty), - new StaticField( "version", FieldIndexTypes.NOT_ANALYZED, false, string.Empty), - new StaticField( "parentID", FieldIndexTypes.NOT_ANALYZED, false, string.Empty), - new StaticField( "level", FieldIndexTypes.NOT_ANALYZED, true, "NUMBER"), - new StaticField( "writerID", FieldIndexTypes.NOT_ANALYZED, false, string.Empty), - new StaticField( "creatorID", FieldIndexTypes.NOT_ANALYZED, false, string.Empty), - new StaticField( "nodeType", FieldIndexTypes.NOT_ANALYZED, false, string.Empty), - new StaticField( "template", FieldIndexTypes.NOT_ANALYZED, false, string.Empty), - new StaticField( "sortOrder", FieldIndexTypes.NOT_ANALYZED, true, "NUMBER"), - new StaticField( "createDate", FieldIndexTypes.NOT_ANALYZED, false, "DATETIME"), - new StaticField( "updateDate", FieldIndexTypes.NOT_ANALYZED, false, "DATETIME"), - new StaticField( "nodeName", FieldIndexTypes.ANALYZED, false, string.Empty), - new StaticField( "urlName", FieldIndexTypes.NOT_ANALYZED, false, string.Empty), - new StaticField( "writerName", FieldIndexTypes.ANALYZED, false, string.Empty), - new StaticField( "creatorName", FieldIndexTypes.ANALYZED, false, string.Empty), - new StaticField( "nodeTypeAlias", FieldIndexTypes.ANALYZED, false, string.Empty), - new StaticField( "path", FieldIndexTypes.NOT_ANALYZED, false, string.Empty) + new StaticField("version", FieldIndexTypes.NOT_ANALYZED, false, string.Empty), + new StaticField("parentID", FieldIndexTypes.NOT_ANALYZED, false, string.Empty), + new StaticField("level", FieldIndexTypes.NOT_ANALYZED, true, "NUMBER"), + new StaticField("writerID", FieldIndexTypes.NOT_ANALYZED, false, string.Empty), + new StaticField("creatorID", FieldIndexTypes.NOT_ANALYZED, false, string.Empty), + new StaticField("nodeType", FieldIndexTypes.NOT_ANALYZED, false, string.Empty), + new StaticField("template", FieldIndexTypes.NOT_ANALYZED, false, string.Empty), + new StaticField("sortOrder", FieldIndexTypes.NOT_ANALYZED, true, "NUMBER"), + new StaticField("createDate", FieldIndexTypes.NOT_ANALYZED, false, "DATETIME"), + new StaticField("updateDate", FieldIndexTypes.NOT_ANALYZED, false, "DATETIME"), + new StaticField("nodeName", FieldIndexTypes.ANALYZED, false, string.Empty), + new StaticField("urlName", FieldIndexTypes.NOT_ANALYZED, false, string.Empty), + new StaticField("writerName", FieldIndexTypes.ANALYZED, false, string.Empty), + new StaticField("creatorName", FieldIndexTypes.ANALYZED, false, string.Empty), + new StaticField("nodeTypeAlias", FieldIndexTypes.ANALYZED, false, string.Empty), + new StaticField("path", FieldIndexTypes.NOT_ANALYZED, false, string.Empty) }; #endregion @@ -804,9 +804,13 @@ namespace UmbracoExamine /// /// protected override FieldIndexTypes GetPolicy(string fieldName) - { - var def = IndexFieldPolicies.Where(x => x.Name == fieldName).ToArray(); - return (def.Any() == false ? FieldIndexTypes.ANALYZED : def.Single().IndexType); + { + StaticField def; + if (IndexFieldPolicies.TryGetValue(fieldName, out def)) + { + return def.IndexType; + } + return FieldIndexTypes.ANALYZED; } /// @@ -816,14 +820,18 @@ namespace UmbracoExamine /// protected override bool ValidateDocument(XElement node) { - var nodeId = int.Parse(node.Attribute("id").Value); // Test for access if we're only indexing published content // return nothing if we're not supporting protected content and it is protected, and we're not supporting unpublished content - if (!SupportUnpublishedContent - && (!SupportProtectedContent - && DataService.ContentService.IsProtected(nodeId, node.Attribute("path").Value))) + if (SupportUnpublishedContent == false + && SupportProtectedContent == false) { - return false; + + var nodeId = int.Parse(node.Attribute("id").Value); + + if (DataService.ContentService.IsProtected(nodeId, node.Attribute("path").Value)) + { + return false; + } } return base.ValidateDocument(node); } diff --git a/src/UmbracoExamine/UmbracoExamine.csproj b/src/UmbracoExamine/UmbracoExamine.csproj index d8fa4586bb..efa5eeed41 100644 --- a/src/UmbracoExamine/UmbracoExamine.csproj +++ b/src/UmbracoExamine/UmbracoExamine.csproj @@ -82,9 +82,8 @@ ..\Solution Items\TheFARM-Public.snk - - ..\packages\Examine.0.1.80\lib\net45\Examine.dll - True + + ..\packages\Examine.0.1.81\lib\net45\Examine.dll ..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll @@ -134,6 +133,7 @@ + diff --git a/src/UmbracoExamine/UmbracoMemberIndexer.cs b/src/UmbracoExamine/UmbracoMemberIndexer.cs index 2e48dff64e..ad393932be 100644 --- a/src/UmbracoExamine/UmbracoMemberIndexer.cs +++ b/src/UmbracoExamine/UmbracoMemberIndexer.cs @@ -117,8 +117,9 @@ namespace UmbracoExamine if (indexerData.UserFields.Any(x => x.Name == "_searchEmail") == false) { var field = new IndexField { Name = "_searchEmail" }; - var policy = IndexFieldPolicies.FirstOrDefault(x => x.Name == "_searchEmail"); - if (policy != null) + + StaticField policy; + if (IndexFieldPolicies.TryGetValue("_searchEmail", out policy)) { field.Type = policy.Type; field.EnableSorting = policy.EnableSorting; @@ -237,10 +238,16 @@ namespace UmbracoExamine { var fields = base.GetSpecialFieldsToIndex(allValuesForIndexing); - //adds the special path property to the index + //adds the special key property to the index string valuesForIndexing; if (allValuesForIndexing.TryGetValue("__key", out valuesForIndexing)) - fields.Add("__key", valuesForIndexing); + { + if (fields.ContainsKey("__key") == false) + { + fields.Add("__key", valuesForIndexing); + } + } + return fields; diff --git a/src/UmbracoExamine/packages.config b/src/UmbracoExamine/packages.config index 0c85a9c3ca..81a5d495c4 100644 --- a/src/UmbracoExamine/packages.config +++ b/src/UmbracoExamine/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/src/umbraco.MacroEngines/packages.config b/src/umbraco.MacroEngines/packages.config index 930b7adbb0..fdd7b5d593 100644 --- a/src/umbraco.MacroEngines/packages.config +++ b/src/umbraco.MacroEngines/packages.config @@ -1,6 +1,6 @@  - + diff --git a/src/umbraco.MacroEngines/umbraco.MacroEngines.csproj b/src/umbraco.MacroEngines/umbraco.MacroEngines.csproj index bdd962f498..d69e861478 100644 --- a/src/umbraco.MacroEngines/umbraco.MacroEngines.csproj +++ b/src/umbraco.MacroEngines/umbraco.MacroEngines.csproj @@ -45,9 +45,8 @@ false - - ..\packages\Examine.0.1.80\lib\net45\Examine.dll - True + + ..\packages\Examine.0.1.81\lib\net45\Examine.dll ..\packages\HtmlAgilityPack.1.4.9\lib\Net45\HtmlAgilityPack.dll