From e6178efcfb1b7a1517434446bbbf6304411c1762 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Mon, 7 Jan 2013 08:12:53 -0100 Subject: [PATCH 001/188] Duplicating fix for U4-483 so that this also fixes U4-1391 in the 4.11.x branch --- src/Umbraco.Core/IO/IOHelper.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Core/IO/IOHelper.cs b/src/Umbraco.Core/IO/IOHelper.cs index 87ea1cfa9a..a53ae8d924 100644 --- a/src/Umbraco.Core/IO/IOHelper.cs +++ b/src/Umbraco.Core/IO/IOHelper.cs @@ -220,7 +220,7 @@ namespace Umbraco.Core.IO { foreach (var character in Path.GetInvalidFileNameChars()) { - filePath = filePath.Replace(character, '_'); + filePath = filePath.Replace(character, '-'); } } else @@ -240,10 +240,14 @@ namespace Umbraco.Core.IO if (reservedCharacters.IndexOf(character) == -1) stringBuilder.Append(character); else - stringBuilder.Append("_"); + stringBuilder.Append("-"); } - return stringBuilder.ToString(); + // Remove repeating dashes + // From: http://stackoverflow.com/questions/5111967/regex-to-remove-a-specific-repeated-character + var reducedString = Regex.Replace(stringBuilder.ToString(), "-+", "-"); + + return reducedString; } } } From a11a1a51c73bc7b50e914b5d75747e8ffcac5d07 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Mon, 7 Jan 2013 13:36:43 -0100 Subject: [PATCH 002/188] Set compilation debug=false explicitly for release version (for uGoLive) --- src/Umbraco.Web.UI/web.Template.Release.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI/web.Template.Release.config b/src/Umbraco.Web.UI/web.Template.Release.config index db712f638e..909ceba642 100644 --- a/src/Umbraco.Web.UI/web.Template.Release.config +++ b/src/Umbraco.Web.UI/web.Template.Release.config @@ -19,7 +19,7 @@ - + From 7d0fecb07866ec2879d551866ae1666cd0f50b35 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Mon, 7 Jan 2013 14:06:07 -0100 Subject: [PATCH 003/188] Update uGoLive to v1.3.0 (has better reporting of which folders have incorrect permissions) --- src/Umbraco.Web.UI/Umbraco.Web.UI.csproj | 6 +++--- src/Umbraco.Web.UI/packages.config | 2 +- src/Umbraco.Web/Umbraco.Web.csproj | 6 +++--- src/Umbraco.Web/packages.config | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index c71a8b1c14..99c9775849 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -119,15 +119,15 @@ False - ..\packages\uGoLive.1.0.0\lib\Our.Umbraco.uGoLive.dll + ..\packages\uGoLive.1.3.0\lib\Our.Umbraco.uGoLive.dll False - ..\packages\uGoLive.1.0.0\lib\Our.Umbraco.uGoLive.47x.dll + ..\packages\uGoLive.1.3.0\lib\Our.Umbraco.uGoLive.47x.dll False - ..\packages\uGoLive.1.0.0\lib\Our.Umbraco.uGoLive.Checks.dll + ..\packages\uGoLive.1.3.0\lib\Our.Umbraco.uGoLive.Checks.dll System diff --git a/src/Umbraco.Web.UI/packages.config b/src/Umbraco.Web.UI/packages.config index 4a5e3f8da5..292779e3a0 100644 --- a/src/Umbraco.Web.UI/packages.config +++ b/src/Umbraco.Web.UI/packages.config @@ -10,6 +10,6 @@ - + \ No newline at end of file diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index e165e4ee1a..f4118f75e8 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -126,15 +126,15 @@ False - ..\packages\uGoLive.1.0.0\lib\Our.Umbraco.uGoLive.dll + ..\packages\uGoLive.1.3.0\lib\Our.Umbraco.uGoLive.dll False - ..\packages\uGoLive.1.0.0\lib\Our.Umbraco.uGoLive.47x.dll + ..\packages\uGoLive.1.3.0\lib\Our.Umbraco.uGoLive.47x.dll False - ..\packages\uGoLive.1.0.0\lib\Our.Umbraco.uGoLive.Checks.dll + ..\packages\uGoLive.1.3.0\lib\Our.Umbraco.uGoLive.Checks.dll System diff --git a/src/Umbraco.Web/packages.config b/src/Umbraco.Web/packages.config index 7924040d73..eaacf49624 100644 --- a/src/Umbraco.Web/packages.config +++ b/src/Umbraco.Web/packages.config @@ -11,7 +11,7 @@ - + From 3f5e20ca0e7904b55073123a134f077df3fad161 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Mon, 7 Jan 2013 15:19:53 -0100 Subject: [PATCH 004/188] Replaced a little bit too much in the compilation section --- src/Umbraco.Web.UI/web.Template.Release.config | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Umbraco.Web.UI/web.Template.Release.config b/src/Umbraco.Web.UI/web.Template.Release.config index 909ceba642..e68d5b45b1 100644 --- a/src/Umbraco.Web.UI/web.Template.Release.config +++ b/src/Umbraco.Web.UI/web.Template.Release.config @@ -19,7 +19,6 @@ - From 147867a7a876190f39827270965d49d1c1f4cb7e Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Mon, 7 Jan 2013 23:24:29 +0300 Subject: [PATCH 005/188] Fixes the requirement for LegacyUploadFieldWorkaround, cleans up some of the code in ContentControl and various other (legacy) places, improves performance slightly too. --- src/Umbraco.Core/IO/FileSystemExtensions.cs | 13 +- src/Umbraco.Core/IO/PhysicalFileSystem.cs | 17 +- .../DataTypes/LegacyUploadFieldWorkaround.cs | 178 +++++++++--------- .../umbraco.presentation/helper.cs | 6 +- .../umbraco/controls/ContentControl.cs | 60 +++--- src/umbraco.cms/Properties/AssemblyInfo.cs | 3 +- .../businesslogic/datatype/DefaultData.cs | 54 +++--- .../businesslogic/datatype/FileHandlerData.cs | 85 ++++----- .../uploadfield/DataTypeUploadField.cs | 14 +- .../uploadfield/uploadField.cs | 82 +++----- 10 files changed, 250 insertions(+), 262 deletions(-) diff --git a/src/Umbraco.Core/IO/FileSystemExtensions.cs b/src/Umbraco.Core/IO/FileSystemExtensions.cs index 49128db5b2..1549ff4f65 100644 --- a/src/Umbraco.Core/IO/FileSystemExtensions.cs +++ b/src/Umbraco.Core/IO/FileSystemExtensions.cs @@ -1,11 +1,12 @@ -using Umbraco.Core.CodeAnnotations; +using System.IO; +using Umbraco.Core.CodeAnnotations; namespace Umbraco.Core.IO { [UmbracoExperimentalFeature("http://issues.umbraco.org/issue/U4-1156", "Will be declared public after 4.10")] public static class FileSystemExtensions { - [UmbracoExperimentalFeature("", "Will be declared public after 4.10")] + [UmbracoExperimentalFeature("http://issues.umbraco.org/issue/U4-1156", "Will be declared public after 4.10")] internal static long GetSize(this IFileSystem fs, string path) { var s = fs.OpenFile(path); @@ -15,10 +16,16 @@ namespace Umbraco.Core.IO return size; } - [UmbracoExperimentalFeature("", "Will be declared public after 4.10")] + [UmbracoExperimentalFeature("http://issues.umbraco.org/issue/U4-1156", "Will be declared public after 4.10")] internal static void CopyFile(this IFileSystem fs, string path, string newPath) { fs.AddFile(newPath, fs.OpenFile(path)); } + + [UmbracoExperimentalFeature("http://issues.umbraco.org/issue/U4-1156", "Will be declared public after 4.10")] + internal static string GetExtension(this IFileSystem fs, string path) + { + return Path.GetExtension(fs.GetFullPath(path)); + } } } diff --git a/src/Umbraco.Core/IO/PhysicalFileSystem.cs b/src/Umbraco.Core/IO/PhysicalFileSystem.cs index 4f3262b560..0682e6d61f 100644 --- a/src/Umbraco.Core/IO/PhysicalFileSystem.cs +++ b/src/Umbraco.Core/IO/PhysicalFileSystem.cs @@ -13,12 +13,12 @@ namespace Umbraco.Core.IO [UmbracoExperimentalFeature("http://issues.umbraco.org/issue/U4-1156", "Will be declared public after 4.10")] internal class PhysicalFileSystem : IFileSystem { - private readonly string _rootPath; + internal string RootPath { get; private set; } private readonly string _rootUrl; public PhysicalFileSystem(string virtualRoot) { - _rootPath = System.Web.Hosting.HostingEnvironment.MapPath(virtualRoot); + RootPath = System.Web.Hosting.HostingEnvironment.MapPath(virtualRoot); _rootUrl = VirtualPathUtility.ToAbsolute(virtualRoot); } @@ -30,7 +30,7 @@ namespace Umbraco.Core.IO if (string.IsNullOrEmpty(rootUrl)) throw new ArgumentException("The argument 'rootUrl' cannot be null or empty."); - _rootPath = rootPath; + RootPath = rootPath; _rootUrl = rootUrl; } @@ -150,17 +150,12 @@ namespace Umbraco.Core.IO return File.Exists(GetFullPath(path)); } - public string GetExtension(string path) - { - return Path.GetExtension(GetFullPath(path)); - } - public string GetRelativePath(string fullPathOrUrl) { var relativePath = fullPathOrUrl .TrimStart(_rootUrl) .Replace('/', Path.DirectorySeparatorChar) - .TrimStart(_rootPath) + .TrimStart(RootPath) .TrimStart(Path.DirectorySeparatorChar); return relativePath; @@ -168,8 +163,8 @@ namespace Umbraco.Core.IO public string GetFullPath(string path) { - return !path.StartsWith(_rootPath) - ? Path.Combine(_rootPath, path) + return !path.StartsWith(RootPath) + ? Path.Combine(RootPath, path) : path; } diff --git a/src/Umbraco.Web/Strategies/DataTypes/LegacyUploadFieldWorkaround.cs b/src/Umbraco.Web/Strategies/DataTypes/LegacyUploadFieldWorkaround.cs index 10b3d63cb2..f737173795 100644 --- a/src/Umbraco.Web/Strategies/DataTypes/LegacyUploadFieldWorkaround.cs +++ b/src/Umbraco.Web/Strategies/DataTypes/LegacyUploadFieldWorkaround.cs @@ -12,112 +12,108 @@ using umbraco.interfaces; namespace Umbraco.Web.Strategies.DataTypes { - /// - /// Before Save Content/Media subscriber that checks for Upload fields and updates related fields accordingly. - /// - /// - /// This is an intermediate fix for the legacy DataTypeUploadField and the FileHandlerData, so that properties - /// are saved correctly when using the Upload field on a (legacy) Document or Media class. - /// - public class LegacyUploadFieldWorkaround : IApplicationStartupHandler - { - public LegacyUploadFieldWorkaround() - { - global::umbraco.cms.businesslogic.media.Media.BeforeSave += MediaBeforeSave; - global::umbraco.cms.businesslogic.web.Document.BeforeSave += DocumentBeforeSave; - } + ///// + ///// Before Save Content/Media subscriber that checks for Upload fields and updates related fields accordingly. + ///// + ///// + ///// This is an intermediate fix for the legacy DataTypeUploadField and the FileHandlerData, so that properties + ///// are saved correctly when using the Upload field on a (legacy) Document or Media class. + ///// + //public class LegacyUploadFieldWorkaround : IApplicationStartupHandler + //{ + // public LegacyUploadFieldWorkaround() + // { + // global::umbraco.cms.businesslogic.media.Media.BeforeSave += MediaBeforeSave; + // global::umbraco.cms.businesslogic.web.Document.BeforeSave += DocumentBeforeSave; + // } - void DocumentBeforeSave(global::umbraco.cms.businesslogic.web.Document sender, global::umbraco.cms.businesslogic.SaveEventArgs e) - { - if (UmbracoSettings.ImageAutoFillImageProperties != null) - { - var property = sender.GenericProperties.FirstOrDefault(x => x.PropertyType.DataTypeDefinition.DataType.Id == new Guid("5032a6e6-69e3-491d-bb28-cd31cd11086c")); - if (property == null) - return; + // void DocumentBeforeSave(global::umbraco.cms.businesslogic.web.Document sender, global::umbraco.cms.businesslogic.SaveEventArgs e) + // { + // if (UmbracoSettings.ImageAutoFillImageProperties != null) + // { + // var property = sender.GenericProperties.FirstOrDefault(x => x.PropertyType.DataTypeDefinition.DataType.Id == new Guid("5032a6e6-69e3-491d-bb28-cd31cd11086c")); + // if (property == null) + // return; - FillProperties(sender.Content, property); - } - } + // FillProperties(sender.Content, property); + // } + // } - void MediaBeforeSave(global::umbraco.cms.businesslogic.media.Media sender, global::umbraco.cms.businesslogic.SaveEventArgs e) - { - if (UmbracoSettings.ImageAutoFillImageProperties != null) - { - var property = sender.GenericProperties.FirstOrDefault(x => x.PropertyType.DataTypeDefinition.DataType.Id == new Guid("5032a6e6-69e3-491d-bb28-cd31cd11086c")); - if (property == null) - return; + // void MediaBeforeSave(global::umbraco.cms.businesslogic.media.Media sender, global::umbraco.cms.businesslogic.SaveEventArgs e) + // { + // if (UmbracoSettings.ImageAutoFillImageProperties != null) + // { + // var property = sender.GenericProperties.FirstOrDefault(x => x.PropertyType.DataTypeDefinition.DataType.Id == new Guid("5032a6e6-69e3-491d-bb28-cd31cd11086c")); + // if (property == null) + // return; - FillProperties(sender.MediaItem, property); - } - } + // FillProperties(sender.MediaItem, property); + // } + // } - private void FillProperties(IContentBase content, global::umbraco.cms.businesslogic.property.Property property) - { - XmlNode uploadFieldConfigNode = global::umbraco.UmbracoSettings.ImageAutoFillImageProperties.SelectSingleNode(string.Format("uploadField [@alias = \"{0}\"]", property.PropertyType.Alias)); + // private void FillProperties(IContentBase content, global::umbraco.cms.businesslogic.property.Property property) + // { + // XmlNode uploadFieldConfigNode = global::umbraco.UmbracoSettings.ImageAutoFillImageProperties.SelectSingleNode(string.Format("uploadField [@alias = \"{0}\"]", property.PropertyType.Alias)); - if (uploadFieldConfigNode != null) - { - var fileSystem = new PhysicalFileSystem("/"); + // if (uploadFieldConfigNode != null) + // { + // var fileSystem = FileSystemProviderManager.Current.GetFileSystemProvider(); + // var path = fileSystem.GetRelativePath(property.Value.ToString()); - var path = string.IsNullOrEmpty(property.Value.ToString()) - ? string.Empty - : System.Web.Hosting.HostingEnvironment.MapPath(property.Value.ToString()); + // if (string.IsNullOrWhiteSpace(path) == false && fileSystem.FileExists(path)) + // { + // long size; + // using (var fileStream = fileSystem.OpenFile(path)) + // { + // size = fileStream.Length; + // } - if (string.IsNullOrWhiteSpace(path) == false && fileSystem.FileExists(path)) - { - long size; - using (var fileStream = fileSystem.OpenFile(path)) - { - size = fileStream.Length; - } + // var extension = fileSystem.GetExtension(path) != null + // ? fileSystem.GetExtension(path).Substring(1).ToLowerInvariant() + // : ""; - var extension = fileSystem.GetExtension(path) != null - ? fileSystem.GetExtension(path).Substring(1).ToLowerInvariant() - : ""; + // var supportsResizing = ("," + UmbracoSettings.ImageFileTypes + ",").Contains(string.Format(",{0},", extension)); + // var dimensions = supportsResizing ? GetDimensions(path, fileSystem) : null; - var supportsResizing = ("," + UmbracoSettings.ImageFileTypes + ",").Contains(string.Format(",{0},", extension)); - var dimensions = supportsResizing ? GetDimensions(path) : null; + // // only add dimensions to web images + // UpdateProperty(uploadFieldConfigNode, content, "widthFieldAlias", supportsResizing ? dimensions.Item1.ToString(CultureInfo.InvariantCulture) : string.Empty); + // UpdateProperty(uploadFieldConfigNode, content, "heightFieldAlias", supportsResizing ? dimensions.Item2.ToString(CultureInfo.InvariantCulture) : string.Empty); - // only add dimensions to web images - UpdateProperty(uploadFieldConfigNode, content, "widthFieldAlias", supportsResizing ? dimensions.Item1.ToString(CultureInfo.InvariantCulture) : string.Empty); - UpdateProperty(uploadFieldConfigNode, content, "heightFieldAlias", supportsResizing ? dimensions.Item2.ToString(CultureInfo.InvariantCulture) : string.Empty); + // UpdateProperty(uploadFieldConfigNode, content, "lengthFieldAlias", size == default(long) ? string.Empty : size.ToString(CultureInfo.InvariantCulture)); + // UpdateProperty(uploadFieldConfigNode, content, "extensionFieldAlias", string.IsNullOrEmpty(extension) ? string.Empty : extension); + // } + // } + // } - UpdateProperty(uploadFieldConfigNode, content, "lengthFieldAlias", size == default(long) ? string.Empty : size.ToString(CultureInfo.InvariantCulture)); - UpdateProperty(uploadFieldConfigNode, content, "extensionFieldAlias", string.IsNullOrEmpty(extension) ? string.Empty : extension); - } - } - } + // private void UpdateProperty(XmlNode uploadFieldConfigNode, IContentBase content, string propertyAlias, object propertyValue) + // { + // XmlNode propertyNode = uploadFieldConfigNode.SelectSingleNode(propertyAlias); + // if (propertyNode != null && !String.IsNullOrEmpty(propertyNode.FirstChild.Value)) + // { + // if (content.Properties.Contains(propertyNode.FirstChild.Value) && content.Properties[propertyNode.FirstChild.Value] != null) + // { + // content.SetValue(propertyNode.FirstChild.Value, propertyValue); + // } + // } + // } - private void UpdateProperty(XmlNode uploadFieldConfigNode, IContentBase content, string propertyAlias, object propertyValue) - { - XmlNode propertyNode = uploadFieldConfigNode.SelectSingleNode(propertyAlias); - if (propertyNode != null && !String.IsNullOrEmpty(propertyNode.FirstChild.Value)) - { - if (content.Properties.Contains(propertyNode.FirstChild.Value) && content.Properties[propertyNode.FirstChild.Value] != null) - { - content.SetValue(propertyNode.FirstChild.Value, propertyValue); - } - } - } - - private Tuple GetDimensions(string path) - { - var fileSystem = new PhysicalFileSystem("/"); + // private Tuple GetDimensions(string path, IFileSystem fs) + // { - int fileWidth; - int fileHeight; - using (var stream = fileSystem.OpenFile(path)) - { - using (var image = Image.FromStream(stream)) - { - fileWidth = image.Width; - fileHeight = image.Height; - } - } + // int fileWidth; + // int fileHeight; + // using (var stream = fs.OpenFile(path)) + // { + // using (var image = Image.FromStream(stream)) + // { + // fileWidth = image.Width; + // fileHeight = image.Height; + // } + // } - return new Tuple(fileWidth, fileHeight); - } - } + // return new Tuple(fileWidth, fileHeight); + // } + //} } \ No newline at end of file diff --git a/src/Umbraco.Web/umbraco.presentation/helper.cs b/src/Umbraco.Web/umbraco.presentation/helper.cs index 3caf4ec5c0..7a965d09ae 100644 --- a/src/Umbraco.Web/umbraco.presentation/helper.cs +++ b/src/Umbraco.Web/umbraco.presentation/helper.cs @@ -27,8 +27,10 @@ namespace umbraco [Obsolete("This method has been superceded. Use the extension method for HttpRequest or HttpRequestBase method: GetItemAsString instead.")] public static string Request(string text) - { - + { + if (HttpContext.Current == null) + return string.Empty; + if (HttpContext.Current.Request[text.ToLower()] != null) if (HttpContext.Current.Request[text] != string.Empty) return HttpContext.Current.Request[text]; diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentControl.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentControl.cs index a8a549383d..e4be986986 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentControl.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentControl.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; +using Umbraco.Core.IO; using umbraco.BasePages; using umbraco.cms.businesslogic; using umbraco.cms.businesslogic.media; @@ -15,7 +16,6 @@ using umbraco.cms.businesslogic.web; using umbraco.interfaces; using umbraco.uicontrols; using Content = umbraco.cms.businesslogic.Content; -using SystemDirectories = umbraco.IO.SystemDirectories; namespace umbraco.controls { @@ -26,19 +26,19 @@ namespace umbraco.controls /// public class ContentControl : TabView { - private Content _content; + private readonly Content _content; internal Dictionary DataTypes = new Dictionary(); - private UmbracoEnsuredPage prntpage; + private UmbracoEnsuredPage _prntpage; public event EventHandler SaveAndPublish; public event EventHandler SaveToPublish; public event EventHandler Save; - private publishModes CanPublish = publishModes.NoPublish; + private readonly publishModes _canPublish = publishModes.NoPublish; public TabPage tpProp; public bool DoesPublish = false; public TextBox NameTxt = new TextBox(); public PlaceHolder NameTxtHolder = new PlaceHolder(); public RequiredFieldValidator NameTxtValidator = new RequiredFieldValidator(); - private static string _UmbracoPath = SystemDirectories.Umbraco; + private static readonly string _UmbracoPath = SystemDirectories.Umbraco; public Pane PropertiesPane = new Pane(); public Content ContentObject @@ -59,7 +59,7 @@ namespace umbraco.controls } // zb-00036 #29889 : load it only once - List virtualTabs; + List _virtualTabs; /// /// Constructor to set default properties. @@ -76,7 +76,7 @@ namespace umbraco.controls public ContentControl(Content c, publishModes CanPublish, string Id) { ID = Id; - this.CanPublish = CanPublish; + this._canPublish = CanPublish; _content = c; Width = 350; @@ -84,16 +84,16 @@ namespace umbraco.controls SaveAndPublish += new EventHandler(standardSaveAndPublishHandler); Save += new EventHandler(standardSaveAndPublishHandler); - prntpage = (UmbracoEnsuredPage)Page; + _prntpage = (UmbracoEnsuredPage)Page; // zb-00036 #29889 : load it only once - if (virtualTabs == null) - virtualTabs = _content.ContentType.getVirtualTabs.ToList(); + if (_virtualTabs == null) + _virtualTabs = _content.ContentType.getVirtualTabs.ToList(); - foreach (ContentType.TabI t in virtualTabs) + foreach (ContentType.TabI t in _virtualTabs) { TabPage tp = NewTabPage(t.Caption); - addSaveAndPublishButtons(ref tp); + AddSaveAndPublishButtons(ref tp); } } @@ -106,15 +106,15 @@ namespace umbraco.controls SaveAndPublish += new EventHandler(standardSaveAndPublishHandler); Save += new EventHandler(standardSaveAndPublishHandler); - prntpage = (UmbracoEnsuredPage)Page; + _prntpage = (UmbracoEnsuredPage)Page; int i = 0; var inTab = new Hashtable(); // zb-00036 #29889 : load it only once - if (virtualTabs == null) - virtualTabs = _content.ContentType.getVirtualTabs.ToList(); + if (_virtualTabs == null) + _virtualTabs = _content.ContentType.getVirtualTabs.ToList(); - foreach (ContentType.TabI tab in virtualTabs) + foreach (ContentType.TabI tab in _virtualTabs) { var tabPage = this.Panels[i] as TabPage; if (tabPage == null) @@ -136,7 +136,7 @@ namespace umbraco.controls var property = _content.getProperty(propertyType); if (property != null && tabPage != null) { - addControlNew(property, tabPage, tab.Caption); + AddControlNew(property, tabPage, tab.Caption); // adding this check, as we occasionally get an already in dictionary error, though not sure why if (!inTab.ContainsKey(propertyType.Id.ToString())) @@ -153,7 +153,7 @@ namespace umbraco.controls // Add property pane tpProp = NewTabPage(ui.Text("general", "properties", null)); - addSaveAndPublishButtons(ref tpProp); + AddSaveAndPublishButtons(ref tpProp); tpProp.Controls.Add( new LiteralControl("
There were errors - data has not been saved!
")); @@ -163,7 +163,7 @@ namespace umbraco.controls foreach (Property p in props) { if (inTab[p.PropertyType.Id.ToString()] == null) - addControlNew(p, tpProp, ui.Text("general", "properties", null)); + AddControlNew(p, tpProp, ui.Text("general", "properties", null)); } } @@ -257,21 +257,21 @@ namespace umbraco.controls Save(this, new EventArgs()); } - private void savePublish(object Sender, ImageClickEventArgs e) + private void DoSaveAndPublish(object sender, ImageClickEventArgs e) { DoesPublish = true; - saveClick(Sender, e); + saveClick(sender, e); SaveAndPublish(this, new EventArgs()); } - private void saveToPublish(object Sender, ImageClickEventArgs e) + private void DoSaveToPublish(object sender, ImageClickEventArgs e) { - saveClick(Sender, e); + saveClick(sender, e); SaveToPublish(this, new EventArgs()); } - private void addSaveAndPublishButtons(ref TabPage tp) + private void AddSaveAndPublishButtons(ref TabPage tp) { MenuImageButton menuSave = tp.Menu.NewImageButton(); menuSave.ID = tp.ID + "_save"; @@ -279,28 +279,28 @@ namespace umbraco.controls menuSave.Click += new ImageClickEventHandler(saveClick); menuSave.OnClickCommand = "invokeSaveHandlers();"; menuSave.AltText = ui.Text("buttons", "save", null); - if (CanPublish == publishModes.Publish) + if (_canPublish == publishModes.Publish) { MenuImageButton menuPublish = tp.Menu.NewImageButton(); menuPublish.ID = tp.ID + "_publish"; menuPublish.ImageUrl = _UmbracoPath + "/images/editor/saveAndPublish.gif"; menuPublish.OnClickCommand = "invokeSaveHandlers();"; - menuPublish.Click += new ImageClickEventHandler(savePublish); + menuPublish.Click += new ImageClickEventHandler(DoSaveAndPublish); menuPublish.AltText = ui.Text("buttons", "saveAndPublish", null); } - else if (CanPublish == publishModes.SendToPublish) + else if (_canPublish == publishModes.SendToPublish) { MenuImageButton menuToPublish = tp.Menu.NewImageButton(); menuToPublish.ID = tp.ID + "_topublish"; menuToPublish.ImageUrl = _UmbracoPath + "/images/editor/saveToPublish.gif"; menuToPublish.OnClickCommand = "invokeSaveHandlers();"; - menuToPublish.Click += new ImageClickEventHandler(saveToPublish); + menuToPublish.Click += new ImageClickEventHandler(DoSaveToPublish); menuToPublish.AltText = ui.Text("buttons", "saveToPublish", null); } } - private void addControlNew(Property p, TabPage tp, string Caption) + private void AddControlNew(Property p, TabPage tp, string Caption) { IDataType dt = p.PropertyType.DataTypeDefinition.DataType; dt.DataEditor.Editor.ID = string.Format("prop_{0}", p.PropertyType.Alias); @@ -497,7 +497,7 @@ namespace umbraco.controls NoPublish } - private string dictinaryItem(string alias) + private string DictinaryItem(string alias) { if (alias.Substring(1, 0) == "#") { diff --git a/src/umbraco.cms/Properties/AssemblyInfo.cs b/src/umbraco.cms/Properties/AssemblyInfo.cs index 2e08a091b9..ca728d05e1 100644 --- a/src/umbraco.cms/Properties/AssemblyInfo.cs +++ b/src/umbraco.cms/Properties/AssemblyInfo.cs @@ -13,4 +13,5 @@ using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("umbraco", AllInternalsVisible=true)] [assembly: InternalsVisibleTo("Umbraco.LegacyTests")] -[assembly: InternalsVisibleTo("Umbraco.Tests")] \ No newline at end of file +[assembly: InternalsVisibleTo("Umbraco.Tests")] +[assembly: InternalsVisibleTo("umbraco.editorControls")] \ No newline at end of file diff --git a/src/umbraco.cms/businesslogic/datatype/DefaultData.cs b/src/umbraco.cms/businesslogic/datatype/DefaultData.cs index ece234542e..1d15edfcad 100644 --- a/src/umbraco.cms/businesslogic/datatype/DefaultData.cs +++ b/src/umbraco.cms/businesslogic/datatype/DefaultData.cs @@ -16,11 +16,13 @@ namespace umbraco.cms.businesslogic.datatype ///
public class DefaultData : IData, IDataWithPreview { - private int m_PropertyId; - private object m_Value; + private int _propertyId; + private object _value; protected BaseDataType _dataType; - private bool m_PreviewMode; - private bool m_ValueLoaded = false; + private bool _previewMode; + private bool _valueLoaded = false; + private Guid? _version = null; + private int? _nodeId = null; [Obsolete("Deprecated, For querying the database use the new UmbracoDatabase object ApplicationContext.Current.DatabaseContext.Database", false)] protected static ISqlHelper SqlHelper @@ -51,8 +53,8 @@ namespace umbraco.cms.businesslogic.datatype /// The init property id. public virtual void Initialize(object InitValue, int InitPropertyId) { - m_PropertyId = InitPropertyId; - m_Value = InitValue; + _propertyId = InitPropertyId; + _value = InitValue; } /// @@ -67,7 +69,7 @@ namespace umbraco.cms.businesslogic.datatype .On(x => x.Id, y => y.PropertyTypeId) .InnerJoin() .On(x => x.DataTypeId, y => y.DataTypeId) - .Where("cmsPropertyData.id = @Id", new {Id = m_PropertyId}); + .Where("cmsPropertyData.id = @Id", new {Id = _propertyId}); var dto = Database.Fetch(sql).FirstOrDefault(); if (dto != null) @@ -79,7 +81,7 @@ namespace umbraco.cms.businesslogic.datatype //get the column name in the cmsPropertyData table that stores the correct information for the data type var fieldName = BaseDataType.GetDataFieldName(dbType); //get the value for the data type, if null, set it to an empty string - m_Value = dto.GetValue; + _value = dto.GetValue; //now that we've set our value, we can update our BaseDataType object with the correct values from the db //instead of making it query for itself. This is a peformance optimization enhancement. _dataType.SetDataTypeProperties(fieldName, dbType); @@ -126,17 +128,17 @@ namespace umbraco.cms.businesslogic.datatype get { //Lazy load the value when it is required. - if (!m_ValueLoaded) + if (!_valueLoaded) { LoadValueFromDatabase(); - m_ValueLoaded = true; + _valueLoaded = true; } - return m_Value; + return _value; } set { - m_Value = value; - m_ValueLoaded = true; + _value = value; + _valueLoaded = true; } } @@ -168,23 +170,27 @@ namespace umbraco.cms.businesslogic.datatype { get { - return m_PropertyId; + return _propertyId; } set { - m_PropertyId = value; + _propertyId = value; //LoadValueFromDatabase(); } } - + // TODO: clean up Legacy - these are needed by the wysiwyeditor, in order to feed the richtextholder with version and nodeid // solution, create a new version of the richtextholder, which does not depend on these. public virtual Guid Version { get { - var dto = Database.FirstOrDefault("WHERE id = @Id", new {Id = PropertyId}); - return dto.VersionId.HasValue ? dto.VersionId.Value : Guid.Empty; + if (_version == null) + { + var dto = Database.FirstOrDefault("WHERE id = @Id", new { Id = PropertyId }); + _version = dto.VersionId.HasValue ? dto.VersionId.Value : Guid.Empty; + } + return _version.Value; } } @@ -196,7 +202,11 @@ namespace umbraco.cms.businesslogic.datatype { get { - return Database.ExecuteScalar("Select contentNodeid from cmsPropertyData where id = @Id", new {Id = PropertyId}); + if (_nodeId == null) + { + _nodeId = Database.ExecuteScalar("Select contentNodeid from cmsPropertyData where id = @Id", new { Id = PropertyId }); + } + return _nodeId.Value; } } @@ -215,16 +225,16 @@ namespace umbraco.cms.businesslogic.datatype { get { - return m_PreviewMode; + return _previewMode; } set { - if (m_PreviewMode != value) + if (_previewMode != value) { // if preview mode is switched off, reload the value from persistent storage if (!value) LoadValueFromDatabase(); - m_PreviewMode = value; + _previewMode = value; } } } diff --git a/src/umbraco.cms/businesslogic/datatype/FileHandlerData.cs b/src/umbraco.cms/businesslogic/datatype/FileHandlerData.cs index 6bdb826e39..eeb934cc9f 100644 --- a/src/umbraco.cms/businesslogic/datatype/FileHandlerData.cs +++ b/src/umbraco.cms/businesslogic/datatype/FileHandlerData.cs @@ -2,9 +2,9 @@ using System.IO; using System.Web; using System.Xml; +using Umbraco.Core.IO; using umbraco.cms.businesslogic.Files; using umbraco.cms.businesslogic.property; -using umbraco.IO; using IContent = Umbraco.Core.Models.IContent; using IMedia = Umbraco.Core.Models.IMedia; @@ -20,38 +20,37 @@ namespace umbraco.cms.businesslogic.datatype _thumbnailSizes = thumbnailSizes; } + /// + /// Gets/sets the loaded Conent object which we can resolve from other classes since this class sets it's properties + /// + internal Content LoadedContentItem { get; set; } + + /// + /// Called to ensure we have a valid LoadedContentItem. + /// + /// + private void EnsureLoadedContentItem(Guid version) + { + if (LoadedContentItem == null) + { + LoadedContentItem = Content.GetContentFromVersion(Version); + } + } + public override object Value { get { return base.Value; } set { - UmbracoFile um = null; - if (value is HttpPostedFile || value is HttpPostedFileBase || value is HttpPostedFileWrapper) + if (value is HttpPostedFile || value is HttpPostedFileBase) { - string name = string.Empty; - Stream fileStream = null; + Stream fileStream = null; - if (value is HttpPostedFile) - { - var file = value as HttpPostedFile; - name = Umbraco.Core.IO.IOHelper.SafeFileName(file.FileName.Substring(file.FileName.LastIndexOf(IOHelper.DirSepChar) + 1, file.FileName.Length - file.FileName.LastIndexOf(IOHelper.DirSepChar) - 1).ToLower()); - fileStream = file.InputStream; - } - else if (value is HttpPostedFileBase) - { - var file = value as HttpPostedFileBase; - name = Umbraco.Core.IO.IOHelper.SafeFileName(file.FileName.Substring(file.FileName.LastIndexOf(IOHelper.DirSepChar) + 1, file.FileName.Length - file.FileName.LastIndexOf(IOHelper.DirSepChar) - 1).ToLower()); - fileStream = file.InputStream; - } - else if (value is HttpPostedFileWrapper) - { - var file = value as HttpPostedFileWrapper; - name = file.FileName; - fileStream = file.InputStream; - } + var file = value as HttpPostedFile; + var name = IOHelper.SafeFileName(file.FileName.Substring(file.FileName.LastIndexOf(IOHelper.DirSepChar) + 1, file.FileName.Length - file.FileName.LastIndexOf(IOHelper.DirSepChar) - 1).ToLower()); + fileStream = file.InputStream; - - // handle upload + // handle upload if (name != String.Empty) { @@ -60,7 +59,7 @@ namespace umbraco.cms.businesslogic.datatype : PropertyId + "-" + name; //fileName = Path.Combine(SystemDirectories.Media, fileName); - um = UmbracoFile.Save(fileStream, fileName); + UmbracoFile um = UmbracoFile.Save(fileStream, fileName); if (um.SupportsResizing) { @@ -94,11 +93,8 @@ namespace umbraco.cms.businesslogic.datatype if (uploadFieldConfigNode != null) { - var legacy = Content.GetContentFromVersion(Version); - if (legacy.ContentBase is IContent == false && legacy.ContentBase is IMedia == false) - { - FillProperties(uploadFieldConfigNode, legacy, um); - } + EnsureLoadedContentItem(Version); + FillProperties(uploadFieldConfigNode, LoadedContentItem, um); } } @@ -110,18 +106,18 @@ namespace umbraco.cms.businesslogic.datatype base.Value = String.Empty; // also reset values of related fields - clearRelatedValues(); + ClearRelatedValues(); } } else { base.Value = value; - clearRelatedValues(); + ClearRelatedValues(); } } } - private void clearRelatedValues() + private void ClearRelatedValues() { string propertyTypeAlias = new Property(PropertyId).PropertyType.Alias; if (UmbracoSettings.ImageAutoFillImageProperties != null) @@ -132,12 +128,13 @@ namespace umbraco.cms.businesslogic.datatype if (uploadFieldConfigNode != null) { // get the current document - Content legacy = Content.GetContentFromVersion(Version); + //Content legacy = Content.GetContentFromVersion(Version); + EnsureLoadedContentItem(Version); // only add dimensions to web images - updateContentProperty(uploadFieldConfigNode, legacy, "widthFieldAlias", String.Empty); - updateContentProperty(uploadFieldConfigNode, legacy, "heightFieldAlias", String.Empty); - updateContentProperty(uploadFieldConfigNode, legacy, "lengthFieldAlias", String.Empty); - updateContentProperty(uploadFieldConfigNode, legacy, "extensionFieldAlias", String.Empty); + UpdateContentProperty(uploadFieldConfigNode, LoadedContentItem, "widthFieldAlias", String.Empty); + UpdateContentProperty(uploadFieldConfigNode, LoadedContentItem, "heightFieldAlias", String.Empty); + UpdateContentProperty(uploadFieldConfigNode, LoadedContentItem, "lengthFieldAlias", String.Empty); + UpdateContentProperty(uploadFieldConfigNode, LoadedContentItem, "extensionFieldAlias", String.Empty); } } } @@ -145,14 +142,14 @@ namespace umbraco.cms.businesslogic.datatype private void FillProperties(XmlNode uploadFieldConfigNode, Content content, UmbracoFile um) { // only add dimensions to web images - updateContentProperty(uploadFieldConfigNode, content, "widthFieldAlias", um.SupportsResizing ? um.GetDimensions().Item1.ToString() : string.Empty); - updateContentProperty(uploadFieldConfigNode, content, "heightFieldAlias", um.SupportsResizing ? um.GetDimensions().Item2.ToString() : string.Empty); + UpdateContentProperty(uploadFieldConfigNode, content, "widthFieldAlias", um.SupportsResizing ? um.GetDimensions().Item1.ToString() : string.Empty); + UpdateContentProperty(uploadFieldConfigNode, content, "heightFieldAlias", um.SupportsResizing ? um.GetDimensions().Item2.ToString() : string.Empty); - updateContentProperty(uploadFieldConfigNode, content, "lengthFieldAlias", um.Length); - updateContentProperty(uploadFieldConfigNode, content, "extensionFieldAlias", um.Extension); + UpdateContentProperty(uploadFieldConfigNode, content, "lengthFieldAlias", um.Length); + UpdateContentProperty(uploadFieldConfigNode, content, "extensionFieldAlias", um.Extension); } - private void updateContentProperty(XmlNode uploadFieldConfigNode, Content content, string propertyAlias, + private static void UpdateContentProperty(XmlNode uploadFieldConfigNode, Content content, string propertyAlias, object propertyValue) { XmlNode propertyNode = uploadFieldConfigNode.SelectSingleNode(propertyAlias); diff --git a/src/umbraco.editorControls/uploadfield/DataTypeUploadField.cs b/src/umbraco.editorControls/uploadfield/DataTypeUploadField.cs index acdf95af82..8d5104094c 100644 --- a/src/umbraco.editorControls/uploadfield/DataTypeUploadField.cs +++ b/src/umbraco.editorControls/uploadfield/DataTypeUploadField.cs @@ -7,20 +7,26 @@ namespace umbraco.editorControls.uploadfield /// public class DataTypeUploadField : cms.businesslogic.datatype.BaseDataType,interfaces.IDataType { - private interfaces.IDataEditor _Editor; + private interfaces.IDataEditor _editor; private interfaces.IData _baseData; private interfaces.IDataPrevalue _prevalueeditor; + /// + /// Always returns an uploadField control + /// public override interfaces.IDataEditor DataEditor { get { - if (_Editor == null) - _Editor = new uploadField(Data, ((uploadFieldPreValue)PrevalueEditor).Configuration); - return _Editor; + if (_editor == null) + _editor = new uploadField(Data, ((uploadFieldPreValue)PrevalueEditor).Configuration); + return _editor; } } + /// + /// Always returns FileHandlerData + /// public override interfaces.IData Data { get diff --git a/src/umbraco.editorControls/uploadfield/uploadField.cs b/src/umbraco.editorControls/uploadfield/uploadField.cs index 933fffd8a1..3723f31c34 100644 --- a/src/umbraco.editorControls/uploadfield/uploadField.cs +++ b/src/umbraco.editorControls/uploadfield/uploadField.cs @@ -14,17 +14,16 @@ namespace umbraco.editorControls [ValidationProperty("IsValid")] public class uploadField : HtmlInputFile, IDataEditor { - private const String _thumbnailext = ".jpg"; - private readonly cms.businesslogic.datatype.DefaultData _data; + private const String Thumbnailext = ".jpg"; + private readonly cms.businesslogic.datatype.FileHandlerData _data; private readonly String _thumbnails; private String _text; - - private MediaFileSystem _fs; + private readonly MediaFileSystem _fs; public uploadField(IData Data, string ThumbnailSizes) { _fs = FileSystemProviderManager.Current.GetFileSystemProvider(); - _data = (cms.businesslogic.datatype.DefaultData) Data; + _data = (cms.businesslogic.datatype.FileHandlerData) Data; //this is always FileHandlerData _thumbnails = ThumbnailSizes; } @@ -79,7 +78,7 @@ namespace umbraco.editorControls if (helper.Request(ClientID + "clear") == "1") { // delete file - deleteFile(_text); + DeleteFile(_text); // set filename in db to nothing _text = ""; @@ -111,51 +110,14 @@ namespace umbraco.editorControls // we update additional properties post image upload if (_data.Value != DBNull.Value && !string.IsNullOrEmpty(_data.Value.ToString())) { - Content content = Content.GetContentFromVersion(_data.Version); - - // update extension in UI - try - { - var extensionControl = FindControlRecursive(Page, "prop_umbracoExtension"); - if (extensionControl != null) - { - extensionControl.RefreshLabel(content.getProperty("umbracoExtension").Value.ToString()); - } - } - catch - { - } - - + var content = _data.LoadedContentItem; + + // update extension in UI + UpdateLabelValue("umbracoExtension", "prop_umbracoExtension", Page, content); // update file size in UI - try - { - var bytesControl = FindControlRecursive(Page, "prop_umbracoBytes"); - if (bytesControl != null) - { - bytesControl.RefreshLabel(content.getProperty("umbracoBytes").Value.ToString()); - } - } - catch - { - } - - try - { - var widthControl = FindControlRecursive(Page, "prop_umbracoWidth"); - if (widthControl != null) - { - widthControl.RefreshLabel(content.getProperty("umbracoWidth").Value.ToString()); - } - var heightControl = FindControlRecursive(Page, "prop_umbracoHeight"); - if (heightControl != null) - { - heightControl.RefreshLabel(content.getProperty("umbracoHeight").Value.ToString()); - } - } - catch - { - } + UpdateLabelValue("umbracoBytes", "prop_umbracoBytes", Page, content); + UpdateLabelValue("umbracoWidth", "prop_umbracoWidth", Page, content); + UpdateLabelValue("umbracoHeight", "prop_umbracoHeight", Page, content); } Text = _data.Value.ToString(); } @@ -163,6 +125,18 @@ namespace umbraco.editorControls #endregion + private static void UpdateLabelValue(string propAlias, string controlId, Page controlPage, Content content) + { + var extensionControl = FindControlRecursive(controlPage, controlId); + if (extensionControl != null) + { + if (content.getProperty(propAlias) != null && content.getProperty(propAlias).Value != null) + { + extensionControl.RefreshLabel(content.getProperty(propAlias).Value.ToString()); + } + } + } + [Obsolete("This method is now obsolete due to a change in the way that files are handled. If you need to check if a URL for an uploaded file is safe you should implement your own as this method will be removed in a future version", false)] public string SafeUrl(string url) { @@ -179,7 +153,7 @@ namespace umbraco.editorControls Text = _data.Value.ToString(); } - private void deleteFile(string fileUrl) + private void DeleteFile(string fileUrl) { if (fileUrl.Length > 0) { @@ -200,8 +174,8 @@ namespace umbraco.editorControls try { - if (_fs.FileExists(relativeThumbFilePath + _thumbnailext)) - _fs.DeleteFile(relativeThumbFilePath + _thumbnailext); + if (_fs.FileExists(relativeThumbFilePath + Thumbnailext)) + _fs.DeleteFile(relativeThumbFilePath + Thumbnailext); } catch { @@ -214,7 +188,7 @@ namespace umbraco.editorControls { if (thumb != "") { - string relativeExtraThumbFilePath = relativeThumbFilePath + "_" + thumb + _thumbnailext; + string relativeExtraThumbFilePath = relativeThumbFilePath + "_" + thumb + Thumbnailext; try { From e49bb2dd5180f0952eae044a8f18c78d65b6233e Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Tue, 8 Jan 2013 00:58:22 +0300 Subject: [PATCH 006/188] Adds a null check to set the label values, if the content item wasn't loaded then no properties were filled and thsu no need to update the labels. Cleans up a tiny bit more code. --- src/Umbraco.Core/IO/FileSystemExtensions.cs | 6 +++++ .../businesslogic/Files/UmbracoFile.cs | 14 +++++----- .../uploadfield/uploadField.cs | 26 ++++++++++++------- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/Umbraco.Core/IO/FileSystemExtensions.cs b/src/Umbraco.Core/IO/FileSystemExtensions.cs index 1549ff4f65..fa7bbbcdb7 100644 --- a/src/Umbraco.Core/IO/FileSystemExtensions.cs +++ b/src/Umbraco.Core/IO/FileSystemExtensions.cs @@ -27,5 +27,11 @@ namespace Umbraco.Core.IO { return Path.GetExtension(fs.GetFullPath(path)); } + + [UmbracoExperimentalFeature("http://issues.umbraco.org/issue/U4-1156", "Will be declared public after 4.10")] + internal static string GetFileName(this IFileSystem fs, string path) + { + return Path.GetFileName(fs.GetFullPath(path)); + } } } diff --git a/src/umbraco.cms/businesslogic/Files/UmbracoFile.cs b/src/umbraco.cms/businesslogic/Files/UmbracoFile.cs index b5dc3152a4..d7aa033e25 100644 --- a/src/umbraco.cms/businesslogic/Files/UmbracoFile.cs +++ b/src/umbraco.cms/businesslogic/Files/UmbracoFile.cs @@ -13,13 +13,13 @@ namespace umbraco.cms.businesslogic.Files { public class UmbracoFile : IFile { - private string _path; + private readonly string _path; private string _fileName; private string _extension; private string _url; private long _length; - private MediaFileSystem _fs; + private readonly MediaFileSystem _fs; #region Constructors @@ -34,7 +34,7 @@ namespace umbraco.cms.businesslogic.Files _path = path; - initialize(); + Initialize(); } #endregion @@ -81,12 +81,12 @@ namespace umbraco.cms.businesslogic.Files #endregion - private void initialize() + private void Initialize() { - _fileName = System.IO.Path.GetFileName(_path); + _fileName = _fs.GetFileName(_path); _length = _fs.GetSize(_path); - _extension = System.IO.Path.GetExtension(_path) != null - ? System.IO.Path.GetExtension(_path).Substring(1).ToLowerInvariant() + _extension = _fs.GetExtension(_path) != null + ? _fs.GetExtension(_path).Substring(1).ToLowerInvariant() : ""; _url = _fs.GetUrl(_path); } diff --git a/src/umbraco.editorControls/uploadfield/uploadField.cs b/src/umbraco.editorControls/uploadfield/uploadField.cs index 3723f31c34..fe8423b2b1 100644 --- a/src/umbraco.editorControls/uploadfield/uploadField.cs +++ b/src/umbraco.editorControls/uploadfield/uploadField.cs @@ -110,14 +110,20 @@ namespace umbraco.editorControls // we update additional properties post image upload if (_data.Value != DBNull.Value && !string.IsNullOrEmpty(_data.Value.ToString())) { - var content = _data.LoadedContentItem; - - // update extension in UI - UpdateLabelValue("umbracoExtension", "prop_umbracoExtension", Page, content); - // update file size in UI - UpdateLabelValue("umbracoBytes", "prop_umbracoBytes", Page, content); - UpdateLabelValue("umbracoWidth", "prop_umbracoWidth", Page, content); - UpdateLabelValue("umbracoHeight", "prop_umbracoHeight", Page, content); + //check the FileHandlerData to see if it already loaded in the content item and set it's properties. + //if not, then the properties haven't changed so skip. + if (_data.LoadedContentItem != null) + { + var content = _data.LoadedContentItem; + + // update extension in UI + UpdateLabelValue("umbracoExtension", "prop_umbracoExtension", Page, content); + // update file size in UI + UpdateLabelValue("umbracoBytes", "prop_umbracoBytes", Page, content); + UpdateLabelValue("umbracoWidth", "prop_umbracoWidth", Page, content); + UpdateLabelValue("umbracoHeight", "prop_umbracoHeight", Page, content); + } + } Text = _data.Value.ToString(); } @@ -249,8 +255,8 @@ namespace umbraco.editorControls { var relativeFilePath = _fs.GetRelativePath(_text); var ext = relativeFilePath.Substring(relativeFilePath.LastIndexOf(".") + 1, relativeFilePath.Length - relativeFilePath.LastIndexOf(".") - 1); - var relativeThumbFilePath = relativeFilePath.Replace("." + ext, "_thumb.jpg"); - var hasThumb = false; + var relativeThumbFilePath = relativeFilePath.Replace("." + ext, "_thumb.jpg"); + var hasThumb = false; try { hasThumb = _fs.FileExists(relativeThumbFilePath); From 3570ba4b9563a6c666ceaaac254a0c76fac92e31 Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Tue, 8 Jan 2013 01:43:01 +0300 Subject: [PATCH 007/188] Un-comments LegacyUploadFieldWorkaround with changes that make use of the MediaFileSystem. --- .../DataTypes/LegacyUploadFieldWorkaround.cs | 176 +++++++++--------- 1 file changed, 88 insertions(+), 88 deletions(-) diff --git a/src/Umbraco.Web/Strategies/DataTypes/LegacyUploadFieldWorkaround.cs b/src/Umbraco.Web/Strategies/DataTypes/LegacyUploadFieldWorkaround.cs index f737173795..aaac98c89c 100644 --- a/src/Umbraco.Web/Strategies/DataTypes/LegacyUploadFieldWorkaround.cs +++ b/src/Umbraco.Web/Strategies/DataTypes/LegacyUploadFieldWorkaround.cs @@ -12,108 +12,108 @@ using umbraco.interfaces; namespace Umbraco.Web.Strategies.DataTypes { - ///// - ///// Before Save Content/Media subscriber that checks for Upload fields and updates related fields accordingly. - ///// - ///// - ///// This is an intermediate fix for the legacy DataTypeUploadField and the FileHandlerData, so that properties - ///// are saved correctly when using the Upload field on a (legacy) Document or Media class. - ///// - //public class LegacyUploadFieldWorkaround : IApplicationStartupHandler - //{ - // public LegacyUploadFieldWorkaround() - // { - // global::umbraco.cms.businesslogic.media.Media.BeforeSave += MediaBeforeSave; - // global::umbraco.cms.businesslogic.web.Document.BeforeSave += DocumentBeforeSave; - // } + /// + /// Before Save Content/Media subscriber that checks for Upload fields and updates related fields accordingly. + /// + /// + /// This is an intermediate fix for the legacy DataTypeUploadField and the FileHandlerData, so that properties + /// are saved correctly when using the Upload field on a (legacy) Document or Media class. + /// + public class LegacyUploadFieldWorkaround : IApplicationStartupHandler + { + public LegacyUploadFieldWorkaround() + { + global::umbraco.cms.businesslogic.media.Media.BeforeSave += MediaBeforeSave; + global::umbraco.cms.businesslogic.web.Document.BeforeSave += DocumentBeforeSave; + } - // void DocumentBeforeSave(global::umbraco.cms.businesslogic.web.Document sender, global::umbraco.cms.businesslogic.SaveEventArgs e) - // { - // if (UmbracoSettings.ImageAutoFillImageProperties != null) - // { - // var property = sender.GenericProperties.FirstOrDefault(x => x.PropertyType.DataTypeDefinition.DataType.Id == new Guid("5032a6e6-69e3-491d-bb28-cd31cd11086c")); - // if (property == null) - // return; + void DocumentBeforeSave(global::umbraco.cms.businesslogic.web.Document sender, global::umbraco.cms.businesslogic.SaveEventArgs e) + { + if (UmbracoSettings.ImageAutoFillImageProperties != null) + { + var property = sender.GenericProperties.FirstOrDefault(x => x.PropertyType.DataTypeDefinition.DataType.Id == new Guid("5032a6e6-69e3-491d-bb28-cd31cd11086c")); + if (property == null) + return; - // FillProperties(sender.Content, property); - // } - // } + FillProperties(sender.Content, property); + } + } - // void MediaBeforeSave(global::umbraco.cms.businesslogic.media.Media sender, global::umbraco.cms.businesslogic.SaveEventArgs e) - // { - // if (UmbracoSettings.ImageAutoFillImageProperties != null) - // { - // var property = sender.GenericProperties.FirstOrDefault(x => x.PropertyType.DataTypeDefinition.DataType.Id == new Guid("5032a6e6-69e3-491d-bb28-cd31cd11086c")); - // if (property == null) - // return; + void MediaBeforeSave(global::umbraco.cms.businesslogic.media.Media sender, global::umbraco.cms.businesslogic.SaveEventArgs e) + { + if (UmbracoSettings.ImageAutoFillImageProperties != null) + { + var property = sender.GenericProperties.FirstOrDefault(x => x.PropertyType.DataTypeDefinition.DataType.Id == new Guid("5032a6e6-69e3-491d-bb28-cd31cd11086c")); + if (property == null) + return; - // FillProperties(sender.MediaItem, property); - // } - // } + FillProperties(sender.MediaItem, property); + } + } - // private void FillProperties(IContentBase content, global::umbraco.cms.businesslogic.property.Property property) - // { - // XmlNode uploadFieldConfigNode = global::umbraco.UmbracoSettings.ImageAutoFillImageProperties.SelectSingleNode(string.Format("uploadField [@alias = \"{0}\"]", property.PropertyType.Alias)); + private void FillProperties(IContentBase content, global::umbraco.cms.businesslogic.property.Property property) + { + XmlNode uploadFieldConfigNode = global::umbraco.UmbracoSettings.ImageAutoFillImageProperties.SelectSingleNode(string.Format("uploadField [@alias = \"{0}\"]", property.PropertyType.Alias)); - // if (uploadFieldConfigNode != null) - // { - // var fileSystem = FileSystemProviderManager.Current.GetFileSystemProvider(); - // var path = fileSystem.GetRelativePath(property.Value.ToString()); + if (uploadFieldConfigNode != null) + { + var fileSystem = FileSystemProviderManager.Current.GetFileSystemProvider(); + var path = fileSystem.GetRelativePath(property.Value.ToString()); - // if (string.IsNullOrWhiteSpace(path) == false && fileSystem.FileExists(path)) - // { - // long size; - // using (var fileStream = fileSystem.OpenFile(path)) - // { - // size = fileStream.Length; - // } + if (string.IsNullOrWhiteSpace(path) == false && fileSystem.FileExists(path)) + { + long size; + using (var fileStream = fileSystem.OpenFile(path)) + { + size = fileStream.Length; + } - // var extension = fileSystem.GetExtension(path) != null - // ? fileSystem.GetExtension(path).Substring(1).ToLowerInvariant() - // : ""; + var extension = fileSystem.GetExtension(path) != null + ? fileSystem.GetExtension(path).Substring(1).ToLowerInvariant() + : ""; - // var supportsResizing = ("," + UmbracoSettings.ImageFileTypes + ",").Contains(string.Format(",{0},", extension)); - // var dimensions = supportsResizing ? GetDimensions(path, fileSystem) : null; + var isImageType = ("," + UmbracoSettings.ImageFileTypes + ",").Contains(string.Format(",{0},", extension)); + var dimensions = isImageType ? GetDimensions(path, fileSystem) : null; - // // only add dimensions to web images - // UpdateProperty(uploadFieldConfigNode, content, "widthFieldAlias", supportsResizing ? dimensions.Item1.ToString(CultureInfo.InvariantCulture) : string.Empty); - // UpdateProperty(uploadFieldConfigNode, content, "heightFieldAlias", supportsResizing ? dimensions.Item2.ToString(CultureInfo.InvariantCulture) : string.Empty); + // only add dimensions to web images + UpdateProperty(uploadFieldConfigNode, content, "widthFieldAlias", isImageType ? dimensions.Item1.ToString(CultureInfo.InvariantCulture) : string.Empty); + UpdateProperty(uploadFieldConfigNode, content, "heightFieldAlias", isImageType ? dimensions.Item2.ToString(CultureInfo.InvariantCulture) : string.Empty); - // UpdateProperty(uploadFieldConfigNode, content, "lengthFieldAlias", size == default(long) ? string.Empty : size.ToString(CultureInfo.InvariantCulture)); - // UpdateProperty(uploadFieldConfigNode, content, "extensionFieldAlias", string.IsNullOrEmpty(extension) ? string.Empty : extension); - // } - // } - // } + UpdateProperty(uploadFieldConfigNode, content, "lengthFieldAlias", size == default(long) ? string.Empty : size.ToString(CultureInfo.InvariantCulture)); + UpdateProperty(uploadFieldConfigNode, content, "extensionFieldAlias", string.IsNullOrEmpty(extension) ? string.Empty : extension); + } + } + } - // private void UpdateProperty(XmlNode uploadFieldConfigNode, IContentBase content, string propertyAlias, object propertyValue) - // { - // XmlNode propertyNode = uploadFieldConfigNode.SelectSingleNode(propertyAlias); - // if (propertyNode != null && !String.IsNullOrEmpty(propertyNode.FirstChild.Value)) - // { - // if (content.Properties.Contains(propertyNode.FirstChild.Value) && content.Properties[propertyNode.FirstChild.Value] != null) - // { - // content.SetValue(propertyNode.FirstChild.Value, propertyValue); - // } - // } - // } + private void UpdateProperty(XmlNode uploadFieldConfigNode, IContentBase content, string propertyAlias, object propertyValue) + { + XmlNode propertyNode = uploadFieldConfigNode.SelectSingleNode(propertyAlias); + if (propertyNode != null && !String.IsNullOrEmpty(propertyNode.FirstChild.Value)) + { + if (content.Properties.Contains(propertyNode.FirstChild.Value) && content.Properties[propertyNode.FirstChild.Value] != null) + { + content.SetValue(propertyNode.FirstChild.Value, propertyValue); + } + } + } - // private Tuple GetDimensions(string path, IFileSystem fs) - // { - - // int fileWidth; - // int fileHeight; - // using (var stream = fs.OpenFile(path)) - // { - // using (var image = Image.FromStream(stream)) - // { - // fileWidth = image.Width; - // fileHeight = image.Height; - // } - // } + private Tuple GetDimensions(string path, IFileSystem fs) + { - // return new Tuple(fileWidth, fileHeight); - // } - //} + int fileWidth; + int fileHeight; + using (var stream = fs.OpenFile(path)) + { + using (var image = Image.FromStream(stream)) + { + fileWidth = image.Width; + fileHeight = image.Height; + } + } + + return new Tuple(fileWidth, fileHeight); + } + } } \ No newline at end of file From 7e060d665b1e751768ba76a1b775ed4c3fa74735 Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Tue, 8 Jan 2013 07:38:54 -0100 Subject: [PATCH 008/188] Renamed a few properties on the PropertyType object, as the original naming was confusing. --- src/Umbraco.Core/Models/ContentExtensions.cs | 4 +-- src/Umbraco.Core/Models/PropertyType.cs | 32 ++++++++--------- .../Models/PropertyTypeExtensions.cs | 4 +-- .../Factories/PropertyGroupFactory.cs | 4 +-- .../Persistence/Mappers/PropertyTypeMapper.cs | 4 +-- .../Repositories/ContentRepository.cs | 2 +- .../Repositories/ContentTypeBaseRepository.cs | 2 +- .../Repositories/MediaRepository.cs | 2 +- src/Umbraco.Core/Services/ContentService.cs | 4 +-- src/Umbraco.Core/Services/DataTypeService.cs | 4 +-- src/Umbraco.Tests/Models/ContentTests.cs | 18 +++++----- .../Repositories/ContentTypeRepositoryTest.cs | 2 +- .../Repositories/MediaTypeRepositoryTest.cs | 2 +- .../Entities/MockedContentTypes.cs | 34 +++++++++---------- 14 files changed, 59 insertions(+), 59 deletions(-) diff --git a/src/Umbraco.Core/Models/ContentExtensions.cs b/src/Umbraco.Core/Models/ContentExtensions.cs index 240724b507..d14c023ae6 100644 --- a/src/Umbraco.Core/Models/ContentExtensions.cs +++ b/src/Umbraco.Core/Models/ContentExtensions.cs @@ -174,10 +174,10 @@ namespace Umbraco.Core.Models //Look up Prevalues for this upload datatype - if it is an upload datatype var uploadFieldId = new Guid("5032a6e6-69e3-491d-bb28-cd31cd11086c"); - if (property.PropertyType.DataTypeControlId == uploadFieldId) + if (property.PropertyType.DataTypeId == uploadFieldId) { //Get Prevalues by the DataType's Id: property.PropertyType.DataTypeId - var values = ApplicationContext.Current.Services.DataTypeService.GetPreValuesByDataTypeId(property.PropertyType.DataTypeId); + var values = ApplicationContext.Current.Services.DataTypeService.GetPreValuesByDataTypeId(property.PropertyType.DataTypeDefinitionId); var thumbnailSizes = values.FirstOrDefault(); //Additional thumbnails configured as prevalues on the DataType if (thumbnailSizes != null) diff --git a/src/Umbraco.Core/Models/PropertyType.cs b/src/Umbraco.Core/Models/PropertyType.cs index 3e3fdcc72e..dc65afa913 100644 --- a/src/Umbraco.Core/Models/PropertyType.cs +++ b/src/Umbraco.Core/Models/PropertyType.cs @@ -17,8 +17,8 @@ namespace Umbraco.Core.Models private string _name; private string _alias; private string _description; - private int _dataTypeId; - private Guid _dataTypeControlId; + private int _dataTypeDefinitionId; + private Guid _dataTypeId; private DataTypeDatabaseType _dataTypeDatabaseType; private bool _mandatory; private string _helpText; @@ -28,9 +28,9 @@ namespace Umbraco.Core.Models public PropertyType(IDataTypeDefinition dataTypeDefinition) { if(dataTypeDefinition.HasIdentity) - DataTypeId = dataTypeDefinition.Id; + DataTypeDefinitionId = dataTypeDefinition.Id; - DataTypeControlId = dataTypeDefinition.ControlId; + DataTypeId = dataTypeDefinition.ControlId; DataTypeDatabaseType = dataTypeDefinition.DatabaseType; EnsureSerializationService(); @@ -38,7 +38,7 @@ namespace Umbraco.Core.Models internal PropertyType(Guid dataTypeControlId, DataTypeDatabaseType dataTypeDatabaseType) { - DataTypeControlId = dataTypeControlId; + DataTypeId = dataTypeControlId; DataTypeDatabaseType = dataTypeDatabaseType; EnsureSerializationService(); @@ -53,8 +53,8 @@ namespace Umbraco.Core.Models private static readonly PropertyInfo NameSelector = ExpressionHelper.GetPropertyInfo(x => x.Name); private static readonly PropertyInfo AliasSelector = ExpressionHelper.GetPropertyInfo(x => x.Alias); private static readonly PropertyInfo DescriptionSelector = ExpressionHelper.GetPropertyInfo(x => x.Description); - private static readonly PropertyInfo DataTypeIdSelector = ExpressionHelper.GetPropertyInfo(x => x.DataTypeId); - private static readonly PropertyInfo DataTypeControlIdSelector = ExpressionHelper.GetPropertyInfo(x => x.DataTypeControlId); + private static readonly PropertyInfo DataTypeDefinitionIdSelector = ExpressionHelper.GetPropertyInfo(x => x.DataTypeDefinitionId); + private static readonly PropertyInfo DataTypeControlIdSelector = ExpressionHelper.GetPropertyInfo(x => x.DataTypeId); private static readonly PropertyInfo DataTypeDatabaseTypeSelector = ExpressionHelper.GetPropertyInfo(x => x.DataTypeDatabaseType); private static readonly PropertyInfo MandatorySelector = ExpressionHelper.GetPropertyInfo(x => x.Mandatory); private static readonly PropertyInfo HelpTextSelector = ExpressionHelper.GetPropertyInfo(x => x.HelpText); @@ -108,13 +108,13 @@ namespace Umbraco.Core.Models /// /// This is actually the Id of the [DataMember] - public int DataTypeId + public int DataTypeDefinitionId { - get { return _dataTypeId; } + get { return _dataTypeDefinitionId; } set { - _dataTypeId = value; - OnPropertyChanged(DataTypeIdSelector); + _dataTypeDefinitionId = value; + OnPropertyChanged(DataTypeDefinitionIdSelector); } } @@ -123,12 +123,12 @@ namespace Umbraco.Core.Models /// /// This is the Id of the actual DataType control [DataMember] - internal Guid DataTypeControlId + public Guid DataTypeId { - get { return _dataTypeControlId; } - set + get { return _dataTypeId; } + internal set { - _dataTypeControlId = value; + _dataTypeId = value; OnPropertyChanged(DataTypeControlIdSelector); } } @@ -280,7 +280,7 @@ namespace Umbraco.Core.Models return argument == type; }*/ - if (DataTypeControlId != Guid.Empty) + if (DataTypeId != Guid.Empty) { //Find DataType by Id //IDataType dataType = DataTypesResolver.Current.GetById(DataTypeControlId); diff --git a/src/Umbraco.Core/Models/PropertyTypeExtensions.cs b/src/Umbraco.Core/Models/PropertyTypeExtensions.cs index 9347760b41..8a4d35c3af 100644 --- a/src/Umbraco.Core/Models/PropertyTypeExtensions.cs +++ b/src/Umbraco.Core/Models/PropertyTypeExtensions.cs @@ -19,8 +19,8 @@ namespace Umbraco.Core.Models internal static IDataType DataType(this PropertyType propertyType, int propertyId) { Mandate.ParameterNotNull(propertyType, "propertyType"); - var dataType = ApplicationContext.Current.Services.DataTypeService.GetDataTypeById(propertyType.DataTypeControlId); - dataType.DataTypeDefinitionId = propertyType.DataTypeId; + var dataType = ApplicationContext.Current.Services.DataTypeService.GetDataTypeById(propertyType.DataTypeId); + dataType.DataTypeDefinitionId = propertyType.DataTypeDefinitionId; dataType.Data.PropertyId = propertyId; return dataType; } diff --git a/src/Umbraco.Core/Persistence/Factories/PropertyGroupFactory.cs b/src/Umbraco.Core/Persistence/Factories/PropertyGroupFactory.cs index 712721af4f..5653f0f86b 100644 --- a/src/Umbraco.Core/Persistence/Factories/PropertyGroupFactory.cs +++ b/src/Umbraco.Core/Persistence/Factories/PropertyGroupFactory.cs @@ -34,7 +34,7 @@ namespace Umbraco.Core.Persistence.Factories typeDto.DataTypeDto.DbType.EnumParse(true)) { Alias = typeDto.Alias, - DataTypeId = typeDto.DataTypeId, + DataTypeDefinitionId = typeDto.DataTypeId, Description = typeDto.Description, Id = typeDto.Id, Name = typeDto.Name, @@ -82,7 +82,7 @@ namespace Umbraco.Core.Persistence.Factories { Alias = propertyType.Alias, ContentTypeId = _id, - DataTypeId = propertyType.DataTypeId, + DataTypeId = propertyType.DataTypeDefinitionId, Description = propertyType.Description, HelpText = propertyType.HelpText, Mandatory = propertyType.Mandatory, diff --git a/src/Umbraco.Core/Persistence/Mappers/PropertyTypeMapper.cs b/src/Umbraco.Core/Persistence/Mappers/PropertyTypeMapper.cs index df3967ad85..1df4c94ee1 100644 --- a/src/Umbraco.Core/Persistence/Mappers/PropertyTypeMapper.cs +++ b/src/Umbraco.Core/Persistence/Mappers/PropertyTypeMapper.cs @@ -29,14 +29,14 @@ namespace Umbraco.Core.Persistence.Mappers { CacheMap(src => src.Id, dto => dto.Id); CacheMap(src => src.Alias, dto => dto.Alias); - CacheMap(src => src.DataTypeId, dto => dto.DataTypeId); + CacheMap(src => src.DataTypeDefinitionId, dto => dto.DataTypeId); CacheMap(src => src.Description, dto => dto.Description); CacheMap(src => src.HelpText, dto => dto.HelpText); CacheMap(src => src.Mandatory, dto => dto.Mandatory); CacheMap(src => src.Name, dto => dto.Name); CacheMap(src => src.SortOrder, dto => dto.SortOrder); CacheMap(src => src.ValidationRegExp, dto => dto.ValidationRegExp); - CacheMap(src => src.DataTypeControlId, dto => dto.ControlId); + CacheMap(src => src.DataTypeId, dto => dto.ControlId); CacheMap(src => src.DataTypeDatabaseType, dto => dto.DbType); } } diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs index c560a68c02..8bc0b6d79f 100644 --- a/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs @@ -379,7 +379,7 @@ namespace Umbraco.Core.Persistence.Repositories //Loop through properties to check if the content contains images/files that should be deleted foreach (var property in entity.Properties) { - if (property.PropertyType.DataTypeControlId == uploadFieldId && + if (property.PropertyType.DataTypeId == uploadFieldId && string.IsNullOrEmpty(property.Value.ToString()) == false && fs.FileExists(IOHelper.MapPath(property.Value.ToString()))) { diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs index 99acdf91d3..1292db1ae1 100644 --- a/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs @@ -130,7 +130,7 @@ namespace Umbraco.Core.Persistence.Repositories //Update the current PropertyType with correct ControlId and DatabaseType var dataTypeDto = Database.FirstOrDefault("WHERE nodeId = @Id", new { Id = propertyTypeDto.DataTypeId }); - propertyType.DataTypeControlId = dataTypeDto.ControlId; + propertyType.DataTypeId = dataTypeDto.ControlId; propertyType.DataTypeDatabaseType = dataTypeDto.DbType.EnumParse(true); } } diff --git a/src/Umbraco.Core/Persistence/Repositories/MediaRepository.cs b/src/Umbraco.Core/Persistence/Repositories/MediaRepository.cs index 56f19595a8..c292218bc2 100644 --- a/src/Umbraco.Core/Persistence/Repositories/MediaRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/MediaRepository.cs @@ -307,7 +307,7 @@ namespace Umbraco.Core.Persistence.Repositories //Loop through properties to check if the media item contains images/file that should be deleted foreach (var property in entity.Properties) { - if (property.PropertyType.DataTypeControlId == uploadFieldId && + if (property.PropertyType.DataTypeId == uploadFieldId && string.IsNullOrEmpty(property.Value.ToString()) == false && fs.FileExists(IOHelper.MapPath(property.Value.ToString()))) { diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs index 958e56d40b..bfcb0ec2fe 100644 --- a/src/Umbraco.Core/Services/ContentService.cs +++ b/src/Umbraco.Core/Services/ContentService.cs @@ -996,13 +996,13 @@ namespace Umbraco.Core.Services uow.Commit(); var uploadFieldId = new Guid("5032a6e6-69e3-491d-bb28-cd31cd11086c"); - if (content.Properties.Any(x => x.PropertyType.DataTypeControlId == uploadFieldId)) + if (content.Properties.Any(x => x.PropertyType.DataTypeId == uploadFieldId)) { bool isUpdated = false; var fs = FileSystemProviderManager.Current.GetFileSystemProvider(); //Loop through properties to check if the content contains media that should be deleted - foreach (var property in content.Properties.Where(x => x.PropertyType.DataTypeControlId == uploadFieldId + foreach (var property in content.Properties.Where(x => x.PropertyType.DataTypeId == uploadFieldId && string.IsNullOrEmpty(x.Value.ToString()) == false)) { if (fs.FileExists(IOHelper.MapPath(property.Value.ToString()))) diff --git a/src/Umbraco.Core/Services/DataTypeService.cs b/src/Umbraco.Core/Services/DataTypeService.cs index 57ad05f15f..49ad5953a4 100644 --- a/src/Umbraco.Core/Services/DataTypeService.cs +++ b/src/Umbraco.Core/Services/DataTypeService.cs @@ -153,7 +153,7 @@ namespace Umbraco.Core.Services using (var repository = _repositoryFactory.CreateContentTypeRepository(uow)) { //Find ContentTypes using this IDataTypeDefinition on a PropertyType - var query = Query.Builder.Where(x => x.DataTypeId == dataTypeDefinition.Id); + var query = Query.Builder.Where(x => x.DataTypeDefinitionId == dataTypeDefinition.Id); var contentTypes = repository.GetByQuery(query); //Loop through the list of results and remove the PropertyTypes that references the DataTypeDefinition that is being deleted @@ -163,7 +163,7 @@ namespace Umbraco.Core.Services foreach (var group in contentType.PropertyGroups) { - var types = @group.PropertyTypes.Where(x => x.DataTypeId == dataTypeDefinition.Id); + var types = @group.PropertyTypes.Where(x => x.DataTypeDefinitionId == dataTypeDefinition.Id); foreach (var propertyType in types) { @group.PropertyTypes.Remove(propertyType); diff --git a/src/Umbraco.Tests/Models/ContentTests.cs b/src/Umbraco.Tests/Models/ContentTests.cs index 9c58a27d8b..c0edec6979 100644 --- a/src/Umbraco.Tests/Models/ContentTests.cs +++ b/src/Umbraco.Tests/Models/ContentTests.cs @@ -159,7 +159,7 @@ namespace Umbraco.Tests.Models HelpText = "", Mandatory = false, SortOrder = 3, - DataTypeId = -88 + DataTypeDefinitionId = -88 }); // Assert @@ -177,7 +177,7 @@ namespace Umbraco.Tests.Models // Act var propertyType = new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { - Alias = "subtitle", Name = "Subtitle", Description = "Optional subtitle", HelpText = "", Mandatory = false, SortOrder = 3, DataTypeId = -88 + Alias = "subtitle", Name = "Subtitle", Description = "Optional subtitle", HelpText = "", Mandatory = false, SortOrder = 3, DataTypeDefinitionId = -88 }; contentType.PropertyGroups["Content"].PropertyTypes.Add(propertyType); content.Properties.Add(new Property(propertyType){Value = "This is a subtitle Test"}); @@ -203,7 +203,7 @@ namespace Umbraco.Tests.Models HelpText = "", Mandatory = false, SortOrder = 3, - DataTypeId = -88 + DataTypeDefinitionId = -88 }; var propertyGroup = new PropertyGroup {Name = "Test Group", SortOrder = 3}; propertyGroup.PropertyTypes.Add(propertyType); @@ -228,7 +228,7 @@ namespace Umbraco.Tests.Models // Act - note that the PropertyType's properties like SortOrder is not updated through the Content object var propertyType = new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { - Alias = "title", Name = "Title", Description = "Title description added", HelpText = "", Mandatory = false, SortOrder = 10, DataTypeId = -88 + Alias = "title", Name = "Title", Description = "Title description added", HelpText = "", Mandatory = false, SortOrder = 10, DataTypeDefinitionId = -88 }; content.Properties.Add(new Property(propertyType)); @@ -377,7 +377,7 @@ namespace Umbraco.Tests.Models HelpText = "", Mandatory = false, SortOrder = 3, - DataTypeId = -88 + DataTypeDefinitionId = -88 }; contentType.PropertyGroups["Content"].PropertyTypes.Add(propertyType); @@ -404,7 +404,7 @@ namespace Umbraco.Tests.Models HelpText = "", Mandatory = false, SortOrder = 4, - DataTypeId = -88 + DataTypeDefinitionId = -88 } })); @@ -437,7 +437,7 @@ namespace Umbraco.Tests.Models HelpText = "", Mandatory = false, SortOrder = 4, - DataTypeId = -88 + DataTypeDefinitionId = -88 } })); @@ -472,7 +472,7 @@ namespace Umbraco.Tests.Models HelpText = "", Mandatory = false, SortOrder = 4, - DataTypeId = -88 + DataTypeDefinitionId = -88 } })); var mixin2 = MockedContentTypes.CreateSimpleContentType("mixin2", "Mixin2", new PropertyTypeCollection( @@ -486,7 +486,7 @@ namespace Umbraco.Tests.Models HelpText = "", Mandatory = false, SortOrder = 4, - DataTypeId = -88 + DataTypeDefinitionId = -88 } })); diff --git a/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs index 0ec1fd5dd0..8e1ca74866 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs @@ -85,7 +85,7 @@ namespace Umbraco.Tests.Persistence.Repositories HelpText = "", Mandatory = false, SortOrder = 1, - DataTypeId = -88 + DataTypeDefinitionId = -88 }); repository.AddOrUpdate(contentType); unitOfWork.Commit(); diff --git a/src/Umbraco.Tests/Persistence/Repositories/MediaTypeRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/MediaTypeRepositoryTest.cs index a39dba0986..b7315de594 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/MediaTypeRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/MediaTypeRepositoryTest.cs @@ -77,7 +77,7 @@ namespace Umbraco.Tests.Persistence.Repositories HelpText = "", Mandatory = false, SortOrder = 1, - DataTypeId = -88 + DataTypeDefinitionId = -88 }); repository.AddOrUpdate(mediaType); unitOfWork.Commit(); diff --git a/src/Umbraco.Tests/TestHelpers/Entities/MockedContentTypes.cs b/src/Umbraco.Tests/TestHelpers/Entities/MockedContentTypes.cs index 6b1544b88b..b3a7f257c9 100644 --- a/src/Umbraco.Tests/TestHelpers/Entities/MockedContentTypes.cs +++ b/src/Umbraco.Tests/TestHelpers/Entities/MockedContentTypes.cs @@ -21,12 +21,12 @@ namespace Umbraco.Tests.TestHelpers.Entities }; var contentCollection = new PropertyTypeCollection(); - contentCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "title", Name = "Title", Description = "", HelpText = "", Mandatory = false, SortOrder = 1, DataTypeId = -88 }); - contentCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "bodyText", Name = "Body Text", Description = "", HelpText = "", Mandatory = false, SortOrder = 2, DataTypeId = -87 }); + contentCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "title", Name = "Title", Description = "", HelpText = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }); + contentCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "bodyText", Name = "Body Text", Description = "", HelpText = "", Mandatory = false, SortOrder = 2, DataTypeDefinitionId = -87 }); var metaCollection = new PropertyTypeCollection(); - metaCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "keywords", Name = "Meta Keywords", Description = "", HelpText = "", Mandatory = false, SortOrder = 1, DataTypeId = -88 }); - metaCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "metaDescription", Name = "Meta Description", Description = "", HelpText = "", Mandatory = false, SortOrder = 2, DataTypeId = -89 }); + metaCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "keywords", Name = "Meta Keywords", Description = "", HelpText = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }); + metaCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "metaDescription", Name = "Meta Description", Description = "", HelpText = "", Mandatory = false, SortOrder = 2, DataTypeDefinitionId = -89 }); contentType.PropertyGroups.Add(new PropertyGroup(contentCollection) { Name = "Content", SortOrder = 1 }); contentType.PropertyGroups.Add(new PropertyGroup(metaCollection) { Name = "Meta", SortOrder = 2 }); @@ -49,8 +49,8 @@ namespace Umbraco.Tests.TestHelpers.Entities }; var metaCollection = new PropertyTypeCollection(); - metaCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "metakeywords", Name = "Meta Keywords", Description = "", HelpText = "", Mandatory = false, SortOrder = 1, DataTypeId = -88 }); - metaCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "metadescription", Name = "Meta Description", Description = "", HelpText = "", Mandatory = false, SortOrder = 2, DataTypeId = -89 }); + metaCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "metakeywords", Name = "Meta Keywords", Description = "", HelpText = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }); + metaCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "metadescription", Name = "Meta Description", Description = "", HelpText = "", Mandatory = false, SortOrder = 2, DataTypeDefinitionId = -89 }); contentType.PropertyGroups.Add(new PropertyGroup(metaCollection) { Name = "Meta", SortOrder = 2 }); @@ -72,9 +72,9 @@ namespace Umbraco.Tests.TestHelpers.Entities }; var contentCollection = new PropertyTypeCollection(); - contentCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "title", Name = "Title", Description = "", HelpText = "", Mandatory = false, SortOrder = 1, DataTypeId = -88 }); - contentCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "bodyText", Name = "Body Text", Description = "", HelpText = "", Mandatory = false, SortOrder = 2, DataTypeId = -87 }); - contentCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "author", Name = "Author", Description = "Name of the author", HelpText = "", Mandatory = false, SortOrder = 3, DataTypeId = -88 }); + contentCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "title", Name = "Title", Description = "", HelpText = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }); + contentCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "bodyText", Name = "Body Text", Description = "", HelpText = "", Mandatory = false, SortOrder = 2, DataTypeDefinitionId = -87 }); + contentCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "author", Name = "Author", Description = "Name of the author", HelpText = "", Mandatory = false, SortOrder = 3, DataTypeDefinitionId = -88 }); contentType.PropertyGroups.Add(new PropertyGroup(contentCollection) { Name = "Content", SortOrder = 1 }); @@ -95,9 +95,9 @@ namespace Umbraco.Tests.TestHelpers.Entities contentType.Trashed = false; var contentCollection = new PropertyTypeCollection(); - contentCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "title", Name = "Title", Description = "", HelpText = "", Mandatory = false, SortOrder = 1, DataTypeId = -88 }); - contentCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "bodyText", Name = "Body Text", Description = "", HelpText = "", Mandatory = false, SortOrder = 2, DataTypeId = -87 }); - contentCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "author", Name = "Author", Description = "Name of the author", HelpText = "", Mandatory = false, SortOrder = 3, DataTypeId = -88 }); + contentCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "title", Name = "Title", Description = "", HelpText = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }); + contentCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "bodyText", Name = "Body Text", Description = "", HelpText = "", Mandatory = false, SortOrder = 2, DataTypeDefinitionId = -87 }); + contentCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "author", Name = "Author", Description = "Name of the author", HelpText = "", Mandatory = false, SortOrder = 3, DataTypeDefinitionId = -88 }); contentType.PropertyGroups.Add(new PropertyGroup(contentCollection) { Name = "Content", SortOrder = 1 }); @@ -119,9 +119,9 @@ namespace Umbraco.Tests.TestHelpers.Entities }; var contentCollection = new PropertyTypeCollection(); - contentCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "title", Name = "Title", Description = "", HelpText = "", Mandatory = mandatory, SortOrder = 1, DataTypeId = -88 }); - contentCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "bodyText", Name = "Body Text", Description = "", HelpText = "", Mandatory = mandatory, SortOrder = 2, DataTypeId = -87 }); - contentCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "author", Name = "Author", Description = "Name of the author", HelpText = "", Mandatory = mandatory, SortOrder = 3, DataTypeId = -88 }); + contentCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "title", Name = "Title", Description = "", HelpText = "", Mandatory = mandatory, SortOrder = 1, DataTypeDefinitionId = -88 }); + contentCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "bodyText", Name = "Body Text", Description = "", HelpText = "", Mandatory = mandatory, SortOrder = 2, DataTypeDefinitionId = -87 }); + contentCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "author", Name = "Author", Description = "Name of the author", HelpText = "", Mandatory = mandatory, SortOrder = 3, DataTypeDefinitionId = -88 }); contentType.PropertyGroups.Add(new PropertyGroup(contentCollection) { Name = "Content", SortOrder = 1 }); @@ -162,8 +162,8 @@ namespace Umbraco.Tests.TestHelpers.Entities }; var contentCollection = new PropertyTypeCollection(); - contentCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "title", Name = "Title", Description = "", HelpText = "", Mandatory = false, SortOrder = 1, DataTypeId = -88 }); - contentCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Nvarchar) { Alias = "videoFile", Name = "Video File", Description = "", HelpText = "", Mandatory = false, SortOrder = 2, DataTypeId = -90 }); + contentCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "title", Name = "Title", Description = "", HelpText = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }); + contentCollection.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Nvarchar) { Alias = "videoFile", Name = "Video File", Description = "", HelpText = "", Mandatory = false, SortOrder = 2, DataTypeDefinitionId = -90 }); mediaType.PropertyGroups.Add(new PropertyGroup(contentCollection) { Name = "Media", SortOrder = 1 }); From c6feb2a27a6feeea11d085887e5478ee734b2d90 Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Tue, 8 Jan 2013 09:49:13 -0100 Subject: [PATCH 009/188] Correcting an issue in the ContentTypeBaseRepository where removing a PropertyType would cause an error if a Property was referencing that PropertyType. Correcting an issue in the ContentRepository that would occur if a new PropertyType had been added after Content is being used. Fixes U4-1402 --- .../Repositories/ContentRepository.cs | 2 + .../Repositories/ContentTypeBaseRepository.cs | 14 +- .../Repositories/ContentTypeRepositoryTest.cs | 122 ++++++++++++++++++ .../businesslogic/web/DocumentType.cs | 3 +- 4 files changed, 137 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs index 8bc0b6d79f..87faaf70df 100644 --- a/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs @@ -365,6 +365,8 @@ namespace Umbraco.Core.Persistence.Repositories { foreach (var property in entity.Properties) { + if(keyDictionary.ContainsKey(property.PropertyTypeId) == false) continue; + property.Id = keyDictionary[property.PropertyTypeId]; } } diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs index 1292db1ae1..68f9a4ad3b 100644 --- a/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs @@ -168,11 +168,19 @@ namespace Umbraco.Core.Persistence.Repositories if (((ICanBeDirty)entity).IsPropertyDirty("PropertyGroups") || entity.PropertyGroups.Any(x => x.IsDirty())) { //Delete PropertyTypes by excepting entries from db with entries from collections - var dbPropertyTypes = Database.Fetch("WHERE contentTypeId = @Id", new { Id = entity.Id }).Select(x => x.Alias); - var entityPropertyTypes = entity.PropertyTypes.Select(x => x.Alias); - var aliases = dbPropertyTypes.Except(entityPropertyTypes); + var dbPropertyTypes = Database.Fetch("WHERE contentTypeId = @Id", new { Id = entity.Id }); + var dbPropertyTypeAlias = dbPropertyTypes.Select(x => x.Alias.ToLowerInvariant()); + var entityPropertyTypes = entity.PropertyTypes.Select(x => x.Alias.ToLowerInvariant()); + var aliases = dbPropertyTypeAlias.Except(entityPropertyTypes); foreach (var alias in aliases) { + //Before a PropertyType can be deleted, all Properties based on that PropertyType should be deleted. + var propertyType = dbPropertyTypes.FirstOrDefault(x => x.Alias.ToLowerInvariant() == alias); + if (propertyType != null) + { + Database.Delete("WHERE propertytypeid = @Id", new { Id = propertyType.Id }); + } + Database.Delete("WHERE contentTypeId = @Id AND Alias = @Alias", new { Id = entity.Id, Alias = alias }); } //Delete Tabs/Groups by excepting entries from db with entries from collections diff --git a/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs index 8e1ca74866..28487509b4 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs @@ -270,6 +270,128 @@ namespace Umbraco.Tests.Persistence.Repositories Assert.That(updated.AllowedContentTypes.Any(x => x.Alias == simpleSubpageContentType.Alias), Is.True); } + [Test] + public void Can_Verify_Removal_Of_Used_PropertyType_From_ContentType() + { + // Arrange + var provider = new PetaPocoUnitOfWorkProvider(); + var unitOfWork = provider.GetUnitOfWork(); + var repository = RepositoryResolver.Current.ResolveByType(unitOfWork); + var contentRepository = RepositoryResolver.Current.ResolveByType(unitOfWork); + var contentType = repository.Get(1046); + + var subpage = MockedContent.CreateTextpageContent(contentType, "Text Page 1", contentType.Id); + contentRepository.AddOrUpdate(subpage); + unitOfWork.Commit(); + + // Act + contentType.RemovePropertyType("keywords"); + repository.AddOrUpdate(contentType); + unitOfWork.Commit(); + + // Assert + Assert.That(contentType.PropertyTypes.Count(), Is.EqualTo(3)); + Assert.That(contentType.PropertyTypes.Any(x => x.Alias == "keywords"), Is.False); + Assert.That(subpage.Properties.First(x => x.Alias == "metaDescription").Value, Is.EqualTo("This is the meta description for a textpage")); + } + + [Test] + public void Can_Verify_Addition_Of_PropertyType_After_ContentType_Is_Used() + { + // Arrange + var provider = new PetaPocoUnitOfWorkProvider(); + var unitOfWork = provider.GetUnitOfWork(); + var repository = RepositoryResolver.Current.ResolveByType(unitOfWork); + var contentRepository = RepositoryResolver.Current.ResolveByType(unitOfWork); + var contentType = repository.Get(1046); + + var subpage = MockedContent.CreateTextpageContent(contentType, "Text Page 1", contentType.Id); + contentRepository.AddOrUpdate(subpage); + unitOfWork.Commit(); + + // Act + var propertyGroup = contentType.PropertyGroups.First(x => x.Name == "Meta"); + propertyGroup.PropertyTypes.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "metaAuthor", Name = "Meta Author", Description = "", HelpText = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }); + repository.AddOrUpdate(contentType); + unitOfWork.Commit(); + + // Assert + Assert.That(contentType.PropertyTypes.Count(), Is.EqualTo(5)); + Assert.That(contentType.PropertyTypes.Any(x => x.Alias == "metaAuthor"), Is.True); + } + + [Test] + public void Can_Verify_Usage_Of_New_PropertyType_On_Content() + { + // Arrange + var provider = new PetaPocoUnitOfWorkProvider(); + var unitOfWork = provider.GetUnitOfWork(); + var repository = RepositoryResolver.Current.ResolveByType(unitOfWork); + var contentRepository = RepositoryResolver.Current.ResolveByType(unitOfWork); + var contentType = repository.Get(1046); + + var subpage = MockedContent.CreateTextpageContent(contentType, "Text Page 1", contentType.Id); + contentRepository.AddOrUpdate(subpage); + unitOfWork.Commit(); + + var propertyGroup = contentType.PropertyGroups.First(x => x.Name == "Meta"); + propertyGroup.PropertyTypes.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "metaAuthor", Name = "Meta Author", Description = "", HelpText = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }); + repository.AddOrUpdate(contentType); + unitOfWork.Commit(); + + // Act + var content = contentRepository.Get(subpage.Id); + content.SetValue("metaAuthor", "John Doe"); + contentRepository.AddOrUpdate(content); + unitOfWork.Commit(); + + //Assert + var updated = contentRepository.Get(subpage.Id); + Assert.That(updated.GetValue("metaAuthor").ToString(), Is.EqualTo("John Doe")); + Assert.That(contentType.PropertyTypes.Count(), Is.EqualTo(5)); + Assert.That(contentType.PropertyTypes.Any(x => x.Alias == "metaAuthor"), Is.True); + } + + [Test] + public void + Can_Verify_That_A_Combination_Of_Adding_And_Deleting_PropertyTypes_Doesnt_Cause_Issues_For_Content_And_ContentType + () + { + // Arrange + var provider = new PetaPocoUnitOfWorkProvider(); + var unitOfWork = provider.GetUnitOfWork(); + var repository = RepositoryResolver.Current.ResolveByType(unitOfWork); + var contentRepository = RepositoryResolver.Current.ResolveByType(unitOfWork); + var contentType = repository.Get(1046); + + var subpage = MockedContent.CreateTextpageContent(contentType, "Text Page 1", contentType.Id); + contentRepository.AddOrUpdate(subpage); + unitOfWork.Commit(); + + //Remove PropertyType + contentType.RemovePropertyType("keywords"); + //Add PropertyType + var propertyGroup = contentType.PropertyGroups.First(x => x.Name == "Meta"); + propertyGroup.PropertyTypes.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext) { Alias = "metaAuthor", Name = "Meta Author", Description = "", HelpText = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }); + repository.AddOrUpdate(contentType); + unitOfWork.Commit(); + + // Act + var content = contentRepository.Get(subpage.Id); + content.SetValue("metaAuthor", "John Doe"); + contentRepository.AddOrUpdate(content); + unitOfWork.Commit(); + + //Assert + var updated = contentRepository.Get(subpage.Id); + Assert.That(updated.GetValue("metaAuthor").ToString(), Is.EqualTo("John Doe")); + Assert.That(updated.Properties.First(x => x.Alias == "metaDescription").Value, Is.EqualTo("This is the meta description for a textpage")); + + Assert.That(contentType.PropertyTypes.Count(), Is.EqualTo(4)); + Assert.That(contentType.PropertyTypes.Any(x => x.Alias == "metaAuthor"), Is.True); + Assert.That(contentType.PropertyTypes.Any(x => x.Alias == "keywords"), Is.False); + } + public void CreateTestData() { //Create and Save ContentType "umbTextpage" -> 1045 diff --git a/src/umbraco.cms/businesslogic/web/DocumentType.cs b/src/umbraco.cms/businesslogic/web/DocumentType.cs index 02bd51b4ba..bb91b66323 100644 --- a/src/umbraco.cms/businesslogic/web/DocumentType.cs +++ b/src/umbraco.cms/businesslogic/web/DocumentType.cs @@ -457,7 +457,8 @@ namespace umbraco.cms.businesslogic.web ApplicationContext.Current.Services.ContentTypeService.Save(_contentType); - //Ensure that DocumentTypes are reloaded from db by clearing cache + //Ensure that DocumentTypes are reloaded from db by clearing cache. + //NOTE Would be nice if we could clear cache by type instead of emptying the entire cache. InMemoryCacheProvider.Current.Clear(); base.Save(); From 8935f5c678a6bb0eb356a12f688f253d3062694b Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Tue, 8 Jan 2013 10:40:38 -0100 Subject: [PATCH 010/188] Check if masterpage file exists before populating it (could've been deleted from disk) --- .../Repositories/TemplateRepository.cs | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/Umbraco.Core/Persistence/Repositories/TemplateRepository.cs b/src/Umbraco.Core/Persistence/Repositories/TemplateRepository.cs index 0433418435..1be95d47aa 100644 --- a/src/Umbraco.Core/Persistence/Repositories/TemplateRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/TemplateRepository.cs @@ -23,20 +23,20 @@ namespace Umbraco.Core.Persistence.Repositories private IFileSystem _masterpagesFileSystem; private IFileSystem _viewsFileSystem; - public TemplateRepository(IDatabaseUnitOfWork work) - : base(work) + public TemplateRepository(IDatabaseUnitOfWork work) + : base(work) { EnsureDepedencies(); } - public TemplateRepository(IDatabaseUnitOfWork work, IRepositoryCacheProvider cache) - : base(work, cache) + public TemplateRepository(IDatabaseUnitOfWork work, IRepositoryCacheProvider cache) + : base(work, cache) { EnsureDepedencies(); } - internal TemplateRepository(IDatabaseUnitOfWork work, IRepositoryCacheProvider cache, IFileSystem masterpageFileSystem, IFileSystem viewFileSystem) - : base(work, cache) + internal TemplateRepository(IDatabaseUnitOfWork work, IRepositoryCacheProvider cache, IFileSystem masterpageFileSystem, IFileSystem viewFileSystem) + : base(work, cache) { _masterpagesFileSystem = masterpageFileSystem; _viewsFileSystem = viewFileSystem; @@ -74,17 +74,20 @@ namespace Umbraco.Core.Persistence.Repositories template.MasterTemplateId = dto.Master.Value; } - if(_viewsFileSystem.FileExists(csViewName)) + if (_viewsFileSystem.FileExists(csViewName)) { PopulateViewTemplate(template, csViewName); } - else if(_viewsFileSystem.FileExists(vbViewName)) + else if (_viewsFileSystem.FileExists(vbViewName)) { PopulateViewTemplate(template, vbViewName); } else { - PopulateMasterpageTemplate(template, masterpageName); + if (_masterpagesFileSystem.FileExists(masterpageName)) + { + PopulateMasterpageTemplate(template, masterpageName); + } } return template; @@ -164,9 +167,9 @@ namespace Umbraco.Core.Persistence.Repositories protected override void PersistNewItem(ITemplate entity) { - using(var stream = new MemoryStream(Encoding.UTF8.GetBytes(entity.Content))) + using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(entity.Content))) { - if(entity.GetTypeOfRenderingEngine() == RenderingEngine.Mvc) + if (entity.GetTypeOfRenderingEngine() == RenderingEngine.Mvc) { _viewsFileSystem.AddFile(entity.Name, stream, true); } @@ -337,7 +340,7 @@ namespace Umbraco.Core.Persistence.Repositories public IEnumerable GetAll(params string[] aliases) { - if(aliases.Any()) + if (aliases.Any()) { foreach (var id in aliases) { @@ -352,7 +355,7 @@ namespace Umbraco.Core.Persistence.Repositories yield return Get(nodeDto.NodeId); } } - + } #endregion From a3be3d00600ddb639f85db5c1bc0862d0ac7b20a Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Tue, 8 Jan 2013 10:42:02 -0100 Subject: [PATCH 011/188] Temporary workaround for TypeFinder not finding migrations. Rename FourEight to FourNine because that's what it should be. --- .../Persistence/Migrations/MigrationRunner.cs | 17 ++++++++++++++++- .../RemoveUmbracoAppConstraints.cs | 2 +- src/Umbraco.Core/Umbraco.Core.csproj | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) rename src/Umbraco.Core/Persistence/Migrations/Upgrades/{TargetVersionFourEightZero => TargetVersionFourNineZero}/RemoveUmbracoAppConstraints.cs (96%) diff --git a/src/Umbraco.Core/Persistence/Migrations/MigrationRunner.cs b/src/Umbraco.Core/Persistence/Migrations/MigrationRunner.cs index 4a341e4521..d5e18445e1 100644 --- a/src/Umbraco.Core/Persistence/Migrations/MigrationRunner.cs +++ b/src/Umbraco.Core/Persistence/Migrations/MigrationRunner.cs @@ -44,7 +44,22 @@ namespace Umbraco.Core.Persistence.Migrations { LogHelper.Info("Initializing database migration"); - var foundMigrations = PluginManager.Current.FindMigrations(); + var foundMigrations = new List + { + new Upgrades.TargetVersionFourNineZero.RemoveUmbracoAppConstraints(), + new Upgrades.TargetVersionSixth.DeleteAppTables(), + new Upgrades.TargetVersionSixth.EnsureAppsTreesUpdated(), + new Upgrades.TargetVersionSixth.MoveMasterContentTypeData(), + new Upgrades.TargetVersionSixth.NewCmsContentType2ContentTypeTable(), + new Upgrades.TargetVersionSixth.RemoveMasterContentTypeColumn(), + new Upgrades.TargetVersionSixth.RenameCmsTabTable(), + new Upgrades.TargetVersionSixth.RenameTabIdColumn(), + new Upgrades.TargetVersionSixth.UpdateCmsContentTypeAllowedContentTypeTable(), + new Upgrades.TargetVersionSixth.UpdateCmsContentTypeTable(), + new Upgrades.TargetVersionSixth.UpdateCmsContentVersionTable(), + new Upgrades.TargetVersionSixth.UpdateCmsPropertyTypeGroupTable() + }; + var migrations = isUpgrade ? OrderedUpgradeMigrations(foundMigrations) : OrderedDowngradeMigrations(foundMigrations); diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionFourEightZero/RemoveUmbracoAppConstraints.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionFourNineZero/RemoveUmbracoAppConstraints.cs similarity index 96% rename from src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionFourEightZero/RemoveUmbracoAppConstraints.cs rename to src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionFourNineZero/RemoveUmbracoAppConstraints.cs index 22c656abe6..2d687e958b 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionFourEightZero/RemoveUmbracoAppConstraints.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionFourNineZero/RemoveUmbracoAppConstraints.cs @@ -1,7 +1,7 @@ using System.Data; using Umbraco.Core.Configuration; -namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionFourEightZero +namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionFourNineZero { [MigrationAttribute("4.8.0", 0, GlobalSettings.UmbracoMigrationName)] public class RemoveUmbracoAppConstraints : MigrationBase diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 6e3e0d2271..f763d66636 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -372,7 +372,7 @@ - + From 08c0da02264a92386b25aea6f3de50135a59ab63 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Tue, 8 Jan 2013 10:42:36 -0100 Subject: [PATCH 012/188] MasterContentType column should not be in DTO, it gives errors querying non-existing column in the database --- src/Umbraco.Core/Models/Rdbms/ContentTypeDto.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Umbraco.Core/Models/Rdbms/ContentTypeDto.cs b/src/Umbraco.Core/Models/Rdbms/ContentTypeDto.cs index 49c8db119e..8d163abf44 100644 --- a/src/Umbraco.Core/Models/Rdbms/ContentTypeDto.cs +++ b/src/Umbraco.Core/Models/Rdbms/ContentTypeDto.cs @@ -43,11 +43,6 @@ namespace Umbraco.Core.Models.Rdbms [Constraint(Default = "0")] public bool AllowAtRoot { get; set; } - [Column("masterContentType")] - [Constraint(Default = "0")] - [NullSetting(NullSetting = NullSettings.Null)] - public int MasterContentType { get; set; }//TODO Delete once "masterContentType" has been removed from the Core - [ResultColumn] public NodeDto NodeDto { get; set; } } From dd61432d9f2e81682f2935f0750c34237d364669 Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Tue, 8 Jan 2013 10:58:06 -0100 Subject: [PATCH 013/188] More work on U4-1402 in order to clear cache in all the right places. --- .../Persistence/Caching/RuntimeCacheProvider.cs | 14 +++++++++++++- .../businesslogic/propertytype/propertytype.cs | 9 +++++---- src/umbraco.cms/businesslogic/web/DocumentType.cs | 1 + 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Core/Persistence/Caching/RuntimeCacheProvider.cs b/src/Umbraco.Core/Persistence/Caching/RuntimeCacheProvider.cs index fa5d5e421e..bb2b80a766 100644 --- a/src/Umbraco.Core/Persistence/Caching/RuntimeCacheProvider.cs +++ b/src/Umbraco.Core/Persistence/Caching/RuntimeCacheProvider.cs @@ -2,6 +2,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Runtime.Caching; +using System.Threading; using Umbraco.Core.Models.EntityBase; namespace Umbraco.Core.Persistence.Caching @@ -23,9 +24,10 @@ namespace Umbraco.Core.Persistence.Caching #endregion - private readonly ObjectCache _memoryCache = new MemoryCache("in-memory"); //TODO Save this in cache as well, so its not limited to a single server usage private ConcurrentDictionary _keyTracker = new ConcurrentDictionary(); + private ObjectCache _memoryCache = new MemoryCache("in-memory"); + private static readonly ReaderWriterLockSlim ClearLock = new ReaderWriterLockSlim(); public IEntity GetById(Type type, Guid id) { @@ -77,6 +79,16 @@ namespace Umbraco.Core.Persistence.Caching _keyTracker.TryRemove(key, out throwaway); } + public void Clear() + { + using (new ReadLock(ClearLock)) + { + _keyTracker.Clear(); + _memoryCache.DisposeIfDisposable(); + _memoryCache = new MemoryCache("in-memory"); + } + } + private string GetCompositeId(Type type, Guid id) { return string.Format("{0}-{1}", type.Name, id.ToString()); diff --git a/src/umbraco.cms/businesslogic/propertytype/propertytype.cs b/src/umbraco.cms/businesslogic/propertytype/propertytype.cs index 2de760e13a..d72a1d3eb3 100644 --- a/src/umbraco.cms/businesslogic/propertytype/propertytype.cs +++ b/src/umbraco.cms/businesslogic/propertytype/propertytype.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Runtime.CompilerServices; using System.Threading; +using Umbraco.Core.Persistence.Caching; using umbraco.BusinessLogic; using umbraco.cms.businesslogic.cache; using umbraco.cms.businesslogic.datatype; @@ -461,10 +462,10 @@ namespace umbraco.cms.businesslogic.propertytype // clear cache in contentype Cache.ClearCacheItem("ContentType_PropertyTypes_Content:" + _contenttypeid); - // clear cache in tab - // zb-00040 #29889 : clear the right cache! t.ContentType is the ctype which _defines_ the tab, not the current one. - // foreach (ContentType.TabI t in new ContentType(ContentTypeId).getVirtualTabs) - // ContentType.FlushTabCache(t.Id, ContentTypeId); + //Ensure that DocumentTypes are reloaded from db by clearing cache - this similar to the Save method on DocumentType. + //NOTE Would be nice if we could clear cache by type instead of emptying the entire cache. + InMemoryCacheProvider.Current.Clear(); + RuntimeCacheProvider.Current.Clear(); } public static PropertyType GetPropertyType(int id) diff --git a/src/umbraco.cms/businesslogic/web/DocumentType.cs b/src/umbraco.cms/businesslogic/web/DocumentType.cs index bb91b66323..6ebca1c12a 100644 --- a/src/umbraco.cms/businesslogic/web/DocumentType.cs +++ b/src/umbraco.cms/businesslogic/web/DocumentType.cs @@ -460,6 +460,7 @@ namespace umbraco.cms.businesslogic.web //Ensure that DocumentTypes are reloaded from db by clearing cache. //NOTE Would be nice if we could clear cache by type instead of emptying the entire cache. InMemoryCacheProvider.Current.Clear(); + RuntimeCacheProvider.Current.Clear();//Runtime cache is used for Content, so we clear that as well base.Save(); FireAfterSave(e); From afb251d5b7eaa28a52554e2313aafca027eeaa1c Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Tue, 8 Jan 2013 11:38:35 -0100 Subject: [PATCH 014/188] Fixes U4-1394 so the DefaultTemplate is not completely removed from the list of allowed templates when changed. --- src/Umbraco.Core/Models/ContentType.cs | 6 ++++++ .../umbraco/settings/EditNodeTypeNew.aspx.cs | 2 ++ src/umbraco.cms/businesslogic/web/DocumentType.cs | 7 ++----- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Core/Models/ContentType.cs b/src/Umbraco.Core/Models/ContentType.cs index 9d747e4c55..9211e1ac98 100644 --- a/src/Umbraco.Core/Models/ContentType.cs +++ b/src/Umbraco.Core/Models/ContentType.cs @@ -72,6 +72,12 @@ namespace Umbraco.Core.Models /// Default public void SetDefaultTemplate(ITemplate template) { + if (template == null) + { + DefaultTemplateId = 0; + return; + } + DefaultTemplateId = template.Id; if(_allowedTemplates.Any(x => x != null && x.Id == template.Id) == false) { diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditNodeTypeNew.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditNodeTypeNew.aspx.cs index 0c3be42e00..170d2324c5 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditNodeTypeNew.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditNodeTypeNew.aspx.cs @@ -128,6 +128,8 @@ namespace umbraco.settings else dt.RemoveDefaultTemplate(); + dt.Save(); + bindTemplates(); } else diff --git a/src/umbraco.cms/businesslogic/web/DocumentType.cs b/src/umbraco.cms/businesslogic/web/DocumentType.cs index 6ebca1c12a..715a045c37 100644 --- a/src/umbraco.cms/businesslogic/web/DocumentType.cs +++ b/src/umbraco.cms/businesslogic/web/DocumentType.cs @@ -420,14 +420,11 @@ namespace umbraco.cms.businesslogic.web return doc; } - [Obsolete("Deprecated, Use RemoveTemplate() on Umbraco.Core.Models.ContentType", false)] + [Obsolete("Deprecated, Use SetDefaultTemplate(null) on Umbraco.Core.Models.ContentType", false)] public void RemoveDefaultTemplate() { _defaultTemplate = 0; - - var template = _contentType.DefaultTemplate; - if(template != null) - _contentType.RemoveTemplate(template); + _contentType.SetDefaultTemplate(null); } public bool HasTemplate() From c9697a519ea26a1f7435171d1ec1a5763fca6a77 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Tue, 8 Jan 2013 11:41:54 -0100 Subject: [PATCH 015/188] The check for IsDefault can't be performed on contenttypes that do not live in the contenttype table --- .../Repositories/ContentTypeRepository.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentTypeRepository.cs index d48ee621a3..48845b2573 100644 --- a/src/Umbraco.Core/Persistence/Repositories/ContentTypeRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/ContentTypeRepository.cs @@ -117,13 +117,12 @@ namespace Umbraco.Core.Persistence.Repositories //TODO Investigate the proper usage of IsDefault on cmsDocumentType var sql = new Sql(); sql.Select(isCount ? "COUNT(*)" : "*") - .From() - .RightJoin() - .On(left => left.NodeId, right => right.ContentTypeNodeId) - .InnerJoin() - .On(left => left.NodeId, right => right.NodeId) - .Where(x => x.NodeObjectType == NodeObjectTypeId) - .Where(x => x.IsDefault == true); + .From() + .RightJoin() + .On(left => left.NodeId, right => right.ContentTypeNodeId) + .InnerJoin() + .On(left => left.NodeId, right => right.NodeId) + .Where(x => x.NodeObjectType == NodeObjectTypeId); return sql; } From 312288d459ec67e8bcbd587aa4a84e256f3d868f Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Tue, 8 Jan 2013 11:42:23 -0100 Subject: [PATCH 016/188] Some properties may be corrupt, so ignore those --- .../Persistence/Factories/PropertyFactory.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Core/Persistence/Factories/PropertyFactory.cs b/src/Umbraco.Core/Persistence/Factories/PropertyFactory.cs index 2dd018ac55..0ab8136d3e 100644 --- a/src/Umbraco.Core/Persistence/Factories/PropertyFactory.cs +++ b/src/Umbraco.Core/Persistence/Factories/PropertyFactory.cs @@ -32,13 +32,19 @@ namespace Umbraco.Core.Persistence.Factories public IEnumerable BuildEntity(IEnumerable dtos) { var properties = new List(); + foreach (var dto in dtos) { - var propertyType = _contentType.CompositionPropertyTypes.FirstOrDefault(x => x.Id == dto.PropertyTypeId); - var property = propertyType.CreatePropertyFromRawValue(dto.GetValue, dto.VersionId.Value, dto.Id); - property.ResetDirtyProperties(); - properties.Add(property); + if (_contentType.CompositionPropertyTypes.Any(x => x.Id == dto.PropertyTypeId)) + { + var propertyType = _contentType.CompositionPropertyTypes.First(x => x.Id == dto.PropertyTypeId); + var property = propertyType.CreatePropertyFromRawValue(dto.GetValue, dto.VersionId.Value, dto.Id); + + property.ResetDirtyProperties(); + properties.Add(property); + } } + return properties; } From ef67aae9d31e214bc7da4b4a1661d495adebd8a2 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Tue, 8 Jan 2013 11:46:59 -0100 Subject: [PATCH 017/188] Fresh installs don't have a version number so this step cannot be complete yet --- .../install/steps/Definitions/Database.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Umbraco.Web/umbraco.presentation/install/steps/Definitions/Database.cs b/src/Umbraco.Web/umbraco.presentation/install/steps/Definitions/Database.cs index ccd713e78b..315e80b805 100644 --- a/src/Umbraco.Web/umbraco.presentation/install/steps/Definitions/Database.cs +++ b/src/Umbraco.Web/umbraco.presentation/install/steps/Definitions/Database.cs @@ -34,6 +34,10 @@ namespace umbraco.presentation.install.steps.Definitions //here we determine if the installer should skip this step... public override bool Completed() { + // Fresh installs don't have a version number so this step cannot be complete yet + if (string.IsNullOrEmpty(Umbraco.Core.Configuration.GlobalSettings.ConfigurationStatus)) + return false; + var configuredVersion = new Version(Umbraco.Core.Configuration.GlobalSettings.ConfigurationStatus); var targetVersion = UmbracoVersion.Current; From 937fc423ad7e9284ba700658eb42e0cdc328953c Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Tue, 8 Jan 2013 13:27:16 -0100 Subject: [PATCH 018/188] Change word deprecated to obsolete --- .../config/ClientDependency.config | 2 +- src/Umbraco.Web.UI/config/Dashboard.config | 8 ++ src/Umbraco.Web.UI/config/UrlRewriting.config | 3 +- .../config/xsltExtensions.config | 8 +- .../umbracobase/baseLibrary.cs | 20 ++--- src/umbraco.cms/businesslogic/CMSNode.cs | 2 +- src/umbraco.cms/businesslogic/Content.cs | 6 +- src/umbraco.cms/businesslogic/ContentType.cs | 2 +- .../businesslogic/datatype/DefaultData.cs | 2 +- src/umbraco.cms/businesslogic/media/Media.cs | 30 ++++---- .../businesslogic/media/MediaType.cs | 8 +- .../businesslogic/member/Member.cs | 4 +- .../businesslogic/template/Template.cs | 2 +- src/umbraco.cms/businesslogic/web/Document.cs | 76 +++++++++---------- .../businesslogic/web/DocumentType.cs | 26 +++---- .../tinymce/TinyMCEDataType.cs | 2 +- 16 files changed, 107 insertions(+), 94 deletions(-) diff --git a/src/Umbraco.Web.UI/config/ClientDependency.config b/src/Umbraco.Web.UI/config/ClientDependency.config index d6edcff895..46c024aac7 100644 --- a/src/Umbraco.Web.UI/config/ClientDependency.config +++ b/src/Umbraco.Web.UI/config/ClientDependency.config @@ -10,7 +10,7 @@ NOTES: * Compression/Combination/Minification is not enabled unless debug="false" is specified on the 'compiliation' element in the web.config * A new version will invalidate both client and server cache and create new persisted files --> - + diff --git a/src/Umbraco.Web.UI/config/Dashboard.config b/src/Umbraco.Web.UI/config/Dashboard.config index 7588d58311..3a7440a233 100644 --- a/src/Umbraco.Web.UI/config/Dashboard.config +++ b/src/Umbraco.Web.UI/config/Dashboard.config @@ -112,4 +112,12 @@ /usercontrols/blog/CommentModeration.ascx +
+ + content + + + /usercontrols/blog/CommentModeration.ascx + +
\ No newline at end of file diff --git a/src/Umbraco.Web.UI/config/UrlRewriting.config b/src/Umbraco.Web.UI/config/UrlRewriting.config index 05ffe1eeb6..20e84a9dcc 100644 --- a/src/Umbraco.Web.UI/config/UrlRewriting.config +++ b/src/Umbraco.Web.UI/config/UrlRewriting.config @@ -28,5 +28,6 @@ Any bugs or problems with the rewriter, contact Anders/Duckie --> + - + \ No newline at end of file diff --git a/src/Umbraco.Web.UI/config/xsltExtensions.config b/src/Umbraco.Web.UI/config/xsltExtensions.config index 58a11e1d5f..354f37fd64 100644 --- a/src/Umbraco.Web.UI/config/xsltExtensions.config +++ b/src/Umbraco.Web.UI/config/xsltExtensions.config @@ -1,4 +1,4 @@ - + @@ -8,4 +8,8 @@ - + + + + + \ No newline at end of file diff --git a/src/Umbraco.Web/umbraco.presentation/umbracobase/baseLibrary.cs b/src/Umbraco.Web/umbraco.presentation/umbracobase/baseLibrary.cs index 9def6a0c77..888280df77 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbracobase/baseLibrary.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbracobase/baseLibrary.cs @@ -17,26 +17,26 @@ using umbraco.cms.businesslogic.property; namespace umbraco.presentation.umbracobase.library { - [Obsolete("Deprecated, use Umbraco.Web.BaseRest.MemberRest.")] + [Obsolete("Obsolete, use Umbraco.Web.BaseRest.MemberRest.")] public class library { - [Obsolete("Deprecated, use Umbraco.Web.BaseRest.MemberRest.GetCurrentMember().", false)] + [Obsolete("Obsolete, use Umbraco.Web.BaseRest.MemberRest.GetCurrentMember().", false)] public static Member GetCurrentMember() { return Member.GetCurrentMember(); } - [Obsolete("Deprecated, use Umbraco.Web.BaseRest.MemberRest.GetCurrentMemberId().", false)] + [Obsolete("Obsolete, use Umbraco.Web.BaseRest.MemberRest.GetCurrentMemberId().", false)] public static int CurrentMemberId() { return Member.CurrentMemberId(); } } - [Obsolete("Deprecated, use Umbraco.Web.BaseRest.MemberRest.")] + [Obsolete("Obsolete, use Umbraco.Web.BaseRest.MemberRest.")] public class member { - [Obsolete("Deprecated, use Umbraco.Web.BaseRest.MemberRest.Login(login, password).", false)] + [Obsolete("Obsolete, use Umbraco.Web.BaseRest.MemberRest.Login(login, password).", false)] public static int login(string loginname, string password) { Member m = Member.GetMemberFromLoginNameAndPassword(loginname, password); @@ -56,7 +56,7 @@ namespace umbraco.presentation.umbracobase.library return library.CurrentMemberId(); } - [Obsolete("Deprecated, use Umbraco.Web.BaseRest.MemberRest.Logout().", false)] + [Obsolete("Obsolete, use Umbraco.Web.BaseRest.MemberRest.Logout().", false)] public static int logout() { Member m = library.GetCurrentMember(); @@ -70,7 +70,7 @@ namespace umbraco.presentation.umbracobase.library return 0; } - [Obsolete("Deprecated, use Umbraco.Web.BaseRest.MemberRest.Logout().", false)] + [Obsolete("Obsolete, use Umbraco.Web.BaseRest.MemberRest.Logout().", false)] public static int logout(int NodeId) { int _currentMemberId = library.CurrentMemberId(); @@ -84,7 +84,7 @@ namespace umbraco.presentation.umbracobase.library return 0; } - [Obsolete("Deprecated, use Umbraco.Web.BaseRest.MemberRest.GetCurrentMemberAsXml().", false)] + [Obsolete("Obsolete, use Umbraco.Web.BaseRest.MemberRest.GetCurrentMemberAsXml().", false)] public static XPathNodeIterator data() { if (library.GetCurrentMember() != null) @@ -98,13 +98,13 @@ namespace umbraco.presentation.umbracobase.library return null; } - [Obsolete("Deprecated, use Umbraco.Web.BaseRest.MemberRest.GetCurrentMemberId().", false)] + [Obsolete("Obsolete, use Umbraco.Web.BaseRest.MemberRest.GetCurrentMemberId().", false)] public static int id() { return library.CurrentMemberId(); } - [Obsolete("Deprecated, use Umbraco.Web.BaseRest.MemberRest.SetProperty(alias, value).", false)] + [Obsolete("Obsolete, use Umbraco.Web.BaseRest.MemberRest.SetProperty(alias, value).", false)] public static string setProperty(string alias, object value) { string retVal = "False"; diff --git a/src/umbraco.cms/businesslogic/CMSNode.cs b/src/umbraco.cms/businesslogic/CMSNode.cs index 24459e7f04..4168dd4f62 100644 --- a/src/umbraco.cms/businesslogic/CMSNode.cs +++ b/src/umbraco.cms/businesslogic/CMSNode.cs @@ -29,7 +29,7 @@ namespace umbraco.cms.businesslogic /// The child classes are required to implement an identifier (Guid) which is used as the objecttype identifier, for /// distinguishing the different types of CMSNodes (ex. Documents/Medias/Stylesheets/documenttypes and so forth). /// - [Obsolete("Deprecated, This class will eventually be phased out", false)] + [Obsolete("Obsolete, This class will eventually be phased out", false)] public class CMSNode : BusinessLogic.console.IconI { #region Private Members diff --git a/src/umbraco.cms/businesslogic/Content.cs b/src/umbraco.cms/businesslogic/Content.cs index dfc0b544eb..7b3e966874 100644 --- a/src/umbraco.cms/businesslogic/Content.cs +++ b/src/umbraco.cms/businesslogic/Content.cs @@ -26,7 +26,7 @@ namespace umbraco.cms.businesslogic /// Note that Content data in umbraco is *not* tablular but in a treestructure. /// /// - [Obsolete("Deprecated, Use Umbraco.Core.Models.Content or Umbraco.Core.Models.Media", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Models.Content or Umbraco.Core.Models.Media", false)] public class Content : CMSNode { #region Private Members @@ -70,7 +70,7 @@ namespace umbraco.cms.businesslogic /// /// The ContentType /// A list of Content objects sharing the ContentType defined. - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.GetContentOfContentType() or Umbraco.Core.Services.MediaService.GetMediaOfMediaType()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.GetContentOfContentType() or Umbraco.Core.Services.MediaService.GetMediaOfMediaType()", false)] public static Content[] getContentOfContentType(ContentType ct) { var list = new List(); @@ -88,7 +88,7 @@ namespace umbraco.cms.businesslogic /// /// The version identifier /// The Content object from the given version - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.GetByIdVersion() or Umbraco.Core.Services.MediaService.GetByIdVersion()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.GetByIdVersion() or Umbraco.Core.Services.MediaService.GetByIdVersion()", false)] public static Content GetContentFromVersion(Guid version) { var content = ApplicationContext.Current.Services.ContentService.GetByVersion(version); diff --git a/src/umbraco.cms/businesslogic/ContentType.cs b/src/umbraco.cms/businesslogic/ContentType.cs index 529fefb11a..4cc0c38e13 100644 --- a/src/umbraco.cms/businesslogic/ContentType.cs +++ b/src/umbraco.cms/businesslogic/ContentType.cs @@ -25,7 +25,7 @@ namespace umbraco.cms.businesslogic /// Besides data definition, the ContentType also defines the sorting and grouping (in tabs) of Properties/Datafields /// on the Content and which Content (by ContentType) can be created as child to the Content of the ContentType. /// - [Obsolete("Deprecated, Use Umbraco.Core.Models.ContentType or Umbraco.Core.Models.MediaType", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Models.ContentType or Umbraco.Core.Models.MediaType", false)] public class ContentType : CMSNode { #region Constructors diff --git a/src/umbraco.cms/businesslogic/datatype/DefaultData.cs b/src/umbraco.cms/businesslogic/datatype/DefaultData.cs index 1d15edfcad..82212664d7 100644 --- a/src/umbraco.cms/businesslogic/datatype/DefaultData.cs +++ b/src/umbraco.cms/businesslogic/datatype/DefaultData.cs @@ -24,7 +24,7 @@ namespace umbraco.cms.businesslogic.datatype private Guid? _version = null; private int? _nodeId = null; - [Obsolete("Deprecated, For querying the database use the new UmbracoDatabase object ApplicationContext.Current.DatabaseContext.Database", false)] + [Obsolete("Obsolete, For querying the database use the new UmbracoDatabase object ApplicationContext.Current.DatabaseContext.Database", false)] protected static ISqlHelper SqlHelper { get { return Application.SqlHelper; } diff --git a/src/umbraco.cms/businesslogic/media/Media.cs b/src/umbraco.cms/businesslogic/media/Media.cs index 9328bbf4fb..614da7d75e 100644 --- a/src/umbraco.cms/businesslogic/media/Media.cs +++ b/src/umbraco.cms/businesslogic/media/Media.cs @@ -14,7 +14,7 @@ namespace umbraco.cms.businesslogic.media /// /// By inheriting the Content class it has a generic datafields which enables custumization /// - [Obsolete("Deprecated, Use Umbraco.Core.Models.Media", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Models.Media", false)] public class Media : Content { #region Constants and static members @@ -73,7 +73,7 @@ namespace umbraco.cms.businesslogic.media /// The user creating the media /// The id of the folder under which the media is created /// - [Obsolete("Deprecated, Use Umbraco.Core.Services.MediaService.CreateMedia()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.MediaService.CreateMedia()", false)] public static Media MakeNew(string Name, MediaType dct, BusinessLogic.User u, int ParentId) { var media = ApplicationContext.Current.Services.MediaService.CreateMedia(ParentId, dct.Alias, u.Id); @@ -100,7 +100,7 @@ namespace umbraco.cms.businesslogic.media /// Retrieve a list of all toplevel medias and folders /// /// - [Obsolete("Deprecated, Use Umbraco.Core.Services.MediaService.GetRootMedia()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.MediaService.GetRootMedia()", false)] public static Media[] GetRootMedias() { var children = ApplicationContext.Current.Services.MediaService.GetRootMedia(); @@ -117,7 +117,7 @@ namespace umbraco.cms.businesslogic.media return retval;*/ } - [Obsolete("Deprecated, Use Umbraco.Core.Services.MediaService.GetChildren()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.MediaService.GetChildren()", false)] public static List GetChildrenForTree(int nodeId) { var children = ApplicationContext.Current.Services.MediaService.GetChildren(nodeId); @@ -144,7 +144,7 @@ namespace umbraco.cms.businesslogic.media return tmp;*/ } - [Obsolete("Deprecated, Use Umbraco.Core.Services.MediaService.GetMediaOfMediaType()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.MediaService.GetMediaOfMediaType()", false)] public static IEnumerable GetMediaOfMediaType(int mediaTypeId) { var children = ApplicationContext.Current.Services.MediaService.GetMediaOfMediaType(mediaTypeId); @@ -174,7 +174,7 @@ namespace umbraco.cms.businesslogic.media /// Use with care. /// /// - [Obsolete("Deprecated, Use Umbraco.Core.Services.MediaService.DeleteMediaOfType()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.MediaService.DeleteMediaOfType()", false)] public static void DeleteFromType(MediaType dt) { ApplicationContext.Current.Services.MediaService.DeleteMediaOfType(dt.Id); @@ -270,7 +270,7 @@ namespace umbraco.cms.businesslogic.media /// /// Retrieve a list of all medias underneath the current /// - [Obsolete("Deprecated, Use Umbraco.Core.Services.MediaService.GetChildren()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.MediaService.GetChildren()", false)] public new Media[] Children { get @@ -289,7 +289,7 @@ namespace umbraco.cms.businesslogic.media /// /// Used to persist object changes to the database. In Version3.0 it's just a stub for future compatibility /// - [Obsolete("Deprecated, Use Umbraco.Core.Services.MediaService.Save()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.MediaService.Save()", false)] public override void Save() { SaveEventArgs e = new SaveEventArgs(); @@ -327,7 +327,7 @@ namespace umbraco.cms.businesslogic.media /// /// Moves the media to the trash /// - [Obsolete("Deprecated, Use Umbraco.Core.Services.MediaService.MoveToRecycleBin()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.MediaService.MoveToRecycleBin()", false)] public override void delete() { MoveToTrash(); @@ -337,7 +337,7 @@ namespace umbraco.cms.businesslogic.media /// With either move the media to the trash or permanently remove it from the database. /// /// flag to set whether or not to completely remove it from the database or just send to trash - [Obsolete("Deprecated, Use Umbraco.Core.Services.MediaService.Delete() or Umbraco.Core.Services.MediaService.MoveToRecycleBin()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.MediaService.Delete() or Umbraco.Core.Services.MediaService.MoveToRecycleBin()", false)] public void delete(bool deletePermanently) { if (!deletePermanently) @@ -350,7 +350,7 @@ namespace umbraco.cms.businesslogic.media } } - [Obsolete("Deprecated, Use Umbraco.Core.Services.MediaService.GetDescendants()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.MediaService.GetDescendants()", false)] public override IEnumerable GetDescendants() { var descendants = ApplicationContext.Current.Services.MediaService.GetDescendants(Id); @@ -378,7 +378,7 @@ namespace umbraco.cms.businesslogic.media SetupNode(media); } - [Obsolete("Deprecated, This method is no longer used")] + [Obsolete("Obsolete, This method is no longer used")] protected void PopulateMediaFromReader(IRecordsReader dr) { var hc = dr.GetInt("children") > 0; @@ -414,7 +414,7 @@ namespace umbraco.cms.businesslogic.media Version = MediaItem.Version; } - [Obsolete("Deprecated, This method is no longer needed", false)] + [Obsolete("Obsolete, This method is no longer needed", false)] private void SetupMediaForTree(Guid uniqueId, int level, int parentId, int user, string path, string text, DateTime createDate, string icon, bool hasChildren, string contentTypeAlias, string contentTypeThumb, string contentTypeDesc, int? masterContentType, int contentTypeId, bool isContainer) @@ -428,7 +428,7 @@ namespace umbraco.cms.businesslogic.media /// Used internally to permanently delete the data from the database /// /// returns true if deletion isn't cancelled - [Obsolete("Deprecated, Use Umbraco.Core.Services.MediaService.Delete()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.MediaService.Delete()", false)] private bool DeletePermanently() { DeleteEventArgs e = new DeleteEventArgs(); @@ -458,7 +458,7 @@ namespace umbraco.cms.businesslogic.media /// Used internally to move the node to the recyle bin /// /// Returns true if the move was not cancelled - [Obsolete("Deprecated, Use Umbraco.Core.Services.MediaService.MoveToRecycleBin()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.MediaService.MoveToRecycleBin()", false)] private bool MoveToTrash() { MoveToTrashEventArgs e = new MoveToTrashEventArgs(); diff --git a/src/umbraco.cms/businesslogic/media/MediaType.cs b/src/umbraco.cms/businesslogic/media/MediaType.cs index 5225972e79..f97bf50ad4 100644 --- a/src/umbraco.cms/businesslogic/media/MediaType.cs +++ b/src/umbraco.cms/businesslogic/media/MediaType.cs @@ -12,7 +12,7 @@ namespace umbraco.cms.businesslogic.media /// /// Due to the inheritance of the ContentType class,it enables definition of generic datafields on a Media. /// - [Obsolete("Deprecated, Use Umbraco.Core.Models.MediaType", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Models.MediaType", false)] public class MediaType : ContentType { #region Constructors @@ -57,7 +57,7 @@ namespace umbraco.cms.businesslogic.media /// /// The alias of the MediaType /// The MediaType with the alias - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentTypeService.GetMediaType()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentTypeService.GetMediaType()", false)] public static new MediaType GetByAlias(string Alias) { var mediaType = ApplicationContext.Current.Services.ContentTypeService.GetMediaType(Alias); @@ -76,7 +76,7 @@ namespace umbraco.cms.businesslogic.media } } - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentTypeService.GetMediaType()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentTypeService.GetMediaType()", false)] public static IEnumerable GetAllAsList() { var mediaTypes = ApplicationContext.Current.Services.ContentTypeService.GetAllMediaTypes(); @@ -89,7 +89,7 @@ namespace umbraco.cms.businesslogic.media /// The Umbraco user context /// The name of the MediaType /// The new MediaType - [Obsolete("Deprecated, Use Umbraco.Core.Models.MediaType and Umbraco.Core.Services.ContentTypeService.Save()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Models.MediaType and Umbraco.Core.Services.ContentTypeService.Save()", false)] public static MediaType MakeNew(BusinessLogic.User u, string Text) { var mediaType = new Umbraco.Core.Models.MediaType(-1) { Name = Text, Alias = Text, CreatorId = u.Id, Thumbnail = "folder.png", Icon = "folder.gif" }; diff --git a/src/umbraco.cms/businesslogic/member/Member.cs b/src/umbraco.cms/businesslogic/member/Member.cs index f9ca2f18df..0c6bb0e532 100644 --- a/src/umbraco.cms/businesslogic/member/Member.cs +++ b/src/umbraco.cms/businesslogic/member/Member.cs @@ -1048,7 +1048,7 @@ namespace umbraco.cms.businesslogic.member /// Can be used in the public website /// /// Member to remove - [Obsolete("Deprecated, use the RemoveMemberFromCache(int NodeId) instead", false)] + [Obsolete("Obsolete, use the RemoveMemberFromCache(int NodeId) instead", false)] public static void RemoveMemberFromCache(Member m) { RemoveMemberFromCache(m.Id); @@ -1071,7 +1071,7 @@ namespace umbraco.cms.businesslogic.member /// Can be used in the public website /// /// Member - [Obsolete("Deprecated, use the ClearMemberFromClient(int NodeId) instead", false)] + [Obsolete("Obsolete, use the ClearMemberFromClient(int NodeId) instead", false)] public static void ClearMemberFromClient(Member m) { diff --git a/src/umbraco.cms/businesslogic/template/Template.cs b/src/umbraco.cms/businesslogic/template/Template.cs index c9c30d1622..f6220b7f27 100644 --- a/src/umbraco.cms/businesslogic/template/Template.cs +++ b/src/umbraco.cms/businesslogic/template/Template.cs @@ -18,7 +18,7 @@ namespace umbraco.cms.businesslogic.template /// /// Summary description for Template. /// - //[Obsolete("Deprecated, This class will eventually be phased out - Use Umbraco.Core.Models.Template", false)] + //[Obsolete("Obsolete, This class will eventually be phased out - Use Umbraco.Core.Models.Template", false)] public class Template : CMSNode { diff --git a/src/umbraco.cms/businesslogic/web/Document.cs b/src/umbraco.cms/businesslogic/web/Document.cs index b4840249ef..ea92bfc1f3 100644 --- a/src/umbraco.cms/businesslogic/web/Document.cs +++ b/src/umbraco.cms/businesslogic/web/Document.cs @@ -21,7 +21,7 @@ namespace umbraco.cms.businesslogic.web /// /// Pubished Documents are exposed to the runtime/the public website in a cached xml document. /// - [Obsolete("Deprecated, Use Umbraco.Core.Models.Content", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Models.Content", false)] public class Document : Content { #region Constructors @@ -325,7 +325,7 @@ namespace umbraco.cms.businesslogic.web /// The usercontext under which the action are performed /// The id of the parent to the document /// The newly created document - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.CreateContent()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.CreateContent()", false)] public static Document MakeNew(string Name, DocumentType dct, User u, int ParentId) { //allows you to cancel a document before anything goes to the DB @@ -371,7 +371,7 @@ namespace umbraco.cms.businesslogic.web /// /// /// - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.GetById()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.GetById()", false)] public static bool IsDocument(int nodeId) { bool isDoc = false; @@ -386,7 +386,7 @@ namespace umbraco.cms.businesslogic.web /// Used to get the firstlevel/root documents of the hierachy /// /// Root documents - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.GetRootContent()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.GetRootContent()", false)] public static Document[] GetRootDocuments() { var content = ApplicationContext.Current.Services.ContentService.GetRootContent(); @@ -411,13 +411,13 @@ namespace umbraco.cms.businesslogic.web /// Note: use with care: this method can result in wast amount of data being deleted. /// /// The type of which documents should be deleted - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.DeleteContentOfType()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.DeleteContentOfType()", false)] public static void DeleteFromType(DocumentType dt) { ApplicationContext.Current.Services.ContentService.DeleteContentOfType(dt.Id); } - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.GetContentOfContentType()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.GetContentOfContentType()", false)] public static IEnumerable GetDocumentsOfDocumentType(int docTypeId) { var contents = ApplicationContext.Current.Services.ContentService.GetContentOfContentType(docTypeId); @@ -435,7 +435,7 @@ namespace umbraco.cms.businesslogic.web /// /// The parentdocuments id /// - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.GetChildren()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.GetChildren()", false)] public static Document[] GetChildrenForTree(int NodeId) { var children = ApplicationContext.Current.Services.ContentService.GetChildren(NodeId).OrderBy(c => c.SortOrder); @@ -443,14 +443,14 @@ namespace umbraco.cms.businesslogic.web return list.ToArray(); } - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.GetChildrenByName()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.GetChildrenByName()", false)] public static List GetChildrenBySearch(int NodeId, string searchString) { var children = ApplicationContext.Current.Services.ContentService.GetChildrenByName(NodeId, searchString); return children.Select(x => new Document(x)).ToList(); } - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.RePublishAll()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.RePublishAll()", false)] public static void RePublishAll() { XmlDocument xd = new XmlDocument(); @@ -502,7 +502,7 @@ namespace umbraco.cms.businesslogic.web /// Retrieve a list of documents with an expirationdate greater than today /// /// A list of documents with expirationdates than today - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.GetContentForExpiration()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.GetContentForExpiration()", false)] public static Document[] GetDocumentsForExpiration() { var contents = ApplicationContext.Current.Services.ContentService.GetContentForExpiration(); @@ -513,7 +513,7 @@ namespace umbraco.cms.businesslogic.web /// Retrieve a list of documents with with releasedate greater than today /// /// Retrieve a list of documents with with releasedate greater than today - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.GetContentForRelease()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.GetContentForRelease()", false)] public static Document[] GetDocumentsForRelease() { var contents = ApplicationContext.Current.Services.ContentService.GetContentForRelease(); @@ -657,7 +657,7 @@ namespace umbraco.cms.businesslogic.web /// A document can be published yet not visible, because of one or more of its /// parents being unpublished. Use PathPublished to get a value indicating whether /// the node and all its parents are published, and therefore whether the node is visible. - [Obsolete("Deprecated, Use Published property on Umbraco.Core.Models.Content", false)] + [Obsolete("Obsolete, Use Published property on Umbraco.Core.Models.Content", false)] public bool Published { get { return _published; } @@ -674,7 +674,7 @@ namespace umbraco.cms.businesslogic.web /// /// Gets a value indicating whether the document and all its parents are published. /// - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.IsPublishable()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.IsPublishable()", false)] public bool PathPublished { get @@ -683,7 +683,7 @@ namespace umbraco.cms.businesslogic.web } } - [Obsolete("Deprecated, Use Name property on Umbraco.Core.Models.Content", false)] + [Obsolete("Obsolete, Use Name property on Umbraco.Core.Models.Content", false)] public override string Text { get @@ -706,7 +706,7 @@ namespace umbraco.cms.businesslogic.web /// /// The date of the last update of the document /// - [Obsolete("Deprecated, Use UpdateDate property on Umbraco.Core.Models.Content", false)] + [Obsolete("Obsolete, Use UpdateDate property on Umbraco.Core.Models.Content", false)] public DateTime UpdateDate { get { return _updated; } @@ -723,7 +723,7 @@ namespace umbraco.cms.businesslogic.web /// /// A datestamp which indicates when a document should be published, used in automated publish/unpublish scenarios /// - [Obsolete("Deprecated, Use ReleaseDate property on Umbraco.Core.Models.Content", false)] + [Obsolete("Obsolete, Use ReleaseDate property on Umbraco.Core.Models.Content", false)] public DateTime ReleaseDate { get { return _release; } @@ -737,7 +737,7 @@ namespace umbraco.cms.businesslogic.web /// /// A datestamp which indicates when a document should be unpublished, used in automated publish/unpublish scenarios /// - [Obsolete("Deprecated, Use ExpireDate property on Umbraco.Core.Models.Content", false)] + [Obsolete("Obsolete, Use ExpireDate property on Umbraco.Core.Models.Content", false)] public DateTime ExpireDate { get { return _expire; } @@ -758,7 +758,7 @@ namespace umbraco.cms.businesslogic.web /// /// ?altTemplate=[templatealias] /// - [Obsolete("Deprecated, Use Template property on Umbraco.Core.Models.Content", false)] + [Obsolete("Obsolete, Use Template property on Umbraco.Core.Models.Content", false)] public int Template { get { return _template; } @@ -780,7 +780,7 @@ namespace umbraco.cms.businesslogic.web /// /// A collection of documents imidiately underneath this document ie. the childdocuments /// - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.GetChildren()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.GetChildren()", false)] public new Document[] Children { get @@ -827,7 +827,7 @@ namespace umbraco.cms.businesslogic.web /// the data. /// /// The usercontext under which the action are performed - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.Publish()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.Publish()", false)] public void Publish(User u) { SaveAndPublish(u); @@ -842,7 +842,7 @@ namespace umbraco.cms.businesslogic.web /// /// The usercontext under which the action are performed /// True if the publishing succeed. Possible causes for not publishing is if an event aborts the publishing - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.Publish()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.Publish()", false)] public bool PublishWithResult(User u) { var e = new PublishEventArgs(); @@ -863,7 +863,7 @@ namespace umbraco.cms.businesslogic.web } } - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.PublishWithChildren()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.PublishWithChildren()", false)] public bool PublishWithChildrenWithResult(User u) { return ApplicationContext.Current.Services.ContentService.PublishWithChildren(Content, u.Id, true); @@ -875,7 +875,7 @@ namespace umbraco.cms.businesslogic.web /// /// The usercontext under which the action are performed /// The unique Id of the version to roll back to - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.Rollback()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.Rollback()", false)] public void RollBack(Guid VersionId, User u) { var e = new RollBackEventArgs(); @@ -895,7 +895,7 @@ namespace umbraco.cms.businesslogic.web /// Envoking this method will publish the documents and all children recursive. /// /// The usercontext under which the action are performed - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.PublishWithChildren()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.PublishWithChildren()", false)] public void PublishWithSubs(User u) { PublishEventArgs e = new PublishEventArgs(); @@ -909,7 +909,7 @@ namespace umbraco.cms.businesslogic.web } } - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.UnPublish()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.UnPublish()", false)] public void UnPublish() { UnPublishEventArgs e = new UnPublishEventArgs(); @@ -927,7 +927,7 @@ namespace umbraco.cms.businesslogic.web /// /// Used to persist object changes to the database. /// - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.Save()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.Save()", false)] public override void Save() { var e = new SaveEventArgs(); @@ -989,7 +989,7 @@ namespace umbraco.cms.businesslogic.web return false; } - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.HasPublishedVersion()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.HasPublishedVersion()", false)] public bool HasPublishedVersion() { return Content.HasPublishedVersion(); @@ -1001,7 +1001,7 @@ namespace umbraco.cms.businesslogic.web /// then this is considered a change. /// /// - [Obsolete("Deprecated, Instead of calling this just check if the latest version of the content is published", false)] + [Obsolete("Obsolete, Instead of calling this just check if the latest version of the content is published", false)] public bool HasPendingChanges() { return Content.Published == false; @@ -1011,7 +1011,7 @@ namespace umbraco.cms.businesslogic.web /// Used for rolling back documents to a previous version /// /// Previous published versions of the document - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.GetVersions()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.GetVersions()", false)] public DocumentVersionList[] GetVersions() { var versions = ApplicationContext.Current.Services.ContentService.GetVersions(Id); @@ -1024,7 +1024,7 @@ namespace umbraco.cms.businesslogic.web /// Returns the published version of this document /// /// The published version of this document - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.GetPublishedVersion()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.GetPublishedVersion()", false)] public DocumentVersionList GetPublishedVersion() { var version = ApplicationContext.Current.Services.ContentService.GetPublishedVersion(Id); @@ -1058,7 +1058,7 @@ namespace umbraco.cms.businesslogic.web /// /// The parentid where the document should be copied to /// The usercontext under which the action are performed - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.Copy()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.Copy()", false)] public Document Copy(int CopyTo, User u) { return Copy(CopyTo, u, false); @@ -1071,7 +1071,7 @@ namespace umbraco.cms.businesslogic.web /// /// /// - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.Copy()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.Copy()", false)] public Document Copy(int CopyTo, User u, bool RelateToOrignal) { var e = new CopyEventArgs(); @@ -1100,7 +1100,7 @@ namespace umbraco.cms.businesslogic.web /// /// Puts the current document in the trash /// - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.MoveToRecycleBin()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.MoveToRecycleBin()", false)] public override void delete() { MoveToTrash(); @@ -1110,7 +1110,7 @@ namespace umbraco.cms.businesslogic.web /// With either move the document to the trash or permanently remove it from the database. /// /// flag to set whether or not to completely remove it from the database or just send to trash - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.Delete() or Umbraco.Core.Services.ContentService.MoveToRecycleBin()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.Delete() or Umbraco.Core.Services.ContentService.MoveToRecycleBin()", false)] public void delete(bool deletePermanently) { if (!deletePermanently) @@ -1127,7 +1127,7 @@ namespace umbraco.cms.businesslogic.web /// Returns all decendants of the current document /// /// - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.GetDescendants()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.GetDescendants()", false)] public override IEnumerable GetDescendants() { var descendants = Content == null @@ -1142,7 +1142,7 @@ namespace umbraco.cms.businesslogic.web /// /// The source xmldocument /// The previous xmlrepresentation of the document - [Obsolete("Deprecated, Doesn't appear to be used anywhere", false)] + [Obsolete("Obsolete, Doesn't appear to be used anywhere", false)] public void XmlNodeRefresh(XmlDocument xd, ref XmlNode x) { x.Attributes.RemoveAll(); @@ -1486,7 +1486,7 @@ namespace umbraco.cms.businesslogic.web /// Used internally to permanently delete the data from the database /// /// returns true if deletion isn't cancelled - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.Delete()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.Delete()", false)] private bool DeletePermanently() { DeleteEventArgs e = new DeleteEventArgs(); @@ -1518,7 +1518,7 @@ namespace umbraco.cms.businesslogic.web /// Used internally to move the node to the recyle bin /// /// Returns true if the move was not cancelled - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.MoveToRecycleBin()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.MoveToRecycleBin()", false)] private bool MoveToTrash() { MoveToTrashEventArgs e = new MoveToTrashEventArgs(); diff --git a/src/umbraco.cms/businesslogic/web/DocumentType.cs b/src/umbraco.cms/businesslogic/web/DocumentType.cs index 715a045c37..882ba8d154 100644 --- a/src/umbraco.cms/businesslogic/web/DocumentType.cs +++ b/src/umbraco.cms/businesslogic/web/DocumentType.cs @@ -18,7 +18,7 @@ namespace umbraco.cms.businesslogic.web /// /// Summary description for DocumentType. /// - [Obsolete("Deprecated, Use Umbraco.Core.Models.ContentType", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Models.ContentType", false)] public class DocumentType : ContentType { #region Constructors @@ -68,7 +68,7 @@ namespace umbraco.cms.businesslogic.web /// Generates the complete (simplified) XML DTD /// /// The DTD as a string - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentTypeService.GetDtd()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentTypeService.GetDtd()", false)] public static string GenerateDtd() { StringBuilder dtd = new StringBuilder(); @@ -83,7 +83,7 @@ namespace umbraco.cms.businesslogic.web return dtd.ToString(); } - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentTypeService.GetContentTypesDtd()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentTypeService.GetContentTypesDtd()", false)] public static string GenerateXmlDocumentType() { StringBuilder dtd = new StringBuilder(); @@ -124,7 +124,7 @@ namespace umbraco.cms.businesslogic.web } - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentTypeService.GetContentType()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentTypeService.GetContentType()", false)] public new static DocumentType GetByAlias(string Alias) { try @@ -138,7 +138,7 @@ namespace umbraco.cms.businesslogic.web } } - [Obsolete("Deprecated, Use Umbraco.Core.Models.ContentType and Umbraco.Core.Services.ContentTypeService.Save()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Models.ContentType and Umbraco.Core.Services.ContentTypeService.Save()", false)] public static DocumentType MakeNew(User u, string Text) { var contentType = new Umbraco.Core.Models.ContentType(-1) { Name = Text, Alias = Text, CreatorId = u.Id, Thumbnail = "folder.png", Icon = "folder.gif" }; @@ -161,7 +161,7 @@ namespace umbraco.cms.businesslogic.web } } - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentTypeService.GetAllContentTypes()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentTypeService.GetAllContentTypes()", false)] public static List GetAllAsList() { var contentTypes = ApplicationContext.Current.Services.ContentTypeService.GetAllContentTypes(); @@ -173,7 +173,7 @@ namespace umbraco.cms.businesslogic.web #endregion #region Public Properties - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentTypeService.HasChildren()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentTypeService.HasChildren()", false)] public override bool HasChildren { get @@ -191,7 +191,7 @@ namespace umbraco.cms.businesslogic.web } } - [Obsolete("Deprecated, Use SetDefaultTemplate() on Umbraco.Core.Models.ContentType", false)] + [Obsolete("Obsolete, Use SetDefaultTemplate() on Umbraco.Core.Models.ContentType", false)] public int DefaultTemplate { get { return _defaultTemplate; } @@ -211,7 +211,7 @@ namespace umbraco.cms.businesslogic.web /// /// Gets/sets the allowed templates for this document type. /// - [Obsolete("Deprecated, Use AllowedTemplates property on Umbraco.Core.Models.ContentType", false)] + [Obsolete("Obsolete, Use AllowedTemplates property on Umbraco.Core.Models.ContentType", false)] public template.Template[] allowedTemplates { get @@ -281,7 +281,7 @@ namespace umbraco.cms.businesslogic.web #region Public Methods - [Obsolete("Deprecated, Use RemoveTemplate() on Umbraco.Core.Models.ContentType", false)] + [Obsolete("Obsolete, Use RemoveTemplate() on Umbraco.Core.Models.ContentType", false)] public void RemoveTemplate(int templateId) { // remove if default template @@ -305,7 +305,7 @@ namespace umbraco.cms.businesslogic.web /// /// /// Throws an exception if trying to delete a document type that is assigned as a master document type - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentTypeService.Delete()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentTypeService.Delete()", false)] public override void delete() { DeleteEventArgs e = new DeleteEventArgs(); @@ -420,7 +420,7 @@ namespace umbraco.cms.businesslogic.web return doc; } - [Obsolete("Deprecated, Use SetDefaultTemplate(null) on Umbraco.Core.Models.ContentType", false)] + [Obsolete("Obsolete, Use SetDefaultTemplate(null) on Umbraco.Core.Models.ContentType", false)] public void RemoveDefaultTemplate() { _defaultTemplate = 0; @@ -435,7 +435,7 @@ namespace umbraco.cms.businesslogic.web /// /// Used to persist object changes to the database. In Version3.0 it's just a stub for future compatibility /// - [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentTypeService.Save()", false)] + [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentTypeService.Save()", false)] public override void Save() { SaveEventArgs e = new SaveEventArgs(); diff --git a/src/umbraco.editorControls/tinymce/TinyMCEDataType.cs b/src/umbraco.editorControls/tinymce/TinyMCEDataType.cs index d30639eb18..0c3fc5e424 100644 --- a/src/umbraco.editorControls/tinymce/TinyMCEDataType.cs +++ b/src/umbraco.editorControls/tinymce/TinyMCEDataType.cs @@ -36,7 +36,7 @@ namespace umbraco.editorControls.tinymce public override string DataTypeName { - get { return "TinyMCE wysiwyg (deprecated, upgrade to tinymce v3!)"; } + get { return "TinyMCE wysiwyg (Obsolete, upgrade to tinymce v3!)"; } } public override umbraco.interfaces.IDataPrevalue PrevalueEditor From becf73bba1cb3065c8a1abca18a63446918dba8a Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Tue, 8 Jan 2013 13:51:57 -0100 Subject: [PATCH 019/188] Change word deprecated to obsolete --- src/umbraco.cms/businesslogic/web/Document.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/umbraco.cms/businesslogic/web/Document.cs b/src/umbraco.cms/businesslogic/web/Document.cs index ea92bfc1f3..4c87c895cc 100644 --- a/src/umbraco.cms/businesslogic/web/Document.cs +++ b/src/umbraco.cms/businesslogic/web/Document.cs @@ -1331,7 +1331,7 @@ namespace umbraco.cms.businesslogic.web #endregion #region Protected Methods - [Obsolete("Deprecated", false)] + [Obsolete("Obsolete", false)] protected override void setupNode() { var content = Version == Guid.Empty @@ -1371,7 +1371,7 @@ namespace umbraco.cms.businesslogic.web _published = Content.Published; } - [Obsolete("Deprecated", false)] + [Obsolete("Obsolete", false)] protected void InitializeDocument(User InitUser, User InitWriter, string InitText, int InitTemplate, DateTime InitReleaseDate, DateTime InitExpireDate, DateTime InitUpdateDate, bool InitPublished) @@ -1394,7 +1394,7 @@ namespace umbraco.cms.businesslogic.web _published = InitPublished; } - [Obsolete("Deprecated", false)] + [Obsolete("Obsolete", false)] protected void PopulateDocumentFromReader(IRecordsReader dr) { bool _hc = false; @@ -1437,7 +1437,7 @@ namespace umbraco.cms.businesslogic.web #endregion #region Private Methods - [Obsolete("Deprecated", false)] + [Obsolete("Obsolete", false)] private void SetupDocumentForTree(Guid uniqueId, int level, int parentId, int creator, int writer, bool publish, string path, string text, DateTime createDate, DateTime updateDate, DateTime versionDate, string icon, bool hasChildren, string contentTypeAlias, string contentTypeThumb, From 03b1b34be7126962ea13a586b7430e2f98be59aa Mon Sep 17 00:00:00 2001 From: Stephan Date: Tue, 8 Jan 2013 16:41:31 -0100 Subject: [PATCH 020/188] U4-1411 - fix post-4.9 regression in NotFoundHandler url --- .../Routing/DefaultLastChanceLookup.cs | 52 ++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web/Routing/DefaultLastChanceLookup.cs b/src/Umbraco.Web/Routing/DefaultLastChanceLookup.cs index 4c9b4fa103..674a6e64a4 100644 --- a/src/Umbraco.Web/Routing/DefaultLastChanceLookup.cs +++ b/src/Umbraco.Web/Routing/DefaultLastChanceLookup.cs @@ -46,16 +46,66 @@ namespace Umbraco.Web.Routing //FIXME: this is temporary and should be obsoleted + string GetLegacyUrlForNotFoundHandlers(PublishedContentRequest docRequest) + { + // that's not backward-compatible because when requesting "/foo.aspx" + // 4.9 : url = "foo.aspx" + // 4.10 : url = "/foo" + //return docRequest.Uri.AbsolutePath; + + // so we have to run the legacy code for url preparation :-( + + // code from requestModule.UmbracoRewrite + string tmp = HttpContext.Current.Request.Path.ToLower(); + + // note: requestModule.UmbracoRewrite also does some confusing stuff + // with stripping &umbPage from the querystring?! ignored. + + // code from requestHandler.cleanUrl + string root = Umbraco.Core.IO.SystemDirectories.Root.ToLower(); + if (!string.IsNullOrEmpty(root) && tmp.StartsWith(root)) + tmp = tmp.Substring(root.Length); + tmp = tmp.TrimEnd('/'); + if (tmp == "/default.aspx") + tmp = string.Empty; + else if (tmp == root) + tmp = string.Empty; + + // code from UmbracoDefault.Page_PreInit + if (tmp != "" && HttpContext.Current.Request["umbPageID"] == null) + { + string tryIntParse = tmp.Replace("/", "").Replace(".aspx", string.Empty); + int result; + if (int.TryParse(tryIntParse, out result)) + tmp = tmp.Replace(".aspx", string.Empty); + } + else if (!string.IsNullOrEmpty(HttpContext.Current.Request["umbPageID"])) + { + int result; + if (int.TryParse(HttpContext.Current.Request["umbPageID"], out result)) + { + tmp = HttpContext.Current.Request["umbPageID"]; + } + } + + // code from requestHandler.ctor + if (tmp != "") + tmp = tmp.Substring(1); + + return tmp; + } + IPublishedContent HandlePageNotFound(PublishedContentRequest docRequest) { LogHelper.Debug("Running for url='{0}'.", () => docRequest.Uri.AbsolutePath); //XmlNode currentPage = null; IPublishedContent currentPage = null; + var url = GetLegacyUrlForNotFoundHandlers(docRequest); foreach (var handler in GetNotFoundHandlers()) { - if (handler.Execute(docRequest.Uri.AbsolutePath) && handler.redirectID > 0) + if (handler.Execute(url) && handler.redirectID > 0) { //currentPage = umbracoContent.GetElementById(handler.redirectID.ToString()); currentPage = docRequest.RoutingContext.PublishedContentStore.GetDocumentById( From a24d202efef754b516326b3473b4cbecde0fc6c7 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Tue, 8 Jan 2013 16:46:56 -0100 Subject: [PATCH 021/188] Make sure MySql gets loaded with old AND new connectionstring --- src/umbraco.datalayer/DataLayerHelper.cs | 98 ++++++++++++------- .../umbraco.datalayer.csproj | 1 + 2 files changed, 65 insertions(+), 34 deletions(-) diff --git a/src/umbraco.datalayer/DataLayerHelper.cs b/src/umbraco.datalayer/DataLayerHelper.cs index c17bdd2057..a6f14de0b9 100644 --- a/src/umbraco.datalayer/DataLayerHelper.cs +++ b/src/umbraco.datalayer/DataLayerHelper.cs @@ -7,10 +7,9 @@ ***********************************************************************************/ using System; +using System.Configuration; using System.Data.Common; using System.Reflection; -using umbraco.DataLayer.SqlHelpers.SqlServer; -using umbraco.DataLayer.SqlHelpers.MySql; namespace umbraco.DataLayer { @@ -19,6 +18,8 @@ namespace umbraco.DataLayer /// public class DataLayerHelper { + private static string _dataHelperTypeName; + private static string _dataHelperAssemblyName; #region Private Constants @@ -27,7 +28,7 @@ namespace umbraco.DataLayer /// Name of the default data layer, that is used when nothing is specified. private const string DefaultDataHelperName = "SqlServer"; /// Format used when the SQL helper is qualified by its simple name, instead of the full class name. - private const string DefaultDataHelperFormat = "umbraco.DataLayer.SqlHelpers.{0}.{0}Helper"; + private const string DefaultDataHelperFormat = "umbraco.DataLayer.SqlHelpers.{0}.{0}Helper"; #endregion @@ -41,7 +42,7 @@ namespace umbraco.DataLayer public static ISqlHelper CreateSqlHelper(string connectionString) { /* check arguments */ - if (String.IsNullOrEmpty(connectionString)) + if (string.IsNullOrEmpty(connectionString)) throw new ArgumentNullException("connectionString"); if (IsEmbeddedDatabase(connectionString) && connectionString.ToLower().Contains("SQLCE4Umbraco".ToLower()) == false) @@ -53,8 +54,9 @@ namespace umbraco.DataLayer connectionString = connectionString.Insert(connectionString.LastIndexOf('|') + 1, "\\"); connectionString = string.Format("datalayer=SQLCE4Umbraco.SqlCEHelper,SQLCE4Umbraco;{0}", connectionString); } + /* try to parse connection string */ - DbConnectionStringBuilder connectionStringBuilder = new DbConnectionStringBuilder(); + var connectionStringBuilder = new DbConnectionStringBuilder(); try { connectionStringBuilder.ConnectionString = connectionString; @@ -64,56 +66,49 @@ namespace umbraco.DataLayer throw new ArgumentException("Bad connection string.", "connectionString", ex); } - // get the data layer type and parse it - string datalayerType = String.Empty; - if (connectionStringBuilder.ContainsKey(ConnectionStringDataLayerIdentifier)) - { - datalayerType = connectionStringBuilder[ConnectionStringDataLayerIdentifier].ToString(); - connectionStringBuilder.Remove(ConnectionStringDataLayerIdentifier); - } - - string[] datalayerTypeParts = datalayerType.Split(",".ToCharArray()); - string helperTypeName = datalayerTypeParts[0].Trim(); - string helperAssemblyName = datalayerTypeParts.Length < 2 ? String.Empty - : datalayerTypeParts[1].Trim(); - if (datalayerTypeParts.Length > 2 || (helperTypeName.Length == 0 && helperAssemblyName.Length > 0)) - throw new ArgumentException("Illegal format of data layer property. Should be 'DataLayer = Full_Type_Name [, Assembly_Name]'.", "connectionString"); + var databaseSettings = ConfigurationManager.ConnectionStrings[Umbraco.Core.Configuration.GlobalSettings.UmbracoConnectionName]; + + if (databaseSettings != null) + SetDataHelperNames(databaseSettings.ProviderName); + else + SetDataHelperNamesLegacyConnectionString(connectionStringBuilder); /* create the helper */ - // find the right assembly - Assembly helperAssembly = Assembly.GetExecutingAssembly(); - if (datalayerTypeParts.Length == 2) + var helperAssembly = Assembly.GetExecutingAssembly(); + if (string.IsNullOrWhiteSpace(_dataHelperAssemblyName) == false) { try { - helperAssembly = Assembly.Load(helperAssemblyName); + helperAssembly = Assembly.Load(_dataHelperAssemblyName); } catch (Exception exception) { - throw new UmbracoException(String.Format("Could not load assembly {0}.", helperAssemblyName), exception); + throw new UmbracoException(String.Format("Could not load assembly {0}.", _dataHelperAssemblyName), exception); } } // find the right type Type helperType; - if (helperTypeName == String.Empty) - helperTypeName = DefaultDataHelperName; - if (!helperTypeName.Contains(".")) - helperTypeName = String.Format(DefaultDataHelperFormat, helperTypeName); + if (_dataHelperTypeName == string.Empty) + _dataHelperTypeName = DefaultDataHelperName; + + if (_dataHelperTypeName.Contains(".") == false) + _dataHelperTypeName = string.Format(DefaultDataHelperFormat, _dataHelperTypeName); + try { - helperType = helperAssembly.GetType(helperTypeName, true, true); + helperType = helperAssembly.GetType(_dataHelperTypeName, true, true); } catch (Exception exception) { - throw new UmbracoException(String.Format("Could not load type {0} ({1}).", helperTypeName, helperAssembly.FullName), exception); + throw new UmbracoException(String.Format("Could not load type {0} ({1}).", _dataHelperTypeName, helperAssembly.FullName), exception); } // find the right constructor - ConstructorInfo constructor = helperType.GetConstructor(new Type[] { typeof(string) }); + var constructor = helperType.GetConstructor(new[] { typeof(string) }); if (constructor == null) - throw new UmbracoException(String.Format("Could not find constructor that takes a connection string as parameter. ({0}, {1}).", helperTypeName, helperAssembly.FullName)); + throw new UmbracoException(String.Format("Could not find constructor that takes a connection string as parameter. ({0}, {1}).", _dataHelperTypeName, helperAssembly.FullName)); // finally, return the helper try @@ -122,15 +117,50 @@ namespace umbraco.DataLayer } catch (Exception exception) { - throw new UmbracoException(String.Format("Could not execute constructor of type {0} ({1}).", helperTypeName, helperAssembly.FullName), exception); + throw new UmbracoException(String.Format("Could not execute constructor of type {0} ({1}).", _dataHelperTypeName, helperAssembly.FullName), exception); } } + private static void SetDataHelperNames(string providerName) + { + if (providerName.StartsWith("MySql")) + { + _dataHelperTypeName = "MySql"; + } + + if (providerName.StartsWith("System.Data.SqlServerCe")) + { + _dataHelperTypeName = "SQLCE4Umbraco.SqlCEHelper"; + _dataHelperAssemblyName = "SQLCE4Umbraco"; + } + } + + private static void SetDataHelperNamesLegacyConnectionString(DbConnectionStringBuilder connectionStringBuilder) + { + // get the data layer type and parse it + var datalayerType = String.Empty; + if (connectionStringBuilder.ContainsKey(ConnectionStringDataLayerIdentifier)) + { + datalayerType = connectionStringBuilder[ConnectionStringDataLayerIdentifier].ToString(); + connectionStringBuilder.Remove(ConnectionStringDataLayerIdentifier); + } + + var datalayerTypeParts = datalayerType.Split(",".ToCharArray()); + + _dataHelperTypeName = datalayerTypeParts[0].Trim(); + _dataHelperAssemblyName = datalayerTypeParts.Length < 2 + ? string.Empty + : datalayerTypeParts[1].Trim(); + + if (datalayerTypeParts.Length > 2 || (_dataHelperTypeName.Length == 0 && _dataHelperAssemblyName.Length > 0)) + throw new ArgumentException("Illegal format of data layer property. Should be 'DataLayer = Full_Type_Name [, Assembly_Name]'.", "connectionString"); + } + public static bool IsEmbeddedDatabase(string connectionString) { return connectionString.ToLower().Contains("|DataDirectory|".ToLower()); } #endregion - } + } } diff --git a/src/umbraco.datalayer/umbraco.datalayer.csproj b/src/umbraco.datalayer/umbraco.datalayer.csproj index e0a225bca1..8130c877a4 100644 --- a/src/umbraco.datalayer/umbraco.datalayer.csproj +++ b/src/umbraco.datalayer/umbraco.datalayer.csproj @@ -79,6 +79,7 @@ ..\packages\MySQL.Data.5.1.2.2\lib\MySql.Data.dll
+ 3.5 From daf5fb5dcf6887b89b46c61f1a19aa1f20a0b0be Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Tue, 8 Jan 2013 17:52:03 -0100 Subject: [PATCH 022/188] Fixes U4-1415 v6 Installing on MySQL gives error --- .../Migrations/Initial/DatabaseSchemaCreation.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Core/Persistence/Migrations/Initial/DatabaseSchemaCreation.cs b/src/Umbraco.Core/Persistence/Migrations/Initial/DatabaseSchemaCreation.cs index 4e2f60eb3c..64492dc001 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Initial/DatabaseSchemaCreation.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Initial/DatabaseSchemaCreation.cs @@ -61,6 +61,11 @@ namespace Umbraco.Core.Persistence.Migrations.Initial if (!e.Cancel) { + // MySQL seems to think that this HAS to be the very first table created? + _database.CreateTable(); + _database.CreateTable(); + _database.CreateTable(); + _database.CreateTable(); _database.CreateTable(); @@ -110,10 +115,6 @@ namespace Umbraco.Core.Persistence.Migrations.Initial _database.CreateTable(); _database.CreateTable(); - _database.CreateTable(); - _database.CreateTable(); - _database.CreateTable(); - _database.CreateTable(); _database.CreateTable(); From 1b5970b4462789c9ce2980007a732a0d2e2502e9 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Wed, 9 Jan 2013 05:08:05 -0100 Subject: [PATCH 023/188] D'oh! Forgot to seperate out the connectionstring --- src/umbraco.datalayer/DataLayerHelper.cs | 25 +++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/umbraco.datalayer/DataLayerHelper.cs b/src/umbraco.datalayer/DataLayerHelper.cs index a6f14de0b9..b1ffd1ee92 100644 --- a/src/umbraco.datalayer/DataLayerHelper.cs +++ b/src/umbraco.datalayer/DataLayerHelper.cs @@ -18,9 +18,6 @@ namespace umbraco.DataLayer /// public class DataLayerHelper { - private static string _dataHelperTypeName; - private static string _dataHelperAssemblyName; - #region Private Constants /// Name of the property that identifies the SQL helper type. @@ -30,6 +27,10 @@ namespace umbraco.DataLayer /// Format used when the SQL helper is qualified by its simple name, instead of the full class name. private const string DefaultDataHelperFormat = "umbraco.DataLayer.SqlHelpers.{0}.{0}Helper"; + private static string _dataHelperTypeName; + private static string _dataHelperAssemblyName; + private static string _connectionString; + #endregion #region Public Methods @@ -69,7 +70,7 @@ namespace umbraco.DataLayer var databaseSettings = ConfigurationManager.ConnectionStrings[Umbraco.Core.Configuration.GlobalSettings.UmbracoConnectionName]; if (databaseSettings != null) - SetDataHelperNames(databaseSettings.ProviderName); + SetDataHelperNames(databaseSettings); else SetDataHelperNamesLegacyConnectionString(connectionStringBuilder); @@ -113,7 +114,7 @@ namespace umbraco.DataLayer // finally, return the helper try { - return constructor.Invoke(new object[] { connectionStringBuilder.ConnectionString }) as ISqlHelper; + return constructor.Invoke(new object[] { _connectionString }) as ISqlHelper; } catch (Exception exception) { @@ -121,14 +122,18 @@ namespace umbraco.DataLayer } } - private static void SetDataHelperNames(string providerName) + private static void SetDataHelperNames(ConnectionStringSettings connectionStringSettings) { - if (providerName.StartsWith("MySql")) + _connectionString = connectionStringSettings.ConnectionString; + + var provider = connectionStringSettings.ProviderName; + + if (provider.StartsWith("MySql")) { _dataHelperTypeName = "MySql"; } - - if (providerName.StartsWith("System.Data.SqlServerCe")) + + if (provider.StartsWith("System.Data.SqlServerCe")) { _dataHelperTypeName = "SQLCE4Umbraco.SqlCEHelper"; _dataHelperAssemblyName = "SQLCE4Umbraco"; @@ -145,6 +150,8 @@ namespace umbraco.DataLayer connectionStringBuilder.Remove(ConnectionStringDataLayerIdentifier); } + _connectionString = connectionStringBuilder.ConnectionString; + var datalayerTypeParts = datalayerType.Split(",".ToCharArray()); _dataHelperTypeName = datalayerTypeParts[0].Trim(); From d6121ebab2f5a10ddc45fa9ada5497f39eddfc95 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Wed, 9 Jan 2013 05:15:28 -0100 Subject: [PATCH 024/188] Connectionstrings section used to be after mailsettings, makes merges easier for people who are upgrading --- src/Umbraco.Web.UI/web.Template.config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web.UI/web.Template.config b/src/Umbraco.Web.UI/web.Template.config index 46bf30db34..e09956a823 100644 --- a/src/Umbraco.Web.UI/web.Template.config +++ b/src/Umbraco.Web.UI/web.Template.config @@ -61,8 +61,6 @@ - - @@ -78,6 +76,8 @@ + + From e0ba903974fbe3e43df12316985c6451ef469d5c Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Wed, 9 Jan 2013 05:18:10 -0100 Subject: [PATCH 025/188] Revert ordering of schema creation it only worked once by fluke and killed sqlce --- .../Migrations/Initial/DatabaseSchemaCreation.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Core/Persistence/Migrations/Initial/DatabaseSchemaCreation.cs b/src/Umbraco.Core/Persistence/Migrations/Initial/DatabaseSchemaCreation.cs index 64492dc001..4e2f60eb3c 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Initial/DatabaseSchemaCreation.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Initial/DatabaseSchemaCreation.cs @@ -61,11 +61,6 @@ namespace Umbraco.Core.Persistence.Migrations.Initial if (!e.Cancel) { - // MySQL seems to think that this HAS to be the very first table created? - _database.CreateTable(); - _database.CreateTable(); - _database.CreateTable(); - _database.CreateTable(); _database.CreateTable(); @@ -115,6 +110,10 @@ namespace Umbraco.Core.Persistence.Migrations.Initial _database.CreateTable(); _database.CreateTable(); + _database.CreateTable(); + _database.CreateTable(); + _database.CreateTable(); + _database.CreateTable(); _database.CreateTable(); From 4553fcedeb4e430a2d2e33fb50fbb02a8b5aed7d Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Wed, 9 Jan 2013 05:40:52 -0100 Subject: [PATCH 026/188] Remove comments/courier from dev dashboard config --- src/Umbraco.Web.UI/config/Dashboard.config | 30 ++++------------------ 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/src/Umbraco.Web.UI/config/Dashboard.config b/src/Umbraco.Web.UI/config/Dashboard.config index 3a7440a233..e4c09f3efd 100644 --- a/src/Umbraco.Web.UI/config/Dashboard.config +++ b/src/Umbraco.Web.UI/config/Dashboard.config @@ -60,7 +60,11 @@ /umbraco/dashboard/startupdashboardkits.ascx - editorwriter + + editor + writer + + /umbraco/dashboard/startupdashboardvideos.ascx @@ -88,14 +92,6 @@ -
- - courier - - - /umbraco/plugins/courier/dashboard/CourierDashboard.ascx - -
developer @@ -104,20 +100,4 @@ /umbraco/plugins/uGoLive/Dashboard.ascx
-
- - content - - - /usercontrols/blog/CommentModeration.ascx - -
-
- - content - - - /usercontrols/blog/CommentModeration.ascx - -
\ No newline at end of file From b8d5d67abd24a22a52734d2da627f8a16c972db9 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Wed, 9 Jan 2013 05:51:01 -0100 Subject: [PATCH 027/188] Additional fix for U4-1394 - DocumentType "Allowed Templates" will not update --- .../Persistence/Repositories/ContentTypeRepository.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentTypeRepository.cs index 48845b2573..7b5a510893 100644 --- a/src/Umbraco.Core/Persistence/Repositories/ContentTypeRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/ContentTypeRepository.cs @@ -37,6 +37,10 @@ namespace Umbraco.Core.Persistence.Repositories var contentTypeSql = GetBaseQuery(false); contentTypeSql.Where(GetBaseWhereClause(), new { Id = id }); + // The SQL will contain one record for each allowed template, so order to put the default one + // at the top to populate the default template property correctly. + contentTypeSql.OrderByDescending(x => x.IsDefault); + var dto = Database.Query(contentTypeSql).FirstOrDefault(); if (dto == null) @@ -114,7 +118,6 @@ namespace Umbraco.Core.Persistence.Repositories protected override Sql GetBaseQuery(bool isCount) { - //TODO Investigate the proper usage of IsDefault on cmsDocumentType var sql = new Sql(); sql.Select(isCount ? "COUNT(*)" : "*") .From() From 65dd21fafcf49d28c3dfd4cc082404760b1cb054 Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Wed, 9 Jan 2013 07:30:57 -0100 Subject: [PATCH 028/188] Test and possible fix for U4-1392 --- src/Umbraco.Tests/LegacyApi/MediaTypeTests.cs | 45 +++++++++++++++++++ .../businesslogic/media/MediaType.cs | 1 + 2 files changed, 46 insertions(+) diff --git a/src/Umbraco.Tests/LegacyApi/MediaTypeTests.cs b/src/Umbraco.Tests/LegacyApi/MediaTypeTests.cs index 6f55b1630f..2d187b35f6 100644 --- a/src/Umbraco.Tests/LegacyApi/MediaTypeTests.cs +++ b/src/Umbraco.Tests/LegacyApi/MediaTypeTests.cs @@ -3,6 +3,8 @@ using System.Linq; using NUnit.Framework; using Umbraco.Tests.TestHelpers; using Umbraco.Tests.TestHelpers.Entities; +using umbraco.BusinessLogic; +using umbraco.cms.businesslogic.datatype; using umbraco.cms.businesslogic.media; namespace Umbraco.Tests.LegacyApi @@ -37,6 +39,49 @@ namespace Umbraco.Tests.LegacyApi Assert.That(updated.AllowedChildContentTypeIDs.Any(x => x == 1045), Is.True); } + [Test] + public void Can_Set_Tab_On_PropertyType() + { + var UPLOAD_DATATYPE_ID = -90; + var CROP_DATATYPE_ID = 1043; + var LABEL_DATATYPE_ID = -92; + var mediaTypeName = "ImageWide"; + + MediaType mediaType = MediaType.MakeNew(new User(0), mediaTypeName); + + int imageTab = mediaType.AddVirtualTab("Image"); + int cropTab = mediaType.AddVirtualTab("Crop"); + + mediaType.AddPropertyType(new DataTypeDefinition(UPLOAD_DATATYPE_ID), "umbracoFile", "Upload image"); + mediaType.AddPropertyType(new DataTypeDefinition(LABEL_DATATYPE_ID), "umbracoWidth", "Width"); + mediaType.AddPropertyType(new DataTypeDefinition(LABEL_DATATYPE_ID), "umbracoHeight", "Height"); + mediaType.AddPropertyType(new DataTypeDefinition(LABEL_DATATYPE_ID), "umbracoBytes", "Size"); + mediaType.AddPropertyType(new DataTypeDefinition(LABEL_DATATYPE_ID), "umbracoExtension", "Type"); + mediaType.AddPropertyType(new DataTypeDefinition(CROP_DATATYPE_ID), "wideImage", "Wide image"); + + mediaType.SetTabOnPropertyType(mediaType.getPropertyType("umbracoFile"), imageTab); + mediaType.SetTabOnPropertyType(mediaType.getPropertyType("umbracoWidth"), imageTab); + mediaType.SetTabOnPropertyType(mediaType.getPropertyType("umbracoHeight"), imageTab); + mediaType.SetTabOnPropertyType(mediaType.getPropertyType("umbracoBytes"), imageTab); + mediaType.SetTabOnPropertyType(mediaType.getPropertyType("umbracoExtension"), imageTab); + mediaType.SetTabOnPropertyType(mediaType.getPropertyType("wideImage"), cropTab); + + mediaType.Text = mediaTypeName; + mediaType.IconUrl = "mediaPhoto.gif"; + mediaType.Save(); + + Assert.That(mediaType.getVirtualTabs.Count(), Is.EqualTo(2)); + Assert.That(mediaType.getVirtualTabs.Any(x => x.Caption.Equals("Image")), Is.True); + Assert.That(mediaType.getVirtualTabs.Any(x => x.Caption.Equals("Crop")), Is.True); + + var updated = new MediaType(mediaType.Id); + Assert.That(updated.getVirtualTabs.Count(), Is.EqualTo(2)); + Assert.That(updated.getVirtualTabs.Any(x => x.Caption.Equals("Image")), Is.True); + Assert.That(updated.getVirtualTabs.Any(x => x.Caption.Equals("Crop")), Is.True); + Assert.That(updated.ContentTypeItem.PropertyGroups.Count(), Is.EqualTo(2)); + Assert.That(updated.ContentTypeItem.PropertyTypes.Count(), Is.EqualTo(6)); + } + public void CreateTestData() { //Create and Save ContentType "video" -> 1045 diff --git a/src/umbraco.cms/businesslogic/media/MediaType.cs b/src/umbraco.cms/businesslogic/media/MediaType.cs index 5225972e79..2adc4f1ee4 100644 --- a/src/umbraco.cms/businesslogic/media/MediaType.cs +++ b/src/umbraco.cms/businesslogic/media/MediaType.cs @@ -118,6 +118,7 @@ namespace umbraco.cms.businesslogic.media //Ensure that MediaTypes are reloaded from db by clearing cache InMemoryCacheProvider.Current.Clear(); + RuntimeCacheProvider.Current.Clear(); base.Save(); From ad2a82cc65781ce7743e952df207a5ecad67727e Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Wed, 9 Jan 2013 09:57:01 -0100 Subject: [PATCH 029/188] Possible fix for U4-1407 and related to the install problems for uBlogsy. Ensures that PropertyGroups are sorted so they are properly mapped. --- .../Persistence/Repositories/ContentTypeBaseRepository.cs | 3 ++- src/umbraco.cms/businesslogic/Content.cs | 8 ++++++-- src/umbraco.cms/businesslogic/Packager/Installer.cs | 2 +- src/umbraco.cms/businesslogic/web/Document.cs | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs index 68f9a4ad3b..dcb9623336 100644 --- a/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs @@ -238,7 +238,8 @@ namespace Umbraco.Core.Persistence.Repositories .On(left => left.Id, right => right.PropertyTypeGroupId) .InnerJoin() .On(left => left.DataTypeId, right => right.DataTypeId) - .Where(x => x.ContentTypeId == id); + .Where(x => x.ContentTypeId == id) + .OrderBy(x => x.PropertyTypeGroupId); var dtos = Database.Fetch(new GroupPropertyTypeRelator().Map, sql); diff --git a/src/umbraco.cms/businesslogic/Content.cs b/src/umbraco.cms/businesslogic/Content.cs index 7b3e966874..dec30c8c05 100644 --- a/src/umbraco.cms/businesslogic/Content.cs +++ b/src/umbraco.cms/businesslogic/Content.cs @@ -677,9 +677,13 @@ namespace umbraco.cms.businesslogic continue; //get the propertyId - var property = propData.LastOrDefault(x => x.PropertyTypeId == pt.Id); + var property = propData.SingleOrDefault(x => x.PropertyTypeId == pt.Id); if (property == null) - continue; + { + //continue; + var prop = Property.MakeNew(pt, this, Version); + property = new {Id = prop.Id, PropertyTypeId = pt.Id}; + } var propertyId = property.Id; Property p = null; diff --git a/src/umbraco.cms/businesslogic/Packager/Installer.cs b/src/umbraco.cms/businesslogic/Packager/Installer.cs index 07b3dfced5..9ab0287ca6 100644 --- a/src/umbraco.cms/businesslogic/Packager/Installer.cs +++ b/src/umbraco.cms/businesslogic/Packager/Installer.cs @@ -425,7 +425,7 @@ namespace umbraco.cms.businesslogic.packager for (int i = 0; i < allowed.Count; i++) adt[i] = (int)allowed[i]; dt.AllowedChildContentTypeIDs = adt; - + dt.Save(); //PPH we log the document type install here. insPack.Data.Documenttypes.Add(dt.Id.ToString()); saveNeeded = true; diff --git a/src/umbraco.cms/businesslogic/web/Document.cs b/src/umbraco.cms/businesslogic/web/Document.cs index 4c87c895cc..1f58d36046 100644 --- a/src/umbraco.cms/businesslogic/web/Document.cs +++ b/src/umbraco.cms/businesslogic/web/Document.cs @@ -1612,7 +1612,7 @@ namespace umbraco.cms.businesslogic.web { if (AfterSave != null) { - AfterSave(this, e); + AfterSave(new Document(this.Id), e); } } From 87017d75be4dbaf9162df7225624d45d90dc256e Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Wed, 9 Jan 2013 10:11:23 -0100 Subject: [PATCH 030/188] Adding sorting to other usages of PetaPoco relators. Fixing Mapper test after having renamed a few properties yesterday. --- .../Persistence/Repositories/ContentTypeBaseRepository.cs | 3 ++- .../Persistence/Repositories/DictionaryRepository.cs | 6 ++++-- .../Persistence/Mappers/PropertyTypeMapperTest.cs | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs index dcb9623336..c5c32f8c01 100644 --- a/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs @@ -40,7 +40,8 @@ namespace Umbraco.Core.Persistence.Repositories .RightJoin() .On(left => left.Id, right => right.PropertyTypeGroupId) .InnerJoin() - .On(left => left.DataTypeId, right => right.DataTypeId); + .On(left => left.DataTypeId, right => right.DataTypeId) + .OrderBy(x => x.PropertyTypeGroupId); var translator = new SqlTranslator(sqlClause, query); var sql = translator.Translate(); diff --git a/src/Umbraco.Core/Persistence/Repositories/DictionaryRepository.cs b/src/Umbraco.Core/Persistence/Repositories/DictionaryRepository.cs index a69fe73149..a0f712daee 100644 --- a/src/Umbraco.Core/Persistence/Repositories/DictionaryRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/DictionaryRepository.cs @@ -35,8 +35,9 @@ namespace Umbraco.Core.Persistence.Repositories protected override IDictionaryItem PerformGet(int id) { - var sql = GetBaseQuery(false); - sql.Where(GetBaseWhereClause(), new { Id = id }); + var sql = GetBaseQuery(false) + .Where(GetBaseWhereClause(), new {Id = id}) + .OrderBy(x => x.UniqueId); var dto = Database.Fetch(new DictionaryLanguageTextRelator().Map, sql).FirstOrDefault(); if (dto == null) @@ -81,6 +82,7 @@ namespace Umbraco.Core.Persistence.Repositories protected override IEnumerable PerformGetByQuery(IQuery query) { var sqlClause = GetBaseQuery(false); + sqlClause.OrderBy(x => x.UniqueId); var translator = new SqlTranslator(sqlClause, query); var sql = translator.Translate(); diff --git a/src/Umbraco.Tests/Persistence/Mappers/PropertyTypeMapperTest.cs b/src/Umbraco.Tests/Persistence/Mappers/PropertyTypeMapperTest.cs index a45cf065e2..f7bfbd71ad 100644 --- a/src/Umbraco.Tests/Persistence/Mappers/PropertyTypeMapperTest.cs +++ b/src/Umbraco.Tests/Persistence/Mappers/PropertyTypeMapperTest.cs @@ -34,13 +34,13 @@ namespace Umbraco.Tests.Persistence.Mappers } [Test] - public void Can_Map_DataTypeId_Property() + public void Can_Map_DataTypeDefinitionId_Property() { // Arrange SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider; // Act - string column = PropertyTypeMapper.Instance.Map("DataTypeId"); + string column = PropertyTypeMapper.Instance.Map("DataTypeDefinitionId"); // Assert Assert.That(column, Is.EqualTo("[cmsPropertyType].[dataTypeId]")); @@ -66,7 +66,7 @@ namespace Umbraco.Tests.Persistence.Mappers SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider; // Act - string column = PropertyTypeMapper.Instance.Map("DataTypeControlId"); + string column = PropertyTypeMapper.Instance.Map("DataTypeId"); // Assert Assert.That(column, Is.EqualTo("[cmsDataType].[controlId]")); From 8a5e61bb266b8b6e0379766425fb4c36091f4e28 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Wed, 9 Jan 2013 10:43:12 -0100 Subject: [PATCH 031/188] Check if the _dataHelperTypeName is null --- src/umbraco.datalayer/DataLayerHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/umbraco.datalayer/DataLayerHelper.cs b/src/umbraco.datalayer/DataLayerHelper.cs index b1ffd1ee92..07a91901aa 100644 --- a/src/umbraco.datalayer/DataLayerHelper.cs +++ b/src/umbraco.datalayer/DataLayerHelper.cs @@ -91,7 +91,7 @@ namespace umbraco.DataLayer // find the right type Type helperType; - if (_dataHelperTypeName == string.Empty) + if (string.IsNullOrWhiteSpace(_dataHelperTypeName)) _dataHelperTypeName = DefaultDataHelperName; if (_dataHelperTypeName.Contains(".") == false) From db971bb0b90d12b0915255b8969c8d560a7f034a Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Wed, 9 Jan 2013 11:44:30 -0100 Subject: [PATCH 032/188] Fixes U4-1418 caused by a size issue in PetaPoco when inserting a string larger then 4000 characters. --- src/Umbraco.Core/Persistence/PetaPoco.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Core/Persistence/PetaPoco.cs b/src/Umbraco.Core/Persistence/PetaPoco.cs index d60525a91c..aa531a7c62 100644 --- a/src/Umbraco.Core/Persistence/PetaPoco.cs +++ b/src/Umbraco.Core/Persistence/PetaPoco.cs @@ -424,7 +424,14 @@ namespace Umbraco.Core.Persistence } else if (t == typeof(string)) { - p.Size = Math.Max((item as string).Length + 1, 4000); // Help query plan caching by using common size + // out of memory exception occurs if trying to save more than 4000 characters to SQL Server CE NText column. Set before attempting to set Size, or Size will always max out at 4000 + if ((item as string).Length + 1 > 4000 && p.GetType().Name == "SqlCeParameter") + p.GetType().GetProperty("SqlDbType").SetValue(p, SqlDbType.NText, null); + + p.Size = (item as string).Length + 1; + if(p.Size < 4000) + p.Size = Math.Max((item as string).Length + 1, 4000); // Help query plan caching by using common size + p.Value = item; } else if (t == typeof(AnsiString)) From 0c7473717cf7e214200a7e5567406628e91a56b3 Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Wed, 9 Jan 2013 12:32:40 -0100 Subject: [PATCH 033/188] Fixes U4-1386 structure problem where the same DocType would show up multiple times. Re-wired the tree to use the new api as its simply used for loading availab doc types. --- .../umbraco/Trees/BaseTree.cs | 10 ++++ .../umbraco/Trees/loadMediaTypes.cs | 27 +++++++--- .../umbraco/Trees/loadNodeTypes.cs | 49 +++++++------------ 3 files changed, 48 insertions(+), 38 deletions(-) diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/BaseTree.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/BaseTree.cs index f48fcae70a..464d2f439e 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/BaseTree.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/BaseTree.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.ComponentModel; using System.Text; using System.Xml; +using Umbraco.Core; +using Umbraco.Core.Services; using umbraco.BusinessLogic; using umbraco.BusinessLogic.Actions; using umbraco.interfaces; @@ -192,6 +194,14 @@ namespace umbraco.cms.presentation.Trees private XmlTree m_xTree = new XmlTree(); + /// + /// Provides easy access to the ServiceContext + /// + protected internal ServiceContext Services + { + get { return ApplicationContext.Current.Services; } + } + /// /// Initializes the class if it hasn't been done already /// diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/loadMediaTypes.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/loadMediaTypes.cs index 670f180228..1971afec3b 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/loadMediaTypes.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/loadMediaTypes.cs @@ -1,7 +1,8 @@ using System; +using System.Globalization; using System.Text; +using Umbraco.Core.Services; using umbraco.businesslogic; -using umbraco.cms.businesslogic.media; using umbraco.cms.presentation.Trees; namespace umbraco @@ -29,14 +30,25 @@ function openMediaType(id) { public override void Render(ref XmlTree tree) { - foreach (var dt in MediaType.GetAllAsList()) + var mediaTypes = Service.GetMediaTypeChildren(base.m_id); + + foreach (var mediaType in mediaTypes) { + var hasChildren = Service.MediaTypeHasChildren(mediaType.Id); + XmlTreeNode xNode = XmlTreeNode.Create(this); - xNode.NodeID = dt.Id.ToString(); - xNode.Text = dt.Text; - xNode.Action = string.Format("javascript:openMediaType({0});", dt.Id); + xNode.NodeID = mediaType.Id.ToString(CultureInfo.InvariantCulture); + xNode.Text = mediaType.Name; + xNode.Action = string.Format("javascript:openMediaType({0});", mediaType.Id); xNode.Icon = "settingDataType.gif"; xNode.OpenIcon = "settingDataType.gif"; + xNode.Source = GetTreeServiceUrl(mediaType.Id); + xNode.HasChildren = hasChildren; + if (hasChildren) + { + xNode.Icon = "settingMasterDataType.gif"; + xNode.OpenIcon = "settingMasterDataType.gif"; + } OnBeforeNodeRender(ref tree, ref xNode, EventArgs.Empty); if (xNode != null) @@ -48,6 +60,9 @@ function openMediaType(id) { } } + private IContentTypeService Service + { + get { return Services.ContentTypeService; } + } } - } diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/loadNodeTypes.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/loadNodeTypes.cs index a54ca203a9..8a0b143521 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/loadNodeTypes.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/loadNodeTypes.cs @@ -1,28 +1,11 @@ using System; -using System.Collections; using System.Collections.Generic; -using System.Data; -using System.IO; +using System.Globalization; using System.Text; -using System.Web; -using System.Xml; -using System.Configuration; -using umbraco.BasePages; -using umbraco.BusinessLogic; +using Umbraco.Core.Services; using umbraco.businesslogic; -using umbraco.cms.businesslogic; -using umbraco.cms.businesslogic.cache; -using umbraco.cms.businesslogic.contentitem; -using umbraco.cms.businesslogic.datatype; -using umbraco.cms.businesslogic.language; -using umbraco.cms.businesslogic.media; -using umbraco.cms.businesslogic.member; -using umbraco.cms.businesslogic.property; -using umbraco.cms.businesslogic.web; using umbraco.interfaces; -using umbraco.DataLayer; using umbraco.BusinessLogic.Actions; -using umbraco.BusinessLogic.Utils; using umbraco.cms.presentation.Trees; @@ -74,23 +57,22 @@ function openNodeType(id) { public override void Render(ref XmlTree tree) { - List docTypes; - docTypes = base.m_id == -1 - ? DocumentType.GetAllAsList().FindAll(dt => dt.MasterContentType == 0) - : DocumentType.GetAllAsList().FindAll(dt => dt.MasterContentTypes.Contains(base.m_id)); + var docTypes = Service.GetContentTypeChildren(base.m_id); - - foreach (DocumentType dt in docTypes) + foreach (var docType in docTypes) { + var hasChildren = Service.HasChildren(docType.Id); + XmlTreeNode xNode = XmlTreeNode.Create(this); - xNode.NodeID = dt.Id.ToString(); - xNode.Text = dt.Text; - xNode.Action = "javascript:openNodeType(" + dt.Id + ");"; + xNode.NodeID = docType.Id.ToString(CultureInfo.InvariantCulture); + xNode.Text = docType.Name; + xNode.Action = "javascript:openNodeType(" + docType.Id + ");"; xNode.Icon = "settingDataType.gif"; xNode.OpenIcon = "settingDataType.gif"; - xNode.Source = GetTreeServiceUrl(dt.Id); - xNode.HasChildren = dt.HasChildren; - if (dt.HasChildren) { + xNode.Source = GetTreeServiceUrl(docType.Id); + xNode.HasChildren = hasChildren; + if (hasChildren) + { xNode.Icon = "settingMasterDataType.gif"; xNode.OpenIcon = "settingMasterDataType.gif"; } @@ -101,9 +83,12 @@ function openNodeType(id) { tree.Add(xNode); OnAfterNodeRender(ref tree, ref xNode, EventArgs.Empty); } - } } + private IContentTypeService Service + { + get { return Services.ContentTypeService; } + } } } From 03e7a5a80b4557d6d2091b17eac8bec956aa2f11 Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Wed, 9 Jan 2013 13:29:32 -0100 Subject: [PATCH 034/188] A bit of tidy up related to the content typoe trees. The PropertyFactory contained an issue for MediaTypes similar to the one that existed for ContentTypes. --- .../Persistence/Factories/PropertyFactory.cs | 12 +++++++---- .../umbraco/config/create/UI.Release.xml | 2 ++ .../umbraco/config/create/UI.xml | 2 ++ .../umbraco/Trees/loadMediaTypes.cs | 11 ++++++++++ .../umbraco/create/MediaTypeTasks.cs | 12 +++++++++-- .../umbraco/create/nodetypeTasks.cs | 2 +- .../umbraco/create/simple.ascx.cs | 20 ++++++++----------- .../businesslogic/media/MediaType.cs | 16 ++++++++++++++- 8 files changed, 57 insertions(+), 20 deletions(-) diff --git a/src/Umbraco.Core/Persistence/Factories/PropertyFactory.cs b/src/Umbraco.Core/Persistence/Factories/PropertyFactory.cs index 0ab8136d3e..886b9007da 100644 --- a/src/Umbraco.Core/Persistence/Factories/PropertyFactory.cs +++ b/src/Umbraco.Core/Persistence/Factories/PropertyFactory.cs @@ -101,10 +101,14 @@ namespace Umbraco.Core.Persistence.Factories var properties = new List(); foreach (var dto in dtos) { - var propertyType = _mediaType.PropertyTypes.FirstOrDefault(x => x.Id == dto.PropertyTypeId); - var property = propertyType.CreatePropertyFromRawValue(dto.GetValue, dto.VersionId.Value, dto.Id); - property.ResetDirtyProperties(); - properties.Add(property); + if (_mediaType.CompositionPropertyTypes.Any(x => x.Id == dto.PropertyTypeId)) + { + var propertyType = _mediaType.CompositionPropertyTypes.First(x => x.Id == dto.PropertyTypeId); + var property = propertyType.CreatePropertyFromRawValue(dto.GetValue, dto.VersionId.Value, dto.Id); + + property.ResetDirtyProperties(); + properties.Add(property); + } } return properties; } diff --git a/src/Umbraco.Web.UI/umbraco/config/create/UI.Release.xml b/src/Umbraco.Web.UI/umbraco/config/create/UI.Release.xml index c9b51953be..b03071a85d 100644 --- a/src/Umbraco.Web.UI/umbraco/config/create/UI.Release.xml +++ b/src/Umbraco.Web.UI/umbraco/config/create/UI.Release.xml @@ -134,7 +134,9 @@
Medie type
+ /create/simple.ascx +
diff --git a/src/Umbraco.Web.UI/umbraco/config/create/UI.xml b/src/Umbraco.Web.UI/umbraco/config/create/UI.xml index fd6c68fd4d..fcd9e09e51 100644 --- a/src/Umbraco.Web.UI/umbraco/config/create/UI.xml +++ b/src/Umbraco.Web.UI/umbraco/config/create/UI.xml @@ -134,7 +134,9 @@
Medie type
+ /create/simple.ascx +
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/loadMediaTypes.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/loadMediaTypes.cs index 1971afec3b..572ec9f013 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/loadMediaTypes.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/loadMediaTypes.cs @@ -1,9 +1,12 @@ using System; +using System.Collections.Generic; using System.Globalization; using System.Text; using Umbraco.Core.Services; +using umbraco.BusinessLogic.Actions; using umbraco.businesslogic; using umbraco.cms.presentation.Trees; +using umbraco.interfaces; namespace umbraco { @@ -18,6 +21,14 @@ namespace umbraco rootNode.NodeID = "init"; } + protected override void CreateAllowedActions(ref List actions) + { + actions.Clear(); + actions.Add(ActionNew.Instance); + actions.Add(ContextMenuSeperator.Instance); + actions.Add(ActionDelete.Instance); + } + public override void RenderJS(ref StringBuilder Javascript) { Javascript.Append( diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/create/MediaTypeTasks.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/create/MediaTypeTasks.cs index 269215d8fc..df96c8a249 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/create/MediaTypeTasks.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/create/MediaTypeTasks.cs @@ -42,8 +42,16 @@ namespace umbraco public bool Save() { - int id = cms.businesslogic.media.MediaType.MakeNew(BusinessLogic.User.GetUser(_userID), Alias.Replace("'", "''")).Id; - m_returnUrl = string.Format("settings/editMediaType.aspx?id={0}", id); + var mediaType = cms.businesslogic.media.MediaType.MakeNew(User.GetUser(_userID), Alias.Replace("'", "''"), + ParentID); + + if (ParentID != -1) + { + mediaType.MasterContentType = ParentID; + mediaType.Save(); + } + + m_returnUrl = string.Format("settings/editMediaType.aspx?id={0}", mediaType.Id); return true; } diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/create/nodetypeTasks.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/create/nodetypeTasks.cs index d355c8b1c0..569930ad06 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/create/nodetypeTasks.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/create/nodetypeTasks.cs @@ -42,7 +42,7 @@ namespace umbraco public bool Save() { - cms.businesslogic.web.DocumentType dt = cms.businesslogic.web.DocumentType.MakeNew(BusinessLogic.User.GetUser(_userID), Alias.Replace("'", "''")); + var dt = cms.businesslogic.web.DocumentType.MakeNew(BusinessLogic.User.GetUser(_userID), Alias.Replace("'", "''")); dt.IconUrl = "folder.gif"; // Create template? diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/create/simple.ascx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/create/simple.ascx.cs index 8c3c56d370..310948c5e7 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/create/simple.ascx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/create/simple.ascx.cs @@ -1,16 +1,9 @@ +using System; +using umbraco.BasePages; + namespace umbraco.cms.presentation.create.controls { - using System; - using System.Data; - using System.Drawing; - using System.Web; - using System.Web.UI.WebControls; - using System.Web.UI.HtmlControls; - using umbraco.cms.helpers; - using umbraco.BasePages; - using umbraco.BusinessLogic; - - /// + /// /// Summary description for simple. /// public partial class simple : System.Web.UI.UserControl @@ -46,7 +39,10 @@ namespace umbraco.cms.presentation.create.controls { if (Page.IsValid) { - int nodeId = -1; + int nodeId; + if (int.TryParse(Request.QueryString["nodeId"], out nodeId) == false) + nodeId = -1; + if (umbraco.helper.Request("nodeId") != "init") nodeId = int.Parse(umbraco.helper.Request("nodeId")); diff --git a/src/umbraco.cms/businesslogic/media/MediaType.cs b/src/umbraco.cms/businesslogic/media/MediaType.cs index d49085f091..50102c175d 100644 --- a/src/umbraco.cms/businesslogic/media/MediaType.cs +++ b/src/umbraco.cms/businesslogic/media/MediaType.cs @@ -92,7 +92,12 @@ namespace umbraco.cms.businesslogic.media [Obsolete("Obsolete, Use Umbraco.Core.Models.MediaType and Umbraco.Core.Services.ContentTypeService.Save()", false)] public static MediaType MakeNew(BusinessLogic.User u, string Text) { - var mediaType = new Umbraco.Core.Models.MediaType(-1) { Name = Text, Alias = Text, CreatorId = u.Id, Thumbnail = "folder.png", Icon = "folder.gif" }; + return MakeNew(u, Text, -1); + } + + internal static MediaType MakeNew(BusinessLogic.User u, string text, int parentId) + { + var mediaType = new Umbraco.Core.Models.MediaType(parentId) { Name = text, Alias = text, CreatorId = u.Id, Thumbnail = "folder.png", Icon = "folder.gif" }; ApplicationContext.Current.Services.ContentTypeService.Save(mediaType, u.Id); var mt = new MediaType(mediaType.Id); @@ -114,6 +119,15 @@ namespace umbraco.cms.businesslogic.media if (!e.Cancel) { + if (MasterContentType != 0) + _mediaType.ParentId = MasterContentType; + + foreach (var masterContentType in MasterContentTypes) + { + var contentType = ApplicationContext.Current.Services.ContentTypeService.GetMediaType(masterContentType); + _mediaType.AddContentType(contentType); + } + ApplicationContext.Current.Services.ContentTypeService.Save(_mediaType); //Ensure that MediaTypes are reloaded from db by clearing cache From ce6711b587856f6218dff0dbfb32c3ab82132a9a Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Wed, 9 Jan 2013 13:58:55 -0100 Subject: [PATCH 035/188] Duplicate fix (ce2f47c11322) #U4-1366 - conflict with partial view macro engine. --- .../Macros/PartialViewMacroEngine.cs | 29 ++++++++---- .../businesslogic/macro/MacroEngineFactory.cs | 45 ++++++++++++++++--- 2 files changed, 59 insertions(+), 15 deletions(-) diff --git a/src/Umbraco.Web/Macros/PartialViewMacroEngine.cs b/src/Umbraco.Web/Macros/PartialViewMacroEngine.cs index 28e558e358..2b56940e4c 100644 --- a/src/Umbraco.Web/Macros/PartialViewMacroEngine.cs +++ b/src/Umbraco.Web/Macros/PartialViewMacroEngine.cs @@ -57,14 +57,27 @@ namespace Umbraco.Web.Macros { get { return EngineName; } } - public IEnumerable SupportedExtensions - { - get { return new[] {"cshtml", "vbhtml"}; } - } - public IEnumerable SupportedUIExtensions - { - get { return new[] { "cshtml", "vbhtml" }; } - } + + //NOTE: We do not return any supported extensions because we don't want the MacroEngineFactory to return this + // macro engine when searching for engines via extension. Those types of engines are reserved for files that are + // stored in the ~/macroScripts folder and each engine must support unique extensions. This is a total Hack until + // we rewrite how macro engines work. + public IEnumerable SupportedExtensions + { + get { return Enumerable.Empty(); } + //get { return new[] {"cshtml", "vbhtml"}; } + } + + //NOTE: We do not return any supported extensions because we don't want the MacroEngineFactory to return this + // macro engine when searching for engines via extension. Those types of engines are reserved for files that are + // stored in the ~/macroScripts folder and each engine must support unique extensions. This is a total Hack until + // we rewrite how macro engines work. + public IEnumerable SupportedUIExtensions + { + get { return Enumerable.Empty(); } + //get { return new[] { "cshtml", "vbhtml" }; } + } + public Dictionary SupportedProperties { get { throw new NotSupportedException(); } diff --git a/src/umbraco.cms/businesslogic/macro/MacroEngineFactory.cs b/src/umbraco.cms/businesslogic/macro/MacroEngineFactory.cs index aab0899de2..961261b0c3 100644 --- a/src/umbraco.cms/businesslogic/macro/MacroEngineFactory.cs +++ b/src/umbraco.cms/businesslogic/macro/MacroEngineFactory.cs @@ -49,25 +49,56 @@ namespace umbraco.cms.businesslogic.macro EnsureInitialize(); } - public static IEnumerable GetSupportedLanguages() { + /// + /// Returns a collectino of MacroEngineLanguage objects, each of which describes a file extension and an associated macro engine + /// + /// + /// + /// Until the macro engines are rewritten, this method explicitly ignores the PartialViewMacroEngine because this method + /// is essentially just used for any macro engine that stores it's files in the ~/macroScripts folder where file extensions + /// cannot overlap. + /// + [Obsolete("This method is not used and will be removed from the codebase in the future")] + public static IEnumerable GetSupportedLanguages() + { var languages = new List(); - foreach(var engine in GetAll()) { - foreach(string lang in engine.SupportedExtensions) + foreach (var engine in GetAll()) + { + foreach (string lang in engine.SupportedExtensions) + { if (languages.Find(t => t.Extension == lang) == null) + { languages.Add(new MacroEngineLanguage(lang, engine.Name)); + } + } } return languages; } - public static IEnumerable GetSupportedUILanguages() { + /// + /// Returns a collectino of MacroEngineLanguage objects, each of which describes a file extension and an associated macro engine that + /// supports file extension lookups. + /// + /// + /// + /// The PartialViewMacroEngine will never be returned in these results because it does not support searching by file extensions. See + /// the notes in the PartialViewMacroEngine regarding this. + /// + public static IEnumerable GetSupportedUILanguages() + { var languages = new List(); - foreach (var engine in GetAll()) { + foreach (var engine in GetAll()) + { foreach (string lang in engine.SupportedUIExtensions) - if (languages.Find(t => t.Extension == lang) == null) + { + if (languages.All(t => t.Extension != lang)) + { languages.Add(new MacroEngineLanguage(lang, engine.Name)); + } + } } return languages.OrderBy(s => s.Extension); - } + } public static List GetAll() { From dc158fee2e27ecb9566506bcddd7ad901790b1d7 Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Wed, 9 Jan 2013 14:37:54 -0100 Subject: [PATCH 036/188] Fixes U4-1393 so Tabs shows as expected on both Content- and MediaTypes. Corrected malformed query for PropertyGroups. --- .../Persistence/Factories/PropertyGroupFactory.cs | 6 ++++-- .../Persistence/Repositories/ContentTypeBaseRepository.cs | 8 ++++---- src/Umbraco.Web/Umbraco.Web.csproj | 4 +++- .../umbraco/controls/ContentTypeControlNew.ascx.cs | 2 +- src/umbraco.cms/businesslogic/ContentType.cs | 4 ++++ 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/Umbraco.Core/Persistence/Factories/PropertyGroupFactory.cs b/src/Umbraco.Core/Persistence/Factories/PropertyGroupFactory.cs index 5653f0f86b..5ec7f12292 100644 --- a/src/Umbraco.Core/Persistence/Factories/PropertyGroupFactory.cs +++ b/src/Umbraco.Core/Persistence/Factories/PropertyGroupFactory.cs @@ -28,7 +28,9 @@ namespace Umbraco.Core.Persistence.Factories group.SortOrder = groupDto.SortOrder; group.PropertyTypes = new PropertyTypeCollection(); - foreach (var typeDto in groupDto.PropertyTypeDtos) + //Because we are likely to have a group with no PropertyTypes we need to ensure that these are excluded + var typeDtos = groupDto.PropertyTypeDtos.Where(x => x.Id > 0); + foreach (var typeDto in typeDtos) { group.PropertyTypes.Add(new PropertyType(typeDto.DataTypeDto.ControlId, typeDto.DataTypeDto.DbType.EnumParse(true)) @@ -53,7 +55,7 @@ namespace Umbraco.Core.Persistence.Factories public IEnumerable BuildDto(IEnumerable entity) { - return entity.Select(propertyGroup => BuildGroupDto(propertyGroup)).ToList(); + return entity.Select(BuildGroupDto).ToList(); } #endregion diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs index c5c32f8c01..f2976e3aa1 100644 --- a/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs @@ -235,12 +235,12 @@ namespace Umbraco.Core.Persistence.Repositories var sql = new Sql(); sql.Select("*") .From() - .RightJoin() + .LeftJoin() .On(left => left.Id, right => right.PropertyTypeGroupId) - .InnerJoin() + .LeftJoin() .On(left => left.DataTypeId, right => right.DataTypeId) - .Where(x => x.ContentTypeId == id) - .OrderBy(x => x.PropertyTypeGroupId); + .Where(x => x.ContentTypeNodeId == id) + .OrderBy(x => x.Id); var dtos = Database.Fetch(new GroupPropertyTypeRelator().Map, sql); diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index f4118f75e8..95969dc266 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -2072,7 +2072,9 @@ - + + ASPXCodeBehind + ASPXCodeBehind diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs index e7f6bed492..5533eeb599 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs @@ -341,7 +341,7 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }}); } private void bindDataGenericProperties(bool Refresh) { - var tabs = cType.getVirtualTabs.DistinctBy(x => x.ContentType).ToArray(); + var tabs = cType.getVirtualTabs; var dtds = cms.businesslogic.datatype.DataTypeDefinition.GetAll(); PropertyTypes.Controls.Clear(); diff --git a/src/umbraco.cms/businesslogic/ContentType.cs b/src/umbraco.cms/businesslogic/ContentType.cs index 4cc0c38e13..59652b27a2 100644 --- a/src/umbraco.cms/businesslogic/ContentType.cs +++ b/src/umbraco.cms/businesslogic/ContentType.cs @@ -6,6 +6,7 @@ using System.Runtime.CompilerServices; using System.Linq; using Umbraco.Core; using Umbraco.Core.Models; +using Umbraco.Core.Persistence.Caching; using umbraco.cms.businesslogic.cache; using umbraco.cms.businesslogic.propertytype; using umbraco.cms.businesslogic.web; @@ -1128,6 +1129,9 @@ namespace umbraco.cms.businesslogic /// The id. public static void FlushFromCache(int id) { + //Ensure that MediaTypes are reloaded from db by clearing cache + InMemoryCacheProvider.Current.Clear(); + ContentType ct = new ContentType(id); Cache.ClearCacheItem(string.Format("UmbracoContentType{0}", id)); Cache.ClearCacheItem(ct.GetPropertiesCacheKey()); From cd0919aeeb33268daece0aacc852f724d580ee37 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Wed, 9 Jan 2013 16:03:56 -0100 Subject: [PATCH 037/188] Update version to 4.11.2 --- build/NuSpecs/UmbracoCms.Core.nuspec | 2 +- build/NuSpecs/UmbracoCms.nuspec | 4 ++-- src/Umbraco.Core/Configuration/GlobalSettings.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/NuSpecs/UmbracoCms.Core.nuspec b/build/NuSpecs/UmbracoCms.Core.nuspec index 82174a539b..0597d6ce9f 100644 --- a/build/NuSpecs/UmbracoCms.Core.nuspec +++ b/build/NuSpecs/UmbracoCms.Core.nuspec @@ -2,7 +2,7 @@ UmbracoCms.Core - 4.11.1 + 4.11.2 Umbraco Cms Core Binaries Morten Christensen Umbraco HQ diff --git a/build/NuSpecs/UmbracoCms.nuspec b/build/NuSpecs/UmbracoCms.nuspec index be4a9342cf..193dbefd6f 100644 --- a/build/NuSpecs/UmbracoCms.nuspec +++ b/build/NuSpecs/UmbracoCms.nuspec @@ -2,7 +2,7 @@ UmbracoCms - 4.11.1 + 4.11.2 Umbraco Cms Morten Christensen Umbraco HQ @@ -15,7 +15,7 @@ en-US umbraco - + diff --git a/src/Umbraco.Core/Configuration/GlobalSettings.cs b/src/Umbraco.Core/Configuration/GlobalSettings.cs index 87c31572df..b5d2f912e8 100644 --- a/src/Umbraco.Core/Configuration/GlobalSettings.cs +++ b/src/Umbraco.Core/Configuration/GlobalSettings.cs @@ -28,7 +28,7 @@ namespace Umbraco.Core.Configuration #region Private static fields // CURRENT UMBRACO VERSION ID - private const string CurrentUmbracoVersion = "4.11.1"; + private const string CurrentUmbracoVersion = "4.11.2"; private static string _reservedUrlsCache; private static string _reservedPathsCache; From 9c792a7a5ea421f55236871583687d8d770c3a65 Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Wed, 9 Jan 2013 18:48:44 -0100 Subject: [PATCH 038/188] Fixes U4-1423 so PropertyTypes not in a group are also included in the list of a Content/MediaTypes PropertyTypes. --- src/Umbraco.Core/Models/ContentTypeBase.cs | 20 ++++++- src/Umbraco.Core/Models/PropertyType.cs | 16 ++++++ .../Factories/PropertyGroupFactory.cs | 9 ++- .../Repositories/ContentTypeBaseRepository.cs | 55 ++++++++++++++----- .../Repositories/ContentTypeRepository.cs | 1 + .../Repositories/DictionaryRepository.cs | 2 +- .../Repositories/MediaTypeRepository.cs | 1 + .../Repositories/ContentTypeRepositoryTest.cs | 33 +++++++++++ 8 files changed, 119 insertions(+), 18 deletions(-) diff --git a/src/Umbraco.Core/Models/ContentTypeBase.cs b/src/Umbraco.Core/Models/ContentTypeBase.cs index 5d86e4cc2c..b2a70d8d6a 100644 --- a/src/Umbraco.Core/Models/ContentTypeBase.cs +++ b/src/Umbraco.Core/Models/ContentTypeBase.cs @@ -29,6 +29,7 @@ namespace Umbraco.Core.Models private bool _isContainer; private bool _trashed; private PropertyGroupCollection _propertyGroups; + private PropertyTypeCollection _propertyTypes; private IEnumerable _allowedContentTypes; protected ContentTypeBase(int parentId) @@ -38,6 +39,7 @@ namespace Umbraco.Core.Models _parentId = new Lazy(() => parentId); _allowedContentTypes = new List(); _propertyGroups = new PropertyGroupCollection(); + _propertyTypes = new PropertyTypeCollection(); } protected ContentTypeBase(IContentTypeBase parent) @@ -47,6 +49,7 @@ namespace Umbraco.Core.Models _parentId = new Lazy(() => parent.Id); _allowedContentTypes = new List(); _propertyGroups = new PropertyGroupCollection(); + _propertyTypes = new PropertyTypeCollection(); } private static readonly PropertyInfo NameSelector = ExpressionHelper.GetPropertyInfo(x => x.Name); @@ -64,12 +67,18 @@ namespace Umbraco.Core.Models private static readonly PropertyInfo TrashedSelector = ExpressionHelper.GetPropertyInfo(x => x.Trashed); private static readonly PropertyInfo AllowedContentTypesSelector = ExpressionHelper.GetPropertyInfo>(x => x.AllowedContentTypes); private static readonly PropertyInfo PropertyGroupCollectionSelector = ExpressionHelper.GetPropertyInfo(x => x.PropertyGroups); + private static readonly PropertyInfo PropertyTypeCollectionSelector = ExpressionHelper.GetPropertyInfo>(x => x.PropertyTypes); protected void PropertyGroupsChanged(object sender, NotifyCollectionChangedEventArgs e) { OnPropertyChanged(PropertyGroupCollectionSelector); } + protected void PropertyTypesChanged(object sender, NotifyCollectionChangedEventArgs e) + { + OnPropertyChanged(PropertyTypeCollectionSelector); + } + /// /// Gets or sets the Id of the Parent entity /// @@ -301,7 +310,16 @@ namespace Umbraco.Core.Models [IgnoreDataMember] public virtual IEnumerable PropertyTypes { - get { return PropertyGroups.SelectMany(x => x.PropertyTypes); } + get + { + var types = _propertyTypes.Union(PropertyGroups.SelectMany(x => x.PropertyTypes)); + return types; + } + internal set + { + _propertyTypes = new PropertyTypeCollection(value); + _propertyTypes.CollectionChanged += PropertyTypesChanged; + } } /// diff --git a/src/Umbraco.Core/Models/PropertyType.cs b/src/Umbraco.Core/Models/PropertyType.cs index dc65afa913..c67a2bd2ed 100644 --- a/src/Umbraco.Core/Models/PropertyType.cs +++ b/src/Umbraco.Core/Models/PropertyType.cs @@ -18,6 +18,7 @@ namespace Umbraco.Core.Models private string _alias; private string _description; private int _dataTypeDefinitionId; + private int _propertyGroupId; private Guid _dataTypeId; private DataTypeDatabaseType _dataTypeDatabaseType; private bool _mandatory; @@ -60,6 +61,7 @@ namespace Umbraco.Core.Models private static readonly PropertyInfo HelpTextSelector = ExpressionHelper.GetPropertyInfo(x => x.HelpText); private static readonly PropertyInfo SortOrderSelector = ExpressionHelper.GetPropertyInfo(x => x.SortOrder); private static readonly PropertyInfo ValidationRegExpSelector = ExpressionHelper.GetPropertyInfo(x => x.ValidationRegExp); + private static readonly PropertyInfo PropertyGroupIdSelector = ExpressionHelper.GetPropertyInfo(x => x.PropertyGroupId); /// /// Gets of Sets the Name of the PropertyType @@ -147,6 +149,20 @@ namespace Umbraco.Core.Models } } + /// + /// Gets or Sets the PropertyGroup's Id for which this PropertyType belongs + /// + [DataMember] + internal int PropertyGroupId + { + get { return _propertyGroupId; } + set + { + _propertyGroupId = value; + OnPropertyChanged(PropertyGroupIdSelector); + } + } + /// /// Gets of Sets the Boolean indicating whether a value for this PropertyType is required /// diff --git a/src/Umbraco.Core/Persistence/Factories/PropertyGroupFactory.cs b/src/Umbraco.Core/Persistence/Factories/PropertyGroupFactory.cs index 5ec7f12292..fb25e3fe32 100644 --- a/src/Umbraco.Core/Persistence/Factories/PropertyGroupFactory.cs +++ b/src/Umbraco.Core/Persistence/Factories/PropertyGroupFactory.cs @@ -42,7 +42,8 @@ namespace Umbraco.Core.Persistence.Factories Name = typeDto.Name, HelpText = typeDto.HelpText, Mandatory = typeDto.Mandatory, - SortOrder = typeDto.SortOrder + SortOrder = typeDto.SortOrder, + PropertyGroupId = groupDto.Id }); } @@ -89,10 +90,12 @@ namespace Umbraco.Core.Persistence.Factories HelpText = propertyType.HelpText, Mandatory = propertyType.Mandatory, Name = propertyType.Name, - SortOrder = propertyType.SortOrder, - PropertyTypeGroupId = tabId + SortOrder = propertyType.SortOrder }; + if (tabId != default(int)) + propertyTypeDto.PropertyTypeGroupId = tabId; + if (propertyType.HasIdentity) propertyTypeDto.Id = propertyType.Id; diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs index f2976e3aa1..c430830b76 100644 --- a/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs @@ -193,7 +193,7 @@ namespace Umbraco.Core.Persistence.Repositories Database.Delete("WHERE contenttypeNodeId = @Id AND text = @Name", new { Id = entity.Id, Name = tabName }); } - //Run through all groups and types to insert or update entries + //Run through all groups to insert or update entries foreach (var propertyGroup in entity.PropertyGroups) { var tabDto = propertyFactory.BuildGroupDto(propertyGroup); @@ -202,19 +202,17 @@ namespace Umbraco.Core.Persistence.Repositories : Convert.ToInt32(Database.Insert(tabDto)); if (!propertyGroup.HasIdentity) propertyGroup.Id = groupPrimaryKey;//Set Id on new PropertyGroup + } - //This should indicate that neither group nor property types has been touched, but this implies a deeper 'Dirty'-lookup - //if(!propertyGroup.IsDirty()) continue; - - foreach (var propertyType in propertyGroup.PropertyTypes) - { - var propertyTypeDto = propertyFactory.BuildPropertyTypeDto(propertyGroup.Id, propertyType); - int typePrimaryKey = propertyType.HasIdentity - ? Database.Update(propertyTypeDto) - : Convert.ToInt32(Database.Insert(propertyTypeDto)); - if (!propertyType.HasIdentity) - propertyType.Id = typePrimaryKey;//Set Id on new PropertyType - } + //Run through all PropertyTypes to insert or update entries + foreach (var propertyType in entity.PropertyTypes) + { + var propertyTypeDto = propertyFactory.BuildPropertyTypeDto(propertyType.PropertyGroupId, propertyType); + int typePrimaryKey = propertyType.HasIdentity + ? Database.Update(propertyTypeDto) + : Convert.ToInt32(Database.Insert(propertyTypeDto)); + if (!propertyType.HasIdentity) + propertyType.Id = typePrimaryKey;//Set Id on new PropertyType } } } @@ -248,5 +246,36 @@ namespace Umbraco.Core.Persistence.Repositories var propertyGroups = propertyFactory.BuildEntity(dtos); return new PropertyGroupCollection(propertyGroups); } + + protected PropertyTypeCollection GetPropertyTypeCollection(int id) + { + var sql = new Sql(); + sql.Select("*") + .From() + .InnerJoin() + .On(left => left.DataTypeId, right => right.DataTypeId) + .Where(x => x.ContentTypeId == id); + + var dtos = Database.Fetch(sql); + + //TODO Move this to a PropertyTypeFactory + var list = (from dto in dtos + where (dto.PropertyTypeGroupId > 0) == false + select + new PropertyType(dto.DataTypeDto.ControlId, + dto.DataTypeDto.DbType.EnumParse(true)) + { + Alias = dto.Alias, + DataTypeDefinitionId = dto.DataTypeId, + Description = dto.Description, + Id = dto.Id, + Name = dto.Name, + HelpText = dto.HelpText, + Mandatory = dto.Mandatory, + SortOrder = dto.SortOrder + }); + + return new PropertyTypeCollection(list); + } } } \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentTypeRepository.cs index 7b5a510893..02659b8f34 100644 --- a/src/Umbraco.Core/Persistence/Repositories/ContentTypeRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/ContentTypeRepository.cs @@ -51,6 +51,7 @@ namespace Umbraco.Core.Persistence.Repositories contentType.AllowedContentTypes = GetAllowedContentTypeIds(id); contentType.PropertyGroups = GetPropertyGroupCollection(id); + ((ContentType)contentType).PropertyTypes = GetPropertyTypeCollection(id); var templates = Database.Fetch("WHERE contentTypeNodeId = @Id", new { Id = id }); if(templates.Any()) diff --git a/src/Umbraco.Core/Persistence/Repositories/DictionaryRepository.cs b/src/Umbraco.Core/Persistence/Repositories/DictionaryRepository.cs index a0f712daee..4bd0e9de63 100644 --- a/src/Umbraco.Core/Persistence/Repositories/DictionaryRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/DictionaryRepository.cs @@ -82,9 +82,9 @@ namespace Umbraco.Core.Persistence.Repositories protected override IEnumerable PerformGetByQuery(IQuery query) { var sqlClause = GetBaseQuery(false); - sqlClause.OrderBy(x => x.UniqueId); var translator = new SqlTranslator(sqlClause, query); var sql = translator.Translate(); + sql.OrderBy(x => x.UniqueId); var dtos = Database.Fetch(new DictionaryLanguageTextRelator().Map, sql); diff --git a/src/Umbraco.Core/Persistence/Repositories/MediaTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/MediaTypeRepository.cs index c4172665c5..44e0b8ae25 100644 --- a/src/Umbraco.Core/Persistence/Repositories/MediaTypeRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/MediaTypeRepository.cs @@ -43,6 +43,7 @@ namespace Umbraco.Core.Persistence.Repositories contentType.AllowedContentTypes = GetAllowedContentTypeIds(id); contentType.PropertyGroups = GetPropertyGroupCollection(id); + ((MediaType)contentType).PropertyTypes = GetPropertyTypeCollection(id); var list = Database.Fetch("WHERE childContentTypeId = @Id", new{ Id = id}); foreach (var contentTypeDto in list) diff --git a/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs index 28487509b4..7fd9ed5127 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs @@ -228,6 +228,39 @@ namespace Umbraco.Tests.Persistence.Repositories Assert.That(contentType.PropertyGroups.Count(), Is.EqualTo(2)); } + [Test] + public void Can_Verify_PropertyType_With_No_Group() + { + // Arrange + var provider = new PetaPocoUnitOfWorkProvider(); + var unitOfWork = provider.GetUnitOfWork(); + var repository = RepositoryResolver.Current.ResolveByType(unitOfWork); + var contentType = repository.Get(1046); + + // Act + var urlAlias = new PropertyType(new Guid(), DataTypeDatabaseType.Nvarchar) + { + Alias = "urlAlias", + Name = "Url Alias", + Description = "", + HelpText = "", + Mandatory = false, + SortOrder = 1, + DataTypeDefinitionId = -88 + }; + var list = new List {urlAlias}; + ((ContentType) contentType).PropertyTypes = list; + repository.AddOrUpdate(contentType); + unitOfWork.Commit(); + + // Assert + var updated = repository.Get(1046); + Assert.That(updated.PropertyGroups.Count(), Is.EqualTo(2)); + Assert.That(updated.PropertyTypes.Count(), Is.EqualTo(5)); + Assert.That(updated.PropertyTypes.Any(x => x.Alias == "urlAlias"), Is.True); + Assert.AreEqual(updated.PropertyTypes.First(x => x.Alias == "urlAlias").PropertyGroupId, default(int)); + } + [Test] public void Can_Verify_AllowedChildContentTypes_On_ContentType() { From 51c1c5c717eea30d68a6b71ce9f5b646b49bd57a Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Thu, 10 Jan 2013 03:59:11 +0300 Subject: [PATCH 039/188] added more HttpRequestExtensions, cleaned up some code in legacyAjaxCalls, adds UmbracoRequestId to UmbracoContext (for future use) --- src/Umbraco.Web/HttpRequestExtensions.cs | 34 ++++- src/Umbraco.Web/UmbracoContext.cs | 6 + .../webservices/legacyAjaxCalls.asmx.cs | 127 ++++++++---------- 3 files changed, 94 insertions(+), 73 deletions(-) diff --git a/src/Umbraco.Web/HttpRequestExtensions.cs b/src/Umbraco.Web/HttpRequestExtensions.cs index b2746c563b..4dcdcb9c08 100644 --- a/src/Umbraco.Web/HttpRequestExtensions.cs +++ b/src/Umbraco.Web/HttpRequestExtensions.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Text; using System.Web; @@ -35,5 +34,36 @@ namespace Umbraco.Web return !val.IsNullOrWhiteSpace() ? val : string.Empty; } + /// + /// Safely get the item from the query string and convert it to type 'T', otherwise will return default(T). + /// + /// + /// + /// + /// + public static T GetItemAs(this HttpRequestBase request, string key) + { + var val = HttpContext.Current.Request[key]; + var whitespaceCheck = !val.IsNullOrWhiteSpace() ? val : string.Empty; + if (whitespaceCheck.IsNullOrWhiteSpace()) + return (T) typeof (T).GetDefaultValue(); + var attempt = val.TryConvertTo(); + if (attempt.Success) + return attempt.Result; + return (T)typeof(T).GetDefaultValue(); + } + + /// + /// Safely get the item from the query string and convert it to type 'T', otherwise will return default(T). + /// + /// + /// + /// + /// + public static T GetItemAs(this HttpRequest request, string key) + { + return new HttpRequestWrapper(request).GetItemAs(key); + } + } } diff --git a/src/Umbraco.Web/UmbracoContext.cs b/src/Umbraco.Web/UmbracoContext.cs index ed6855b3e2..eecfcc7ff4 100644 --- a/src/Umbraco.Web/UmbracoContext.cs +++ b/src/Umbraco.Web/UmbracoContext.cs @@ -49,6 +49,7 @@ namespace Umbraco.Web if (applicationContext == null) throw new ArgumentNullException("applicationContext"); ObjectCreated = DateTime.Now; + UmbracoRequestId = Guid.NewGuid(); HttpContext = httpContext; Application = applicationContext; @@ -109,6 +110,11 @@ namespace Umbraco.Web /// internal DateTime ObjectCreated { get; private set; } + /// + /// This is used internally for debugging and also used to define anything required to distinguish this request from another. + /// + internal Guid UmbracoRequestId { get; private set; } + /// /// Gets the current ApplicationContext /// diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/legacyAjaxCalls.asmx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/legacyAjaxCalls.asmx.cs index f9e9127325..ac154c71f6 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/legacyAjaxCalls.asmx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/legacyAjaxCalls.asmx.cs @@ -16,8 +16,8 @@ using System.Text.RegularExpressions; using System.Diagnostics; using System.Net; using System.Web.UI; +using Umbraco.Core.IO; using umbraco.businesslogic.Exceptions; -using umbraco.IO; using umbraco.cms.businesslogic.web; using umbraco.cms.businesslogic.media; using umbraco.BasePages; @@ -205,15 +205,15 @@ namespace umbraco.presentation.webservices switch (fileType) { case "xslt": - return saveXslt(fileName, fileContents, ignoreDebug); + return SaveXslt(fileName, fileContents, ignoreDebug); case "python": return "true"; case "css": - return saveCss(fileName, fileContents, fileID); + return SaveCss(fileName, fileContents, fileID); case "script": - return saveScript(fileName, fileContents); + return SaveScript(fileName, fileContents); case "template": - return saveTemplate(fileName, fileAlias, fileContents, fileID, masterID); + return SaveTemplate(fileName, fileAlias, fileContents, fileID, masterID); default: throw new ArgumentException(String.Format("Invalid fileType passed: '{0}'", fileType)); } @@ -228,38 +228,34 @@ namespace umbraco.presentation.webservices } - private string saveCss(string fileName, string fileContents, int fileID) + private static string SaveCss(string fileName, string fileContents, int fileID) { - string returnValue = "false"; - cms.businesslogic.web.StyleSheet stylesheet = new cms.businesslogic.web.StyleSheet(fileID); + string returnValue; + var stylesheet = new StyleSheet(fileID) {Content = fileContents, Text = fileName}; - if (stylesheet != null) - { - stylesheet.Content = fileContents; - stylesheet.Text = fileName; - try - { - stylesheet.saveCssToFile(); - returnValue = "true"; - } - catch (Exception ee) - { - throw new Exception("Couldn't save file", ee); - } + try + { + stylesheet.saveCssToFile(); + returnValue = "true"; + } + catch (Exception ee) + { + throw new Exception("Couldn't save file", ee); + } - //this.speechBubble(speechBubbleIcon.save, ui.Text("speechBubbles", "editStylesheetSaved", base.getUser()), ""); - } - return returnValue; + //this.speechBubble(speechBubbleIcon.save, ui.Text("speechBubbles", "editStylesheetSaved", base.getUser()), ""); + return returnValue; } - private string saveXslt(string fileName, string fileContents, bool ignoreDebugging) - { - StreamWriter SW; - string tempFileName = IOHelper.MapPath(SystemDirectories.Xslt + "/" + System.DateTime.Now.Ticks + "_temp.xslt"); - SW = File.CreateText(tempFileName); - SW.Write(fileContents); - SW.Close(); - + private string SaveXslt(string fileName, string fileContents, bool ignoreDebugging) + { + var tempFileName = IOHelper.MapPath(SystemDirectories.Xslt + "/" + System.DateTime.Now.Ticks + "_temp.xslt"); + using (var sw = File.CreateText(tempFileName)) + { + sw.Write(fileContents); + sw.Close(); + } + // Test the xslt string errorMessage = ""; if (!ignoreDebugging) @@ -363,13 +359,15 @@ namespace umbraco.presentation.webservices if (errorMessage == "" && fileName.ToLower().EndsWith(".xslt")) { //Hardcoded security-check... only allow saving files in xslt directory... - string savePath = IOHelper.MapPath(SystemDirectories.Xslt + "/" + fileName); + var savePath = IOHelper.MapPath(SystemDirectories.Xslt + "/" + fileName); if (savePath.StartsWith(IOHelper.MapPath(SystemDirectories.Xslt))) { - SW = File.CreateText(savePath); - SW.Write(fileContents); - SW.Close(); + using (var sw = File.CreateText(savePath)) + { + sw.Write(fileContents); + sw.Close(); + } errorMessage = "true"; } else @@ -378,26 +376,19 @@ namespace umbraco.presentation.webservices } } - System.IO.File.Delete(tempFileName); + File.Delete(tempFileName); return errorMessage; } - - private string savePython(string filename, string contents) + + private static string SaveScript(string filename, string contents) { - - - return "true"; - } - - private string saveScript(string filename, string contents) - { - string val = contents; - string returnValue = "false"; + var val = contents; + string returnValue; try { - string savePath = IOHelper.MapPath(SystemDirectories.Scripts + "/" + filename); + var savePath = IOHelper.MapPath(SystemDirectories.Scripts + "/" + filename); //Directory check.. only allow files in script dir and below to be edited if (savePath.StartsWith(IOHelper.MapPath(SystemDirectories.Scripts + "/"))) @@ -422,34 +413,28 @@ namespace umbraco.presentation.webservices return returnValue; } - private string saveTemplate(string templateName, string templateAlias, string templateContents, int templateID, int masterTemplateID) + private static string SaveTemplate(string templateName, string templateAlias, string templateContents, int templateID, int masterTemplateID) { + var tp = new cms.businesslogic.template.Template(templateID); + var retVal = "false"; - cms.businesslogic.template.Template _template = new global::umbraco.cms.businesslogic.template.Template(templateID); - string retVal = "false"; + tp.Text = templateName; + tp.Alias = templateAlias; + tp.MasterTemplate = masterTemplateID; + tp.Design = templateContents; - if (_template != null) - { - _template.Text = templateName; - _template.Alias = templateAlias; - _template.MasterTemplate = masterTemplateID; - _template.Design = templateContents; + retVal = "true"; - retVal = "true"; - - // Clear cache in rutime - if (UmbracoSettings.UseDistributedCalls) - cache.dispatcher.Refresh( - new Guid("dd12b6a0-14b9-46e8-8800-c154f74047c8"), - _template.Id); - else - template.ClearCachedTemplate(_template.Id); - } - else - return "false"; + // Clear cache in rutime + if (UmbracoSettings.UseDistributedCalls) + cache.dispatcher.Refresh( + new Guid("dd12b6a0-14b9-46e8-8800-c154f74047c8"), + tp.Id); + else + template.ClearCachedTemplate(tp.Id); - return retVal; + return retVal; } From 4532c1b5b9253e68db853cd7dde2013598187536 Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Thu, 10 Jan 2013 04:33:30 +0300 Subject: [PATCH 040/188] Updated IMigrations to use the proper plugin format using resolvers, updated unit tests and are passing. --- src/Umbraco.Core/CoreBootManager.cs | 22 ++++++++++++- .../Migrations/MigrationResolver.cs | 32 ++++++++++++++++++ .../Persistence/Migrations/MigrationRunner.cs | 18 ++-------- src/Umbraco.Core/Umbraco.Core.csproj | 1 + .../Migrations/Upgrades/BaseUpgradeTest.cs | 33 +++++++++++++------ .../config/ClientDependency.config | 2 +- 6 files changed, 80 insertions(+), 28 deletions(-) create mode 100644 src/Umbraco.Core/Persistence/Migrations/MigrationResolver.cs diff --git a/src/Umbraco.Core/CoreBootManager.cs b/src/Umbraco.Core/CoreBootManager.cs index 53bf71444e..697bc34177 100644 --- a/src/Umbraco.Core/CoreBootManager.cs +++ b/src/Umbraco.Core/CoreBootManager.cs @@ -7,10 +7,13 @@ using Umbraco.Core.Logging; using Umbraco.Core.ObjectResolution; using Umbraco.Core.Persistence; using Umbraco.Core.Persistence.Mappers; +using Umbraco.Core.Persistence.Migrations; using Umbraco.Core.Persistence.UnitOfWork; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Publishing; using Umbraco.Core.Services; +using MigrationsVersionSixth = Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixth; +using MigrationsVersionFourNineZero = Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionFourNineZero; namespace Umbraco.Core { @@ -40,7 +43,7 @@ namespace Umbraco.Core //create database and service contexts for the app context var dbFactory = new DefaultDatabaseFactory(GlobalSettings.UmbracoConnectionName); - UmbracoDatabase.Mapper = new PetaPocoMapper(); + Database.Mapper = new PetaPocoMapper(); var dbContext = new DatabaseContext(dbFactory); var serviceContext = new ServiceContext( new PetaPocoUnitOfWorkProvider(dbFactory), @@ -138,6 +141,23 @@ namespace Umbraco.Core PropertyEditorValueConvertersResolver.Current.AddType(); PropertyEditorValueConvertersResolver.Current.AddType(); PropertyEditorValueConvertersResolver.Current.AddType(); + + //the database migration objects + MigrationResolver.Current = new MigrationResolver(new List + { + typeof (MigrationsVersionFourNineZero.RemoveUmbracoAppConstraints), + typeof (MigrationsVersionSixth.DeleteAppTables), + typeof (MigrationsVersionSixth.EnsureAppsTreesUpdated), + typeof (MigrationsVersionSixth.MoveMasterContentTypeData), + typeof (MigrationsVersionSixth.NewCmsContentType2ContentTypeTable), + typeof (MigrationsVersionSixth.RemoveMasterContentTypeColumn), + typeof (MigrationsVersionSixth.RenameCmsTabTable), + typeof (MigrationsVersionSixth.RenameTabIdColumn), + typeof (MigrationsVersionSixth.UpdateCmsContentTypeAllowedContentTypeTable), + typeof (MigrationsVersionSixth.UpdateCmsContentTypeTable), + typeof (MigrationsVersionSixth.UpdateCmsContentVersionTable), + typeof (MigrationsVersionSixth.UpdateCmsPropertyTypeGroupTable) + }); } } } diff --git a/src/Umbraco.Core/Persistence/Migrations/MigrationResolver.cs b/src/Umbraco.Core/Persistence/Migrations/MigrationResolver.cs new file mode 100644 index 0000000000..b11107d7cb --- /dev/null +++ b/src/Umbraco.Core/Persistence/Migrations/MigrationResolver.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using Umbraco.Core.ObjectResolution; + +namespace Umbraco.Core.Persistence.Migrations +{ + /// + /// A resolver to return all IMigrations + /// + internal class MigrationResolver : ManyObjectsResolverBase + { + /// + /// Constructor + /// + /// + /// + /// Use transient objects as we don't want these as singletons and take up memory that is not required + /// + public MigrationResolver(IEnumerable surfaceControllers) + : base(surfaceControllers, ObjectLifetimeScope.Transient) + { + } + + /// + /// Gets the migrations + /// + public IEnumerable Migrations + { + get { return Values; } + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/Migrations/MigrationRunner.cs b/src/Umbraco.Core/Persistence/Migrations/MigrationRunner.cs index d5e18445e1..9b0bfa6516 100644 --- a/src/Umbraco.Core/Persistence/Migrations/MigrationRunner.cs +++ b/src/Umbraco.Core/Persistence/Migrations/MigrationRunner.cs @@ -5,7 +5,7 @@ using Umbraco.Core.Logging; namespace Umbraco.Core.Persistence.Migrations { - /// + /// /// Represents the Migration Runner, which is used to apply migrations to /// the umbraco database. /// @@ -44,21 +44,7 @@ namespace Umbraco.Core.Persistence.Migrations { LogHelper.Info("Initializing database migration"); - var foundMigrations = new List - { - new Upgrades.TargetVersionFourNineZero.RemoveUmbracoAppConstraints(), - new Upgrades.TargetVersionSixth.DeleteAppTables(), - new Upgrades.TargetVersionSixth.EnsureAppsTreesUpdated(), - new Upgrades.TargetVersionSixth.MoveMasterContentTypeData(), - new Upgrades.TargetVersionSixth.NewCmsContentType2ContentTypeTable(), - new Upgrades.TargetVersionSixth.RemoveMasterContentTypeColumn(), - new Upgrades.TargetVersionSixth.RenameCmsTabTable(), - new Upgrades.TargetVersionSixth.RenameTabIdColumn(), - new Upgrades.TargetVersionSixth.UpdateCmsContentTypeAllowedContentTypeTable(), - new Upgrades.TargetVersionSixth.UpdateCmsContentTypeTable(), - new Upgrades.TargetVersionSixth.UpdateCmsContentVersionTable(), - new Upgrades.TargetVersionSixth.UpdateCmsPropertyTypeGroupTable() - }; + var foundMigrations = MigrationResolver.Current.Migrations; var migrations = isUpgrade ? OrderedUpgradeMigrations(foundMigrations) diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index f763d66636..bcc78b02e8 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -265,6 +265,7 @@ + diff --git a/src/Umbraco.Tests/Migrations/Upgrades/BaseUpgradeTest.cs b/src/Umbraco.Tests/Migrations/Upgrades/BaseUpgradeTest.cs index 54a8232e68..7836e6881a 100644 --- a/src/Umbraco.Tests/Migrations/Upgrades/BaseUpgradeTest.cs +++ b/src/Umbraco.Tests/Migrations/Upgrades/BaseUpgradeTest.cs @@ -1,8 +1,10 @@ using System; +using System.Collections.Generic; using System.Text.RegularExpressions; using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.Configuration; +using Umbraco.Core.ObjectResolution; using Umbraco.Core.Persistence; using Umbraco.Core.Persistence.Migrations; using Umbraco.Core.Persistence.SqlSyntax; @@ -15,7 +17,7 @@ namespace Umbraco.Tests.Migrations.Upgrades public abstract class BaseUpgradeTest { /// Regular expression that finds multiline block comments. - private static readonly Regex m_findComments = new Regex(@"\/\*.*?\*\/", RegexOptions.Singleline | RegexOptions.Compiled); + private static readonly Regex FindComments = new Regex(@"\/\*.*?\*\/", RegexOptions.Singleline | RegexOptions.Compiled); [SetUp] public virtual void Initialize() @@ -27,15 +29,24 @@ namespace Umbraco.Tests.Migrations.Upgrades AppDomain.CurrentDomain.SetData("DataDirectory", Path); UmbracoSettings.UseLegacyXmlSchema = false; + + MigrationResolver.Current = new MigrationResolver(new List + { + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionFourNineZero.RemoveUmbracoAppConstraints), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.DeleteAppTables), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.EnsureAppsTreesUpdated), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.MoveMasterContentTypeData), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.NewCmsContentType2ContentTypeTable), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.RemoveMasterContentTypeColumn), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.RenameCmsTabTable), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.RenameTabIdColumn), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.UpdateCmsContentTypeAllowedContentTypeTable), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.UpdateCmsContentTypeTable), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.UpdateCmsContentVersionTable), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.UpdateCmsPropertyTypeGroupTable) + }); - //this ensures its reset - PluginManager.Current = new PluginManager(false); - - //for testing, we'll specify which assemblies are scanned for the PluginTypeResolver - PluginManager.Current.AssembliesToScan = new[] - { - typeof (MigrationRunner).Assembly - }; + Resolution.Freeze(); DatabaseSpecificSetUp(); @@ -53,7 +64,7 @@ namespace Umbraco.Tests.Migrations.Upgrades //Create db schema and data from old Total.sql file for Sql Ce string statements = GetDatabaseSpecificSqlScript(); // replace block comments by whitespace - statements = m_findComments.Replace(statements, " "); + statements = FindComments.Replace(statements, " "); // execute all non-empty statements foreach (string statement in statements.Split(";".ToCharArray())) { @@ -82,6 +93,8 @@ namespace Umbraco.Tests.Migrations.Upgrades { PluginManager.Current = null; SyntaxConfig.SqlSyntaxProvider = null; + MigrationResolver.Reset(); + Resolution.IsFrozen = false; TestHelper.CleanContentDirectories(); diff --git a/src/Umbraco.Web.UI/config/ClientDependency.config b/src/Umbraco.Web.UI/config/ClientDependency.config index 46c024aac7..91d1e0bb24 100644 --- a/src/Umbraco.Web.UI/config/ClientDependency.config +++ b/src/Umbraco.Web.UI/config/ClientDependency.config @@ -10,7 +10,7 @@ NOTES: * Compression/Combination/Minification is not enabled unless debug="false" is specified on the 'compiliation' element in the web.config * A new version will invalidate both client and server cache and create new persisted files --> - + From b8f455e50bdcaa058f985d67138638efa780080b Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Thu, 10 Jan 2013 04:49:12 +0300 Subject: [PATCH 041/188] Removed PluginManagerExtensions for finding IMigrations since we are manually initializing the resolver instead of type finding. Updated unit tests to use resolvers and are passing. --- .../Migrations/PluginManagerExtension.cs | 13 ------ src/Umbraco.Core/Umbraco.Core.csproj | 1 - .../Migrations/FindingMigrationsTest.cs | 36 ++++++++-------- .../Migrations/PluginManagerExtensions.cs | 24 ----------- .../TargetVersionSixthMigrationsTest.cs | 41 ++++++++++--------- src/Umbraco.Tests/Umbraco.Tests.csproj | 1 - 6 files changed, 38 insertions(+), 78 deletions(-) delete mode 100644 src/Umbraco.Core/Persistence/Migrations/PluginManagerExtension.cs delete mode 100644 src/Umbraco.Tests/Migrations/PluginManagerExtensions.cs diff --git a/src/Umbraco.Core/Persistence/Migrations/PluginManagerExtension.cs b/src/Umbraco.Core/Persistence/Migrations/PluginManagerExtension.cs deleted file mode 100644 index 8540f8dbf7..0000000000 --- a/src/Umbraco.Core/Persistence/Migrations/PluginManagerExtension.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Collections.Generic; - -namespace Umbraco.Core.Persistence.Migrations -{ - internal static class PluginManagerExtension - { - public static IEnumerable FindMigrations(this PluginManager resolver) - { - var types = resolver.ResolveTypesWithAttribute(); - return resolver.CreateInstances(types); - } - } -} \ No newline at end of file diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index bcc78b02e8..18ca0566c8 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -267,7 +267,6 @@ - diff --git a/src/Umbraco.Tests/Migrations/FindingMigrationsTest.cs b/src/Umbraco.Tests/Migrations/FindingMigrationsTest.cs index c148ec222e..7239f21fc1 100644 --- a/src/Umbraco.Tests/Migrations/FindingMigrationsTest.cs +++ b/src/Umbraco.Tests/Migrations/FindingMigrationsTest.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using NUnit.Framework; using Umbraco.Core; +using Umbraco.Core.ObjectResolution; using Umbraco.Core.Persistence; using Umbraco.Core.Persistence.Migrations; using Umbraco.Core.Persistence.SqlSyntax; @@ -19,31 +20,25 @@ namespace Umbraco.Tests.Migrations { TestHelper.SetupLog4NetForTests(); - //this ensures its reset - PluginManager.Current = new PluginManager(false); + MigrationResolver.Current = new MigrationResolver(new List + { + typeof (AlterUserTableMigrationStub), + typeof(Dummy), + typeof (FourNineMigration), + typeof (FourTenMigration), + typeof (FourElevenMigration), + typeof (FourElevenMigration) + }); - //for testing, we'll specify which assemblies are scanned for the PluginTypeResolver - PluginManager.Current.AssembliesToScan = new[] - { - typeof (FourNineMigration).Assembly - }; + Resolution.Freeze(); SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider; - } - - [Test] - public void Can_Find_Migrations_In_Current_Assembly() - { - var foundTypes = PluginManager.Current.ResolveMigrationTypes(); - - Assert.That(foundTypes.Any(), Is.True); - Assert.That(foundTypes.Count(), Is.EqualTo(4)); - } + } [Test] public void Can_Find_Migrations_With_Targtet_Version_Six() { - var foundMigrations = PluginManager.Current.FindMigrations(); + var foundMigrations = MigrationResolver.Current.Migrations; var targetVersion = new Version("6.0.0"); var list = new List(); @@ -78,8 +73,9 @@ namespace Umbraco.Tests.Migrations [TearDown] public void TearDown() - { - PluginManager.Current = null; + { + MigrationResolver.Reset(); + Resolution.IsFrozen = false; } } } \ No newline at end of file diff --git a/src/Umbraco.Tests/Migrations/PluginManagerExtensions.cs b/src/Umbraco.Tests/Migrations/PluginManagerExtensions.cs deleted file mode 100644 index 77b63703b0..0000000000 --- a/src/Umbraco.Tests/Migrations/PluginManagerExtensions.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using Umbraco.Core; -using Umbraco.Core.Persistence.Migrations; - -namespace Umbraco.Tests.Migrations -{ - /// - /// Used for TypeInheritanceTest and CodeFirstTests - /// - internal static class PluginManagerExtensions - { - public static IEnumerable ResolveMigrationTypes(this PluginManager resolver) - { - return resolver.ResolveTypesWithAttribute(); - } - - public static IEnumerable FindMigrations(this PluginManager resolver) - { - var types = resolver.ResolveTypesWithAttribute(); - return resolver.CreateInstances(types); - } - } -} \ No newline at end of file diff --git a/src/Umbraco.Tests/Migrations/TargetVersionSixthMigrationsTest.cs b/src/Umbraco.Tests/Migrations/TargetVersionSixthMigrationsTest.cs index 2b15022dd6..a1e02bc18a 100644 --- a/src/Umbraco.Tests/Migrations/TargetVersionSixthMigrationsTest.cs +++ b/src/Umbraco.Tests/Migrations/TargetVersionSixthMigrationsTest.cs @@ -1,7 +1,9 @@ using System; +using System.Collections.Generic; using System.Linq; using NUnit.Framework; using Umbraco.Core; +using Umbraco.Core.ObjectResolution; using Umbraco.Core.Persistence; using Umbraco.Core.Persistence.Migrations; using Umbraco.Core.Persistence.SqlSyntax; @@ -18,33 +20,33 @@ namespace Umbraco.Tests.Migrations { TestHelper.SetupLog4NetForTests(); - //this ensures its reset - PluginManager.Current = new PluginManager(false); + MigrationResolver.Current = new MigrationResolver(new List + { + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionFourNineZero.RemoveUmbracoAppConstraints), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.DeleteAppTables), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.EnsureAppsTreesUpdated), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.MoveMasterContentTypeData), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.NewCmsContentType2ContentTypeTable), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.RemoveMasterContentTypeColumn), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.RenameCmsTabTable), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.RenameTabIdColumn), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.UpdateCmsContentTypeAllowedContentTypeTable), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.UpdateCmsContentTypeTable), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.UpdateCmsContentVersionTable), + typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.UpdateCmsPropertyTypeGroupTable) + }); - //for testing, we'll specify which assemblies are scanned for the PluginTypeResolver - PluginManager.Current.AssembliesToScan = new[] - { - typeof (MigrationRunner).Assembly - }; + Resolution.Freeze(); SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider; } - - [Test] - public void Can_Find_Migrations_In_Current_Assembly() - { - var foundTypes = PluginManager.Current.ResolveMigrationTypes(); - - Assert.That(foundTypes.Any(), Is.True); - Assert.That(foundTypes.Count(), Is.GreaterThanOrEqualTo(11)); - } - + [Test] public void Can_Find_Targetted_Migrations() { var configuredVersion = new Version("4.11.0"); var targetVersion = new Version("6.0.0"); - var foundMigrations = PluginManager.Current.FindMigrations(); + var foundMigrations = MigrationResolver.Current.Migrations; var migrationRunner = new MigrationRunner(configuredVersion, targetVersion, GlobalSettings.UmbracoMigrationName); var migrations = migrationRunner.OrderedUpgradeMigrations(foundMigrations); @@ -66,7 +68,8 @@ namespace Umbraco.Tests.Migrations [TearDown] public void TearDown() { - PluginManager.Current = null; + MigrationResolver.Reset(); + Resolution.IsFrozen = false; } } } \ No newline at end of file diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index 9770fe643e..95c7b5bd12 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -168,7 +168,6 @@ SqlResources.resx - From 89332bf3f586e774d3a578f12d89d11decff9f81 Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Thu, 10 Jan 2013 05:08:52 +0300 Subject: [PATCH 042/188] updated all editors using the new html 5 doc type to declare the content area below the ASP.Net page declarations (I didn't even know asp.net allowed having controls listed above) --- .../umbraco/developer/Python/editPython.aspx | 7 ++++++- src/Umbraco.Web.UI/umbraco/developer/Xslt/editXslt.aspx | 8 ++++++-- src/Umbraco.Web.UI/umbraco/settings/editTemplate.aspx | 8 ++++++-- .../umbraco/settings/scripts/editScript.aspx | 7 ++++++- src/Umbraco.Web.UI/umbraco/settings/views/EditView.aspx | 7 ++++++- .../umbraco/developer/Python/editPython.aspx | 7 ++++++- .../umbraco/settings/scripts/editScript.aspx | 7 ++++++- 7 files changed, 42 insertions(+), 9 deletions(-) diff --git a/src/Umbraco.Web.UI/umbraco/developer/Python/editPython.aspx b/src/Umbraco.Web.UI/umbraco/developer/Python/editPython.aspx index b86f1226b1..f1c3b6d617 100644 --- a/src/Umbraco.Web.UI/umbraco/developer/Python/editPython.aspx +++ b/src/Umbraco.Web.UI/umbraco/developer/Python/editPython.aspx @@ -1,7 +1,12 @@ <%@ Page ValidateRequest="false" Language="c#" MasterPageFile="../../masterpages/umbracoPage.Master" - CodeBehind="editPython.aspx.cs" AutoEventWireup="True" Inherits="umbraco.cms.presentation.developer.editPython" %> + CodeBehind="editPython.aspx.cs" AutoEventWireup="True" Inherits="umbraco.cms.presentation.developer.editPython" %> <%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %> + + + + + + diff --git a/src/Umbraco.Web.UI/umbraco/settings/editTemplate.aspx b/src/Umbraco.Web.UI/umbraco/settings/editTemplate.aspx index 3a00b330be..1cd43e160c 100644 --- a/src/Umbraco.Web.UI/umbraco/settings/editTemplate.aspx +++ b/src/Umbraco.Web.UI/umbraco/settings/editTemplate.aspx @@ -13,7 +13,7 @@ PathNameAlias="UmbracoClient" /> - "; - macroProperties.Controls.Add(noProps); + //var noProps = new Literal(); + //noProps.Text = ""; + //macroProperties.Controls.Add(noProps); } else { //if we have properties, we'll render the controls for them... - foreach (cms.businesslogic.macro.MacroProperty mp in _m.Properties) + foreach (cms.businesslogic.macro.MacroProperty mp in MacroObject.Properties) { var macroAssembly = mp.Type.Assembly; var macroType = mp.Type.Type; @@ -126,7 +126,7 @@ namespace umbraco.dialogs else { IRecordsReader macroRenderings; - if (helper.Request("editor") != "") + if (Request.GetItemAsString("editor") != "") macroRenderings = SqlHelper.ExecuteReader("select macroAlias, macroName from cmsMacro where macroUseInEditor = 1 order by macroName"); else macroRenderings = SqlHelper.ExecuteReader("select macroAlias, macroName from cmsMacro order by macroName"); @@ -138,32 +138,8 @@ namespace umbraco.dialogs macroRenderings.Close(); } } - else - { - ScriptManager.RegisterOnSubmitStatement(Page, Page.GetType(), "myHandlerKey", "Umbraco.Dialogs.EditMacro.getInstance().updateMacro()"); - } - } - - #region Web Form Designer generated code - override protected void OnInit(EventArgs e) - { - // - // CODEGEN: This call is required by the ASP.NET Web Form Designer. - // - InitializeComponent(); - base.OnInit(e); - } - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - - } - #endregion + } /// /// pl_edit control. From 8ed1d76bc708cbc93a9b63a61bfd31f10c9ca2c6 Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Thu, 10 Jan 2013 05:55:55 +0300 Subject: [PATCH 044/188] cleans up a bit of code relating to U4-1412 --- src/Umbraco.Web.UI/umbraco/dialogs/editMacro.aspx | 2 +- src/Umbraco.Web.UI/umbraco_client/Dialogs/EditMacro.js | 7 ++++--- src/Umbraco.Web/HttpRequestExtensions.cs | 8 +++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Umbraco.Web.UI/umbraco/dialogs/editMacro.aspx b/src/Umbraco.Web.UI/umbraco/dialogs/editMacro.aspx index ae741e39a1..87c146c9c1 100644 --- a/src/Umbraco.Web.UI/umbraco/dialogs/editMacro.aspx +++ b/src/Umbraco.Web.UI/umbraco/dialogs/editMacro.aspx @@ -15,7 +15,7 @@ Umbraco.Dialogs.EditMacro.getInstance().init({ useAspNetMasterPages: <%=umbraco.UmbracoSettings.UseAspNetMasterPages.ToString().ToLower() %>, codeEditorElementId: "<%=Request.GetItemAsString("objectId")%>", - renderingEngine: "<%=Request.GetItemAsString("renderingEngine")%>", + renderingEngine: "<%=Request.GetItemAsString("renderingEngine", "Mvc")%>", macroAlias: '<%= _macroAlias %>' }); }); diff --git a/src/Umbraco.Web.UI/umbraco_client/Dialogs/EditMacro.js b/src/Umbraco.Web.UI/umbraco_client/Dialogs/EditMacro.js index 2e1daccabc..a3cbab36f3 100644 --- a/src/Umbraco.Web.UI/umbraco_client/Dialogs/EditMacro.js +++ b/src/Umbraco.Web.UI/umbraco_client/Dialogs/EditMacro.js @@ -130,8 +130,9 @@ /// Initializes the class and any UI bindings // Merge options with default - this._opts = $.extend({ + this._opts = $.extend({ // Default options go here + renderingEngine: "Mvc" }, opts); var self = this; @@ -152,8 +153,8 @@ updateMacro: function () { var macroSyntax = null; - //if it is Mvc or empty, then use Mvc - if (this._opts.renderingEngine == "Mvc" || this._opts.renderingEngine == "") { + + if (this._opts.renderingEngine == "Mvc") { macroSyntax = this._getMacroSyntaxMvc(); } else { diff --git a/src/Umbraco.Web/HttpRequestExtensions.cs b/src/Umbraco.Web/HttpRequestExtensions.cs index 4dcdcb9c08..238ac06523 100644 --- a/src/Umbraco.Web/HttpRequestExtensions.cs +++ b/src/Umbraco.Web/HttpRequestExtensions.cs @@ -16,8 +16,9 @@ namespace Umbraco.Web /// /// /// + /// The value to return if the key is not found in the collection /// - public static string GetItemAsString(this HttpRequest request, string key) + public static string GetItemAsString(this HttpRequest request, string key, string valueIfNotFound = "") { return new HttpRequestWrapper(request).GetItemAsString(key); } @@ -27,11 +28,12 @@ namespace Umbraco.Web /// /// /// + /// The value to return if the key is not found in the collection /// - public static string GetItemAsString(this HttpRequestBase request, string key) + public static string GetItemAsString(this HttpRequestBase request, string key, string valueIfNotFound = "") { var val = HttpContext.Current.Request[key]; - return !val.IsNullOrWhiteSpace() ? val : string.Empty; + return !val.IsNullOrWhiteSpace() ? val : valueIfNotFound; } /// From 0c00f1e3b1971a42ee8a73a521b61a83f9f08918 Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Thu, 10 Jan 2013 06:18:12 +0300 Subject: [PATCH 045/188] Fixes: #U4-1414 - split buttons not working in template editor --- .../umbraco/settings/editTemplate.aspx | 42 +++++++++---------- .../umbraco/settings/views/EditView.aspx | 2 +- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/Umbraco.Web.UI/umbraco/settings/editTemplate.aspx b/src/Umbraco.Web.UI/umbraco/settings/editTemplate.aspx index 1cd43e160c..879cc3e7c2 100644 --- a/src/Umbraco.Web.UI/umbraco/settings/editTemplate.aspx +++ b/src/Umbraco.Web.UI/umbraco/settings/editTemplate.aspx @@ -9,31 +9,31 @@ - - + + + - + From 36f8a8e1dd57d50b11ba5675722329d5a0472014 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Thu, 17 Jan 2013 14:17:04 -0100 Subject: [PATCH 154/188] Fixed U4-1492 Insert image in RTE gives null reference error --- .../datatype/DataTypeDefinition.cs | 64 ++++++++++--------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/src/umbraco.cms/businesslogic/datatype/DataTypeDefinition.cs b/src/umbraco.cms/businesslogic/datatype/DataTypeDefinition.cs index 9081532ce6..4633085987 100644 --- a/src/umbraco.cms/businesslogic/datatype/DataTypeDefinition.cs +++ b/src/umbraco.cms/businesslogic/datatype/DataTypeDefinition.cs @@ -2,6 +2,7 @@ using System; using System.Data; using System.Collections; +using System.Linq; using umbraco.DataLayer; using System.Xml; using umbraco.interfaces; @@ -9,20 +10,20 @@ using umbraco.cms.businesslogic.propertytype; namespace umbraco.cms.businesslogic.datatype { - /// - /// Datatypedefinitions is the basic buildingblocks of umbraco's documents/medias/members generic datastructure - /// - /// A datatypedefinition encapsulates an object which implements the interface IDataType, and are used when defining - /// the properties of a document in the documenttype. This extra layer between IDataType and a documenttypes propertytype - /// are used amongst other for enabling shared prevalues. - /// - /// - public class DataTypeDefinition : CMSNode - { + /// + /// Datatypedefinitions is the basic buildingblocks of umbraco's documents/medias/members generic datastructure + /// + /// A datatypedefinition encapsulates an object which implements the interface IDataType, and are used when defining + /// the properties of a document in the documenttype. This extra layer between IDataType and a documenttypes propertytype + /// are used amongst other for enabling shared prevalues. + /// + /// + public class DataTypeDefinition : CMSNode + { #region Private fields private Guid _controlId; - private static Guid _objectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"); + private static Guid _objectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"); #endregion #region Constructors @@ -37,8 +38,8 @@ namespace umbraco.cms.businesslogic.datatype /// Initialization of the datatypedefinition /// /// Datattypedefininition id - public DataTypeDefinition(Guid id) : base(id) { } - + public DataTypeDefinition(Guid id) : base(id) { } + #endregion #region Public Properties @@ -64,16 +65,16 @@ namespace umbraco.cms.businesslogic.datatype } set { - if (SqlHelper == null) - throw new InvalidOperationException("Cannot execute a SQL command when the SqlHelper is null"); - if (value == null) - throw new InvalidOperationException("The value passed in is null. The DataType property cannot be set to a null value"); + if (SqlHelper == null) + throw new InvalidOperationException("Cannot execute a SQL command when the SqlHelper is null"); + if (value == null) + throw new InvalidOperationException("The value passed in is null. The DataType property cannot be set to a null value"); SqlHelper.ExecuteNonQuery("update cmsDataType set controlId = @id where nodeID = " + this.Id.ToString(), SqlHelper.CreateParameter("@id", value.Id)); _controlId = value.Id; } - } + } #endregion #region Public methods @@ -81,7 +82,7 @@ namespace umbraco.cms.businesslogic.datatype { //first clear the prevalues PreValues.DeleteByDataTypeDefinition(this.Id); - + //next clear out the property types var propTypes = PropertyType.GetByDataTypeDefinition(this.Id); foreach (var p in propTypes) @@ -147,7 +148,7 @@ namespace umbraco.cms.businesslogic.datatype dt.AppendChild(prevalues); return dt; - } + } #endregion #region Static methods @@ -172,11 +173,11 @@ namespace umbraco.cms.businesslogic.datatype DataTypeDefinition dtd = MakeNew(u, _name, new Guid(_def)); - var dataType = f.DataType(new Guid(_id)); - if (dataType == null) - throw new NullReferenceException("Could not resolve a data type with id " + _id); + var dataType = f.DataType(new Guid(_id)); + if (dataType == null) + throw new NullReferenceException("Could not resolve a data type with id " + _id); - dtd.DataType = dataType; + dtd.DataType = dataType; dtd.Save(); //add prevalues @@ -248,11 +249,11 @@ namespace umbraco.cms.businesslogic.datatype int newId = CMSNode.MakeNew(-1, _objectType, u.Id, 1, Text, UniqueId).Id; cms.businesslogic.datatype.controls.Factory f = new cms.businesslogic.datatype.controls.Factory(); - + // initial control id changed to empty to ensure that it'll always work no matter if 3rd party configurators fail // ref: http://umbraco.codeplex.com/workitem/29788 Guid FirstcontrolId = Guid.Empty; - + SqlHelper.ExecuteNonQuery("Insert into cmsDataType (nodeId, controlId, dbType) values (" + newId.ToString() + ",@controlId,'Ntext')", SqlHelper.CreateParameter("@controlId", FirstcontrolId)); @@ -270,7 +271,8 @@ namespace umbraco.cms.businesslogic.datatype public static DataTypeDefinition GetByDataTypeId(Guid DataTypeId) { int dfId = 0; - foreach (DataTypeDefinition df in DataTypeDefinition.GetAll()) + // When creating a datatype and not saving it, it will be null, so we need this check + foreach (DataTypeDefinition df in DataTypeDefinition.GetAll().Where(x => x.DataType != null)) if (df.DataType.Id == DataTypeId) { dfId = df.Id; @@ -317,7 +319,7 @@ namespace umbraco.cms.businesslogic.datatype System.Web.HttpRuntime.Cache.Insert(string.Format("UmbracoDataTypeDefinition{0}", id.ToString()), dt); } return (DataTypeDefinition)System.Web.HttpRuntime.Cache[string.Format("UmbracoDataTypeDefinition{0}", id.ToString())]; - } + } #endregion #region Protected methods @@ -334,8 +336,8 @@ namespace umbraco.cms.businesslogic.datatype else throw new ArgumentException("No dataType with id = " + this.Id.ToString() + " found"); } - - } + + } #endregion #region Events @@ -366,7 +368,7 @@ namespace umbraco.cms.businesslogic.datatype { if (Deleting != null) Deleting(this, e); - } + } #endregion } From ad62cf012388b6d1d56a4792d3b0201c89d14343 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Thu, 17 Jan 2013 14:53:55 -0100 Subject: [PATCH 155/188] Fix merge issue, sorry --- src/Umbraco.Core/StringExtensions.cs | 211 ++++++++++++++------------- 1 file changed, 111 insertions(+), 100 deletions(-) diff --git a/src/Umbraco.Core/StringExtensions.cs b/src/Umbraco.Core/StringExtensions.cs index 5be5256bb9..2ad3b927fc 100644 --- a/src/Umbraco.Core/StringExtensions.cs +++ b/src/Umbraco.Core/StringExtensions.cs @@ -11,6 +11,7 @@ using System.Text.RegularExpressions; using System.Web; using System.Xml; using Umbraco.Core.Configuration; +using System.Web.Security; namespace Umbraco.Core { @@ -20,47 +21,57 @@ namespace Umbraco.Core /// public static class StringExtensions { - //this is from SqlMetal and just makes it a bit of fun to allow pluralisation - public static string MakePluralName(this string name) - { - if ((name.EndsWith("x", StringComparison.OrdinalIgnoreCase) || name.EndsWith("ch", StringComparison.OrdinalIgnoreCase)) || (name.EndsWith("ss", StringComparison.OrdinalIgnoreCase) || name.EndsWith("sh", StringComparison.OrdinalIgnoreCase))) - { - name = name + "es"; - return name; - } - if ((name.EndsWith("y", StringComparison.OrdinalIgnoreCase) && (name.Length > 1)) && !IsVowel(name[name.Length - 2])) - { - name = name.Remove(name.Length - 1, 1); - name = name + "ies"; - return name; - } - if (!name.EndsWith("s", StringComparison.OrdinalIgnoreCase)) - { - name = name + "s"; - } - return name; - } + public static string EncryptWithMachineKey(this string toEncrypt) + { + var output = FormsAuthentication.Encrypt(new FormsAuthenticationTicket(0, "temp", DateTime.Now, DateTime.MaxValue, false, toEncrypt)); + return output; + } + public static string DecryptWithMachineKey(this string encrypted) + { + var output = FormsAuthentication.Decrypt(encrypted); + return output.UserData; + } + //this is from SqlMetal and just makes it a bit of fun to allow pluralisation + public static string MakePluralName(this string name) + { + if ((name.EndsWith("x", StringComparison.OrdinalIgnoreCase) || name.EndsWith("ch", StringComparison.OrdinalIgnoreCase)) || (name.EndsWith("ss", StringComparison.OrdinalIgnoreCase) || name.EndsWith("sh", StringComparison.OrdinalIgnoreCase))) + { + name = name + "es"; + return name; + } + if ((name.EndsWith("y", StringComparison.OrdinalIgnoreCase) && (name.Length > 1)) && !IsVowel(name[name.Length - 2])) + { + name = name.Remove(name.Length - 1, 1); + name = name + "ies"; + return name; + } + if (!name.EndsWith("s", StringComparison.OrdinalIgnoreCase)) + { + name = name + "s"; + } + return name; + } - public static bool IsVowel(this char c) - { - switch (c) - { - case 'O': - case 'U': - case 'Y': - case 'A': - case 'E': - case 'I': - case 'o': - case 'u': - case 'y': - case 'a': - case 'e': - case 'i': - return true; - } - return false; - } + public static bool IsVowel(this char c) + { + switch (c) + { + case 'O': + case 'U': + case 'Y': + case 'A': + case 'E': + case 'I': + case 'o': + case 'u': + case 'y': + case 'a': + case 'e': + case 'i': + return true; + } + return false; + } /// /// Trims the specified value from a string; accepts a string input whereas the in-built implementation only accepts char or char[]. @@ -74,49 +85,49 @@ namespace Umbraco.Core return value.TrimEnd(forRemoving).TrimStart(forRemoving); } - public static string EncodeJsString(this string s) - { - var sb = new StringBuilder(); - foreach (var c in s) - { - switch (c) - { - case '\"': - sb.Append("\\\""); - break; - case '\\': - sb.Append("\\\\"); - break; - case '\b': - sb.Append("\\b"); - break; - case '\f': - sb.Append("\\f"); - break; - case '\n': - sb.Append("\\n"); - break; - case '\r': - sb.Append("\\r"); - break; - case '\t': - sb.Append("\\t"); - break; - default: - int i = (int)c; - if (i < 32 || i > 127) - { - sb.AppendFormat("\\u{0:X04}", i); - } - else - { - sb.Append(c); - } - break; - } - } - return sb.ToString(); - } + public static string EncodeJsString(this string s) + { + var sb = new StringBuilder(); + foreach (var c in s) + { + switch (c) + { + case '\"': + sb.Append("\\\""); + break; + case '\\': + sb.Append("\\\\"); + break; + case '\b': + sb.Append("\\b"); + break; + case '\f': + sb.Append("\\f"); + break; + case '\n': + sb.Append("\\n"); + break; + case '\r': + sb.Append("\\r"); + break; + case '\t': + sb.Append("\\t"); + break; + default: + int i = (int)c; + if (i < 32 || i > 127) + { + sb.AppendFormat("\\u{0:X04}", i); + } + else + { + sb.Append(c); + } + break; + } + } + return sb.ToString(); + } public static string TrimEnd(this string value, string forRemoving) { @@ -144,25 +155,25 @@ namespace Umbraco.Core return toStartWith + input.TrimStart(toStartWith.ToArray()); // Ensure each char is removed first from input, e.g. ~/ plus /Path will equal ~/Path not ~//Path } - public static string EnsureStartsWith(this string input, char value) - { - return input.StartsWith(value.ToString()) ? input : value + input; - } + public static string EnsureStartsWith(this string input, char value) + { + return input.StartsWith(value.ToString()) ? input : value + input; + } - public static string EnsureEndsWith(this string input, char value) - { - return input.EndsWith(value.ToString()) ? input : input + value; - } + public static string EnsureEndsWith(this string input, char value) + { + return input.EndsWith(value.ToString()) ? input : input + value; + } public static bool IsLowerCase(this char ch) { return ch.ToString(CultureInfo.InvariantCulture) == ch.ToString(CultureInfo.InvariantCulture).ToLower(); } - public static bool IsUpperCase(this char ch) - { - return ch.ToString(CultureInfo.InvariantCulture) == ch.ToString(CultureInfo.InvariantCulture).ToUpper(); - } + public static bool IsUpperCase(this char ch) + { + return ch.ToString(CultureInfo.InvariantCulture) == ch.ToString(CultureInfo.InvariantCulture).ToUpper(); + } /// Is null or white space. /// The str. @@ -479,10 +490,10 @@ namespace Umbraco.Core return String.Equals(compare, compareTo, StringComparison.InvariantCultureIgnoreCase); } - public static bool InvariantStartsWith(this string compare, string compareTo) - { - return compare.StartsWith(compareTo, StringComparison.InvariantCultureIgnoreCase); - } + public static bool InvariantStartsWith(this string compare, string compareTo) + { + return compare.StartsWith(compareTo, StringComparison.InvariantCultureIgnoreCase); + } public static bool InvariantContains(this string compare, string compareTo) { @@ -697,7 +708,7 @@ namespace Umbraco.Core .TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar; return currentFolder; } - + /// /// Truncates the specified text string. From c0b5525dd783b63937f09617fe70b3bc21927a35 Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Fri, 18 Jan 2013 02:31:51 +0300 Subject: [PATCH 156/188] Removed 'Boot' method from WebBootManager as it was never supposed to be there in the first place. Removed test code from 'SurfaceController'. Added comments to IApplicationEventHandler. --- src/Umbraco.Web/IApplicationEventHandler.cs | 18 +++++++++ src/Umbraco.Web/Mvc/SurfaceController.cs | 41 --------------------- src/Umbraco.Web/WebBootManager.cs | 7 +--- 3 files changed, 19 insertions(+), 47 deletions(-) diff --git a/src/Umbraco.Web/IApplicationEventHandler.cs b/src/Umbraco.Web/IApplicationEventHandler.cs index 9ed0e3dbb9..63c34d1589 100644 --- a/src/Umbraco.Web/IApplicationEventHandler.cs +++ b/src/Umbraco.Web/IApplicationEventHandler.cs @@ -8,8 +8,26 @@ namespace Umbraco.Web /// public interface IApplicationEventHandler : IApplicationStartupHandler { + /// + /// ApplicationContext is created and other static objects that require initialization have been setup + /// + /// + /// void OnApplicationInitialized(UmbracoApplication httpApplication, ApplicationContext applicationContext); + + /// + /// All resolvers have been initialized but resolution is not frozen so they can be modified in this method + /// + /// + /// void OnApplicationStarting(UmbracoApplication httpApplication, ApplicationContext applicationContext); + + /// + /// Bootup is completed, this allows you to perform any other bootup logic required for the application. + /// Resolution is frozen so now they can be used to resolve instances. + /// + /// + /// void OnApplicationStarted(UmbracoApplication httpApplication, ApplicationContext applicationContext); } } \ No newline at end of file diff --git a/src/Umbraco.Web/Mvc/SurfaceController.cs b/src/Umbraco.Web/Mvc/SurfaceController.cs index ee4cc7c3ec..c114b286dc 100644 --- a/src/Umbraco.Web/Mvc/SurfaceController.cs +++ b/src/Umbraco.Web/Mvc/SurfaceController.cs @@ -6,47 +6,6 @@ using Umbraco.Core; namespace Umbraco.Web.Mvc { - //[PluginController("MyTestSurfaceController")] - //public class TestSurfaceController : SurfaceController - //{ - // public ActionResult Index() - // { - // return View(); - // //return Content("hello"); - // } - - // public ActionResult PostVals(string name) - // { - // ModelState.AddModelError("name", "bad name!"); - // return CurrentUmbracoPage(); - // } - - // [ChildActionOnly] - // public ActionResult DoThis(string asdf) - // { - // return PartialView("DoThis", asdf + " DONE!"); - // } - //} - - //public class LocalSurfaceController : SurfaceController - //{ - // public ActionResult Index() - // { - // return View(); - // } - - // public ActionResult PostVals([Bind(Prefix = "blah")]string name) - // { - // ModelState.AddModelError("name", "you suck!"); - // return this.RedirectToCurrentUmbracoPage(); - // } - - // [ChildActionOnly] - // public ActionResult DoThis(string asdf) - // { - // return PartialView("DoThis", asdf + " DONE Again!"); - // } - //} /// /// The base controller that all Presentation Add-in controllers should inherit from diff --git a/src/Umbraco.Web/WebBootManager.cs b/src/Umbraco.Web/WebBootManager.cs index fd0cbf6d59..5c6d5684e7 100644 --- a/src/Umbraco.Web/WebBootManager.cs +++ b/src/Umbraco.Web/WebBootManager.cs @@ -45,12 +45,7 @@ namespace Umbraco.Web _umbracoApplication = umbracoApplication; if (umbracoApplication == null) throw new ArgumentNullException("umbracoApplication"); } - - public void Boot() - { - InitializeResolvers(); - } - + /// /// Initialize objects before anything during the boot cycle happens /// From 1304a9d7916337c976fe110cd60c46df0387eb55 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Fri, 18 Jan 2013 08:44:39 -0100 Subject: [PATCH 157/188] Fixed U4-1495 Include Umbraco assemblies' XML files to make use of comments --- build/Build.proj | 15 ++++++++++++++- src/SQLCE4Umbraco/SqlCE4Umbraco.csproj | 1 + src/Umbraco.Core/Umbraco.Core.csproj | 1 + .../umbraco.MacroEngines.csproj | 1 + .../umbraco.businesslogic.csproj | 2 +- src/umbraco.cms/umbraco.cms.csproj | 2 +- src/umbraco.controls/umbraco.controls.csproj | 2 +- src/umbraco.datalayer/umbraco.datalayer.csproj | 2 +- .../umbraco.editorControls.csproj | 2 +- src/umbraco.interfaces/umbraco.interfaces.csproj | 2 +- .../umbraco.macroRenderings.csproj | 2 +- src/umbraco.providers/umbraco.providers.csproj | 2 +- .../umbraco.webservices.csproj | 2 +- 13 files changed, 26 insertions(+), 10 deletions(-) diff --git a/build/Build.proj b/build/Build.proj index e300df172e..e5c0116e15 100644 --- a/build/Build.proj +++ b/build/Build.proj @@ -147,7 +147,7 @@ - + @@ -158,6 +158,19 @@ SkipUnchangedFiles="false" /> + + + + + + + + + + diff --git a/src/SQLCE4Umbraco/SqlCE4Umbraco.csproj b/src/SQLCE4Umbraco/SqlCE4Umbraco.csproj index ca9bd06eb3..db3caf4b82 100644 --- a/src/SQLCE4Umbraco/SqlCE4Umbraco.csproj +++ b/src/SQLCE4Umbraco/SqlCE4Umbraco.csproj @@ -39,6 +39,7 @@ TRACE prompt 4 + bin\Release\SQLCE4Umbraco.XML diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 15015c77f6..81dd77af1a 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -31,6 +31,7 @@ TRACE prompt 4 + bin\Release\Umbraco.Core.xml diff --git a/src/umbraco.MacroEngines/umbraco.MacroEngines.csproj b/src/umbraco.MacroEngines/umbraco.MacroEngines.csproj index f1932c9c8e..6a48f06cf6 100644 --- a/src/umbraco.MacroEngines/umbraco.MacroEngines.csproj +++ b/src/umbraco.MacroEngines/umbraco.MacroEngines.csproj @@ -39,6 +39,7 @@ TRACE prompt 4 + bin\Release\umbraco.MacroEngines.xml diff --git a/src/umbraco.businesslogic/umbraco.businesslogic.csproj b/src/umbraco.businesslogic/umbraco.businesslogic.csproj index e07ae3cc1d..7586e83e68 100644 --- a/src/umbraco.businesslogic/umbraco.businesslogic.csproj +++ b/src/umbraco.businesslogic/umbraco.businesslogic.csproj @@ -88,7 +88,7 @@ TRACE - bin\release\businesslogic.XML + bin\release\businesslogic.xml false 4096 false diff --git a/src/umbraco.cms/umbraco.cms.csproj b/src/umbraco.cms/umbraco.cms.csproj index f00c31a471..a8cb396ac6 100644 --- a/src/umbraco.cms/umbraco.cms.csproj +++ b/src/umbraco.cms/umbraco.cms.csproj @@ -88,7 +88,7 @@ TRACE - bin\Release\cms.XML + bin\Release\cms.xml false 4096 false diff --git a/src/umbraco.controls/umbraco.controls.csproj b/src/umbraco.controls/umbraco.controls.csproj index 4ae38fb1ea..4b377aab47 100644 --- a/src/umbraco.controls/umbraco.controls.csproj +++ b/src/umbraco.controls/umbraco.controls.csproj @@ -62,7 +62,7 @@ TRACE prompt 4 - bin\Release\controls.XML + bin\Release\controls.xml AllRules.ruleset diff --git a/src/umbraco.datalayer/umbraco.datalayer.csproj b/src/umbraco.datalayer/umbraco.datalayer.csproj index 8130c877a4..58706d07da 100644 --- a/src/umbraco.datalayer/umbraco.datalayer.csproj +++ b/src/umbraco.datalayer/umbraco.datalayer.csproj @@ -62,7 +62,7 @@ TRACE prompt 4 - bin\Release\umbraco.DataLayer.XML + bin\Release\umbraco.DataLayer.xml AllRules.ruleset diff --git a/src/umbraco.editorControls/umbraco.editorControls.csproj b/src/umbraco.editorControls/umbraco.editorControls.csproj index de7c1cb73b..52ba1ea312 100644 --- a/src/umbraco.editorControls/umbraco.editorControls.csproj +++ b/src/umbraco.editorControls/umbraco.editorControls.csproj @@ -88,7 +88,7 @@ TRACE - bin\Release\umbraco.editorControls.XML + bin\Release\umbraco.editorControls.xml false 4096 false diff --git a/src/umbraco.interfaces/umbraco.interfaces.csproj b/src/umbraco.interfaces/umbraco.interfaces.csproj index 8548c44273..4af542ac21 100644 --- a/src/umbraco.interfaces/umbraco.interfaces.csproj +++ b/src/umbraco.interfaces/umbraco.interfaces.csproj @@ -86,7 +86,7 @@ TRACE - bin\Release\interfaces.XML + bin\Release\interfaces.xml false 4096 false diff --git a/src/umbraco.macroRenderings/umbraco.macroRenderings.csproj b/src/umbraco.macroRenderings/umbraco.macroRenderings.csproj index d7688cef4c..fb5e2d5400 100644 --- a/src/umbraco.macroRenderings/umbraco.macroRenderings.csproj +++ b/src/umbraco.macroRenderings/umbraco.macroRenderings.csproj @@ -88,7 +88,7 @@ TRACE - bin\Release\umbraco.macroRenderings.XML + bin\Release\umbraco.macroRenderings.xml false 4096 false diff --git a/src/umbraco.providers/umbraco.providers.csproj b/src/umbraco.providers/umbraco.providers.csproj index f9d60c14c7..29e8df7ccc 100644 --- a/src/umbraco.providers/umbraco.providers.csproj +++ b/src/umbraco.providers/umbraco.providers.csproj @@ -60,7 +60,7 @@ TRACE prompt 4 - bin\Release\umbraco.providers.XML + bin\Release\umbraco.providers.xml AllRules.ruleset diff --git a/src/umbraco.webservices/umbraco.webservices.csproj b/src/umbraco.webservices/umbraco.webservices.csproj index 14ed9df3b7..dd66057656 100644 --- a/src/umbraco.webservices/umbraco.webservices.csproj +++ b/src/umbraco.webservices/umbraco.webservices.csproj @@ -58,7 +58,7 @@ TRACE prompt 4 - bin\Release\umbraco.webservices.XML + bin\Release\umbraco.webservices.xml AllRules.ruleset From f5ce9dc9d08327f5571ae00816001613acd6d651 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Fri, 18 Jan 2013 08:54:53 -0100 Subject: [PATCH 158/188] U4-1496 Remove Boot() method from WebBootManager - Applying 024896ba7bcf to v6 --- src/Umbraco.Web/WebBootManager.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Umbraco.Web/WebBootManager.cs b/src/Umbraco.Web/WebBootManager.cs index 58b62c6425..4f14a34bc6 100644 --- a/src/Umbraco.Web/WebBootManager.cs +++ b/src/Umbraco.Web/WebBootManager.cs @@ -47,11 +47,6 @@ namespace Umbraco.Web if (umbracoApplication == null) throw new ArgumentNullException("umbracoApplication"); } - public void Boot() - { - InitializeResolvers(); - } - /// /// Initialize objects before anything during the boot cycle happens /// From b5a140945a68b468381e74236272dd54745152bd Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Fri, 18 Jan 2013 09:00:18 -0100 Subject: [PATCH 159/188] Fixes U4-1479 by adding .ToList() to allowed templates, which ensures that the list is fetched from the database while the connection is still open. Fixing typo in usage of LogHelper in PhysicalFileSystem. Ensures connection is closed after using TableExists for MySql. Adds logging to UmbracoDatabase. --- src/Umbraco.Core/IO/PhysicalFileSystem.cs | 2 +- .../Repositories/ContentTypeRepository.cs | 3 +-- .../SqlSyntax/MySqlSyntaxProvider.cs | 20 ++++++++++++++----- .../Persistence/UmbracoDatabase.cs | 12 +++++++---- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/Umbraco.Core/IO/PhysicalFileSystem.cs b/src/Umbraco.Core/IO/PhysicalFileSystem.cs index 1be25138e6..74d7f27671 100644 --- a/src/Umbraco.Core/IO/PhysicalFileSystem.cs +++ b/src/Umbraco.Core/IO/PhysicalFileSystem.cs @@ -147,7 +147,7 @@ namespace Umbraco.Core.IO } catch (FileNotFoundException ex) { - LogHelper.Info(string.Format("DeleteFile failed with FileNotFoundException: {0}", ex.InnerException)); + LogHelper.Info(string.Format("DeleteFile failed with FileNotFoundException: {0}", ex.InnerException)); } } diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentTypeRepository.cs index 4e81334a56..03bb6ceca3 100644 --- a/src/Umbraco.Core/Persistence/Repositories/ContentTypeRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/ContentTypeRepository.cs @@ -56,8 +56,7 @@ namespace Umbraco.Core.Persistence.Repositories var templates = Database.Fetch("WHERE contentTypeNodeId = @Id", new { Id = id }); if(templates.Any()) { - contentType.AllowedTemplates = - templates.Select(template => _templateRepository.Get(template.TemplateNodeId)); + contentType.AllowedTemplates = templates.Select(template => _templateRepository.Get(template.TemplateNodeId)).ToList(); } var list = Database.Fetch("WHERE childContentTypeId = @Id", new { Id = id}); diff --git a/src/Umbraco.Core/Persistence/SqlSyntax/MySqlSyntaxProvider.cs b/src/Umbraco.Core/Persistence/SqlSyntax/MySqlSyntaxProvider.cs index 8439daa1c7..1d124b3687 100644 --- a/src/Umbraco.Core/Persistence/SqlSyntax/MySqlSyntaxProvider.cs +++ b/src/Umbraco.Core/Persistence/SqlSyntax/MySqlSyntaxProvider.cs @@ -41,11 +41,21 @@ namespace Umbraco.Core.Persistence.SqlSyntax public override bool DoesTableExist(Database db, string tableName) { - db.OpenSharedConnection(); - var result = - db.ExecuteScalar("SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES " + - "WHERE TABLE_NAME = @TableName AND " + - "TABLE_SCHEMA = @TableSchema", new { TableName = tableName, TableSchema = db.Connection.Database }); + long result; + try + { + db.OpenSharedConnection(); + result = + db.ExecuteScalar("SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES " + + "WHERE TABLE_NAME = @TableName AND " + + "TABLE_SCHEMA = @TableSchema", + new {TableName = tableName, TableSchema = db.Connection.Database}); + + } + finally + { + db.CloseSharedConnection(); + } return result > 0; } diff --git a/src/Umbraco.Core/Persistence/UmbracoDatabase.cs b/src/Umbraco.Core/Persistence/UmbracoDatabase.cs index a67e7960ba..60d28e5292 100644 --- a/src/Umbraco.Core/Persistence/UmbracoDatabase.cs +++ b/src/Umbraco.Core/Persistence/UmbracoDatabase.cs @@ -1,6 +1,7 @@ using System; using System.Data; using System.Data.Common; +using Umbraco.Core.Logging; namespace Umbraco.Core.Persistence { @@ -14,10 +15,7 @@ namespace Umbraco.Core.Persistence /// public class UmbracoDatabase : Database { - - - - private readonly Guid _instanceId = Guid.NewGuid(); + private readonly Guid _instanceId = Guid.NewGuid(); /// /// Used for testing /// @@ -41,5 +39,11 @@ namespace Umbraco.Core.Persistence public UmbracoDatabase(string connectionStringName) : base(connectionStringName) { } + + public override void OnException(Exception x) + { + LogHelper.Info(x.StackTrace); + base.OnException(x); + } } } \ No newline at end of file From 53ddda9f5936149d0c53099d431ff32251fbbe55 Mon Sep 17 00:00:00 2001 From: "NielsHartvig@UMBRACORATI.localdomain" Date: Fri, 18 Jan 2013 09:03:58 -0100 Subject: [PATCH 160/188] Fixes U4-1480 ContentBase.SetPropertyValue has no override for long datatype --- src/Umbraco.Core/Models/ContentBase.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Umbraco.Core/Models/ContentBase.cs b/src/Umbraco.Core/Models/ContentBase.cs index ee4deeb96d..abac49248f 100644 --- a/src/Umbraco.Core/Models/ContentBase.cs +++ b/src/Umbraco.Core/Models/ContentBase.cs @@ -309,6 +309,17 @@ namespace Umbraco.Core.Models SetValueOnProperty(propertyTypeAlias, value); } + /// + /// Sets the value of a Property + /// + /// Alias of the PropertyType + /// Value to set for the Property + public virtual void SetPropertyValue(string propertyTypeAlias, long value) + { + string val = value.ToString(); + SetValueOnProperty(propertyTypeAlias, val); + } + /// /// Sets the value of a Property /// From 307a7fa77baeacede35278dcfe47dfa059ebf0b7 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Fri, 18 Jan 2013 09:15:21 -0100 Subject: [PATCH 161/188] NuGet too: U4-1495 Include Umbraco assemblies' XML files to make use of comments --- build/NuSpecs/UmbracoCms.Core.nuspec | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/build/NuSpecs/UmbracoCms.Core.nuspec b/build/NuSpecs/UmbracoCms.Core.nuspec index 5f115b8442..f6a35fa4d6 100644 --- a/build/NuSpecs/UmbracoCms.Core.nuspec +++ b/build/NuSpecs/UmbracoCms.Core.nuspec @@ -22,17 +22,23 @@ + + + + + + @@ -44,14 +50,22 @@ + + + + + + + + From 9ef07ed2eb2a2b5da0e616d2001325d517a423b2 Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Fri, 18 Jan 2013 10:56:14 -0100 Subject: [PATCH 162/188] Fixes U4-1214 and U4-1484 for both Content and Media --- .../Repositories/ContentRepository.cs | 1 + .../Repositories/MediaRepository.cs | 1 + src/Umbraco.Core/Services/ContentService.cs | 130 ++++++++++++------ src/Umbraco.Core/Services/MediaService.cs | 36 +++++ 4 files changed, 126 insertions(+), 42 deletions(-) diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs index f699b8fec4..b284a4550a 100644 --- a/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs @@ -280,6 +280,7 @@ namespace Umbraco.Core.Persistence.Repositories { var parent = Database.First("WHERE id = @ParentId", new { ParentId = entity.ParentId }); entity.Path = string.Concat(parent.Path, ",", entity.Id); + entity.Level = parent.Level + 1; var maxSortOrder = Database.ExecuteScalar("SELECT coalesce(max(sortOrder),0) FROM umbracoNode WHERE parentid = @ParentId", new { ParentId = entity.ParentId }); entity.SortOrder = maxSortOrder; } diff --git a/src/Umbraco.Core/Persistence/Repositories/MediaRepository.cs b/src/Umbraco.Core/Persistence/Repositories/MediaRepository.cs index 9731e92610..33a7a35e9f 100644 --- a/src/Umbraco.Core/Persistence/Repositories/MediaRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/MediaRepository.cs @@ -245,6 +245,7 @@ namespace Umbraco.Core.Persistence.Repositories { var parent = Database.First("WHERE id = @ParentId", new { ParentId = entity.ParentId }); entity.Path = string.Concat(parent.Path, ",", entity.Id); + entity.Level = parent.Level + 1; var maxSortOrder = Database.ExecuteScalar("SELECT coalesce(max(sortOrder),0) FROM umbracoNode WHERE parentid = @ParentId", new { ParentId = entity.ParentId }); entity.SortOrder = maxSortOrder; } diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs index 87409151e3..b225a3a5cb 100644 --- a/src/Umbraco.Core/Services/ContentService.cs +++ b/src/Umbraco.Core/Services/ContentService.cs @@ -894,56 +894,76 @@ namespace Umbraco.Core.Services } /// - /// Moves an object to a new location by changing its parent id. - /// - /// - /// If the object is already published it will be - /// published after being moved to its new location. Otherwise it'll just - /// be saved with a new parent id. - /// - /// The to move - /// Id of the Content's new Parent - /// Optional Id of the User moving the Content - public void Move(IContent content, int parentId, int userId = -1) - { - //This ensures that the correct method is called if this method is used to Move to recycle bin. - if (parentId == -20) - { - MoveToRecycleBin(content, userId); - return; - } + /// Moves an object to a new location by changing its parent id. + /// + /// + /// If the object is already published it will be + /// published after being moved to its new location. Otherwise it'll just + /// be saved with a new parent id. + /// + /// The to move + /// Id of the Content's new Parent + /// Optional Id of the User moving the Content + public void Move(IContent content, int parentId, int userId = -1) + { + //This ensures that the correct method is called if this method is used to Move to recycle bin. + if (parentId == -20) + { + MoveToRecycleBin(content, userId); + return; + } - if (Moving.IsRaisedEventCancelled(new MoveEventArgs(content, parentId), this)) - return; - - SetWriter(content, userId); + if (Moving.IsRaisedEventCancelled(new MoveEventArgs(content, parentId), this)) + return; - //If Content is being moved away from Recycle Bin, its state should be un-trashed - if (content.Trashed && parentId != -20) - { - content.ChangeTrashedState(false, parentId); - } - else - { - content.ParentId = parentId; - } + SetWriter(content, userId); - //If Content is published, it should be (re)published from its new location - if (content.Published) - { - SaveAndPublish(content, userId); - } - else - { - Save(content, userId); - } + //If Content is being moved away from Recycle Bin, its state should be un-trashed + if (content.Trashed && parentId != -20) + { + content.ChangeTrashedState(false, parentId); + } + else + { + content.ParentId = parentId; + } - Moved.RaiseEvent(new MoveEventArgs(content, false, parentId), this); + //If Content is published, it should be (re)published from its new location + if (content.Published) + { + SaveAndPublish(content, userId); + } + else + { + Save(content, userId); + } + + //Ensure that Path and Level is updated on children + var children = GetChildren(content.Id); + if (children.Any()) + { + var parentPath = content.Path; + var parentLevel = content.Level; + var updatedDescendents = UpdatePathAndLevelOnChildren(children, parentPath, parentLevel); + + //collection of descendents that needs to be saved and published + var descendentsToSaveAndPublish = updatedDescendents.Where(x => x.Published); + foreach (var c in descendentsToSaveAndPublish) + { + SaveAndPublish(c, userId); + } + + //collection of descendents that only needs to be saved + var descendentsToSave = updatedDescendents.Where(x => x.Published == false); + Save(descendentsToSave, userId); + } + + Moved.RaiseEvent(new MoveEventArgs(content, false, parentId), this); Audit.Add(AuditTypes.Move, "Move Content performed by user", userId == -1 ? 0 : userId, content.Id); } - /// + /// /// Empties the Recycle Bin by deleting all that resides in the bin /// public void EmptyRecycleBin() @@ -1202,6 +1222,32 @@ namespace Umbraco.Core.Services return true; } + /// + /// Updates the Path and Level on a collection of objects + /// based on the Parent's Path and Level. + /// + /// Collection of objects to update + /// Path of the Parent content + /// Level of the Parent content + /// Collection of updated objects + private List UpdatePathAndLevelOnChildren(IEnumerable children, string parentPath, int parentLevel) + { + var list = new List(); + foreach (var child in children) + { + child.Path = string.Concat(parentPath, ",", child.Id); + child.Level = parentLevel + 1; + list.Add(child); + + var grandkids = GetChildren(child.Id); + if (grandkids.Any()) + { + list.AddRange(UpdatePathAndLevelOnChildren(grandkids, child.Path, child.Level)); + } + } + return list; + } + /// /// Updates a content object with the User (id), who created the content. /// diff --git a/src/Umbraco.Core/Services/MediaService.cs b/src/Umbraco.Core/Services/MediaService.cs index c456f5d95e..bb5d0ac844 100644 --- a/src/Umbraco.Core/Services/MediaService.cs +++ b/src/Umbraco.Core/Services/MediaService.cs @@ -276,6 +276,16 @@ namespace Umbraco.Core.Services media.ParentId = parentId; Save(media, userId); + //Ensure that Path and Level is updated on children + var children = GetChildren(media.Id); + if (children.Any()) + { + var parentPath = media.Path; + var parentLevel = media.Level; + var updatedDescendents = UpdatePathAndLevelOnChildren(children, parentPath, parentLevel); + Save(updatedDescendents, userId); + } + Moved.RaiseEvent(new MoveEventArgs(media, false, parentId), this); Audit.Add(AuditTypes.Move, "Move Media performed by user", userId == -1 ? 0 : userId, media.Id); @@ -513,6 +523,32 @@ namespace Umbraco.Core.Services _httpContext = httpContext; } + /// + /// Updates the Path and Level on a collection of objects + /// based on the Parent's Path and Level. + /// + /// Collection of objects to update + /// Path of the Parent media + /// Level of the Parent media + /// Collection of updated objects + private List UpdatePathAndLevelOnChildren(IEnumerable children, string parentPath, int parentLevel) + { + var list = new List(); + foreach (var child in children) + { + child.Path = string.Concat(parentPath, ",", child.Id); + child.Level = parentLevel + 1; + list.Add(child); + + var grandkids = GetChildren(child.Id); + if (grandkids.Any()) + { + list.AddRange(UpdatePathAndLevelOnChildren(grandkids, child.Path, child.Level)); + } + } + return list; + } + /// /// Updates a media object with the User (id), who created the content. /// From 0292ca9bf3ed88de1044ff42e0cdfcd6530b4436 Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Fri, 18 Jan 2013 11:18:19 -0100 Subject: [PATCH 163/188] Fixes issue with duplicated tags on inherited doc types. --- src/umbraco.cms/businesslogic/ContentType.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/umbraco.cms/businesslogic/ContentType.cs b/src/umbraco.cms/businesslogic/ContentType.cs index 59652b27a2..f0ee6bf8f7 100644 --- a/src/umbraco.cms/businesslogic/ContentType.cs +++ b/src/umbraco.cms/businesslogic/ContentType.cs @@ -1224,7 +1224,7 @@ namespace umbraco.cms.businesslogic temporaryList.Sort((a, b) => a.SortOrder.CompareTo(b.SortOrder)); // now that we aren't going to modify the list, we can set it to the class-scoped variable. - m_VirtualTabs = temporaryList; + m_VirtualTabs = temporaryList.DistinctBy(x => x.Id).ToList(); } private void populateMasterContentTypes(PropertyType pt, int docTypeId) From e8361c2ab51cf5f30bf6ae7bab8f77ce149a051c Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Fri, 18 Jan 2013 11:45:01 -0100 Subject: [PATCH 164/188] Allow specified content types to be created at the root level --- .../controls/ContentTypeControlNew.ascx | 4 + .../controls/ContentTypeControlNew.ascx | 4 + .../controls/ContentTypeControlNew.ascx.cs | 3 + .../ContentTypeControlNew.ascx.designer.cs | 18 ++++ .../umbraco/create/content.ascx.cs | 8 +- .../umbraco/create/media.ascx.cs | 94 ++++++++++--------- 6 files changed, 84 insertions(+), 47 deletions(-) diff --git a/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx b/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx index d0d0899bd7..a0588b4516 100644 --- a/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx +++ b/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx @@ -78,6 +78,10 @@ + +
+ Only Content Types with this checked can be created at the root level of Content and Media trees +
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx index d0d0899bd7..a0588b4516 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx @@ -78,6 +78,10 @@ + +
+ Only Content Types with this checked can be created at the root level of Content and Media trees +
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs index 5533eeb599..549ce2657c 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs @@ -296,6 +296,8 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }}); } dualAllowedContentTypes.Value = chosenContentTypeIDs; } + + allowAtRoot.Checked = cType.AllowAtRoot; } private void SaveAllowedChildTypes() @@ -309,6 +311,7 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }}); int[] ids = new int[tmp.Count]; for (int i = 0; i < tmp.Count; i++) ids[i] = (int)tmp[i]; cType.AllowedChildContentTypeIDs = ids; + cType.AllowAtRoot = allowAtRoot.Checked; } #endregion diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.designer.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.designer.cs index bc732a166a..465ea3bbca 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.designer.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.designer.cs @@ -255,6 +255,24 @@ namespace umbraco.controls { /// protected global::umbraco.uicontrols.Pane Pane5; + /// + /// pp_Root control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel pp_Root; + + /// + /// allowAtRoot control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.CheckBox allowAtRoot; + /// /// pp_allowedChildren control. /// diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/create/content.ascx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/create/content.ascx.cs index e39bef550f..14347b5c04 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/create/content.ascx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/create/content.ascx.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Text; using System.Web.UI; using System.Web.UI.WebControls; @@ -35,7 +36,8 @@ namespace umbraco.cms.presentation.create.controls int counter = 0; bool typeInited = false; StringBuilder js = new StringBuilder(); - foreach (DocumentType dt in DocumentType.GetAllAsList()) + var documentTypeList = DocumentType.GetAllAsList().ToList(); + foreach (DocumentType dt in documentTypeList) { string docDescription = "No description available..."; if (dt.Description != null && dt.Description != "") @@ -68,7 +70,9 @@ namespace umbraco.cms.presentation.create.controls counter++; } } - else { + // The Any check is here for backwards compatibility, if none are allowed at root, then all are allowed + else if (documentTypeList.Any(d => d.AllowAtRoot) == false || dt.AllowAtRoot) + { nodeType.Items.Add(li); js.Append("typeInfo[" + counter + "] = '

" + docDescription + "

'\n"); diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/create/media.ascx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/create/media.ascx.cs index d6b615316a..2149fb1d22 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/create/media.ascx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/create/media.ascx.cs @@ -1,17 +1,19 @@ +using System.Linq; + namespace umbraco.cms.presentation.create.controls { - using System; - using System.Web.UI.WebControls; - using umbraco.BasePages; + using System; + using System.Web.UI.WebControls; + using umbraco.BasePages; - /// - /// Summary description for media. - /// - public partial class media : System.Web.UI.UserControl - { + /// + /// Summary description for media. + /// + public partial class media : System.Web.UI.UserControl + { - protected void Page_Load(object sender, System.EventArgs e) + protected void Page_Load(object sender, System.EventArgs e) { sbmt.Text = ui.Text("create"); int NodeId = int.Parse(Request["nodeID"]); @@ -23,7 +25,8 @@ namespace umbraco.cms.presentation.create.controls allowedIds = c.ContentType.AllowedChildContentTypeIDs; } - foreach (var dt in cms.businesslogic.media.MediaType.GetAllAsList()) + var documentTypeList = businesslogic.media.MediaType.GetAllAsList().ToList(); + foreach (var dt in documentTypeList) { ListItem li = new ListItem(); li.Text = dt.Text; @@ -32,47 +35,48 @@ namespace umbraco.cms.presentation.create.controls if (NodeId > 2) { foreach (int i in allowedIds) if (i == dt.Id) nodeType.Items.Add(li); - } - else + } + // The Any check is here for backwards compatibility, if none are allowed at root, then all are allowed + else if (documentTypeList.Any(d => d.AllowAtRoot) == false || dt.AllowAtRoot) nodeType.Items.Add(li); } } - #region Web Form Designer generated code - override protected void OnInit(EventArgs e) - { - // - // CODEGEN: This call is required by the ASP.NET Web Form Designer. - // - InitializeComponent(); - base.OnInit(e); - } - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { + #region Web Form Designer generated code + override protected void OnInit(EventArgs e) + { + // + // CODEGEN: This call is required by the ASP.NET Web Form Designer. + // + InitializeComponent(); + base.OnInit(e); + } - } - #endregion + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { - protected void sbmt_Click(object sender, System.EventArgs e) - { - if (Page.IsValid) - { - string returnUrl = umbraco.presentation.create.dialogHandler_temp.Create( - umbraco.helper.Request("nodeType"), - int.Parse(nodeType.SelectedValue), - int.Parse(Request["nodeID"]), - rename.Text); + } + #endregion - BasePage.Current.ClientTools - .ChangeContentFrameUrl(returnUrl) - .CloseModalWindow(); + protected void sbmt_Click(object sender, System.EventArgs e) + { + if (Page.IsValid) + { + string returnUrl = umbraco.presentation.create.dialogHandler_temp.Create( + umbraco.helper.Request("nodeType"), + int.Parse(nodeType.SelectedValue), + int.Parse(Request["nodeID"]), + rename.Text); - } - } - } + BasePage.Current.ClientTools + .ChangeContentFrameUrl(returnUrl) + .CloseModalWindow(); + + } + } + } } From caea28afd0a44d34c9f469b51d8ce2b68f8111e5 Mon Sep 17 00:00:00 2001 From: "NielsHartvig@UMBRACORATI.localdomain" Date: Fri, 18 Jan 2013 11:54:55 -0100 Subject: [PATCH 165/188] Implements U4-1500 Make sure doctype import/export and packager can set root doctypes --- src/umbraco.cms/businesslogic/Packager/Installer.cs | 9 +++++++++ src/umbraco.cms/businesslogic/web/DocumentType.cs | 1 + 2 files changed, 10 insertions(+) diff --git a/src/umbraco.cms/businesslogic/Packager/Installer.cs b/src/umbraco.cms/businesslogic/Packager/Installer.cs index 9ab0287ca6..69b1c5899a 100644 --- a/src/umbraco.cms/businesslogic/Packager/Installer.cs +++ b/src/umbraco.cms/businesslogic/Packager/Installer.cs @@ -714,6 +714,15 @@ namespace umbraco.cms.businesslogic.packager dt.Thumbnail = xmlHelper.GetNodeValue(n.SelectSingleNode("Info/Thumbnail")); dt.Description = xmlHelper.GetNodeValue(n.SelectSingleNode("Info/Description")); + // Allow at root (check for node due to legacy) + bool allowAtRoot = false; + string allowAtRootNode = xmlHelper.GetNodeValue(n.SelectSingleNode("Info/AllowAtRoot")); + if (!String.IsNullOrEmpty(allowAtRootNode)) + { + bool.TryParse(allowAtRootNode, out allowAtRoot); + } + dt.AllowAtRoot = allowAtRoot; + // Templates ArrayList templates = new ArrayList(); foreach (XmlNode tem in n.SelectNodes("Info/AllowedTemplates/Template")) diff --git a/src/umbraco.cms/businesslogic/web/DocumentType.cs b/src/umbraco.cms/businesslogic/web/DocumentType.cs index 882ba8d154..04cc8ec314 100644 --- a/src/umbraco.cms/businesslogic/web/DocumentType.cs +++ b/src/umbraco.cms/businesslogic/web/DocumentType.cs @@ -348,6 +348,7 @@ namespace umbraco.cms.businesslogic.web info.AppendChild(XmlHelper.AddTextNode(xd, "Icon", IconUrl)); info.AppendChild(XmlHelper.AddTextNode(xd, "Thumbnail", Thumbnail)); info.AppendChild(XmlHelper.AddTextNode(xd, "Description", Description)); + info.AppendChild(XmlHelper.AddTextNode(xd, "AllowAtRoot", AllowAtRoot.ToString())); //TODO: Add support for mixins! if (this.MasterContentType > 0) From 62bd1ce4facd6a78859f26883a4b2a5c5e00806b Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Fri, 18 Jan 2013 12:00:29 -0100 Subject: [PATCH 166/188] Updates namespace for v6 migrations. Adds update parentId migration for MasterContentType. --- src/Umbraco.Core/CoreBootManager.cs | 24 +++++++++---------- .../DeleteAppTables.cs | 4 ++-- .../EnsureAppsTreesUpdated.cs | 4 ++-- .../MoveMasterContentTypeData.cs | 6 +++-- .../NewCmsContentType2ContentTypeTable.cs | 4 ++-- .../RemoveMasterContentTypeColumn.cs | 4 ++-- .../RenameCmsTabTable.cs | 4 ++-- .../RenameTabIdColumn.cs | 4 ++-- ...teCmsContentTypeAllowedContentTypeTable.cs | 4 ++-- .../UpdateCmsContentTypeTable.cs | 4 ++-- .../UpdateCmsContentVersionTable.cs | 4 ++-- .../UpdateCmsPropertyTypeGroupTable.cs | 4 ++-- src/Umbraco.Core/Umbraco.Core.csproj | 22 ++++++++--------- .../TargetVersionSixthMigrationsTest.cs | 23 +++++++++--------- .../Migrations/Upgrades/BaseUpgradeTest.cs | 23 +++++++++--------- .../EnsureAppsTreesUpdatedOnUpgrade.cs | 2 +- 16 files changed, 72 insertions(+), 68 deletions(-) rename src/Umbraco.Core/Persistence/Migrations/Upgrades/{TargetVersionSixth => TargetVersionSix}/DeleteAppTables.cs (77%) rename src/Umbraco.Core/Persistence/Migrations/Upgrades/{TargetVersionSixth => TargetVersionSix}/EnsureAppsTreesUpdated.cs (83%) rename src/Umbraco.Core/Persistence/Migrations/Upgrades/{TargetVersionSixth => TargetVersionSix}/MoveMasterContentTypeData.cs (59%) rename src/Umbraco.Core/Persistence/Migrations/Upgrades/{TargetVersionSixth => TargetVersionSix}/NewCmsContentType2ContentTypeTable.cs (88%) rename src/Umbraco.Core/Persistence/Migrations/Upgrades/{TargetVersionSixth => TargetVersionSix}/RemoveMasterContentTypeColumn.cs (89%) rename src/Umbraco.Core/Persistence/Migrations/Upgrades/{TargetVersionSixth => TargetVersionSix}/RenameCmsTabTable.cs (80%) rename src/Umbraco.Core/Persistence/Migrations/Upgrades/{TargetVersionSixth => TargetVersionSix}/RenameTabIdColumn.cs (95%) rename src/Umbraco.Core/Persistence/Migrations/Upgrades/{TargetVersionSixth => TargetVersionSix}/UpdateCmsContentTypeAllowedContentTypeTable.cs (83%) rename src/Umbraco.Core/Persistence/Migrations/Upgrades/{TargetVersionSixth => TargetVersionSix}/UpdateCmsContentTypeTable.cs (86%) rename src/Umbraco.Core/Persistence/Migrations/Upgrades/{TargetVersionSixth => TargetVersionSix}/UpdateCmsContentVersionTable.cs (82%) rename src/Umbraco.Core/Persistence/Migrations/Upgrades/{TargetVersionSixth => TargetVersionSix}/UpdateCmsPropertyTypeGroupTable.cs (88%) diff --git a/src/Umbraco.Core/CoreBootManager.cs b/src/Umbraco.Core/CoreBootManager.cs index 697bc34177..3559a436a2 100644 --- a/src/Umbraco.Core/CoreBootManager.cs +++ b/src/Umbraco.Core/CoreBootManager.cs @@ -8,11 +8,11 @@ using Umbraco.Core.ObjectResolution; using Umbraco.Core.Persistence; using Umbraco.Core.Persistence.Mappers; using Umbraco.Core.Persistence.Migrations; +using Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix; using Umbraco.Core.Persistence.UnitOfWork; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Publishing; using Umbraco.Core.Services; -using MigrationsVersionSixth = Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixth; using MigrationsVersionFourNineZero = Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionFourNineZero; namespace Umbraco.Core @@ -146,17 +146,17 @@ namespace Umbraco.Core MigrationResolver.Current = new MigrationResolver(new List { typeof (MigrationsVersionFourNineZero.RemoveUmbracoAppConstraints), - typeof (MigrationsVersionSixth.DeleteAppTables), - typeof (MigrationsVersionSixth.EnsureAppsTreesUpdated), - typeof (MigrationsVersionSixth.MoveMasterContentTypeData), - typeof (MigrationsVersionSixth.NewCmsContentType2ContentTypeTable), - typeof (MigrationsVersionSixth.RemoveMasterContentTypeColumn), - typeof (MigrationsVersionSixth.RenameCmsTabTable), - typeof (MigrationsVersionSixth.RenameTabIdColumn), - typeof (MigrationsVersionSixth.UpdateCmsContentTypeAllowedContentTypeTable), - typeof (MigrationsVersionSixth.UpdateCmsContentTypeTable), - typeof (MigrationsVersionSixth.UpdateCmsContentVersionTable), - typeof (MigrationsVersionSixth.UpdateCmsPropertyTypeGroupTable) + typeof (DeleteAppTables), + typeof (EnsureAppsTreesUpdated), + typeof (MoveMasterContentTypeData), + typeof (NewCmsContentType2ContentTypeTable), + typeof (RemoveMasterContentTypeColumn), + typeof (RenameCmsTabTable), + typeof (RenameTabIdColumn), + typeof (UpdateCmsContentTypeAllowedContentTypeTable), + typeof (UpdateCmsContentTypeTable), + typeof (UpdateCmsContentVersionTable), + typeof (UpdateCmsPropertyTypeGroupTable) }); } } diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/DeleteAppTables.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/DeleteAppTables.cs similarity index 77% rename from src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/DeleteAppTables.cs rename to src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/DeleteAppTables.cs index 4b41295d3b..567f641e5c 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/DeleteAppTables.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/DeleteAppTables.cs @@ -1,8 +1,8 @@ using Umbraco.Core.Configuration; -namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixth +namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix { - [MigrationAttribute("6.0.0", 10, GlobalSettings.UmbracoMigrationName)] + [Migration("6.0.0", 10, GlobalSettings.UmbracoMigrationName)] public class DeleteAppTables : MigrationBase { public override void Up() diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/EnsureAppsTreesUpdated.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/EnsureAppsTreesUpdated.cs similarity index 83% rename from src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/EnsureAppsTreesUpdated.cs rename to src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/EnsureAppsTreesUpdated.cs index 09f5191f68..2da4abf34e 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/EnsureAppsTreesUpdated.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/EnsureAppsTreesUpdated.cs @@ -1,9 +1,9 @@ using System; using Umbraco.Core.Configuration; -namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixth +namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix { - [MigrationAttribute("6.0.0", 9, GlobalSettings.UmbracoMigrationName)] + [Migration("6.0.0", 9, GlobalSettings.UmbracoMigrationName)] public class EnsureAppsTreesUpdated : MigrationBase { public override void Up() diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/MoveMasterContentTypeData.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/MoveMasterContentTypeData.cs similarity index 59% rename from src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/MoveMasterContentTypeData.cs rename to src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/MoveMasterContentTypeData.cs index 235f7a0a8a..cff2f5ad9c 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/MoveMasterContentTypeData.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/MoveMasterContentTypeData.cs @@ -1,14 +1,16 @@ using Umbraco.Core.Configuration; -namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixth +namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix { - [MigrationAttribute("6.0.0", 5, GlobalSettings.UmbracoMigrationName)] + [Migration("6.0.0", 5, GlobalSettings.UmbracoMigrationName)] public class MoveMasterContentTypeData : MigrationBase { public override void Up() { Execute.Sql( "INSERT INTO cmsContentType2ContentType (parentContentTypeId, childContentTypeId) SELECT masterContentType, nodeId FROM cmsContentType WHERE not masterContentType is null and masterContentType != 0"); + + Execute.Sql("UPDATE umbracoNode SET parentID = cmsContentType.masterContentType FROM umbracoNode, cmsContentType WHERE umbracoNode.id = cmsContentType.nodeId AND not cmsContentType.masterContentType is null AND cmsContentType.masterContentType != 0"); } public override void Down() diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/NewCmsContentType2ContentTypeTable.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/NewCmsContentType2ContentTypeTable.cs similarity index 88% rename from src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/NewCmsContentType2ContentTypeTable.cs rename to src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/NewCmsContentType2ContentTypeTable.cs index 3366691e0d..7ff03087c4 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/NewCmsContentType2ContentTypeTable.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/NewCmsContentType2ContentTypeTable.cs @@ -1,8 +1,8 @@ using Umbraco.Core.Configuration; -namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixth +namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix { - [MigrationAttribute("6.0.0", 4, GlobalSettings.UmbracoMigrationName)] + [Migration("6.0.0", 4, GlobalSettings.UmbracoMigrationName)] public class NewCmsContentType2ContentTypeTable : MigrationBase { public override void Up() diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/RemoveMasterContentTypeColumn.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/RemoveMasterContentTypeColumn.cs similarity index 89% rename from src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/RemoveMasterContentTypeColumn.cs rename to src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/RemoveMasterContentTypeColumn.cs index 7dc9b1bb19..680b2001a0 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/RemoveMasterContentTypeColumn.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/RemoveMasterContentTypeColumn.cs @@ -1,8 +1,8 @@ using Umbraco.Core.Configuration; -namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixth +namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix { - [MigrationAttribute("6.0.0", 6, GlobalSettings.UmbracoMigrationName)] + [Migration("6.0.0", 6, GlobalSettings.UmbracoMigrationName)] public class RemoveMasterContentTypeColumn : MigrationBase { public override void Up() diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/RenameCmsTabTable.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/RenameCmsTabTable.cs similarity index 80% rename from src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/RenameCmsTabTable.cs rename to src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/RenameCmsTabTable.cs index 9aaeb6b1a5..0f8635af09 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/RenameCmsTabTable.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/RenameCmsTabTable.cs @@ -1,8 +1,8 @@ using Umbraco.Core.Configuration; -namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixth +namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix { - [MigrationAttribute("6.0.0", 0, GlobalSettings.UmbracoMigrationName)] + [Migration("6.0.0", 0, GlobalSettings.UmbracoMigrationName)] public class RenameCmsTabTable : MigrationBase { public override void Up() diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/RenameTabIdColumn.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/RenameTabIdColumn.cs similarity index 95% rename from src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/RenameTabIdColumn.cs rename to src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/RenameTabIdColumn.cs index 31e8f18a0a..6f3f7edc80 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/RenameTabIdColumn.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/RenameTabIdColumn.cs @@ -1,9 +1,9 @@ using System.Data; using Umbraco.Core.Configuration; -namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixth +namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix { - [MigrationAttribute("6.0.0", 7, GlobalSettings.UmbracoMigrationName)] + [Migration("6.0.0", 7, GlobalSettings.UmbracoMigrationName)] public class RenameTabIdColumn : MigrationBase { public override void Up() diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/UpdateCmsContentTypeAllowedContentTypeTable.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/UpdateCmsContentTypeAllowedContentTypeTable.cs similarity index 83% rename from src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/UpdateCmsContentTypeAllowedContentTypeTable.cs rename to src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/UpdateCmsContentTypeAllowedContentTypeTable.cs index 3b5d86ad79..be704466a8 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/UpdateCmsContentTypeAllowedContentTypeTable.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/UpdateCmsContentTypeAllowedContentTypeTable.cs @@ -1,8 +1,8 @@ using Umbraco.Core.Configuration; -namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixth +namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix { - [MigrationAttribute("6.0.0", 3, GlobalSettings.UmbracoMigrationName)] + [Migration("6.0.0", 3, GlobalSettings.UmbracoMigrationName)] public class UpdateCmsContentTypeAllowedContentTypeTable : MigrationBase { public override void Up() diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/UpdateCmsContentTypeTable.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/UpdateCmsContentTypeTable.cs similarity index 86% rename from src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/UpdateCmsContentTypeTable.cs rename to src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/UpdateCmsContentTypeTable.cs index 35f0e76c36..3e6b4cf05c 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/UpdateCmsContentTypeTable.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/UpdateCmsContentTypeTable.cs @@ -1,8 +1,8 @@ using Umbraco.Core.Configuration; -namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixth +namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix { - [MigrationAttribute("6.0.0", 2, GlobalSettings.UmbracoMigrationName)] + [Migration("6.0.0", 2, GlobalSettings.UmbracoMigrationName)] public class UpdateCmsContentTypeTable : MigrationBase { public override void Up() diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/UpdateCmsContentVersionTable.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/UpdateCmsContentVersionTable.cs similarity index 82% rename from src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/UpdateCmsContentVersionTable.cs rename to src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/UpdateCmsContentVersionTable.cs index 55d1234022..1dc8998e68 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/UpdateCmsContentVersionTable.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/UpdateCmsContentVersionTable.cs @@ -1,8 +1,8 @@ using Umbraco.Core.Configuration; -namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixth +namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix { - [MigrationAttribute("6.0.0", 8, GlobalSettings.UmbracoMigrationName)] + [Migration("6.0.0", 8, GlobalSettings.UmbracoMigrationName)] public class UpdateCmsContentVersionTable : MigrationBase { public override void Up() diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/UpdateCmsPropertyTypeGroupTable.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/UpdateCmsPropertyTypeGroupTable.cs similarity index 88% rename from src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/UpdateCmsPropertyTypeGroupTable.cs rename to src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/UpdateCmsPropertyTypeGroupTable.cs index 62938eb1d3..2bd03f15bc 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixth/UpdateCmsPropertyTypeGroupTable.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/UpdateCmsPropertyTypeGroupTable.cs @@ -1,9 +1,9 @@ using System.Data; using Umbraco.Core.Configuration; -namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixth +namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix { - [MigrationAttribute("6.0.0", 1, GlobalSettings.UmbracoMigrationName)] + [Migration("6.0.0", 1, GlobalSettings.UmbracoMigrationName)] public class UpdateCmsPropertyTypeGroupTable : MigrationBase { public override void Up() diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 81dd77af1a..2b556f637f 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -377,17 +377,17 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/src/Umbraco.Tests/Migrations/TargetVersionSixthMigrationsTest.cs b/src/Umbraco.Tests/Migrations/TargetVersionSixthMigrationsTest.cs index a1e02bc18a..54ab36a387 100644 --- a/src/Umbraco.Tests/Migrations/TargetVersionSixthMigrationsTest.cs +++ b/src/Umbraco.Tests/Migrations/TargetVersionSixthMigrationsTest.cs @@ -6,6 +6,7 @@ using Umbraco.Core; using Umbraco.Core.ObjectResolution; using Umbraco.Core.Persistence; using Umbraco.Core.Persistence.Migrations; +using Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix; using Umbraco.Core.Persistence.SqlSyntax; using Umbraco.Tests.TestHelpers; using GlobalSettings = Umbraco.Core.Configuration.GlobalSettings; @@ -23,17 +24,17 @@ namespace Umbraco.Tests.Migrations MigrationResolver.Current = new MigrationResolver(new List { typeof (Core.Persistence.Migrations.Upgrades.TargetVersionFourNineZero.RemoveUmbracoAppConstraints), - typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.DeleteAppTables), - typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.EnsureAppsTreesUpdated), - typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.MoveMasterContentTypeData), - typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.NewCmsContentType2ContentTypeTable), - typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.RemoveMasterContentTypeColumn), - typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.RenameCmsTabTable), - typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.RenameTabIdColumn), - typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.UpdateCmsContentTypeAllowedContentTypeTable), - typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.UpdateCmsContentTypeTable), - typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.UpdateCmsContentVersionTable), - typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.UpdateCmsPropertyTypeGroupTable) + typeof (DeleteAppTables), + typeof (EnsureAppsTreesUpdated), + typeof (MoveMasterContentTypeData), + typeof (NewCmsContentType2ContentTypeTable), + typeof (RemoveMasterContentTypeColumn), + typeof (RenameCmsTabTable), + typeof (RenameTabIdColumn), + typeof (UpdateCmsContentTypeAllowedContentTypeTable), + typeof (UpdateCmsContentTypeTable), + typeof (UpdateCmsContentVersionTable), + typeof (UpdateCmsPropertyTypeGroupTable) }); Resolution.Freeze(); diff --git a/src/Umbraco.Tests/Migrations/Upgrades/BaseUpgradeTest.cs b/src/Umbraco.Tests/Migrations/Upgrades/BaseUpgradeTest.cs index e0d6444a5d..e229655699 100644 --- a/src/Umbraco.Tests/Migrations/Upgrades/BaseUpgradeTest.cs +++ b/src/Umbraco.Tests/Migrations/Upgrades/BaseUpgradeTest.cs @@ -7,6 +7,7 @@ using Umbraco.Core.Configuration; using Umbraco.Core.ObjectResolution; using Umbraco.Core.Persistence; using Umbraco.Core.Persistence.Migrations; +using Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix; using Umbraco.Core.Persistence.SqlSyntax; using Umbraco.Tests.TestHelpers; using Umbraco.Web.Strategies.Migrations; @@ -34,17 +35,17 @@ namespace Umbraco.Tests.Migrations.Upgrades MigrationResolver.Current = new MigrationResolver(new List { typeof (Core.Persistence.Migrations.Upgrades.TargetVersionFourNineZero.RemoveUmbracoAppConstraints), - typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.DeleteAppTables), - typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.EnsureAppsTreesUpdated), - typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.MoveMasterContentTypeData), - typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.NewCmsContentType2ContentTypeTable), - typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.RemoveMasterContentTypeColumn), - typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.RenameCmsTabTable), - typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.RenameTabIdColumn), - typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.UpdateCmsContentTypeAllowedContentTypeTable), - typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.UpdateCmsContentTypeTable), - typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.UpdateCmsContentVersionTable), - typeof (Core.Persistence.Migrations.Upgrades.TargetVersionSixth.UpdateCmsPropertyTypeGroupTable) + typeof (DeleteAppTables), + typeof (EnsureAppsTreesUpdated), + typeof (MoveMasterContentTypeData), + typeof (NewCmsContentType2ContentTypeTable), + typeof (RemoveMasterContentTypeColumn), + typeof (RenameCmsTabTable), + typeof (RenameTabIdColumn), + typeof (UpdateCmsContentTypeAllowedContentTypeTable), + typeof (UpdateCmsContentTypeTable), + typeof (UpdateCmsContentVersionTable), + typeof (UpdateCmsPropertyTypeGroupTable) }); Resolution.Freeze(); diff --git a/src/Umbraco.Web/Strategies/Migrations/EnsureAppsTreesUpdatedOnUpgrade.cs b/src/Umbraco.Web/Strategies/Migrations/EnsureAppsTreesUpdatedOnUpgrade.cs index 2c5a63f802..582980b0bc 100644 --- a/src/Umbraco.Web/Strategies/Migrations/EnsureAppsTreesUpdatedOnUpgrade.cs +++ b/src/Umbraco.Web/Strategies/Migrations/EnsureAppsTreesUpdatedOnUpgrade.cs @@ -1,4 +1,4 @@ -using Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixth; +using Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix; using umbraco.BusinessLogic; using umbraco.interfaces; From f6ceb937a1f05b4441fada7c30108e84dccf236c Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Fri, 18 Jan 2013 12:05:00 -0100 Subject: [PATCH 167/188] Changes the CoreBootManager to resolve migrations through the use of the PluginManager instead of having the migration types hardcoded. --- src/Umbraco.Core/CoreBootManager.cs | 23 ++++--------------- .../Migrations/MigrationResolver.cs | 6 ++--- src/Umbraco.Core/PluginManager.cs | 10 ++++++++ 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/Umbraco.Core/CoreBootManager.cs b/src/Umbraco.Core/CoreBootManager.cs index 3559a436a2..4a9ab5f182 100644 --- a/src/Umbraco.Core/CoreBootManager.cs +++ b/src/Umbraco.Core/CoreBootManager.cs @@ -135,29 +135,16 @@ namespace Umbraco.Core MacroPropertyTypeResolver.Current = new MacroPropertyTypeResolver( PluginManager.Current.ResolveMacroPropertyTypes()); + //the database migration objects + MigrationResolver.Current = new MigrationResolver( + PluginManager.Current.ResolveMigrationTypes()); + PropertyEditorValueConvertersResolver.Current = new PropertyEditorValueConvertersResolver( PluginManager.Current.ResolvePropertyEditorValueConverters()); //add the internal ones, these are not public currently so need to add them manually PropertyEditorValueConvertersResolver.Current.AddType(); PropertyEditorValueConvertersResolver.Current.AddType(); PropertyEditorValueConvertersResolver.Current.AddType(); - - //the database migration objects - MigrationResolver.Current = new MigrationResolver(new List - { - typeof (MigrationsVersionFourNineZero.RemoveUmbracoAppConstraints), - typeof (DeleteAppTables), - typeof (EnsureAppsTreesUpdated), - typeof (MoveMasterContentTypeData), - typeof (NewCmsContentType2ContentTypeTable), - typeof (RemoveMasterContentTypeColumn), - typeof (RenameCmsTabTable), - typeof (RenameTabIdColumn), - typeof (UpdateCmsContentTypeAllowedContentTypeTable), - typeof (UpdateCmsContentTypeTable), - typeof (UpdateCmsContentVersionTable), - typeof (UpdateCmsPropertyTypeGroupTable) - }); - } + } } } diff --git a/src/Umbraco.Core/Persistence/Migrations/MigrationResolver.cs b/src/Umbraco.Core/Persistence/Migrations/MigrationResolver.cs index b11107d7cb..2c9af738ff 100644 --- a/src/Umbraco.Core/Persistence/Migrations/MigrationResolver.cs +++ b/src/Umbraco.Core/Persistence/Migrations/MigrationResolver.cs @@ -12,12 +12,12 @@ namespace Umbraco.Core.Persistence.Migrations /// /// Constructor /// - /// + /// /// /// Use transient objects as we don't want these as singletons and take up memory that is not required /// - public MigrationResolver(IEnumerable surfaceControllers) - : base(surfaceControllers, ObjectLifetimeScope.Transient) + public MigrationResolver(IEnumerable migrations) + : base(migrations, ObjectLifetimeScope.Transient) { } diff --git a/src/Umbraco.Core/PluginManager.cs b/src/Umbraco.Core/PluginManager.cs index 42ca5fc1f5..4f1f18c2ab 100644 --- a/src/Umbraco.Core/PluginManager.cs +++ b/src/Umbraco.Core/PluginManager.cs @@ -11,6 +11,7 @@ using System.Xml.Linq; using Umbraco.Core.IO; using Umbraco.Core.Logging; using Umbraco.Core.Models; +using Umbraco.Core.Persistence.Migrations; using Umbraco.Core.PropertyEditors; using umbraco.interfaces; using File = System.IO.File; @@ -458,6 +459,15 @@ namespace Umbraco.Core return ResolveTypes(); } + /// + /// Returns all available IMigrations in application + /// + /// + internal IEnumerable ResolveMigrationTypes() + { + return ResolveTypes(); + } + /// /// Gets/sets which assemblies to scan when type finding, generally used for unit testing, if not explicitly set /// this will search all assemblies known to have plugins and exclude ones known to not have them. From 1bd4cbdb9934ba540229740b8b3e028483cd8ec3 Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Fri, 18 Jan 2013 12:50:34 -0100 Subject: [PATCH 168/188] Adds If-condition to Execute Sql migrations. Updates MoveMasterContentTypeData migration to have a Sql Server specific sql statement. --- .../Migrations/Syntax/Execute/ExecuteBuilder.cs | 9 +++++++-- .../Execute/Expressions/ExecuteSqlStatementExpression.cs | 3 +++ .../Migrations/Syntax/IfDatabase/IIfDatabaseBuilder.cs | 2 ++ .../Migrations/Syntax/IfDatabase/IfDatabaseBuilder.cs | 6 ++++++ .../TargetVersionSix/MoveMasterContentTypeData.cs | 3 ++- 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Core/Persistence/Migrations/Syntax/Execute/ExecuteBuilder.cs b/src/Umbraco.Core/Persistence/Migrations/Syntax/Execute/ExecuteBuilder.cs index b51646c064..7a70b0991e 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Syntax/Execute/ExecuteBuilder.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Syntax/Execute/ExecuteBuilder.cs @@ -5,15 +5,20 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Execute public class ExecuteBuilder : IExecuteBuilder { private readonly IMigrationContext _context; + private readonly DatabaseProviders[] _databaseProviders; - public ExecuteBuilder(IMigrationContext context) + public ExecuteBuilder(IMigrationContext context, params DatabaseProviders[] databaseProviders) { _context = context; + _databaseProviders = databaseProviders; } public void Sql(string sqlStatement) { - var expression = new ExecuteSqlStatementExpression {SqlStatement = sqlStatement}; + var expression = _databaseProviders == null + ? new ExecuteSqlStatementExpression {SqlStatement = sqlStatement} + : new ExecuteSqlStatementExpression(_context.CurrentDatabaseProvider, + _databaseProviders) {SqlStatement = sqlStatement}; _context.Expressions.Add(expression); } } diff --git a/src/Umbraco.Core/Persistence/Migrations/Syntax/Execute/Expressions/ExecuteSqlStatementExpression.cs b/src/Umbraco.Core/Persistence/Migrations/Syntax/Execute/Expressions/ExecuteSqlStatementExpression.cs index a7d3c4432e..308a7719dd 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Syntax/Execute/Expressions/ExecuteSqlStatementExpression.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Syntax/Execute/Expressions/ExecuteSqlStatementExpression.cs @@ -14,6 +14,9 @@ public override string ToString() { + if (IsExpressionSupported() == false) + return string.Empty; + return SqlStatement; } } diff --git a/src/Umbraco.Core/Persistence/Migrations/Syntax/IfDatabase/IIfDatabaseBuilder.cs b/src/Umbraco.Core/Persistence/Migrations/Syntax/IfDatabase/IIfDatabaseBuilder.cs index 050af489a9..feeceeb148 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Syntax/IfDatabase/IIfDatabaseBuilder.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Syntax/IfDatabase/IIfDatabaseBuilder.cs @@ -1,5 +1,6 @@ using Umbraco.Core.Persistence.Migrations.Syntax.Create; using Umbraco.Core.Persistence.Migrations.Syntax.Delete; +using Umbraco.Core.Persistence.Migrations.Syntax.Execute; using Umbraco.Core.Persistence.Migrations.Syntax.Rename; namespace Umbraco.Core.Persistence.Migrations.Syntax.IfDatabase @@ -7,6 +8,7 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.IfDatabase public interface IIfDatabaseBuilder : IFluentSyntax { ICreateBuilder Create { get; } + IExecuteBuilder Execute { get; } IDeleteBuilder Delete { get; } IRenameBuilder Rename { get; } } diff --git a/src/Umbraco.Core/Persistence/Migrations/Syntax/IfDatabase/IfDatabaseBuilder.cs b/src/Umbraco.Core/Persistence/Migrations/Syntax/IfDatabase/IfDatabaseBuilder.cs index 6657cb9cf4..178729fdb4 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Syntax/IfDatabase/IfDatabaseBuilder.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Syntax/IfDatabase/IfDatabaseBuilder.cs @@ -1,5 +1,6 @@ using Umbraco.Core.Persistence.Migrations.Syntax.Create; using Umbraco.Core.Persistence.Migrations.Syntax.Delete; +using Umbraco.Core.Persistence.Migrations.Syntax.Execute; using Umbraco.Core.Persistence.Migrations.Syntax.Rename; namespace Umbraco.Core.Persistence.Migrations.Syntax.IfDatabase @@ -20,6 +21,11 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.IfDatabase get { return new CreateBuilder(_context, _databaseProviders); } } + public IExecuteBuilder Execute + { + get { return new ExecuteBuilder(_context, _databaseProviders); } + } + public IDeleteBuilder Delete { get { return new DeleteBuilder(_context, _databaseProviders); } diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/MoveMasterContentTypeData.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/MoveMasterContentTypeData.cs index cff2f5ad9c..10841e9bd8 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/MoveMasterContentTypeData.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/MoveMasterContentTypeData.cs @@ -10,7 +10,8 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix Execute.Sql( "INSERT INTO cmsContentType2ContentType (parentContentTypeId, childContentTypeId) SELECT masterContentType, nodeId FROM cmsContentType WHERE not masterContentType is null and masterContentType != 0"); - Execute.Sql("UPDATE umbracoNode SET parentID = cmsContentType.masterContentType FROM umbracoNode, cmsContentType WHERE umbracoNode.id = cmsContentType.nodeId AND not cmsContentType.masterContentType is null AND cmsContentType.masterContentType != 0"); + IfDatabase(DatabaseProviders.SqlServer) + .Execute.Sql("UPDATE umbracoNode SET parentID = cmsContentType.masterContentType FROM umbracoNode, cmsContentType WHERE umbracoNode.id = cmsContentType.nodeId AND not cmsContentType.masterContentType is null AND cmsContentType.masterContentType != 0"); } public override void Down() From 480bd39687840b396e79604d73fca86d451f5525 Mon Sep 17 00:00:00 2001 From: "NielsHartvig@UMBRACORATI.localdomain" Date: Fri, 18 Jan 2013 12:56:30 -0100 Subject: [PATCH 169/188] Fixes U4-1437 Contact form in business starter kit doesn't work --- src/umbraco.cms/businesslogic/macro/Macro.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/umbraco.cms/businesslogic/macro/Macro.cs b/src/umbraco.cms/businesslogic/macro/Macro.cs index 1216c95f42..a69aff9cc5 100644 --- a/src/umbraco.cms/businesslogic/macro/Macro.cs +++ b/src/umbraco.cms/businesslogic/macro/Macro.cs @@ -333,6 +333,10 @@ namespace umbraco.cms.businesslogic.macro m.Xslt = xmlHelper.GetNodeValue(n.SelectSingleNode("xslt")); m.RefreshRate = int.Parse(xmlHelper.GetNodeValue(n.SelectSingleNode("refreshRate"))); + // we need to validate if the usercontrol is missing the tilde prefix requirement introduced in v6 + if (String.IsNullOrEmpty(m.Assembly) && !String.IsNullOrEmpty(m.Type) && !m.Type.StartsWith("~")) + m.Type = "~/" + m.Type; + if (n.SelectSingleNode("scriptingFile") != null) m.ScriptingFile = xmlHelper.GetNodeValue(n.SelectSingleNode("scriptingFile")); From 5cb865f4c443ce88073acfe5bd8c99fc72c09973 Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Fri, 18 Jan 2013 13:51:40 -0100 Subject: [PATCH 170/188] Updating the MigrationContext to take the PetaPoco database via the ctor, so it can be used to fetch entries during migration. Changing the MoveMasterContentTypeData migration to use the fluent Update statement with dynamic entries from the database. Adding IfDatabase condition for Update. Updating a few tests, which were using the MigrationContext. --- .../Migrations/IMigrationContext.cs | 1 + .../Persistence/Migrations/MigrationBase.cs | 22 +++++++++---------- .../Migrations/MigrationContext.cs | 5 ++++- .../Persistence/Migrations/MigrationRunner.cs | 2 +- .../Syntax/IfDatabase/IIfDatabaseBuilder.cs | 2 ++ .../Syntax/IfDatabase/IfDatabaseBuilder.cs | 6 +++++ .../Expressions/UpdateDataExpression.cs | 3 +++ .../Migrations/Syntax/Update/UpdateBuilder.cs | 8 +++++-- .../MoveMasterContentTypeData.cs | 14 +++++++++--- .../Migrations/AlterMigrationTests.cs | 2 +- .../Migrations/FindingMigrationsTest.cs | 2 +- .../TargetVersionSixthMigrationsTest.cs | 2 +- 12 files changed, 48 insertions(+), 21 deletions(-) diff --git a/src/Umbraco.Core/Persistence/Migrations/IMigrationContext.cs b/src/Umbraco.Core/Persistence/Migrations/IMigrationContext.cs index 616c7b16c5..159efb6ff8 100644 --- a/src/Umbraco.Core/Persistence/Migrations/IMigrationContext.cs +++ b/src/Umbraco.Core/Persistence/Migrations/IMigrationContext.cs @@ -6,5 +6,6 @@ namespace Umbraco.Core.Persistence.Migrations { ICollection Expressions { get; set; } DatabaseProviders CurrentDatabaseProvider { get; } + Database Database { get; } } } \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/Migrations/MigrationBase.cs b/src/Umbraco.Core/Persistence/Migrations/MigrationBase.cs index 725cb2c7a0..642a920319 100644 --- a/src/Umbraco.Core/Persistence/Migrations/MigrationBase.cs +++ b/src/Umbraco.Core/Persistence/Migrations/MigrationBase.cs @@ -11,61 +11,61 @@ namespace Umbraco.Core.Persistence.Migrations { public abstract class MigrationBase : IMigration { - internal IMigrationContext _context; + internal IMigrationContext Context; public abstract void Up(); public abstract void Down(); public virtual void GetUpExpressions(IMigrationContext context) { - _context = context; + Context = context; Up(); } public virtual void GetDownExpressions(IMigrationContext context) { - _context = context; + Context = context; Down(); } public IAlterSyntaxBuilder Alter { - get { return new AlterSyntaxBuilder(_context); } + get { return new AlterSyntaxBuilder(Context); } } public ICreateBuilder Create { - get { return new CreateBuilder(_context); } + get { return new CreateBuilder(Context); } } public IDeleteBuilder Delete { - get { return new DeleteBuilder(_context); } + get { return new DeleteBuilder(Context); } } public IExecuteBuilder Execute { - get { return new ExecuteBuilder(_context); } + get { return new ExecuteBuilder(Context); } } public IInsertBuilder Insert { - get { return new InsertBuilder(_context); } + get { return new InsertBuilder(Context); } } public IRenameBuilder Rename { - get { return new RenameBuilder(_context); } + get { return new RenameBuilder(Context); } } public IUpdateBuilder Update { - get { return new UpdateBuilder(_context); } + get { return new UpdateBuilder(Context); } } public IIfDatabaseBuilder IfDatabase(params DatabaseProviders[] databaseProviders) { - return new IfDatabaseBuilder(_context, databaseProviders); + return new IfDatabaseBuilder(Context, databaseProviders); } } } \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/Migrations/MigrationContext.cs b/src/Umbraco.Core/Persistence/Migrations/MigrationContext.cs index 90779e4317..e173bccc6d 100644 --- a/src/Umbraco.Core/Persistence/Migrations/MigrationContext.cs +++ b/src/Umbraco.Core/Persistence/Migrations/MigrationContext.cs @@ -5,14 +5,17 @@ namespace Umbraco.Core.Persistence.Migrations { internal class MigrationContext : IMigrationContext { - public MigrationContext(DatabaseProviders databaseProvider) + public MigrationContext(DatabaseProviders databaseProvider, Database database) { Expressions = new Collection(); CurrentDatabaseProvider = databaseProvider; + Database = database; } public ICollection Expressions { get; set; } public DatabaseProviders CurrentDatabaseProvider { get; private set; } + + public Database Database { get; private set; } } } \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/Migrations/MigrationRunner.cs b/src/Umbraco.Core/Persistence/Migrations/MigrationRunner.cs index 6b682f8546..ed86495007 100644 --- a/src/Umbraco.Core/Persistence/Migrations/MigrationRunner.cs +++ b/src/Umbraco.Core/Persistence/Migrations/MigrationRunner.cs @@ -55,7 +55,7 @@ namespace Umbraco.Core.Persistence.Migrations return false; //Loop through migrations to generate sql - var context = new MigrationContext(databaseProvider); + var context = new MigrationContext(databaseProvider, database); foreach (MigrationBase migration in migrations) { if (isUpgrade) diff --git a/src/Umbraco.Core/Persistence/Migrations/Syntax/IfDatabase/IIfDatabaseBuilder.cs b/src/Umbraco.Core/Persistence/Migrations/Syntax/IfDatabase/IIfDatabaseBuilder.cs index feeceeb148..b274c215ea 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Syntax/IfDatabase/IIfDatabaseBuilder.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Syntax/IfDatabase/IIfDatabaseBuilder.cs @@ -2,6 +2,7 @@ using Umbraco.Core.Persistence.Migrations.Syntax.Delete; using Umbraco.Core.Persistence.Migrations.Syntax.Execute; using Umbraco.Core.Persistence.Migrations.Syntax.Rename; +using Umbraco.Core.Persistence.Migrations.Syntax.Update; namespace Umbraco.Core.Persistence.Migrations.Syntax.IfDatabase { @@ -11,5 +12,6 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.IfDatabase IExecuteBuilder Execute { get; } IDeleteBuilder Delete { get; } IRenameBuilder Rename { get; } + IUpdateBuilder Update { get; } } } \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/Migrations/Syntax/IfDatabase/IfDatabaseBuilder.cs b/src/Umbraco.Core/Persistence/Migrations/Syntax/IfDatabase/IfDatabaseBuilder.cs index 178729fdb4..b7105170f1 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Syntax/IfDatabase/IfDatabaseBuilder.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Syntax/IfDatabase/IfDatabaseBuilder.cs @@ -2,6 +2,7 @@ using Umbraco.Core.Persistence.Migrations.Syntax.Delete; using Umbraco.Core.Persistence.Migrations.Syntax.Execute; using Umbraco.Core.Persistence.Migrations.Syntax.Rename; +using Umbraco.Core.Persistence.Migrations.Syntax.Update; namespace Umbraco.Core.Persistence.Migrations.Syntax.IfDatabase { @@ -35,5 +36,10 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.IfDatabase { get { return new RenameBuilder(_context, _databaseProviders); } } + + public IUpdateBuilder Update + { + get { return new UpdateBuilder(_context, _databaseProviders); } + } } } \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/Migrations/Syntax/Update/Expressions/UpdateDataExpression.cs b/src/Umbraco.Core/Persistence/Migrations/Syntax/Update/Expressions/UpdateDataExpression.cs index c3cfbcda0f..9baa3501cf 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Syntax/Update/Expressions/UpdateDataExpression.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Syntax/Update/Expressions/UpdateDataExpression.cs @@ -22,6 +22,9 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Update.Expressions public override string ToString() { + if (IsExpressionSupported() == false) + return string.Empty; + var updateItems = new List(); var whereClauses = new List(); diff --git a/src/Umbraco.Core/Persistence/Migrations/Syntax/Update/UpdateBuilder.cs b/src/Umbraco.Core/Persistence/Migrations/Syntax/Update/UpdateBuilder.cs index 9df3e26f6d..e2e118c05f 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Syntax/Update/UpdateBuilder.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Syntax/Update/UpdateBuilder.cs @@ -5,15 +5,19 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Update public class UpdateBuilder : IUpdateBuilder { private readonly IMigrationContext _context; + private readonly DatabaseProviders[] _databaseProviders; - public UpdateBuilder(IMigrationContext context) + public UpdateBuilder(IMigrationContext context, params DatabaseProviders[] databaseProviders) { _context = context; + _databaseProviders = databaseProviders; } public IUpdateSetSyntax Table(string tableName) { - var expression = new UpdateDataExpression { TableName = tableName }; + var expression = _databaseProviders == null + ? new UpdateDataExpression { TableName = tableName } + : new UpdateDataExpression(_context.CurrentDatabaseProvider, _databaseProviders) { TableName = tableName }; _context.Expressions.Add(expression); return new UpdateDataBuilder(expression, _context); } diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/MoveMasterContentTypeData.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/MoveMasterContentTypeData.cs index 10841e9bd8..482c02381f 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/MoveMasterContentTypeData.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/MoveMasterContentTypeData.cs @@ -7,11 +7,19 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix { public override void Up() { + //Reading entries from the cmsContentType table in order to update the parentID on the umbracoNode table. + //NOTE This is primarily done because of a shortcoming in sql ce, which has really bad support for updates (can't use FROM or subqueries with multiple results). + if (base.Context != null && base.Context.Database != null) + { + var list = base.Context.Database.Fetch("SELECT nodeId, masterContentType FROM cmsContentType WHERE not masterContentType is null AND masterContentType != 0"); + foreach (var item in list) + { + Update.Table("umbracoNode").Set(new { parentID = item.masterContentType }).Where(new { id = item.nodeId }); + } + } + Execute.Sql( "INSERT INTO cmsContentType2ContentType (parentContentTypeId, childContentTypeId) SELECT masterContentType, nodeId FROM cmsContentType WHERE not masterContentType is null and masterContentType != 0"); - - IfDatabase(DatabaseProviders.SqlServer) - .Execute.Sql("UPDATE umbracoNode SET parentID = cmsContentType.masterContentType FROM umbracoNode, cmsContentType WHERE umbracoNode.id = cmsContentType.nodeId AND not cmsContentType.masterContentType is null AND cmsContentType.masterContentType != 0"); } public override void Down() diff --git a/src/Umbraco.Tests/Migrations/AlterMigrationTests.cs b/src/Umbraco.Tests/Migrations/AlterMigrationTests.cs index 3ebe04a48d..a752e94662 100644 --- a/src/Umbraco.Tests/Migrations/AlterMigrationTests.cs +++ b/src/Umbraco.Tests/Migrations/AlterMigrationTests.cs @@ -21,7 +21,7 @@ namespace Umbraco.Tests.Migrations public void Can_Get_Up_Migration_From_MigrationStub() { // Arrange - var context = new MigrationContext(DatabaseProviders.SqlServerCE); + var context = new MigrationContext(DatabaseProviders.SqlServerCE, null); var stub = new AlterUserTableMigrationStub(); // Act diff --git a/src/Umbraco.Tests/Migrations/FindingMigrationsTest.cs b/src/Umbraco.Tests/Migrations/FindingMigrationsTest.cs index 7239f21fc1..7601aa2f59 100644 --- a/src/Umbraco.Tests/Migrations/FindingMigrationsTest.cs +++ b/src/Umbraco.Tests/Migrations/FindingMigrationsTest.cs @@ -56,7 +56,7 @@ namespace Umbraco.Tests.Migrations Assert.That(list.Count, Is.EqualTo(3)); - var context = new MigrationContext(DatabaseProviders.SqlServerCE); + var context = new MigrationContext(DatabaseProviders.SqlServerCE, null); foreach (MigrationBase migration in list) { migration.GetUpExpressions(context); diff --git a/src/Umbraco.Tests/Migrations/TargetVersionSixthMigrationsTest.cs b/src/Umbraco.Tests/Migrations/TargetVersionSixthMigrationsTest.cs index 54ab36a387..beb1d2058d 100644 --- a/src/Umbraco.Tests/Migrations/TargetVersionSixthMigrationsTest.cs +++ b/src/Umbraco.Tests/Migrations/TargetVersionSixthMigrationsTest.cs @@ -52,7 +52,7 @@ namespace Umbraco.Tests.Migrations var migrationRunner = new MigrationRunner(configuredVersion, targetVersion, GlobalSettings.UmbracoMigrationName); var migrations = migrationRunner.OrderedUpgradeMigrations(foundMigrations); - var context = new MigrationContext(DatabaseProviders.SqlServerCE); + var context = new MigrationContext(DatabaseProviders.SqlServerCE, null); foreach (MigrationBase migration in migrations) { migration.GetUpExpressions(context); From 3e28376ae77651705b460666239f286c948314f0 Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Sat, 19 Jan 2013 06:38:02 +0300 Subject: [PATCH 171/188] Fixes: #U4-1472 - XmlHelper. Fixes: #U4-1488 - partial view macro engine issues. --- src/Umbraco.Core/XmlHelper.cs | 14 +++---- .../Macros/PartialViewMacroEngine.cs | 41 +++++++++++-------- src/Umbraco.Web/Mvc/Constants.cs | 7 +++- src/Umbraco.Web/Mvc/ControllerExtensions.cs | 4 +- src/Umbraco.Web/Mvc/UmbracoViewPage.cs | 19 +++++++++ src/Umbraco.Web/Mvc/ViewContextExtensions.cs | 19 +++++++++ 6 files changed, 78 insertions(+), 26 deletions(-) diff --git a/src/Umbraco.Core/XmlHelper.cs b/src/Umbraco.Core/XmlHelper.cs index 0a3d16e9c8..27f4d0e923 100644 --- a/src/Umbraco.Core/XmlHelper.cs +++ b/src/Umbraco.Core/XmlHelper.cs @@ -20,7 +20,7 @@ namespace Umbraco.Core /// The text. /// The XML doc. /// - internal static XmlNode ImportXmlNodeFromText(string text, ref XmlDocument xmlDoc) + public static XmlNode ImportXmlNodeFromText(string text, ref XmlDocument xmlDoc) { xmlDoc.LoadXml(text); return xmlDoc.FirstChild; @@ -80,7 +80,7 @@ namespace Umbraco.Core /// The node name. /// The node value. /// A XmlNode - public static XmlNode AddCDataNode(XmlDocument xd, string name, string value) + public static XmlNode AddCDataNode(XmlDocument xd, string name, string value) { var temp = xd.CreateNode(XmlNodeType.Element, name, ""); temp.AppendChild(xd.CreateCDataSection(value)); @@ -92,7 +92,7 @@ namespace Umbraco.Core /// /// The XmlNode. /// the value as a string - internal static string GetNodeValue(XmlNode n) + public static string GetNodeValue(XmlNode n) { var value = string.Empty; if (n == null || n.FirstChild == null) @@ -108,7 +108,7 @@ namespace Umbraco.Core /// /// true if the specified string appears to be XML; otherwise, false. /// - internal static bool CouldItBeXml(string xml) + public static bool CouldItBeXml(string xml) { if (!string.IsNullOrEmpty(xml)) { @@ -131,7 +131,7 @@ namespace Umbraco.Core /// Name of the root. /// Name of the element. /// Returns an System.Xml.XmlDocument representation of the delimited string data. - internal static XmlDocument Split(string data, string[] separator, string rootName, string elementName) + public static XmlDocument Split(string data, string[] separator, string rootName, string elementName) { return Split(new XmlDocument(), data, separator, rootName, elementName); } @@ -145,7 +145,7 @@ namespace Umbraco.Core /// Name of the root node. /// Name of the element node. /// Returns an System.Xml.XmlDocument representation of the delimited string data. - internal static XmlDocument Split(XmlDocument xml, string data, string[] separator, string rootName, string elementName) + public static XmlDocument Split(XmlDocument xml, string data, string[] separator, string rootName, string elementName) { // load new XML document. xml.LoadXml(string.Concat("<", rootName, "/>")); @@ -174,7 +174,7 @@ namespace Umbraco.Core ///
/// /// - internal static Dictionary GetAttributesFromElement(string tag) + public static Dictionary GetAttributesFromElement(string tag) { var m = Regex.Matches(tag, "(?\\S*)=\"(?[^\"]*)\"", diff --git a/src/Umbraco.Web/Macros/PartialViewMacroEngine.cs b/src/Umbraco.Web/Macros/PartialViewMacroEngine.cs index 1d18aabad7..595c94bebb 100644 --- a/src/Umbraco.Web/Macros/PartialViewMacroEngine.cs +++ b/src/Umbraco.Web/Macros/PartialViewMacroEngine.cs @@ -13,6 +13,7 @@ using umbraco.cms.businesslogic.macro; using umbraco.interfaces; using Umbraco.Web.Mvc; using Umbraco.Core; +using System.Web.Mvc.Html; namespace Umbraco.Web.Macros { @@ -65,8 +66,7 @@ namespace Umbraco.Web.Macros // we rewrite how macro engines work. public IEnumerable SupportedExtensions { - get { return Enumerable.Empty(); } - //get { return new[] {"cshtml", "vbhtml"}; } + get { return Enumerable.Empty(); } } //NOTE: We do not return any supported extensions because we don't want the MacroEngineFactory to return this @@ -76,7 +76,6 @@ namespace Umbraco.Web.Macros public IEnumerable SupportedUIExtensions { get { return Enumerable.Empty(); } - //get { return new[] { "cshtml", "vbhtml" }; } } public Dictionary SupportedProperties { @@ -118,26 +117,32 @@ namespace Umbraco.Web.Macros routeVals.Values.Add("action", "Index"); routeVals.DataTokens.Add("umbraco-context", umbCtx); //required for UmbracoViewPage - ////lets render this controller as a child action if we are currently executing using MVC - ////(otherwise don't do this since we're using webforms) - //var mvcHandler = http.CurrentHandler as MvcHandler; - //if (mvcHandler != null) - //{ - // routeVals.DataTokens.Add("ParentActionViewContext", - // //If we could get access to the currently executing controller we could do this but this is nearly - // //impossible. The only way to do that would be to store the controller instance in the route values - // //in the base class of the UmbracoController.... but not sure the reprocussions of that, i think it could - // //work but is a bit nasty. - // new ViewContext()); - //} + //lets render this controller as a child action if we are currently executing using MVC + //(otherwise don't do this since we're using webforms) + var mvcHandler = http.CurrentHandler as MvcHandler; + var viewContext = new ViewContext {ViewData = new ViewDataDictionary()};; + if (mvcHandler != null) + { + //try and extract the current view context from the route values, this would be set in the UmbracoViewPage. + if (mvcHandler.RequestContext.RouteData.DataTokens.ContainsKey(Constants.DataTokenCurrentViewContext)) + { + viewContext = (ViewContext) mvcHandler.RequestContext.RouteData.DataTokens[Constants.DataTokenCurrentViewContext]; + } + routeVals.DataTokens.Add("ParentActionViewContext", viewContext); + } var request = new RequestContext(http, routeVals); string output; using (var controller = new PartialViewMacroController(umbCtx, macro, currentPage)) { - controller.ControllerContext = new ControllerContext(request, controller); + //bubble up the model state from the main view context to our custom controller. + //when merging we'll create a new dictionary, otherwise you might run into an enumeration error + // caused from ModelStateDictionary + controller.ModelState.Merge(new ModelStateDictionary(viewContext.ViewData.ModelState)); + controller.ControllerContext = new ControllerContext(request, controller); + //call the action to render var result = controller.Index(); - output = controller.RenderViewResultAsString(result); + output = controller.RenderViewResultAsString(result); } return output; @@ -163,5 +168,7 @@ namespace Umbraco.Web.Macros throw new InvalidCastException("All Partial View Macro views must inherit from " + typeof(PartialViewMacroPage).FullName); return webPage; } + } + } diff --git a/src/Umbraco.Web/Mvc/Constants.cs b/src/Umbraco.Web/Mvc/Constants.cs index 1ec35e4928..4151c412f4 100644 --- a/src/Umbraco.Web/Mvc/Constants.cs +++ b/src/Umbraco.Web/Mvc/Constants.cs @@ -1,7 +1,12 @@ namespace Umbraco.Web.Mvc { + /// + /// constants + /// internal static class Constants { - public const string ViewLocation = "~/Views"; + internal const string ViewLocation = "~/Views"; + + internal const string DataTokenCurrentViewContext = "umbraco-current-view-context"; } } \ No newline at end of file diff --git a/src/Umbraco.Web/Mvc/ControllerExtensions.cs b/src/Umbraco.Web/Mvc/ControllerExtensions.cs index 59900e6489..b26ed39b79 100644 --- a/src/Umbraco.Web/Mvc/ControllerExtensions.cs +++ b/src/Umbraco.Web/Mvc/ControllerExtensions.cs @@ -108,7 +108,9 @@ namespace Umbraco.Web.Mvc /// internal static void EnsureViewObjectDataOnResult(this ControllerBase controller, ViewResultBase result) { - result.ViewData.ModelState.Merge(controller.ViewData.ModelState); + //when merging we'll create a new dictionary, otherwise you might run into an enumeration error + // caused from ModelStateDictionary + result.ViewData.ModelState.Merge(new ModelStateDictionary(controller.ViewData.ModelState)); // Temporarily copy the dictionary to avoid enumerator-modification errors var newViewDataDict = new ViewDataDictionary(controller.ViewData); diff --git a/src/Umbraco.Web/Mvc/UmbracoViewPage.cs b/src/Umbraco.Web/Mvc/UmbracoViewPage.cs index ff926fd4b4..92a46a9858 100644 --- a/src/Umbraco.Web/Mvc/UmbracoViewPage.cs +++ b/src/Umbraco.Web/Mvc/UmbracoViewPage.cs @@ -93,5 +93,24 @@ namespace Umbraco.Web.Mvc get { return _helper ?? (_helper = new UmbracoHelper(UmbracoContext)); } } + /// + /// Ensure that the current view context is added to the route data tokens so we can extract it if we like + /// + /// + /// Currently this is required by mvc macro engines + /// + protected override void InitializePage() + { + base.InitializePage(); + if (!ViewContext.IsChildAction) + { + if (!ViewContext.RouteData.DataTokens.ContainsKey(Constants.DataTokenCurrentViewContext)) + { + ViewContext.RouteData.DataTokens.Add(Constants.DataTokenCurrentViewContext, this.ViewContext); + } + } + + } + } } \ No newline at end of file diff --git a/src/Umbraco.Web/Mvc/ViewContextExtensions.cs b/src/Umbraco.Web/Mvc/ViewContextExtensions.cs index 30dcccbbbb..1cb39e2487 100644 --- a/src/Umbraco.Web/Mvc/ViewContextExtensions.cs +++ b/src/Umbraco.Web/Mvc/ViewContextExtensions.cs @@ -1,3 +1,4 @@ +using System.IO; using System.Web.Mvc; namespace Umbraco.Web.Mvc @@ -30,5 +31,23 @@ namespace Umbraco.Web.Mvc Writer = vc.Writer }; } + + //public static ViewContext CloneWithWriter(this ViewContext vc, TextWriter writer) + //{ + // return new ViewContext + // { + // Controller = vc.Controller, + // HttpContext = vc.HttpContext, + // RequestContext = vc.RequestContext, + // RouteData = vc.RouteData, + // TempData = vc.TempData, + // View = vc.View, + // ViewData = vc.ViewData, + // FormContext = vc.FormContext, + // ClientValidationEnabled = vc.ClientValidationEnabled, + // UnobtrusiveJavaScriptEnabled = vc.UnobtrusiveJavaScriptEnabled, + // Writer = writer + // }; + //} } } \ No newline at end of file From e2b86cf2df702783d1da4b0946111ac7ade3fc29 Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Sat, 19 Jan 2013 06:50:22 +0300 Subject: [PATCH 172/188] Fixes: #U4-1504 - insert macro syntax for views issue. --- .../umbraco_client/Dialogs/EditMacro.js | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/Umbraco.Web.UI/umbraco_client/Dialogs/EditMacro.js b/src/Umbraco.Web.UI/umbraco_client/Dialogs/EditMacro.js index a3cbab36f3..4f78683a19 100644 --- a/src/Umbraco.Web.UI/umbraco_client/Dialogs/EditMacro.js +++ b/src/Umbraco.Web.UI/umbraco_client/Dialogs/EditMacro.js @@ -74,16 +74,20 @@ _getMacroSyntaxMvc: function() { /// Return the macro syntax to insert for MVC - var macroString = "@Umbraco.RenderMacro(\"" + this._opts.macroAlias + "\", new {"; - - for (var i = 0; i < this._macroAliases.length; i++) { - macroString += this._getMacroParameter(this._macroAliases[i]); - if (i < this._macroAliases.length - 1) { - macroString += ", "; - } + var macroString = "@Umbraco.RenderMacro(\"" + this._opts.macroAlias + "\""; + + if (this._macroAliases.length > 0) { + macroString += ", new {"; + for (var i = 0; i < this._macroAliases.length; i++) { + macroString += this._getMacroParameter(this._macroAliases[i]); + if (i < this._macroAliases.length - 1) { + macroString += ", "; + } + } + macroString += "}"; } - - macroString += "});"; + + macroString += ")"; return macroString; }, From 84e4727ef5d5fa8e2272e091d9f2a398c6832b92 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Mon, 21 Jan 2013 10:01:14 -0100 Subject: [PATCH 173/188] Revert to explicit list of migrations. Migrations were enumerated multiple times so added ToList() to them. --- src/Umbraco.Core/CoreBootManager.cs | 23 ++++++++++++++++--- .../Persistence/Migrations/MigrationRunner.cs | 6 ++--- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Core/CoreBootManager.cs b/src/Umbraco.Core/CoreBootManager.cs index 4a9ab5f182..eda2cf494c 100644 --- a/src/Umbraco.Core/CoreBootManager.cs +++ b/src/Umbraco.Core/CoreBootManager.cs @@ -135,9 +135,26 @@ namespace Umbraco.Core MacroPropertyTypeResolver.Current = new MacroPropertyTypeResolver( PluginManager.Current.ResolveMacroPropertyTypes()); - //the database migration objects - MigrationResolver.Current = new MigrationResolver( - PluginManager.Current.ResolveMigrationTypes()); + //TODO: Y U NO WORK? + //MigrationResolver.Current = new MigrationResolver( + // PluginManager.Current.ResolveMigrationTypes()); + + //the database migration objects + MigrationResolver.Current = new MigrationResolver(new List + { + typeof (MigrationsVersionFourNineZero.RemoveUmbracoAppConstraints), + typeof (DeleteAppTables), + typeof (EnsureAppsTreesUpdated), + typeof (MoveMasterContentTypeData), + typeof (NewCmsContentType2ContentTypeTable), + typeof (RemoveMasterContentTypeColumn), + typeof (RenameCmsTabTable), + typeof (RenameTabIdColumn), + typeof (UpdateCmsContentTypeAllowedContentTypeTable), + typeof (UpdateCmsContentTypeTable), + typeof (UpdateCmsContentVersionTable), + typeof (UpdateCmsPropertyTypeGroupTable) + }); PropertyEditorValueConvertersResolver.Current = new PropertyEditorValueConvertersResolver( PluginManager.Current.ResolvePropertyEditorValueConverters()); diff --git a/src/Umbraco.Core/Persistence/Migrations/MigrationRunner.cs b/src/Umbraco.Core/Persistence/Migrations/MigrationRunner.cs index ed86495007..74721961dd 100644 --- a/src/Umbraco.Core/Persistence/Migrations/MigrationRunner.cs +++ b/src/Umbraco.Core/Persistence/Migrations/MigrationRunner.cs @@ -48,9 +48,9 @@ namespace Umbraco.Core.Persistence.Migrations var foundMigrations = MigrationResolver.Current.Migrations; var migrations = isUpgrade - ? OrderedUpgradeMigrations(foundMigrations) - : OrderedDowngradeMigrations(foundMigrations); - + ? OrderedUpgradeMigrations(foundMigrations).ToList() + : OrderedDowngradeMigrations(foundMigrations).ToList(); + if (Migrating.IsRaisedEventCancelled(new MigrationEventArgs(migrations, _configuredVersion, _targetVersion, true), this)) return false; From cac1c4a29691b293a16716b0d33a6b0673d8d6cb Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Mon, 21 Jan 2013 12:24:34 -0100 Subject: [PATCH 174/188] Merge in language changes --- src/Umbraco.Web.UI/umbraco/config/lang/it.xml | 4 ++++ src/Umbraco.Web.UI/umbraco/config/lang/ru.xml | 8 +++++++- src/Umbraco.Web.UI/umbraco/config/lang/zh.xml | 6 +++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/it.xml b/src/Umbraco.Web.UI/umbraco/config/lang/it.xml index ab70d7880c..65ad6abb02 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/it.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/it.xml @@ -659,6 +659,10 @@ Per gestire il tuo sito web, è sufficiente aprire il back office di Umbraco e i + Partial view salvata + Partial view salvata senza errori! + Partial view non salvata + Errore durante il salvataggio del file. diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/ru.xml b/src/Umbraco.Web.UI/umbraco/config/lang/ru.xml index 1a0e884ad2..7b5daa8c96 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/ru.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/ru.xml @@ -32,6 +32,7 @@ Сортировать Направить на публикацию Перевести + Скрыть Обновить @@ -682,6 +683,7 @@ Вкладка создана Вкладка удалена Вкладка с идентификатором (id): %0% удалена + Документ скрыт (публикация отменена) Стиль CSS не сохранен Стиль CSS сохранен Стиль CSS сохранен без ошибок @@ -706,6 +708,10 @@ Файл сохранен Файл сохранен без ошибок Язык сохранен + Представление не сохранено + Произошла ошибка при сохранении файла + Представление сохранено + Представление сохранено без ошибок Cкрипт Python не сохранен Cкрипт Python не может быть сохранен в связи с ошибками Cкрипт Python сохранен @@ -869,7 +875,7 @@ Имя входа (логин) Начальный узел в Медиа-библиотеке Разделы - Сменить пароль + Новый пароль Отключить доступ к административной панели Umbraco Пароль Ваш пароль доступа изменен! diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/zh.xml b/src/Umbraco.Web.UI/umbraco/config/lang/zh.xml index a158293f42..189c352d63 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/zh.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/zh.xml @@ -709,6 +709,10 @@ XSLT无法保存,请检查权限。 XSLT已保存 XSLT无错误 + Partial视图已保存 + Partial视图保存,无错误。 + Partial视图未保存 + Partial视图因为错误未能保存 使用CSS语法,如:h1、.redHeader、.blueTex。 @@ -878,4 +882,4 @@ 用户类型 撰稿人 - + From 801eb2c3d3a4f1ac192cb869d003b70a6200e253 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Mon, 21 Jan 2013 12:34:56 -0100 Subject: [PATCH 175/188] Change version to RC --- build/Build.bat | 2 +- src/Umbraco.Core/Configuration/UmbracoVersion.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/Build.bat b/build/Build.bat index 8e9bacaa5a..525f3cf41b 100644 --- a/build/Build.bat +++ b/build/Build.bat @@ -1,6 +1,6 @@ @ECHO OFF SET release=6.0.0 -SET comment=beta +SET comment=RC SET version=%release% IF [%comment%] EQU [] (SET version=%release%) ELSE (SET version=%release%-%comment%) diff --git a/src/Umbraco.Core/Configuration/UmbracoVersion.cs b/src/Umbraco.Core/Configuration/UmbracoVersion.cs index 6b566cf0ee..60bf0ee45a 100644 --- a/src/Umbraco.Core/Configuration/UmbracoVersion.cs +++ b/src/Umbraco.Core/Configuration/UmbracoVersion.cs @@ -23,7 +23,7 @@ namespace Umbraco.Core.Configuration /// Gets the version comment (like beta or RC). ///
/// The version comment. - public static string CurrentComment { get { return "beta"; } } + public static string CurrentComment { get { return "RC"; } } // 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 From 46a83e553bec57a4b467a507b17457c7788da862 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Mon, 21 Jan 2013 12:41:37 -0100 Subject: [PATCH 176/188] Include any version comments in the about dialog --- src/Umbraco.Web/Umbraco.Web.csproj | 4 +++- .../umbraco.presentation/umbraco/dialogs/about.aspx | 3 +-- .../umbraco.presentation/umbraco/dialogs/about.aspx.cs | 8 +++++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 1ae39ad88d..5ce59b214e 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -1947,7 +1947,9 @@ - + + ASPXCodeBehind + ASPXCodeBehind diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/about.aspx b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/about.aspx index f3351f130e..63e967296d 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/about.aspx +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/about.aspx @@ -11,8 +11,7 @@

- umbraco v -
+ Umbraco v

Copyright 2001 - diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/about.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/about.aspx.cs index 051756a942..463361a635 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/about.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/about.aspx.cs @@ -12,12 +12,14 @@ namespace umbraco.dialogs protected void Page_Load(object sender, EventArgs e) { - // Put user code to initialize the page here + // Put user code to initialize the page here thisYear.Text = DateTime.Now.Year.ToString(CultureInfo.InvariantCulture); - version.Text = string.Format("{0} (Assembly version: {1})", UmbracoVersion.Current.ToString(3), UmbracoVersion.AssemblyVersion); + version.Text = string.IsNullOrEmpty(UmbracoVersion.CurrentComment) + ? string.Format("{0} (Assembly version: {1})", UmbracoVersion.Current.ToString(3), UmbracoVersion.AssemblyVersion) + : string.Format("{0}-{1} (Assembly version: {2})", UmbracoVersion.Current.ToString(3), UmbracoVersion.CurrentComment, UmbracoVersion.AssemblyVersion); } - #region Web Form Designer generated code + #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // From 04d1bf3604eb1ca650a0e3a60aa8a3960c12011d Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Mon, 21 Jan 2013 12:45:18 -0100 Subject: [PATCH 177/188] Include any version comments in the about dialog --- src/Umbraco.Web.UI/umbraco/dialogs/about.aspx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Umbraco.Web.UI/umbraco/dialogs/about.aspx b/src/Umbraco.Web.UI/umbraco/dialogs/about.aspx index f3351f130e..63e967296d 100644 --- a/src/Umbraco.Web.UI/umbraco/dialogs/about.aspx +++ b/src/Umbraco.Web.UI/umbraco/dialogs/about.aspx @@ -11,8 +11,7 @@

- umbraco v -
+ Umbraco v

Copyright 2001 - From d3bdb8b743935a3f422c2c3936c5b8fc2ac44489 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Mon, 21 Jan 2013 12:45:33 -0100 Subject: [PATCH 178/188] log4net.xml doesn't exist, so don't include it --- build/NuSpecs/UmbracoCms.Core.nuspec | 1 - 1 file changed, 1 deletion(-) diff --git a/build/NuSpecs/UmbracoCms.Core.nuspec b/build/NuSpecs/UmbracoCms.Core.nuspec index f6a35fa4d6..68486878d3 100644 --- a/build/NuSpecs/UmbracoCms.Core.nuspec +++ b/build/NuSpecs/UmbracoCms.Core.nuspec @@ -36,7 +36,6 @@ - From 07a8b1de795580843c7374ac66bae211ca196ad1 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Mon, 21 Jan 2013 12:52:31 -0100 Subject: [PATCH 179/188] Fixes double qoutes in navigation.cshtml razor template --- .../umbraco/scripting/templates/cshtml/Navigation.cshtml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web.UI/umbraco/scripting/templates/cshtml/Navigation.cshtml b/src/Umbraco.Web.UI/umbraco/scripting/templates/cshtml/Navigation.cshtml index 03398f28b3..dd8be57d9b 100644 --- a/src/Umbraco.Web.UI/umbraco/scripting/templates/cshtml/Navigation.cshtml +++ b/src/Umbraco.Web.UI/umbraco/scripting/templates/cshtml/Navigation.cshtml @@ -15,6 +15,8 @@

    @foreach (var page in root.Children.Where("Visible")) { -
  • @page.Name
  • - } -
+
  • + @page.Name +
  • + } + From 675cc0b850a3c39a76c513af9e3935b10632b8a9 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Mon, 21 Jan 2013 13:02:51 -0100 Subject: [PATCH 180/188] Show Allow At Root on a seperate pane --- .../umbraco/controls/ContentTypeControlNew.ascx | 13 +++++++++---- .../umbraco/controls/ContentTypeControlNew.ascx | 13 +++++++++---- .../controls/ContentTypeControlNew.ascx.designer.cs | 13 +++++++++++-- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx b/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx index a0588b4516..a2f8735faa 100644 --- a/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx +++ b/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx @@ -76,12 +76,16 @@ + + + +
    + Only Content Types with this checked can be created at the root level of Content and Media trees +
    +
    - -
    - Only Content Types with this checked can be created at the root level of Content and Media trees -
    + @@ -89,6 +93,7 @@
    +

    Master Content Type enabled
    This Content Type uses as a Master Content Type. Properties from Master Content Types are not shown and can only be edited on the Master Content Type itself

    diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx index a0588b4516..a2f8735faa 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx @@ -76,12 +76,16 @@
    + + + +
    + Only Content Types with this checked can be created at the root level of Content and Media trees +
    +
    - -
    - Only Content Types with this checked can be created at the root level of Content and Media trees -
    + @@ -89,6 +93,7 @@
    +

    Master Content Type enabled
    This Content Type uses as a Master Content Type. Properties from Master Content Types are not shown and can only be edited on the Master Content Type itself

    diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.designer.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.designer.cs index 465ea3bbca..320848521d 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.designer.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.designer.cs @@ -247,13 +247,13 @@ namespace umbraco.controls { protected global::System.Web.UI.WebControls.Panel pnlStructure; /// - /// Pane5 control. + /// Pane6 control. /// /// /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::umbraco.uicontrols.Pane Pane5; + protected global::umbraco.uicontrols.Pane Pane6; /// /// pp_Root control. @@ -273,6 +273,15 @@ namespace umbraco.controls { /// protected global::System.Web.UI.WebControls.CheckBox allowAtRoot; + /// + /// Pane5 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.Pane Pane5; + /// /// pp_allowedChildren control. /// From f547e21f0bfc4b462d131e3d85552b88462a5101 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Mon, 21 Jan 2013 14:21:29 -0100 Subject: [PATCH 181/188] Fixes U4-1482 Regression - RTE unable to edit hyperlink on image --- .../tinymce3/plugins/umbracolink/js/umbracolink.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Umbraco.Web.UI/umbraco_client/tinymce3/plugins/umbracolink/js/umbracolink.js b/src/Umbraco.Web.UI/umbraco_client/tinymce3/plugins/umbracolink/js/umbracolink.js index f2c540ea60..b0cce49bc1 100644 --- a/src/Umbraco.Web.UI/umbraco_client/tinymce3/plugins/umbracolink/js/umbracolink.js +++ b/src/Umbraco.Web.UI/umbraco_client/tinymce3/plugins/umbracolink/js/umbracolink.js @@ -73,6 +73,7 @@ function init() { * EO UMBRACO SPECIFIC */ + elm = inst.dom.getParent(elm, "A"); if (elm != null && elm.nodeName == "A") action = "update"; From 4bf9cf270d7ae0450547cbdbf5c30e491000f6df Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Mon, 21 Jan 2013 14:50:58 -0100 Subject: [PATCH 182/188] Fixes Move when parent is unpublished. --- src/Umbraco.Core/Services/ContentService.cs | 117 +++++++++--------- .../umbraco/dialogs/moveOrCopy.aspx.cs | 21 +--- .../umbraco/editContent.aspx.cs | 11 +- 3 files changed, 68 insertions(+), 81 deletions(-) diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs index b225a3a5cb..973c665349 100644 --- a/src/Umbraco.Core/Services/ContentService.cs +++ b/src/Umbraco.Core/Services/ContentService.cs @@ -246,7 +246,7 @@ namespace Umbraco.Core.Services { using (var repository = _repositoryFactory.CreateContentRepository(_uowProvider.GetUnitOfWork())) { - var query = Query.Builder.Where(x => x.Path.StartsWith(content.Path)); + var query = Query.Builder.Where(x => x.Path.StartsWith(content.Path) && x.Id != content.Id); var contents = repository.GetByQuery(query); return contents; @@ -643,25 +643,7 @@ namespace Umbraco.Core.Services /// Optional Id of the User saving the Content public void Save(IContent content, int userId = -1) { - if (Saving.IsRaisedEventCancelled(new SaveEventArgs(content), this)) - return; - - var uow = _uowProvider.GetUnitOfWork(); - using (var repository = _repositoryFactory.CreateContentRepository(uow)) - { - SetWriter(content, userId); - - //Only change the publish state if the "previous" version was actually published - if (content.Published) - content.ChangePublishedState(PublishedState.Saved); - - repository.AddOrUpdate(content); - uow.Commit(); - } - - Saved.RaiseEvent(new SaveEventArgs(content, false), this); - - Audit.Add(AuditTypes.Save, "Save Content performed by user", userId == -1 ? 0 : userId, content.Id); + Save(content, true, userId); } /// @@ -917,6 +899,9 @@ namespace Umbraco.Core.Services return; SetWriter(content, userId); + var parent = GetById(parentId); + content.Path = string.Concat(parent.Path, ",", content.Id); + content.Level = parent.Level + 1; //If Content is being moved away from Recycle Bin, its state should be un-trashed if (content.Trashed && parentId != -20) @@ -931,7 +916,28 @@ namespace Umbraco.Core.Services //If Content is published, it should be (re)published from its new location if (content.Published) { - SaveAndPublish(content, userId); + //If Content is Publishable its saved and published + //otherwise we save the content without changing the publish state, and generate new xml because the Path, Level and Parent has changed. + if (IsPublishable(content)) + { + SaveAndPublish(content, userId); + } + else + { + Save(content, false, userId); + + using (var uow = _uowProvider.GetUnitOfWork()) + { + var xml = content.ToXml(); + var poco = new ContentXmlDto {NodeId = content.Id, Xml = xml.ToString(SaveOptions.None)}; + var exists = + uow.Database.FirstOrDefault("WHERE nodeId = @Id", new {Id = content.Id}) != + null; + int result = exists + ? uow.Database.Update(poco) + : Convert.ToInt32(uow.Database.Insert(poco)); + } + } } else { @@ -942,20 +948,10 @@ namespace Umbraco.Core.Services var children = GetChildren(content.Id); if (children.Any()) { - var parentPath = content.Path; - var parentLevel = content.Level; - var updatedDescendents = UpdatePathAndLevelOnChildren(children, parentPath, parentLevel); - - //collection of descendents that needs to be saved and published - var descendentsToSaveAndPublish = updatedDescendents.Where(x => x.Published); - foreach (var c in descendentsToSaveAndPublish) + foreach (var child in children) { - SaveAndPublish(c, userId); + Move(child, content.Id, userId); } - - //collection of descendents that only needs to be saved - var descendentsToSave = updatedDescendents.Where(x => x.Published == false); - Save(descendentsToSave, userId); } Moved.RaiseEvent(new MoveEventArgs(content, false, parentId), this); @@ -1162,6 +1158,35 @@ namespace Umbraco.Core.Services #region Private Methods + /// + /// Saves a single object + /// + /// The to save + /// Boolean indicating whether or not to change the Published state upon saving + /// Optional Id of the User saving the Content + private void Save(IContent content, bool changeState, int userId = -1) + { + if (Saving.IsRaisedEventCancelled(new SaveEventArgs(content), this)) + return; + + var uow = _uowProvider.GetUnitOfWork(); + using (var repository = _repositoryFactory.CreateContentRepository(uow)) + { + SetWriter(content, userId); + + //Only change the publish state if the "previous" version was actually published + if (changeState && content.Published) + content.ChangePublishedState(PublishedState.Saved); + + repository.AddOrUpdate(content); + uow.Commit(); + } + + Saved.RaiseEvent(new SaveEventArgs(content, false), this); + + Audit.Add(AuditTypes.Save, "Save Content performed by user", userId == -1 ? 0 : userId, content.Id); + } + /// /// Gets a flat list of decendents of content from parent id /// @@ -1222,32 +1247,6 @@ namespace Umbraco.Core.Services return true; } - /// - /// Updates the Path and Level on a collection of objects - /// based on the Parent's Path and Level. - /// - /// Collection of objects to update - /// Path of the Parent content - /// Level of the Parent content - /// Collection of updated objects - private List UpdatePathAndLevelOnChildren(IEnumerable children, string parentPath, int parentLevel) - { - var list = new List(); - foreach (var child in children) - { - child.Path = string.Concat(parentPath, ",", child.Id); - child.Level = parentLevel + 1; - list.Add(child); - - var grandkids = GetChildren(child.Id); - if (grandkids.Any()) - { - list.AddRange(UpdatePathAndLevelOnChildren(grandkids, child.Path, child.Level)); - } - } - return list; - } - /// /// Updates a content object with the User (id), who created the content. /// diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/moveOrCopy.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/moveOrCopy.aspx.cs index afbd497d4d..aeab148ef7 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/moveOrCopy.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/moveOrCopy.aspx.cs @@ -261,26 +261,7 @@ namespace umbraco.dialogs var documentId = int.Parse(helper.Request("id")); var document = new Document(documentId); document.Move(int.Parse(helper.Request("copyTo"))); - if (document.Published) - { - //TODO HACK - Have to get the Document again, to get the new path from the database.. - document = new Document(documentId); - - document.Publish(new umbraco.BusinessLogic.User(0)); - //using library.publish to support load balancing. - //umbraco.library.PublishSingleNode(d.Id); - umbraco.library.UpdateDocumentCache(document.Id); - - //PPH added handling of load balanced moving of multiple nodes... - if (document.HasChildren) - handleChildNodes(document); - - //Using the general Refresh content method instead as it supports load balancing. - //we only need to do this if the node is actually published. - library.RefreshContent(); - } - - document.Save(); //stub to save stuff to the db. + library.RefreshContent(); } else { diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/editContent.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/editContent.aspx.cs index 0fc4268239..08fa0f6ed8 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/editContent.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/editContent.aspx.cs @@ -331,8 +331,15 @@ namespace umbraco.cms.presentation _documentHasPublishedVersion = _document.HasPublishedVersion(); var descendants = ApplicationContext.Current.Services.ContentService.GetDescendants(_document.Id); - foreach (var descendant in descendants.Where(descendant => descendant.HasPublishedVersion())) - library.UpdateDocumentCache(descendant.Id); + var publishableDescendants = descendants.Where(descendant => descendant.HasPublishedVersion()).ToList(); + if(publishableDescendants.Any()) + { + foreach (var descendant in publishableDescendants) + { + library.UpdateDocumentCache(descendant.Id); + } + library.RefreshContent(); + } } else { From 652abe383891033ec2c635ffedd900ae972d7b7f Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Mon, 21 Jan 2013 15:26:56 -0100 Subject: [PATCH 183/188] Usercontrols defined in v4 didn't work as they're saved without the tilde --- src/Umbraco.Web/umbraco.presentation/macro.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Umbraco.Web/umbraco.presentation/macro.cs b/src/Umbraco.Web/umbraco.presentation/macro.cs index 446599a88d..d42f8f2a60 100644 --- a/src/Umbraco.Web/umbraco.presentation/macro.cs +++ b/src/Umbraco.Web/umbraco.presentation/macro.cs @@ -422,6 +422,11 @@ namespace umbraco try { TraceInfo("umbracoMacro","Usercontrol added (" + Model.TypeName + ")"); + + // Add tilde for v4 defined macros + if (string.IsNullOrEmpty(Model.TypeName) == false && Model.TypeName.StartsWith("~") == false) + Model.TypeName = "~/" + Model.TypeName; + macroControl = loadUserControl(ScriptType, Model, pageElements); break; } From 00e316b5bdcb552ed95e859d072dee5af78c6b81 Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Mon, 21 Jan 2013 15:27:22 -0100 Subject: [PATCH 184/188] Minor update to AssemblyInfo --- src/Umbraco.Core/Properties/AssemblyInfo.cs | 3 ++- src/Umbraco.Web/Properties/AssemblyInfo.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Core/Properties/AssemblyInfo.cs b/src/Umbraco.Core/Properties/AssemblyInfo.cs index 2c428fab52..2e6146ffed 100644 --- a/src/Umbraco.Core/Properties/AssemblyInfo.cs +++ b/src/Umbraco.Core/Properties/AssemblyInfo.cs @@ -37,4 +37,5 @@ using System.Security.Permissions; [assembly: InternalsVisibleTo("Umbraco.Tests")] [assembly: InternalsVisibleTo("Umbraco.Core")] [assembly: InternalsVisibleTo("Umbraco.Web")] -[assembly: InternalsVisibleTo("Umbraco.Web.UI")] \ No newline at end of file +[assembly: InternalsVisibleTo("Umbraco.Web.UI")] +[assembly: InternalsVisibleTo("Umbraco.Courier.Persistence")] \ No newline at end of file diff --git a/src/Umbraco.Web/Properties/AssemblyInfo.cs b/src/Umbraco.Web/Properties/AssemblyInfo.cs index 7a1e98c88e..42c2237380 100644 --- a/src/Umbraco.Web/Properties/AssemblyInfo.cs +++ b/src/Umbraco.Web/Properties/AssemblyInfo.cs @@ -29,4 +29,5 @@ using System.Security; [assembly: InternalsVisibleTo("Umbraco.Tests")] [assembly: InternalsVisibleTo("umbraco.MacroEngines")] -[assembly: InternalsVisibleTo("Umbraco.Web.UI")] \ No newline at end of file +[assembly: InternalsVisibleTo("Umbraco.Web.UI")] +[assembly: InternalsVisibleTo("Umbraco.Courier.Persistence")] \ No newline at end of file From 1c6346233ee9b1aa168a40ce01e2525a185024f7 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Mon, 21 Jan 2013 15:27:38 -0100 Subject: [PATCH 185/188] Added tag Release-6.0.0-RC for changeset 56015ac26f5a --- .hgtags | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.hgtags b/.hgtags index e628ea09c0..6a3fe90af2 100644 --- a/.hgtags +++ b/.hgtags @@ -22,4 +22,5 @@ f6da531fbb4c251ff61d314e2a7effb13c71e74a Release-4.10.0 73711b806a4044dbf0d7d7c095ddfdda23b09932 Release-4.11.2 77db220b89e166b3c0736ed321ecfd6416cddbcd Release-4.11.2.1 54cde33b809dcb3a1f7e7ae0d5375f6dd0d89c8d Release-4.11.2.2 -ff3bb24ea0c915878396a6ae27f1ff164e8ac150 Release-6.0.0-beta \ No newline at end of file +ff3bb24ea0c915878396a6ae27f1ff164e8ac150 Release-6.0.0-beta +56015ac26f5ab60e3c61b1d09075297b660afa07 Release-6.0.0-RC From 2dde71abb3936ddee7bae1ad8830af9863987a9c Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Mon, 21 Jan 2013 15:35:39 -0100 Subject: [PATCH 186/188] Moving the sql ce binaries from the UmbracoCms.Core to UmbracoCms package as Lee K. has a point. The Sql Ce binaries located in the Content/bin folder are only relevant when setting up a site. --- build/NuSpecs/UmbracoCms.Core.nuspec | 2 -- build/NuSpecs/UmbracoCms.nuspec | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build/NuSpecs/UmbracoCms.Core.nuspec b/build/NuSpecs/UmbracoCms.Core.nuspec index 68486878d3..90e25d6b3f 100644 --- a/build/NuSpecs/UmbracoCms.Core.nuspec +++ b/build/NuSpecs/UmbracoCms.Core.nuspec @@ -68,7 +68,5 @@ - - \ No newline at end of file diff --git a/build/NuSpecs/UmbracoCms.nuspec b/build/NuSpecs/UmbracoCms.nuspec index a62a9c1de8..b7e9ba8100 100644 --- a/build/NuSpecs/UmbracoCms.nuspec +++ b/build/NuSpecs/UmbracoCms.nuspec @@ -19,7 +19,9 @@ - + + + From 72ff03f1429ff4184d7e1cf19dcf52a06ad96ebd Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Tue, 22 Jan 2013 08:44:06 -0100 Subject: [PATCH 187/188] Fixes U4-1512 by using the same safe alias method as in the legacy code base. This should ensure that published content aliases has the same format as in v4. --- src/Umbraco.Core/Models/ContentExtensions.cs | 6 +-- src/Umbraco.Core/Models/PropertyExtensions.cs | 3 +- src/Umbraco.Core/StringExtensions.cs | 49 +++++++++++++++++++ src/Umbraco.Tests/Models/ContentXmlTest.cs | 2 +- 4 files changed, 55 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Core/Models/ContentExtensions.cs b/src/Umbraco.Core/Models/ContentExtensions.cs index 1ed91eb59a..e2b81de74e 100644 --- a/src/Umbraco.Core/Models/ContentExtensions.cs +++ b/src/Umbraco.Core/Models/ContentExtensions.cs @@ -392,8 +392,7 @@ namespace Umbraco.Core.Models public static XElement ToXml(this IContent content) { //nodeName should match Casing.SafeAliasWithForcingCheck(content.ContentType.Alias); - //var nodeName = content.ContentType.Alias.ToUmbracoAlias(StringAliasCaseType.CamelCase, true); - var nodeName = content.ContentType.Alias; + var nodeName = UmbracoSettings.UseLegacyXmlSchema ? "node" : content.ContentType.Alias.ToSafeAliasWithForcingCheck(); var niceUrl = content.Name.FormatUrl().ToLower(); var xml = new XElement(nodeName, @@ -412,7 +411,8 @@ namespace Umbraco.Core.Models new XAttribute("writerName", content.GetWriterProfile().Name), new XAttribute("creatorName", content.GetCreatorProfile().Name), new XAttribute("path", content.Path), - new XAttribute("isDoc", "")); + new XAttribute("isDoc", ""), + UmbracoSettings.UseLegacyXmlSchema ? new XAttribute("nodeTypeAlias", content.ContentType.Alias) : null); foreach (var property in content.Properties) { diff --git a/src/Umbraco.Core/Models/PropertyExtensions.cs b/src/Umbraco.Core/Models/PropertyExtensions.cs index 0f3a40fe07..c4568e8472 100644 --- a/src/Umbraco.Core/Models/PropertyExtensions.cs +++ b/src/Umbraco.Core/Models/PropertyExtensions.cs @@ -1,6 +1,7 @@ using System; using System.Xml; using System.Xml.Linq; +using Umbraco.Core.Configuration; namespace Umbraco.Core.Models { @@ -13,7 +14,7 @@ namespace Umbraco.Core.Models /// Xml of the property and its value public static XElement ToXml(this Property property) { - string nodeName = property.Alias.ToUmbracoAlias(StringAliasCaseType.CamelCase, true); + string nodeName = UmbracoSettings.UseLegacyXmlSchema ? "data" : property.Alias.ToSafeAlias(); var xd = new XmlDocument(); XmlNode xmlNode = xd.CreateNode(XmlNodeType.Element, nodeName, ""); diff --git a/src/Umbraco.Core/StringExtensions.cs b/src/Umbraco.Core/StringExtensions.cs index 2ad3b927fc..40f8648165 100644 --- a/src/Umbraco.Core/StringExtensions.cs +++ b/src/Umbraco.Core/StringExtensions.cs @@ -771,5 +771,54 @@ namespace Umbraco.Core return newUrl; } + + /// + /// An extention method to ensure that an Alias string doesn't contains any illegal characters + /// which is defined in a private constant 'ValidCharacters' in this class. + /// Conventions over configuration, baby. You can't touch this - MC Hammer! + /// + /// + /// Copied and cleaned up a bit from umbraco.cms.helpers.Casing. + /// + /// The alias. + /// An alias guaranteed not to contain illegal characters + public static string ToSafeAlias(this string alias) + { + const string validAliasCharacters = "_-abcdefghijklmnopqrstuvwxyz1234567890"; + const string invalidFirstCharacters = "01234567890"; + var safeString = new StringBuilder(); + int aliasLength = alias.Length; + for (int i = 0; i < aliasLength; i++) + { + string currentChar = alias.Substring(i, 1); + if (validAliasCharacters.Contains(currentChar.ToLower())) + { + // check for camel (if previous character is a space, we'll upper case the current one + if (safeString.Length == 0 && invalidFirstCharacters.Contains(currentChar.ToLower())) + { + currentChar = ""; + } + else + { + if (i < aliasLength - 1 && i > 0 && alias.Substring(i - 1, 1) == " ") + currentChar = currentChar.ToUpper(); + + safeString.Append(currentChar); + } + } + } + + return safeString.ToString(); + } + + public static string ToSafeAliasWithForcingCheck(this string alias) + { + if (UmbracoSettings.ForceSafeAliases) + { + return alias.ToSafeAlias(); + } + + return alias; + } } } diff --git a/src/Umbraco.Tests/Models/ContentXmlTest.cs b/src/Umbraco.Tests/Models/ContentXmlTest.cs index 343dc0be9b..d080e037b6 100644 --- a/src/Umbraco.Tests/Models/ContentXmlTest.cs +++ b/src/Umbraco.Tests/Models/ContentXmlTest.cs @@ -53,7 +53,7 @@ namespace Umbraco.Tests.Models var content = MockedContent.CreateTextpageContent(contentType, "Root Home", -1); ServiceContext.ContentService.Save(content, 0); - var nodeName = content.ContentType.Alias.ToUmbracoAlias(StringAliasCaseType.CamelCase, true); + var nodeName = content.ContentType.Alias.ToSafeAliasWithForcingCheck(); // Act XElement element = content.ToXml(); From a95c1291167ecd096654d772190ad2cc7b6f6d48 Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Tue, 22 Jan 2013 11:23:33 -0100 Subject: [PATCH 188/188] Refactoring a few methods in the ContentService, so the omitCacheRefresh parameter isn't exposed in the new api, as its only relevant to the old api. Correcting the calls from Document to the internal methods in the ContentService, which ensures that the cache isn't refreshed as its handled elsewhere. Correcting broken unit test after having changed the GetDescendents method. --- src/Umbraco.Core/Services/ContentService.cs | 537 +++++++++++------- src/Umbraco.Core/Services/IContentService.cs | 15 +- .../Services/ContentServiceTests.cs | 2 +- src/umbraco.cms/businesslogic/web/Document.cs | 11 +- 4 files changed, 328 insertions(+), 237 deletions(-) diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs index 973c665349..fb8a3168ed 100644 --- a/src/Umbraco.Core/Services/ContentService.cs +++ b/src/Umbraco.Core/Services/ContentService.cs @@ -376,63 +376,10 @@ namespace Umbraco.Core.Services /// Re-Publishes all Content /// /// Optional Id of the User issueing the publishing - /// Optional boolean to avoid having the cache refreshed when calling this RePublish method. By default this method will update the cache. /// True if publishing succeeded, otherwise False - public bool RePublishAll(int userId = -1, bool omitCacheRefresh = false) + public bool RePublishAll(int userId = -1) { - //TODO Refactor this so omitCacheRefresh isn't exposed in the public method, but only in an internal one as its purely there for legacy reasons. - var list = new List(); - var updated = new List(); - - //Consider creating a Path query instead of recursive method: - //var query = Query.Builder.Where(x => x.Path.StartsWith("-1")); - - var rootContent = GetRootContent(); - foreach (var content in rootContent) - { - if (content.IsValid()) - { - list.Add(content); - list.AddRange(GetChildrenDeep(content.Id)); - } - } - - //Publish and then update the database with new status - var published = _publishingStrategy.PublishWithChildren(list, userId); - if (published) - { - var uow = _uowProvider.GetUnitOfWork(); - using (var repository = _repositoryFactory.CreateContentRepository(uow)) - { - //Only loop through content where the Published property has been updated - foreach (var item in list.Where(x => ((ICanBeDirty) x).IsPropertyDirty("Published"))) - { - SetWriter(item, userId); - repository.AddOrUpdate(item); - updated.Add(item); - } - - uow.Commit(); - - foreach (var c in updated) - { - var xml = c.ToXml(); - var poco = new ContentXmlDto {NodeId = c.Id, Xml = xml.ToString(SaveOptions.None)}; - var exists = uow.Database.FirstOrDefault("WHERE nodeId = @Id", new {Id = c.Id}) != - null; - int result = exists - ? uow.Database.Update(poco) - : Convert.ToInt32(uow.Database.Insert(poco)); - } - } - //Updating content to published state is finished, so we fire event through PublishingStrategy to have cache updated - if (omitCacheRefresh == false) - _publishingStrategy.PublishingFinalized(updated, true); - } - - Audit.Add(AuditTypes.Publish, "RePublish All performed by user", userId == -1 ? 0 : userId, -1); - - return published; + return RePublishAllDo(false, userId); } /// @@ -440,12 +387,10 @@ namespace Umbraco.Core.Services /// /// The to publish /// Optional Id of the User issueing the publishing - /// Optional boolean to avoid having the cache refreshed when calling this Publish method. By default this method will update the cache. /// True if publishing succeeded, otherwise False - public bool Publish(IContent content, int userId = -1, bool omitCacheRefresh = false) + public bool Publish(IContent content, int userId = -1) { - //TODO Refactor this so omitCacheRefresh isn't exposed in the public method, but only in an internal one as its purely there for legacy reasons. - return SaveAndPublish(content, userId, omitCacheRefresh); + return SaveAndPublishDo(content, false, userId); } /// @@ -453,76 +398,10 @@ namespace Umbraco.Core.Services /// /// The to publish along with its children /// Optional Id of the User issueing the publishing - /// Optional boolean to avoid having the cache refreshed when calling this Publish method. By default this method will update the cache. /// True if publishing succeeded, otherwise False - public bool PublishWithChildren(IContent content, int userId = -1, bool omitCacheRefresh = false) + public bool PublishWithChildren(IContent content, int userId = -1) { - //TODO Refactor this so omitCacheRefresh isn't exposed in the public method, but only in an internal one as its purely there for legacy reasons. - - //Check if parent is published (although not if its a root node) - if parent isn't published this Content cannot be published - if (content.ParentId != -1 && content.ParentId != -20 && IsPublishable(content) == false) - { - LogHelper.Info( - string.Format( - "Content '{0}' with Id '{1}' could not be published because its parent or one of its ancestors is not published.", - content.Name, content.Id)); - return false; - } - - //Content contains invalid property values and can therefore not be published - fire event? - if (!content.IsValid()) - { - LogHelper.Info( - string.Format("Content '{0}' with Id '{1}' could not be published because of invalid properties.", - content.Name, content.Id)); - return false; - } - - //Consider creating a Path query instead of recursive method: - //var query = Query.Builder.Where(x => x.Path.StartsWith(content.Path)); - - var updated = new List(); - var list = new List(); - list.Add(content); - list.AddRange(GetChildrenDeep(content.Id)); - - //Publish and then update the database with new status - var published = _publishingStrategy.PublishWithChildren(list, userId); - if (published) - { - var uow = _uowProvider.GetUnitOfWork(); - using (var repository = _repositoryFactory.CreateContentRepository(uow)) - { - //Only loop through content where the Published property has been updated - foreach (var item in list.Where(x => ((ICanBeDirty) x).IsPropertyDirty("Published"))) - { - SetWriter(item, userId); - repository.AddOrUpdate(item); - updated.Add(item); - } - - uow.Commit(); - - foreach (var c in updated) - { - var xml = c.ToXml(); - var poco = new ContentXmlDto {NodeId = c.Id, Xml = xml.ToString(SaveOptions.None)}; - var exists = uow.Database.FirstOrDefault("WHERE nodeId = @Id", new {Id = c.Id}) != - null; - int result = exists - ? uow.Database.Update(poco) - : Convert.ToInt32(uow.Database.Insert(poco)); - } - } - //Save xml to db and call following method to fire event: - if (omitCacheRefresh == false) - _publishingStrategy.PublishingFinalized(updated, false); - - Audit.Add(AuditTypes.Publish, "Publish with Children performed by user", userId == -1 ? 0 : userId, - content.Id); - } - - return published; + return PublishWithChildrenDo(content, false, userId); } /// @@ -530,33 +409,10 @@ namespace Umbraco.Core.Services /// /// The to publish /// Optional Id of the User issueing the publishing - /// Optional boolean to avoid having the cache refreshed when calling this Unpublish method. By default this method will update the cache. /// True if unpublishing succeeded, otherwise False - public bool UnPublish(IContent content, int userId = -1, bool omitCacheRefresh = false) + public bool UnPublish(IContent content, int userId = -1) { - //TODO Refactor this so omitCacheRefresh isn't exposed in the public method, but only in an internal one as its purely there for legacy reasons. - - var unpublished = _publishingStrategy.UnPublish(content, userId); - if (unpublished) - { - var uow = _uowProvider.GetUnitOfWork(); - using (var repository = _repositoryFactory.CreateContentRepository(uow)) - { - repository.AddOrUpdate(content); - - //Remove 'published' xml from the cmsContentXml table for the unpublished content - uow.Database.Delete("WHERE nodeId = @Id", new {Id = content.Id}); - - uow.Commit(); - } - //Delete xml from db? and call following method to fire event through PublishingStrategy to update cache - if (omitCacheRefresh == false) - _publishingStrategy.UnPublishingFinalized(content); - - Audit.Add(AuditTypes.UnPublish, "UnPublish performed by user", userId == -1 ? 0 : userId, content.Id); - } - - return unpublished; + return UnPublishDo(content, false, userId); } /// @@ -564,76 +420,10 @@ namespace Umbraco.Core.Services /// /// The to save and publish /// Optional Id of the User issueing the publishing - /// Optional boolean to avoid having the cache refreshed when calling this Publish method. By default this method will update the cache. /// True if publishing succeeded, otherwise False - public bool SaveAndPublish(IContent content, int userId = -1, bool omitCacheRefresh = false) + public bool SaveAndPublish(IContent content, int userId = -1) { - //TODO Refactor this so omitCacheRefresh isn't exposed in the public method, but only in an internal one as its purely there for legacy reasons. - if (Saving.IsRaisedEventCancelled(new SaveEventArgs(content), this)) - return false; - - //Check if parent is published (although not if its a root node) - if parent isn't published this Content cannot be published - if (content.ParentId != -1 && content.ParentId != -20 && IsPublishable(content) == false) - { - LogHelper.Info( - string.Format( - "Content '{0}' with Id '{1}' could not be published because its parent is not published.", - content.Name, content.Id)); - return false; - } - - //Content contains invalid property values and can therefore not be published - fire event? - if (!content.IsValid()) - { - LogHelper.Info( - string.Format( - "Content '{0}' with Id '{1}' could not be published because of invalid properties.", - content.Name, content.Id)); - return false; - } - - //Publish and then update the database with new status - bool published = _publishingStrategy.Publish(content, userId); - - var uow = _uowProvider.GetUnitOfWork(); - using (var repository = _repositoryFactory.CreateContentRepository(uow)) - { - //Since this is the Save and Publish method, the content should be saved even though the publish fails or isn't allowed - SetWriter(content, userId); - repository.AddOrUpdate(content); - - uow.Commit(); - - if (published) - { - var xml = content.ToXml(); - var poco = new ContentXmlDto { NodeId = content.Id, Xml = xml.ToString(SaveOptions.None) }; - var exists = uow.Database.FirstOrDefault("WHERE nodeId = @Id", new {Id = content.Id}) != null; - int result = exists - ? uow.Database.Update(poco) - : Convert.ToInt32(uow.Database.Insert(poco)); - } - } - - Saved.RaiseEvent(new SaveEventArgs(content, false), this); - - //Save xml to db and call following method to fire event through PublishingStrategy to update cache - if (omitCacheRefresh == false) - _publishingStrategy.PublishingFinalized(content); - - //We need to check if children and their publish state to ensure that we republish content that was previously published - if (HasChildren(content.Id)) - { - var children = GetChildrenDeep(content.Id); - var shouldBeRepublished = children.Where(child => HasPublishedVersion(child.Id)); - - if (omitCacheRefresh == false) - _publishingStrategy.PublishingFinalized(shouldBeRepublished, false); - } - - Audit.Add(AuditTypes.Publish, "Save and Publish performed by user", userId == -1 ? 0 : userId, content.Id); - - return published; + return SaveAndPublishDo(content, false, userId); } /// @@ -1003,7 +793,7 @@ namespace Umbraco.Core.Services // A copy should never be set to published // automatically even if the original was - this.UnPublish(copy); + this.UnPublish(copy, userId); if (Copying.IsRaisedEventCancelled(new CopyEventArgs(content, copy, parentId), this)) return null; @@ -1154,10 +944,315 @@ namespace Umbraco.Core.Services { _httpContext = httpContext; } + + /// + /// Internal method to Re-Publishes all Content for legacy purposes. + /// + /// Optional Id of the User issueing the publishing + /// Optional boolean to avoid having the cache refreshed when calling this RePublish method. By default this method will not update the cache. + /// True if publishing succeeded, otherwise False + internal bool RePublishAll(bool omitCacheRefresh = true, int userId = -1) + { + return RePublishAllDo(omitCacheRefresh, userId); + } + + /// + /// Internal method that Publishes a single object for legacy purposes. + /// + /// The to publish + /// Optional boolean to avoid having the cache refreshed when calling this Publish method. By default this method will not update the cache. + /// Optional Id of the User issueing the publishing + /// True if publishing succeeded, otherwise False + internal bool Publish(IContent content, bool omitCacheRefresh = true, int userId = -1) + { + return SaveAndPublishDo(content, omitCacheRefresh, userId); + } + + /// + /// Internal method that Publishes a object and all its children for legacy purposes. + /// + /// The to publish along with its children + /// Optional boolean to avoid having the cache refreshed when calling this Publish method. By default this method will not update the cache. + /// Optional Id of the User issueing the publishing + /// True if publishing succeeded, otherwise False + internal bool PublishWithChildren(IContent content, bool omitCacheRefresh = true, int userId = -1) + { + return PublishWithChildrenDo(content, omitCacheRefresh, userId); + } + + /// + /// Internal method that UnPublishes a single object for legacy purposes. + /// + /// The to publish + /// Optional boolean to avoid having the cache refreshed when calling this Unpublish method. By default this method will not update the cache. + /// Optional Id of the User issueing the publishing + /// True if unpublishing succeeded, otherwise False + internal bool UnPublish(IContent content, bool omitCacheRefresh = true, int userId = -1) + { + return UnPublishDo(content, omitCacheRefresh, userId); + } + + /// + /// Saves and Publishes a single object + /// + /// The to save and publish + /// Optional boolean to avoid having the cache refreshed when calling this Publish method. By default this method will not update the cache. + /// Optional Id of the User issueing the publishing + /// True if publishing succeeded, otherwise False + internal bool SaveAndPublish(IContent content, bool omitCacheRefresh = true, int userId = -1) + { + return SaveAndPublishDo(content, omitCacheRefresh, userId); + } + #endregion #region Private Methods + /// + /// Re-Publishes all Content + /// + /// Optional Id of the User issueing the publishing + /// Optional boolean to avoid having the cache refreshed when calling this RePublish method. By default this method will update the cache. + /// True if publishing succeeded, otherwise False + private bool RePublishAllDo(bool omitCacheRefresh = false, int userId = -1) + { + var list = new List(); + var updated = new List(); + + //Consider creating a Path query instead of recursive method: + //var query = Query.Builder.Where(x => x.Path.StartsWith("-1")); + + var rootContent = GetRootContent(); + foreach (var content in rootContent) + { + if (content.IsValid()) + { + list.Add(content); + list.AddRange(GetChildrenDeep(content.Id)); + } + } + + //Publish and then update the database with new status + var published = _publishingStrategy.PublishWithChildren(list, userId); + if (published) + { + var uow = _uowProvider.GetUnitOfWork(); + using (var repository = _repositoryFactory.CreateContentRepository(uow)) + { + //Only loop through content where the Published property has been updated + foreach (var item in list.Where(x => ((ICanBeDirty)x).IsPropertyDirty("Published"))) + { + SetWriter(item, userId); + repository.AddOrUpdate(item); + updated.Add(item); + } + + uow.Commit(); + + foreach (var c in updated) + { + var xml = c.ToXml(); + var poco = new ContentXmlDto { NodeId = c.Id, Xml = xml.ToString(SaveOptions.None) }; + var exists = uow.Database.FirstOrDefault("WHERE nodeId = @Id", new { Id = c.Id }) != + null; + int result = exists + ? uow.Database.Update(poco) + : Convert.ToInt32(uow.Database.Insert(poco)); + } + } + //Updating content to published state is finished, so we fire event through PublishingStrategy to have cache updated + if (omitCacheRefresh == false) + _publishingStrategy.PublishingFinalized(updated, true); + } + + Audit.Add(AuditTypes.Publish, "RePublish All performed by user", userId == -1 ? 0 : userId, -1); + + return published; + } + + /// + /// Publishes a object and all its children + /// + /// The to publish along with its children + /// Optional boolean to avoid having the cache refreshed when calling this Publish method. By default this method will update the cache. + /// Optional Id of the User issueing the publishing + /// True if publishing succeeded, otherwise False + private bool PublishWithChildrenDo(IContent content, bool omitCacheRefresh = false, int userId = -1) + { + //Check if parent is published (although not if its a root node) - if parent isn't published this Content cannot be published + if (content.ParentId != -1 && content.ParentId != -20 && IsPublishable(content) == false) + { + LogHelper.Info( + string.Format( + "Content '{0}' with Id '{1}' could not be published because its parent or one of its ancestors is not published.", + content.Name, content.Id)); + return false; + } + + //Content contains invalid property values and can therefore not be published - fire event? + if (!content.IsValid()) + { + LogHelper.Info( + string.Format("Content '{0}' with Id '{1}' could not be published because of invalid properties.", + content.Name, content.Id)); + return false; + } + + //Consider creating a Path query instead of recursive method: + //var query = Query.Builder.Where(x => x.Path.StartsWith(content.Path)); + + var updated = new List(); + var list = new List(); + list.Add(content); + list.AddRange(GetChildrenDeep(content.Id)); + + //Publish and then update the database with new status + var published = _publishingStrategy.PublishWithChildren(list, userId); + if (published) + { + var uow = _uowProvider.GetUnitOfWork(); + using (var repository = _repositoryFactory.CreateContentRepository(uow)) + { + //Only loop through content where the Published property has been updated + foreach (var item in list.Where(x => ((ICanBeDirty)x).IsPropertyDirty("Published"))) + { + SetWriter(item, userId); + repository.AddOrUpdate(item); + updated.Add(item); + } + + uow.Commit(); + + foreach (var c in updated) + { + var xml = c.ToXml(); + var poco = new ContentXmlDto { NodeId = c.Id, Xml = xml.ToString(SaveOptions.None) }; + var exists = uow.Database.FirstOrDefault("WHERE nodeId = @Id", new { Id = c.Id }) != + null; + int result = exists + ? uow.Database.Update(poco) + : Convert.ToInt32(uow.Database.Insert(poco)); + } + } + //Save xml to db and call following method to fire event: + if (omitCacheRefresh == false) + _publishingStrategy.PublishingFinalized(updated, false); + + Audit.Add(AuditTypes.Publish, "Publish with Children performed by user", userId == -1 ? 0 : userId, + content.Id); + } + + return published; + } + + /// + /// UnPublishes a single object + /// + /// The to publish + /// Optional boolean to avoid having the cache refreshed when calling this Unpublish method. By default this method will update the cache. + /// Optional Id of the User issueing the publishing + /// True if unpublishing succeeded, otherwise False + private bool UnPublishDo(IContent content, bool omitCacheRefresh = false, int userId = -1) + { + var unpublished = _publishingStrategy.UnPublish(content, userId); + if (unpublished) + { + var uow = _uowProvider.GetUnitOfWork(); + using (var repository = _repositoryFactory.CreateContentRepository(uow)) + { + repository.AddOrUpdate(content); + + //Remove 'published' xml from the cmsContentXml table for the unpublished content + uow.Database.Delete("WHERE nodeId = @Id", new { Id = content.Id }); + + uow.Commit(); + } + //Delete xml from db? and call following method to fire event through PublishingStrategy to update cache + if (omitCacheRefresh == false) + _publishingStrategy.UnPublishingFinalized(content); + + Audit.Add(AuditTypes.UnPublish, "UnPublish performed by user", userId == -1 ? 0 : userId, content.Id); + } + + return unpublished; + } + + /// + /// Saves and Publishes a single object + /// + /// The to save and publish + /// Optional boolean to avoid having the cache refreshed when calling this Publish method. By default this method will update the cache. + /// Optional Id of the User issueing the publishing + /// True if publishing succeeded, otherwise False + private bool SaveAndPublishDo(IContent content, bool omitCacheRefresh = false, int userId = -1) + { + if (Saving.IsRaisedEventCancelled(new SaveEventArgs(content), this)) + return false; + + //Check if parent is published (although not if its a root node) - if parent isn't published this Content cannot be published + if (content.ParentId != -1 && content.ParentId != -20 && IsPublishable(content) == false) + { + LogHelper.Info( + string.Format( + "Content '{0}' with Id '{1}' could not be published because its parent is not published.", + content.Name, content.Id)); + return false; + } + + //Content contains invalid property values and can therefore not be published - fire event? + if (!content.IsValid()) + { + LogHelper.Info( + string.Format( + "Content '{0}' with Id '{1}' could not be published because of invalid properties.", + content.Name, content.Id)); + return false; + } + + //Publish and then update the database with new status + bool published = _publishingStrategy.Publish(content, userId); + + var uow = _uowProvider.GetUnitOfWork(); + using (var repository = _repositoryFactory.CreateContentRepository(uow)) + { + //Since this is the Save and Publish method, the content should be saved even though the publish fails or isn't allowed + SetWriter(content, userId); + repository.AddOrUpdate(content); + + uow.Commit(); + + if (published) + { + var xml = content.ToXml(); + var poco = new ContentXmlDto { NodeId = content.Id, Xml = xml.ToString(SaveOptions.None) }; + var exists = uow.Database.FirstOrDefault("WHERE nodeId = @Id", new { Id = content.Id }) != null; + int result = exists + ? uow.Database.Update(poco) + : Convert.ToInt32(uow.Database.Insert(poco)); + } + } + + Saved.RaiseEvent(new SaveEventArgs(content, false), this); + + //Save xml to db and call following method to fire event through PublishingStrategy to update cache + if (omitCacheRefresh == false) + _publishingStrategy.PublishingFinalized(content); + + //We need to check if children and their publish state to ensure that we republish content that was previously published + if (HasChildren(content.Id)) + { + var children = GetChildrenDeep(content.Id); + var shouldBeRepublished = children.Where(child => HasPublishedVersion(child.Id)); + + if (omitCacheRefresh == false) + _publishingStrategy.PublishingFinalized(shouldBeRepublished, false); + } + + Audit.Add(AuditTypes.Publish, "Save and Publish performed by user", userId == -1 ? 0 : userId, content.Id); + + return published; + } + /// /// Saves a single object /// diff --git a/src/Umbraco.Core/Services/IContentService.cs b/src/Umbraco.Core/Services/IContentService.cs index 20a2f9b072..1f902ed266 100644 --- a/src/Umbraco.Core/Services/IContentService.cs +++ b/src/Umbraco.Core/Services/IContentService.cs @@ -210,45 +210,40 @@ namespace Umbraco.Core.Services /// Re-Publishes all Content /// /// Optional Id of the User issueing the publishing - /// Optional boolean to avoid having the cache refreshed when calling this RePublish method. By default this method will update the cache. /// True if publishing succeeded, otherwise False - bool RePublishAll(int userId = -1, bool omitCacheRefresh = false); + bool RePublishAll(int userId = -1); /// /// Publishes a single object /// /// The to publish /// Optional Id of the User issueing the publishing - /// Optional boolean to avoid having the cache refreshed when calling this Publish method. By default this method will update the cache. /// True if publishing succeeded, otherwise False - bool Publish(IContent content, int userId = -1, bool omitCacheRefresh = false); + bool Publish(IContent content, int userId = -1); /// /// Publishes a object and all its children /// /// The to publish along with its children /// Optional Id of the User issueing the publishing - /// Optional boolean to avoid having the cache refreshed when calling this Publish method. By default this method will update the cache. /// True if publishing succeeded, otherwise False - bool PublishWithChildren(IContent content, int userId = -1, bool omitCacheRefresh = false); + bool PublishWithChildren(IContent content, int userId = -1); /// /// UnPublishes a single object /// /// The to publish /// Optional Id of the User issueing the publishing - /// Optional boolean to avoid having the cache refreshed when calling this Unpublish method. By default this method will update the cache. /// True if unpublishing succeeded, otherwise False - bool UnPublish(IContent content, int userId = -1, bool omitCacheRefresh = false); + bool UnPublish(IContent content, int userId = -1); /// /// Saves and Publishes a single object /// /// The to save and publish /// Optional Id of the User issueing the publishing - /// Optional boolean to avoid having the cache refreshed when calling this Publish method. By default this method will update the cache. /// True if publishing succeeded, otherwise False - bool SaveAndPublish(IContent content, int userId = -1, bool omitCacheRefresh = false); + bool SaveAndPublish(IContent content, int userId = -1); /// /// Permanently deletes an object. diff --git a/src/Umbraco.Tests/Services/ContentServiceTests.cs b/src/Umbraco.Tests/Services/ContentServiceTests.cs index 6f7bb646dd..235c2ede83 100644 --- a/src/Umbraco.Tests/Services/ContentServiceTests.cs +++ b/src/Umbraco.Tests/Services/ContentServiceTests.cs @@ -217,7 +217,7 @@ namespace Umbraco.Tests.Services // Assert Assert.That(contents, Is.Not.Null); Assert.That(contents.Any(), Is.True); - Assert.That(contents.Count(), Is.EqualTo(53)); + Assert.That(contents.Count(), Is.EqualTo(52)); } [Test] diff --git a/src/umbraco.cms/businesslogic/web/Document.cs b/src/umbraco.cms/businesslogic/web/Document.cs index 9f1bb00e69..4b57ddd758 100644 --- a/src/umbraco.cms/businesslogic/web/Document.cs +++ b/src/umbraco.cms/businesslogic/web/Document.cs @@ -7,6 +7,7 @@ using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.Logging; using Umbraco.Core.Persistence.Caching; +using Umbraco.Core.Services; using umbraco.BusinessLogic; using umbraco.BusinessLogic.Actions; using umbraco.cms.helpers; @@ -855,7 +856,7 @@ namespace umbraco.cms.businesslogic.web if (!e.Cancel) { - var result = ApplicationContext.Current.Services.ContentService.Publish(Content, u.Id, true); + var result = ((ContentService)ApplicationContext.Current.Services.ContentService).Publish(Content, true, u.Id); _published = result; FireAfterPublish(e); @@ -871,7 +872,7 @@ namespace umbraco.cms.businesslogic.web [Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.PublishWithChildren()", false)] public bool PublishWithChildrenWithResult(User u) { - return ApplicationContext.Current.Services.ContentService.PublishWithChildren(Content, u.Id, true); + return ((ContentService)ApplicationContext.Current.Services.ContentService).PublishWithChildren(Content, true, u.Id); } /// @@ -908,7 +909,7 @@ namespace umbraco.cms.businesslogic.web if (!e.Cancel) { - var published = ApplicationContext.Current.Services.ContentService.PublishWithChildren(Content, u.Id, true); + var published = ((ContentService)ApplicationContext.Current.Services.ContentService).PublishWithChildren(Content, true, u.Id); FireAfterPublish(e); } @@ -923,7 +924,7 @@ namespace umbraco.cms.businesslogic.web if (!e.Cancel) { - _published = ApplicationContext.Current.Services.ContentService.UnPublish(Content, 0, true); + _published = ((ContentService)ApplicationContext.Current.Services.ContentService).UnPublish(Content, true, 0); FireAfterUnPublish(e); } @@ -980,7 +981,7 @@ namespace umbraco.cms.businesslogic.web if (!e.Cancel) { - var result = ApplicationContext.Current.Services.ContentService.SaveAndPublish(Content, u.Id, true); + var result = ((ContentService)ApplicationContext.Current.Services.ContentService).SaveAndPublish(Content, true, u.Id); base.Save(); // update preview xml