From bdcf8f8fc0ae09aa151d1c8d5676dfc72bc893ff Mon Sep 17 00:00:00 2001 From: Shannon Date: Fri, 14 Nov 2014 17:57:44 +1100 Subject: [PATCH] Removes more unused code --- src/Umbraco.Core/ApplicationContext.cs | 8 +- src/Umbraco.Tests/UmbracoExamine/IndexTest.cs | 3 +- .../Controllers/InstallApiController.cs | 12 -- .../umbraco.presentation/template.cs | 17 +-- .../controls/ContentTypeControlNew.ascx.cs | 120 ------------------ .../developer/Packages/installer.aspx.cs | 8 -- .../umbraco/uQuery/NodeExtensions.cs | 22 ---- src/UmbracoExamine/UmbracoMemberIndexer.cs | 7 - .../BasePages/ClientTools.cs | 8 +- 9 files changed, 7 insertions(+), 198 deletions(-) diff --git a/src/Umbraco.Core/ApplicationContext.cs b/src/Umbraco.Core/ApplicationContext.cs index f1bb929a94..1ff21615bc 100644 --- a/src/Umbraco.Core/ApplicationContext.cs +++ b/src/Umbraco.Core/ApplicationContext.cs @@ -208,13 +208,7 @@ namespace Umbraco.Core } } - private void AssertIsReady() - { - if (!this.IsReady) - throw new Exception("ApplicationContext is not ready yet."); - } - - private void AssertIsNotReady() + private void AssertIsNotReady() { if (this.IsReady) throw new Exception("ApplicationContext has already been initialized."); diff --git a/src/Umbraco.Tests/UmbracoExamine/IndexTest.cs b/src/Umbraco.Tests/UmbracoExamine/IndexTest.cs index cf58f420ca..736f6c3eb0 100644 --- a/src/Umbraco.Tests/UmbracoExamine/IndexTest.cs +++ b/src/Umbraco.Tests/UmbracoExamine/IndexTest.cs @@ -192,8 +192,7 @@ namespace Umbraco.Tests.UmbracoExamine #region Private methods and properties - private readonly TestContentService _contentService = new TestContentService(); - private readonly TestMediaService _mediaService = new TestMediaService(); + private readonly TestMediaService _mediaService = new TestMediaService(); private static UmbracoExamineSearcher _searcher; private static UmbracoContentIndexer _indexer; diff --git a/src/Umbraco.Web/Install/Controllers/InstallApiController.cs b/src/Umbraco.Web/Install/Controllers/InstallApiController.cs index 6041e23ca5..20dcef71ba 100644 --- a/src/Umbraco.Web/Install/Controllers/InstallApiController.cs +++ b/src/Umbraco.Web/Install/Controllers/InstallApiController.cs @@ -1,10 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Net; -using System.Net.Http; using System.Reflection; -using System.Text; using System.Web.Http; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -281,14 +278,5 @@ namespace Umbraco.Web.Install.Controllers } } } - - private HttpResponseMessage Json(object jsonObject, HttpStatusCode status) - { - var response = Request.CreateResponse(status); - var json = JObject.FromObject(jsonObject); - response.Content = new StringContent(json.ToString(), Encoding.UTF8, "application/json"); - return response; - } - } } diff --git a/src/Umbraco.Web/umbraco.presentation/template.cs b/src/Umbraco.Web/umbraco.presentation/template.cs index a1469c3f18..7b064a8ba7 100644 --- a/src/Umbraco.Web/umbraco.presentation/template.cs +++ b/src/Umbraco.Web/umbraco.presentation/template.cs @@ -280,7 +280,7 @@ namespace umbraco macro tempMacro; String macroID = helper.FindAttribute(attributes, "macroid"); if (macroID != String.Empty) - tempMacro = getMacro(macroID); + tempMacro = GetMacro(macroID); else tempMacro = macro.GetMacro(helper.FindAttribute(attributes, "macroalias")); @@ -409,7 +409,7 @@ namespace umbraco String macroID = helper.FindAttribute(attributes, "macroid"); if (macroID != "") { - macro tempMacro = getMacro(macroID); + macro tempMacro = GetMacro(macroID); _templateOutput.Replace(tag.Value.ToString(), tempMacro.MacroContent.ToString()); } } @@ -427,7 +427,7 @@ namespace umbraco String macroID = helper.FindAttribute(tempAttributes, "macroid"); if (Convert.ToInt32(macroID) > 0) { - macro tempContentMacro = getMacro(macroID); + macro tempContentMacro = GetMacro(macroID); _templateOutput.Replace(tag.Value.ToString(), tempContentMacro.MacroContent.ToString()); } @@ -452,21 +452,12 @@ namespace umbraco #region private methods - private macro getMacro(String macroID) + private static macro GetMacro(String macroID) { System.Web.HttpContext.Current.Trace.Write("umbracoTemplate", "Starting macro (" + macroID.ToString() + ")"); return macro.GetMacro(Convert.ToInt16(macroID)); } - private String FindAttribute(Hashtable attributes, String key) - { - if (attributes[key] != null) - return attributes[key].ToString(); - else - return ""; - } - - #endregion protected static ISqlHelper SqlHelper 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 f31c41dd96..cf4d3a9d3a 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs @@ -3,7 +3,6 @@ using System.Collections; using System.Collections.Generic; using System.Data; using System.Globalization; -using System.IO; using System.Linq; using System.Web; using System.Web.Mvc; @@ -24,7 +23,6 @@ using umbraco.BusinessLogic; using umbraco.cms.businesslogic; using umbraco.cms.businesslogic.propertytype; using umbraco.cms.businesslogic.web; -using umbraco.cms.helpers; using umbraco.controls.GenericProperties; using umbraco.presentation; using umbraco.BasePages; @@ -476,114 +474,8 @@ namespace umbraco.controls else lt_icon.Text = _contentType.IconUrl.TrimStart('.'); - /* - var dirInfo = new DirectoryInfo(Server.MapPath(SystemDirectories.Umbraco + "/images/umbraco")); - var fileInfo = dirInfo.GetFiles(); - - var spriteFileNames = CMSNode.DefaultIconClasses.Select(IconClassToIconFileName).ToList(); - var diskFileNames = fileInfo.Select(FileNameToIconFileName).ToList(); - var listOfIcons = new List(); - // .sprNew was never intended to be in the document type editor - foreach (var iconClass in CMSNode.DefaultIconClasses.Where(iconClass => iconClass.Equals(".sprNew", StringComparison.InvariantCultureIgnoreCase) == false)) - { - // Still shows the selected even if we tell it to hide sprite duplicates so as not to break an existing selection - if (_contentType.IconUrl.Equals(iconClass, StringComparison.InvariantCultureIgnoreCase) == false - && UmbracoConfiguration.Current.UmbracoSettings.Content.IconPickerBehaviour == IconPickerBehaviour.HideSpriteDuplicates - && diskFileNames.Contains(IconClassToIconFileName(iconClass))) - continue; - - AddSpriteListItem(iconClass, listOfIcons); - } - - foreach (var file in fileInfo) - { - // NH: don't show the sprite file - if (file.Name.ToLowerInvariant() == "sprites.png".ToLowerInvariant() || file.Name.ToLowerInvariant() == "sprites_ie6.gif".ToLowerInvariant()) - continue; - - // Still shows the selected even if we tell it to hide file duplicates so as not to break an existing selection - if (_contentType.IconUrl.Equals(file.Name, StringComparison.InvariantCultureIgnoreCase) == false - && UmbracoConfiguration.Current.UmbracoSettings.Content.IconPickerBehaviour == IconPickerBehaviour.HideFileDuplicates - && spriteFileNames.Contains(FileNameToIconFileName(file))) - continue; - - var listItemValue = ResolveClientUrl(SystemDirectories.Umbraco + "/images/umbraco/" + file.Name); - - AddFileListItem(file.Name, listItemValue, listOfIcons); - } - - ddlIcons.Items.AddRange(listOfIcons.OrderBy(o => o.Text).ToArray()); - - - // Get thumbnails - dirInfo = new DirectoryInfo(IOHelper.MapPath(SystemDirectories.Umbraco + "/images/thumbnails")); - fileInfo = dirInfo.GetFiles(); - - foreach (var file in fileInfo) - { - var li = new ListItem(file.Name); - li.Attributes.Add("title", this.ResolveClientUrl(SystemDirectories.Umbraco + "/images/thumbnails/" + file.Name)); - - if (this.Page.IsPostBack == false && li.Value == _contentType.Thumbnail) - li.Selected = true; - - // ddlThumbnails.Items.Add(li); - } - - - Page.ClientScript.RegisterStartupScript(this.GetType(), "thumbnailsDropDown", string.Format(@" -function refreshDropDowns() {{ - jQuery('#{1}').msDropDown({{ showIcon: true, style: 'width:250px;' }}); - jQuery('#{3}').msDropDown({{ showIcon: false, rowHeight: '130', visibleRows: '2', style: 'width:250px;' }}); -}} -jQuery(document).ready(function() {{ refreshDropDowns(); }}); -", ddlIcons.ClientID, ddlIcons.ClientID, ddlIcons.ClientID, ddlThumbnails.ClientID, 500), true); - txtName.Text = _contentType.GetRawText(); - txtAlias.Text = _contentType.Alias; - description.Text = _contentType.GetRawDescription(); - */ } - private void AddSpriteListItem(string iconClass, ICollection listOfIcons) - { - var li = new ListItem( - helper.SpaceCamelCasing((iconClass.Substring(1, iconClass.Length - 1))) - .Replace("Spr Tree", "") - .Trim(), iconClass); - - li.Attributes.Add("class", "spriteBackground sprTree " + iconClass.Trim('.')); - li.Attributes.Add("style", "padding-left:24px !important; background-repeat:no-repeat; width:auto; height:auto;"); - - AddListItem(listOfIcons, li); - } - - private void AddFileListItem(string fileName, string listItemValue, ICollection listOfIcons) - { - var li = new ListItem(fileName, fileName); - - li.Attributes.Add("title", listItemValue); - - AddListItem(listOfIcons, li); - } - - private void AddListItem(ICollection listOfIcons, ListItem li) - { - if (this.Page.IsPostBack == false && li.Value == _contentType.IconUrl) - li.Selected = true; - - listOfIcons.Add(li); - } - - private static string IconClassToIconFileName(string iconClass) - { - return iconClass.Substring(1, iconClass.Length - 1).ToLowerInvariant().Replace("sprTree".ToLowerInvariant(), ""); - } - - private static string FileNameToIconFileName(FileInfo file) - { - return file.Name.Substring(0, file.Name.LastIndexOf(".", StringComparison.Ordinal)).ToLowerInvariant(); - } - #endregion #region "Structure" Pane @@ -1070,18 +962,6 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }}); } } - private bool DoesPropertyTypeAliasExist(GenericProperty gpData) - { - bool hasAlias = _contentType.getPropertyType(Casing.SafeAliasWithForcingCheck(gpData.Alias.Trim())) != null; - ContentType ct = _contentType; - while (ct.MasterContentType > 0) - { - ct = new ContentType(ct.MasterContentType); - hasAlias = ct.getPropertyType(Casing.SafeAliasWithForcingCheck(gpData.Alias.Trim())) != null; - } - return !hasAlias; - } - /// /// Called asynchronously in order to delete a content type property /// diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/installer.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/installer.aspx.cs index a78e2293f0..a666c8fbe2 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/installer.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/installer.aspx.cs @@ -336,14 +336,6 @@ namespace umbraco.presentation.developer.packages PerformPostInstallCleanup(packageId, dir); } - /// - /// Runs Post refresh actions such reloading the correct tree nodes, etc... - /// - private void PerformPostRefreshAction() - { - BasePage.Current.ClientTools.ReloadActionNode(true, true); - } - /// /// Runs Post install actions such as clearning any necessary cache, reloading the correct tree nodes, etc... /// diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/uQuery/NodeExtensions.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/uQuery/NodeExtensions.cs index a3b7b93a06..5843e3c282 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/uQuery/NodeExtensions.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/uQuery/NodeExtensions.cs @@ -504,17 +504,6 @@ namespace umbraco return default(T); } - /// - /// Get a string value for the supplied property alias - /// - /// an umbraco.presentation.nodeFactory.Node object - /// alias of propety to get - /// empty string, or property value as string - private static string GetPropertyAsString(this Node node, string propertyAlias) - { - return GetPropertyAsString((INode)node, propertyAlias); - } - /// /// Get a string value for the supplied property alias /// @@ -534,17 +523,6 @@ namespace umbraco return propertyValue; } - /// - /// Get a boolean value for the supplied property alias (works with built in Yes/No dataype) - /// - /// an umbraco.presentation.nodeFactory.Node object - /// alias of propety to get - /// true if can cast value, else false for all other circumstances - private static bool GetPropertyAsBoolean(this Node node, string propertyAlias) - { - return GetPropertyAsBoolean((INode)node, propertyAlias); - } - /// /// Get a boolean value for the supplied property alias (works with built in Yes/No dataype) /// diff --git a/src/UmbracoExamine/UmbracoMemberIndexer.cs b/src/UmbracoExamine/UmbracoMemberIndexer.cs index d23ff26751..cdb9c4ffde 100644 --- a/src/UmbracoExamine/UmbracoMemberIndexer.cs +++ b/src/UmbracoExamine/UmbracoMemberIndexer.cs @@ -192,12 +192,5 @@ namespace UmbracoExamine e.Fields.Add("_searchEmail", e.Node.Attribute("email").Value.Replace(".", " ").Replace("@", " ")); } } - - private static XElement GetMemberItem(int nodeId) - { - //TODO: Change this so that it is not using the LegacyLibrary, just serialize manually! - var nodes = LegacyLibrary.GetMember(nodeId); - return XElement.Parse(nodes.Current.OuterXml); - } } } diff --git a/src/umbraco.businesslogic/BasePages/ClientTools.cs b/src/umbraco.businesslogic/BasePages/ClientTools.cs index c164b086f1..0f5aab184b 100644 --- a/src/umbraco.businesslogic/BasePages/ClientTools.cs +++ b/src/umbraco.businesslogic/BasePages/ClientTools.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Text; -using System.Web; using umbraco.BasePages; using System.Web.UI; using Umbraco.Core.IO; @@ -326,12 +325,7 @@ namespace umbraco.BasePages return this; } - private Page GetCurrentPage() - { - return HttpContext.Current.CurrentHandler as Page; - } - - /// + /// /// This will use the ScriptManager to register the script if one is available, otherwise will default to the ClientScript /// class of the page. ///