From 19edfdb2a4ff3ec8a2ccb98c2ccce2bc14a9cd42 Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 1 May 2018 01:30:36 +1000 Subject: [PATCH] Removes unused and obsoleted code --- src/Umbraco.Core/Models/File.cs | 8 +- src/Umbraco.Core/Models/IFile.cs | 4 +- .../Persistence/Dtos/StylesheetDto.cs | 24 - .../Persistence/Dtos/StylesheetPropertyDto.cs | 28 - src/Umbraco.Core/Umbraco.Core.csproj | 2 - .../Persistence/SqlCeTableByTableTest.cs | 30 +- src/Umbraco.Web/Models/RegisterModel.cs | 7 +- .../Mvc/SurfaceControllerFactory.cs | 68 -- src/Umbraco.Web/Umbraco.Web.csproj | 3 - src/Umbraco.Web/_Legacy/Actions/ActionQuit.cs | 88 --- .../umbraco/controls/ContentControl.cs | 699 ------------------ 11 files changed, 4 insertions(+), 957 deletions(-) delete mode 100644 src/Umbraco.Core/Persistence/Dtos/StylesheetDto.cs delete mode 100644 src/Umbraco.Core/Persistence/Dtos/StylesheetPropertyDto.cs delete mode 100644 src/Umbraco.Web/Mvc/SurfaceControllerFactory.cs delete mode 100644 src/Umbraco.Web/_Legacy/Actions/ActionQuit.cs delete mode 100644 src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentControl.cs diff --git a/src/Umbraco.Core/Models/File.cs b/src/Umbraco.Core/Models/File.cs index cf202ea54f..41aff25a81 100644 --- a/src/Umbraco.Core/Models/File.cs +++ b/src/Umbraco.Core/Models/File.cs @@ -146,13 +146,7 @@ namespace Umbraco.Core.Models /// Gets or sets the file's virtual path (i.e. the file path relative to the root of the website) /// public string VirtualPath { get; set; } - - [Obsolete("This is no longer used and will be removed from the codebase in future versions")] - public virtual bool IsValid() - { - return true; - } - + // this exists so that class that manage name and alias differently, eg Template, // can implement their own cloning - (though really, not sure it's even needed) protected virtual void DeepCloneNameAndAlias(File clone) diff --git a/src/Umbraco.Core/Models/IFile.cs b/src/Umbraco.Core/Models/IFile.cs index 9b974276c1..109d65f554 100644 --- a/src/Umbraco.Core/Models/IFile.cs +++ b/src/Umbraco.Core/Models/IFile.cs @@ -43,8 +43,6 @@ namespace Umbraco.Core.Models /// Gets or sets the file's virtual path (i.e. the file path relative to the root of the website) /// string VirtualPath { get; set; } - - [Obsolete("This is no longer used and will be removed from the codebase in future versions")] - bool IsValid(); + } } diff --git a/src/Umbraco.Core/Persistence/Dtos/StylesheetDto.cs b/src/Umbraco.Core/Persistence/Dtos/StylesheetDto.cs deleted file mode 100644 index f340d34d16..0000000000 --- a/src/Umbraco.Core/Persistence/Dtos/StylesheetDto.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using NPoco; -using Umbraco.Core.Persistence.DatabaseAnnotations; - -namespace Umbraco.Core.Persistence.Dtos -{ - [Obsolete("This is no longer used and will be removed from Umbraco in future versions")] - internal class StylesheetDto - { - [Column("nodeId")] - [PrimaryKeyColumn(AutoIncrement = false)] - [ForeignKey(typeof(NodeDto))] - public int NodeId { get; set; } - - [Column("filename")] - [Length(100)] - public string Filename { get; set; } - - [Column("content")] - [SpecialDbType(SpecialDbTypes.NTEXT)] - [NullSetting(NullSetting = NullSettings.Null)] - public string Content { get; set; } - } -} diff --git a/src/Umbraco.Core/Persistence/Dtos/StylesheetPropertyDto.cs b/src/Umbraco.Core/Persistence/Dtos/StylesheetPropertyDto.cs deleted file mode 100644 index 5ef1aed9cc..0000000000 --- a/src/Umbraco.Core/Persistence/Dtos/StylesheetPropertyDto.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using NPoco; -using Umbraco.Core.Persistence.DatabaseAnnotations; - -namespace Umbraco.Core.Persistence.Dtos -{ - [Obsolete("This is no longer used and will be removed from Umbraco in future versions")] - internal class StylesheetPropertyDto - { - [Column("nodeId")] - [PrimaryKeyColumn(AutoIncrement = false)] - public int NodeId { get; set; } - - [Column("stylesheetPropertyEditor")] - [NullSetting(NullSetting = NullSettings.Null)] - public bool? Editor { get; set; } - - [Column("stylesheetPropertyAlias")] - [NullSetting(NullSetting = NullSettings.Null)] - [Length(50)] - public string Alias { get; set; } - - [Column("stylesheetPropertyValue")] - [NullSetting(NullSetting = NullSettings.Null)] - [Length(400)] - public string Value { get; set; } - } -} diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 411e4db1bf..18d51d6507 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -797,8 +797,6 @@ - - diff --git a/src/Umbraco.Tests/Persistence/SqlCeTableByTableTest.cs b/src/Umbraco.Tests/Persistence/SqlCeTableByTableTest.cs index 9d2c574743..f52bfdaa59 100644 --- a/src/Umbraco.Tests/Persistence/SqlCeTableByTableTest.cs +++ b/src/Umbraco.Tests/Persistence/SqlCeTableByTableTest.cs @@ -415,35 +415,7 @@ namespace Umbraco.Tests.Persistence scope.Complete(); } } - - [Test] - public void Can_Create_cmsStylesheet_Table() - { - using (var scope = ScopeProvider.CreateScope()) - { - var helper = new DatabaseSchemaCreator(scope.Database, Mock.Of()); - - helper.CreateTable(); - helper.CreateTable(); - - scope.Complete(); - } - } - - [Test] - public void Can_Create_cmsStylesheetProperty_Table() - { - using (var scope = ScopeProvider.CreateScope()) - { - var helper = new DatabaseSchemaCreator(scope.Database, Mock.Of()); - - helper.CreateTable(); - helper.CreateTable(); - - scope.Complete(); - } - } - + [Test] public void Can_Create_cmsTags_Table() { diff --git a/src/Umbraco.Web/Models/RegisterModel.cs b/src/Umbraco.Web/Models/RegisterModel.cs index 971cb8b916..2851db54a4 100644 --- a/src/Umbraco.Web/Models/RegisterModel.cs +++ b/src/Umbraco.Web/Models/RegisterModel.cs @@ -25,7 +25,6 @@ namespace Umbraco.Web.Models private RegisterModel(bool doLookup) { MemberTypeAlias = Constants.Conventions.MemberTypes.DefaultAlias; - RedirectOnSucces = false; UsernameIsEmail = true; MemberProperties = new List(); LoginOnSuccess = true; @@ -69,11 +68,7 @@ namespace Umbraco.Web.Models /// [Required] public string Password { get; set; } - - [ReadOnly(true)] - [Obsolete("This is no longer used and will be removed from the codebase in future versions")] - public bool RedirectOnSucces { get; set; } - + /// /// The username of the model, if UsernameIsEmail is true then this is ignored. /// diff --git a/src/Umbraco.Web/Mvc/SurfaceControllerFactory.cs b/src/Umbraco.Web/Mvc/SurfaceControllerFactory.cs deleted file mode 100644 index abccbf648b..0000000000 --- a/src/Umbraco.Web/Mvc/SurfaceControllerFactory.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System; -using System.Web.Mvc; -using System.Web.Routing; - -namespace Umbraco.Web.Mvc -{ - /// - /// Creates SurfaceControllers - /// - [Obsolete("This is not used in the codebase and will be removed from the core in future versions")] - public class SurfaceControllerFactory : RenderControllerFactory - { - /// - /// Check if the correct data tokens are in the route values so that we know its a surface controller route - /// - /// - /// - public override bool CanHandle(RequestContext request) - { - var area = request.RouteData.DataTokens["area"]; - - //if its a non-area route don't handle, all surface controllers will be in the 'umbraco' area - if (area == null || string.IsNullOrWhiteSpace(area.ToString())) - return false; - - //ensure there is an umbraco token set - var umbracoToken = request.RouteData.DataTokens[Core.Constants.Web.UmbracoDataToken]; - if (umbracoToken == null || string.IsNullOrWhiteSpace(umbracoToken.ToString())) - return false; - - return true; - } - - /// - /// Create the controller - /// - /// - /// - /// - public override IController CreateController(RequestContext requestContext, string controllerName) - { - //first try to instantiate with the DependencyResolver, if that fails, try with the UmbracoContext as a param, if that fails try with no params. - var controllerType = GetControllerType(requestContext, controllerName); - if (controllerType == null) - throw new InvalidOperationException("Could not find a controller type for the controller name " + controllerName); - - object controllerObject; - try - { - controllerObject = DependencyResolver.Current.GetService(controllerType); - } - catch (Exception) - { - try - { - controllerObject = Activator.CreateInstance(controllerType, UmbracoContext.Current); - } - catch (Exception) - { - //if this throws an exception, we'll let it - controllerObject = Activator.CreateInstance(controllerType); - } - } - //if an exception is thrown here, we want it to be thrown as its an invalid cast. - return (IController)controllerObject; - } - } -} diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index efb94856b9..8477662cae 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -471,7 +471,6 @@ - @@ -1058,7 +1057,6 @@ - @@ -1231,7 +1229,6 @@ Code - diff --git a/src/Umbraco.Web/_Legacy/Actions/ActionQuit.cs b/src/Umbraco.Web/_Legacy/Actions/ActionQuit.cs deleted file mode 100644 index 6e8fe64c4b..0000000000 --- a/src/Umbraco.Web/_Legacy/Actions/ActionQuit.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System; -using Umbraco.Web.UI.Pages; - -namespace Umbraco.Web._Legacy.Actions -{ - /// - /// This action is invoked when a user logs out - /// - [Obsolete("This should not be used and will be removed from the codebase in future versions")] - public class ActionQuit : IAction - { - //create singleton -#pragma warning disable 612,618 - private static readonly ActionQuit m_instance = new ActionQuit(); -#pragma warning restore 612,618 - - /// - /// A public constructor exists ONLY for backwards compatibility in regards to 3rd party add-ons. - /// All Umbraco assemblies should use the singleton instantiation (this.Instance) - /// When this applicatio is refactored, this constuctor should be made private. - /// - [Obsolete("Use the singleton instantiation instead of a constructor")] - public ActionQuit() { } - - public static ActionQuit Instance - { - get { return m_instance; } - } - - #region IAction Members - - public char Letter - { - get - { - return 'Q'; - } - } - - public string JsFunctionName - { - get - { - return string.Format("{0}.actionQuit()", ClientTools.Scripts.GetAppActions); - } - } - - public string JsSource - { - get - { - return null; - } - } - - public string Alias - { - get - { - return "logout"; - } - } - - public string Icon - { - get - { - return "signout"; - } - } - - public bool ShowInNotifier - { - get - { - return false; - } - } - public bool CanBePermissionAssigned - { - get - { - return false; - } - } - #endregion - } -} diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentControl.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentControl.cs deleted file mode 100644 index 2619747074..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentControl.cs +++ /dev/null @@ -1,699 +0,0 @@ -//TODO: This needs a full rewrite in angular! kept here for reference for now - -//using System; -//using System.Collections; -//using System.Collections.Generic; -//using System.ComponentModel; -//using System.Globalization; -//using System.Linq; -//using System.Web; -//using System.Web.UI; -//using System.Web.UI.WebControls; -//using Umbraco.Core; -//using Umbraco.Core.Configuration; -//using Umbraco.Core.IO; -//using Umbraco.Core.Models; -// -//using umbraco.cms.businesslogic.web; -//using umbraco.interfaces; -//using Umbraco.Web._Legacy.Controls; -//using Content = umbraco.cms.businesslogic.Content; -//using ContentType = umbraco.cms.businesslogic.ContentType; -//using Media = umbraco.cms.businesslogic.media.Media; -//using Property = umbraco.cms.businesslogic.property.Property; -//using StylesheetProperty = umbraco.cms.businesslogic.web.StylesheetProperty; - -//namespace umbraco.controls -//{ -// public class ContentControlLoadEventArgs : CancelEventArgs { } - -// /// -// /// Summary description for ContentControl. -// /// -// public class ContentControl : TabView -// { - - -// internal Dictionary DataTypes = new Dictionary(); -// private readonly Content _content; -// private UmbracoEnsuredPage _prntpage; -// public event EventHandler SaveAndPublish; -// public event EventHandler SaveToPublish; -// public event EventHandler Save; -// 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 readonly CustomValidator _nameTxtCustomValidator = new CustomValidator(); -// private static readonly string UmbracoPath = SystemDirectories.Umbraco; -// public Pane PropertiesPane = new Pane(); -// // zb-00036 #29889 : load it only once -// List _virtualTabs; -// //default to true! -// private bool _savePropertyDataWhenInvalid = true; -// private ContentType _contentType; - - -// public Content ContentObject -// { -// get { return _content; } -// } - -// /// -// /// This property controls whether the content property values are persisted even if validation -// /// fails. If set to false, then the values will not be persisted. -// /// -// /// -// /// This is required because when we are editing content we should be persisting invalid values to the database -// /// as this makes it easier for editors to come back and fix up their changes before they publish. Of course we -// /// don't publish if the page is invalid. In the case of media and members, we don't want to persist the values -// /// to the database when the page is invalid because there is no published state. -// /// Relates to: http://issues.umbraco.org/issue/U4-227 -// /// -// public bool SavePropertyDataWhenInvalid -// { -// get { return _savePropertyDataWhenInvalid; } -// set { _savePropertyDataWhenInvalid = value; } -// } - -// [Obsolete("This is no longer used and will be removed from the codebase in future versions")] -// private string _errorMessage = ""; - -// [Obsolete("This is no longer used and will be removed from the codebase in future versions")] -// public string ErrorMessage -// { -// set { _errorMessage = value; } -// } - -// [Obsolete("This is no longer used and will be removed from the codebase in future versions")] -// protected void standardSaveAndPublishHandler(object sender, EventArgs e) -// { -// } - - -// /// -// /// Constructor to set default properties. -// /// -// /// -// /// -// /// -// /// -// /// This method used to create all of the child controls too which is BAD since -// /// the page hasn't started initializing yet. Control IDs were not being named -// /// correctly, etc... I've moved the child control setup/creation to the CreateChildControls -// /// method where they are suposed to be. -// /// -// public ContentControl(Content c, publishModes CanPublish, string Id) -// { -// ID = Id; -// this._canPublish = CanPublish; -// _content = c; - -// Width = 350; -// Height = 350; - -// _prntpage = (UmbracoEnsuredPage)Page; - -// // zb-00036 #29889 : load it only once -// if (_virtualTabs == null) -// _virtualTabs = _content.ContentType.getVirtualTabs.ToList(); - -// foreach (ContentType.TabI t in _virtualTabs) -// { -// TabPage tp = NewTabPage(t.Caption); -// AddSaveAndPublishButtons(ref tp); -// } -// } - -// /// -// /// Create and setup all of the controls child controls. -// /// -// protected override void CreateChildControls() -// { -// base.CreateChildControls(); - - -// _prntpage = (UmbracoEnsuredPage)Page; -// int i = 0; -// Hashtable inTab = new Hashtable(); - -// // zb-00036 #29889 : load it only once -// if (_virtualTabs == null) -// _virtualTabs = _content.ContentType.getVirtualTabs.ToList(); - -// if(_contentType == null) -// _contentType = ContentType.GetContentType(_content.ContentType.Id); - -// foreach (ContentType.TabI tab in _virtualTabs) -// { -// var tabPage = this.Panels[i] as TabPage; -// if (tabPage == null) -// { -// throw new ArgumentException("Unable to load tab \"" + tab.Caption + "\""); -// } - -// tabPage.Style.Add("text-align", "center"); - -// //Legacy vs New API loading of PropertyTypes -// if (_contentType.ContentTypeItem != null) -// { -// LoadPropertyTypes(_contentType.ContentTypeItem, tabPage, inTab, tab.Id, tab.Caption); -// } -// else -// { -// LoadPropertyTypes(tab, tabPage, inTab); -// } - -// i++; -// } - -// // Add property pane -// tpProp = NewTabPage(Services.TextService.Localize("general/properties")); -// AddSaveAndPublishButtons(ref tpProp); -// tpProp.Controls.Add( -// new LiteralControl("
There were errors - data has not been saved!
")); - -// //if the property is not in a tab, add it to the general tab -// var props = _content.GenericProperties; -// foreach (Property p in props.OrderBy(x => x.PropertyType.SortOrder)) -// { -// if (inTab[p.PropertyType.Id.ToString()] == null) -// AddControlNew(p, tpProp, Services.TextService.Localize("general/properties")); -// } - -// } - -// /// -// /// Loades PropertyTypes by Tab/PropertyGroup using the new API. -// /// -// /// -// /// -// /// -// /// -// /// -// private void LoadPropertyTypes(IContentTypeComposition contentType, TabPage tabPage, Hashtable inTab, int tabId, string tabCaption) -// { -// var propertyGroups = contentType.CompositionPropertyGroups.Where(x => x.Id == tabId || x.ParentId == tabId); -// var propertyTypeAliases = propertyGroups.SelectMany(x => x.PropertyTypes.OrderBy(y => y.SortOrder).Select(y => new Tuple(y.Id, y.Alias, y.SortOrder))); -// foreach (var items in propertyTypeAliases) -// { -// var property = _content.getProperty(items.Item2); -// if (property != null) -// { -// AddControlNew(property, tabPage, tabCaption); - -// if (!inTab.ContainsKey(items.Item1.ToString(CultureInfo.InvariantCulture))) -// inTab.Add(items.Item1.ToString(CultureInfo.InvariantCulture), true); -// } -// else -// { -// throw new ArgumentNullException( -// string.Format( -// "Property {0} ({1}) on Content Type {2} could not be retrieved for Document {3} on Tab Page {4}. To fix this problem, delete the property and recreate it.", -// items.Item2, items.Item1, _content.ContentType.Alias, _content.Id, -// tabCaption)); -// } -// } -// } - -// /// -// /// Loades PropertyTypes by Tab using the Legacy API. -// /// -// /// -// /// -// /// -// private void LoadPropertyTypes(ContentType.TabI tab, TabPage tabPage, Hashtable inTab) -// { -// // Iterate through the property types and add them to the tab -// // zb-00036 #29889 : fix property types getter to get the right set of properties -// // ge : had a bit of a corrupt db and got weird NRE errors so rewrote this to catch the error and rethrow with detail -// var propertyTypes = tab.GetPropertyTypes(_content.ContentType.Id); -// foreach (var propertyType in propertyTypes.OrderBy(x => x.SortOrder)) -// { -// var property = _content.getProperty(propertyType); -// if (property != null && tabPage != null) -// { -// 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(CultureInfo.InvariantCulture))) -// inTab.Add(propertyType.Id.ToString(CultureInfo.InvariantCulture), true); -// } -// else -// { -// throw new ArgumentNullException( -// string.Format( -// "Property {0} ({1}) on Content Type {2} could not be retrieved for Document {3} on Tab Page {4}. To fix this problem, delete the property and recreate it.", -// propertyType.Alias, propertyType.Id, _content.ContentType.Alias, _content.Id, tab.Caption)); -// } -// } -// } - -// /// -// /// Initializes the control and ensures child controls are setup -// /// -// /// -// protected override void OnInit(EventArgs e) -// { -// base.OnInit(e); - -// EnsureChildControls(); - -// // Add extras for the property tabpage. . -// ContentControlLoadEventArgs contentcontrolEvent = new ContentControlLoadEventArgs(); -// FireBeforeContentControlLoad(contentcontrolEvent); - -// if (!contentcontrolEvent.Cancel) -// { - -// NameTxt.ID = "NameTxt"; -// if (!Page.IsPostBack) -// { -// NameTxt.Text = _content.Text; -// } - -// // Name validation -// NameTxtValidator.ControlToValidate = NameTxt.ID; -// _nameTxtCustomValidator.ControlToValidate = NameTxt.ID; -// string[] errorVars = { Services.TextService.Localize("name") }; -// NameTxtValidator.ErrorMessage = " " + ui.Text("errorHandling", "errorMandatoryWithoutTab", errorVars) + "
"; -// NameTxtValidator.EnableClientScript = false; -// NameTxtValidator.Display = ValidatorDisplay.Dynamic; -// _nameTxtCustomValidator.EnableClientScript = false; -// _nameTxtCustomValidator.Display = ValidatorDisplay.Dynamic; -// _nameTxtCustomValidator.ServerValidate += NameTxtCustomValidatorServerValidate; -// _nameTxtCustomValidator.ValidateEmptyText = false; - -// NameTxtHolder.Controls.Add(NameTxt); -// NameTxtHolder.Controls.Add(NameTxtValidator); -// NameTxtHolder.Controls.Add(_nameTxtCustomValidator); -// PropertiesPane.addProperty(Services.TextService.Localize("general/name"), NameTxtHolder); - -// Literal ltt = new Literal(); -// ltt.Text = _content.User.Name; -// PropertiesPane.addProperty(Services.TextService.Localize("content/createBy"), ltt); - -// ltt = new Literal(); -// ltt.Text = _content.CreateDateTime.ToString(); -// PropertiesPane.addProperty(Services.TextService.Localize("content/createDate"), ltt); - -// ltt = new Literal(); -// ltt.Text = _content.Id.ToString(); -// PropertiesPane.addProperty("Id", ltt); - -// if (_content is Media) -// { -// PropertiesPane.addProperty(Services.TextService.Localize("content/mediatype"), new LiteralControl(_content.ContentType.Alias)); -// } - -// tpProp.Controls.AddAt(0, PropertiesPane); -// tpProp.Style.Add("text-align", "center"); -// } -// } - -// /// -// /// Custom validates the content name field -// /// -// /// -// /// -// /// -// /// We need to ensure people are not entering XSS attacks on this field -// /// http://issues.umbraco.org/issue/U4-485 -// /// -// /// This doesn't actually 'validate' but changes the text field value and strips html -// /// -// void NameTxtCustomValidatorServerValidate(object source, ServerValidateEventArgs args) -// { -// NameTxt.Text = NameTxt.Text.StripHtml(); -// args.IsValid = true; -// } - -// protected override void OnLoad(EventArgs e) -// { -// base.OnLoad(e); - -// ContentControlLoadEventArgs contentcontrolEvent = new ContentControlLoadEventArgs(); -// FireAfterContentControlLoad(contentcontrolEvent); -// } - -// /// -// /// Sets the name (text) and values on the data types of the document -// /// -// private void SetNameAndDataTypeValues() -// { -// //we only continue saving anything if: -// // SavePropertyDataWhenInvalid == true -// // OR if the page is actually valid. -// if (SavePropertyDataWhenInvalid || Page.IsValid) -// { - -// foreach (var property in DataTypes) -// { -// var defaultData = property.Value.Data as DefaultData; -// if (defaultData != null) -// { -// defaultData.PropertyTypeAlias = property.Key; -// defaultData.NodeId = _content.Id; -// } -// property.Value.DataEditor.Save(); -// } - -// //don't update if the name is empty -// if (!NameTxt.Text.IsNullOrWhiteSpace()) -// { -// _content.Text = NameTxt.Text; -// } -// } -// } - -// private void SaveClick(object sender, ImageClickEventArgs e) -// { -// SetNameAndDataTypeValues(); - -// if (Save != null) -// { -// Save(this, new EventArgs()); -// } -// } - -// private void DoSaveAndPublish(object sender, ImageClickEventArgs e) -// { -// DoesPublish = true; - -// SetNameAndDataTypeValues(); - -// //NOTE: This is only here to keep backwards compatibility. -// // see: http://issues.umbraco.org/issue/U4-1660 -// Save(this, new EventArgs()); - -// if (SaveAndPublish != null) -// { -// SaveAndPublish(this, new EventArgs()); -// } -// } - -// private void DoSaveToPublish(object sender, ImageClickEventArgs e) -// { -// SaveClick(sender, e); -// if (SaveToPublish != null) -// { -// SaveToPublish(this, new EventArgs()); -// } -// } - -// private void AddSaveAndPublishButtons(ref TabPage tp) -// { -// MenuImageButton menuSave = tp.Menu.NewImageButton(); -// menuSave.ID = tp.ID + "_save"; -// menuSave.ImageUrl = UmbracoPath + "/images/editor/save.gif"; -// menuSave.Click += new ImageClickEventHandler(SaveClick); -// menuSave.OnClickCommand = "invokeSaveHandlers();"; -// menuSave.AltText = Services.TextService.Localize("buttons/save"); -// 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(DoSaveAndPublish); -// menuPublish.AltText = Services.TextService.Localize("buttons/saveAndPublish"); -// } -// 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(DoSaveToPublish); -// menuToPublish.AltText = Services.TextService.Localize("buttons/saveToPublish"); -// } -// } - - -// private void AddControlNew(Property p, TabPage tp, string cap) -// { -// IDataType dt = p.PropertyType.DataTypeDefinition.DataType; - -// //check that property editor has been set for the data type used by this property -// if (dt != null) -// { -// dt.DataEditor.Editor.ID = string.Format("prop_{0}", p.PropertyType.Alias); - -// dt.Data.PropertyId = p.Id; - -// //Add the DataType to an internal dictionary, which will be used to call the save method on the IDataEditor -// //and to retrieve the value from IData in editContent.aspx.cs, so that it can be set on the legacy Document class. -// DataTypes.Add(p.PropertyType.Alias, dt); - -// // check for buttons -// IDataFieldWithButtons df1 = dt.DataEditor.Editor as IDataFieldWithButtons; -// if (df1 != null) -// { -// ((Control)df1).ID = p.PropertyType.Alias; - - -// if (df1.MenuIcons.Length > 0) -// tp.Menu.InsertSplitter(); - - -// // Add buttons -// int c = 0; -// bool atEditHtml = false; -// bool atSplitter = false; -// foreach (object o in df1.MenuIcons) -// { -// try -// { -// MenuIconI m = (MenuIconI)o; -// MenuIconI mi = tp.Menu.NewIcon(); -// mi.ImageURL = m.ImageURL; -// mi.OnClickCommand = m.OnClickCommand; -// mi.AltText = m.AltText; -// mi.ID = tp.ID + "_" + m.ID; - -// if (m.ID == "html") -// atEditHtml = true; -// else -// atEditHtml = false; - -// atSplitter = false; -// } -// catch -// { -// tp.Menu.InsertSplitter(); -// atSplitter = true; -// } - -// // Testing custom styles in editor -// if (atSplitter && atEditHtml && dt.DataEditor.TreatAsRichTextEditor) -// { -// DropDownList ddl = tp.Menu.NewDropDownList(); - -// ddl.Style.Add("margin-bottom", "5px"); -// ddl.Items.Add(Services.TextService.Localize("buttons/styleChoose")); -// ddl.ID = tp.ID + "_editorStyle"; -// if (StyleSheet.GetAll().Length > 0) -// { -// foreach (StyleSheet s in StyleSheet.GetAll()) -// { -// foreach (StylesheetProperty sp in s.Properties) -// { -// ddl.Items.Add(new ListItem(sp.Text, sp.Alias)); -// } -// } -// } -// ddl.Attributes.Add("onChange", "addStyle(this, '" + p.PropertyType.Alias + "');"); -// atEditHtml = false; -// } -// c++; -// } -// } - -// // check for element additions -// IMenuElement menuElement = dt.DataEditor.Editor as IMenuElement; -// if (menuElement != null) -// { -// // add separator -// tp.Menu.InsertSplitter(); - -// // add the element -// tp.Menu.NewElement(menuElement.ElementName, menuElement.ElementIdPreFix + p.Id.ToString(), -// menuElement.ElementClass, menuElement.ExtraMenuWidth); -// } - -// Pane pp = new Pane(); -// Control holder = new Control(); -// holder.Controls.Add(dt.DataEditor.Editor); -// if (p.PropertyType.DataTypeDefinition.DataType.DataEditor.ShowLabel) -// { -// string caption = p.PropertyType.Name; -// if (p.PropertyType.Description != null && p.PropertyType.Description != String.Empty) -// switch (UmbracoConfig.For.UmbracoSettings().Content.PropertyContextHelpOption) -// { -// case "icon": -// caption += " \"""; -// break; -// case "text": -// caption += "
" + umbraco.library.ReplaceLineBreaks(p.PropertyType.Description) + ""; -// break; -// } -// pp.addProperty(caption, holder); -// } -// else -// pp.addProperty(holder); - -// // Validation -// if (p.PropertyType.Mandatory) -// { -// try -// { -// var rq = new RequiredFieldValidator -// { -// ControlToValidate = dt.DataEditor.Editor.ID, -// CssClass = "error" -// }; -// rq.Style.Add(HtmlTextWriterStyle.Display, "block"); -// rq.Style.Add(HtmlTextWriterStyle.Padding, "2px"); -// var component = dt.DataEditor.Editor; // holder.FindControl(rq.ControlToValidate); -// var attribute = (ValidationPropertyAttribute)TypeDescriptor.GetAttributes(component)[typeof(ValidationPropertyAttribute)]; -// PropertyDescriptor pd = null; -// if (attribute != null) -// { -// pd = TypeDescriptor.GetProperties(component, null)[attribute.Name]; -// } -// if (pd != null) -// { -// rq.EnableClientScript = false; -// rq.Display = ValidatorDisplay.Dynamic; -// string[] errorVars = { p.PropertyType.Name, cap }; -// rq.ErrorMessage = ui.Text("errorHandling", "errorMandatory", errorVars) + "
"; -// holder.Controls.AddAt(0, rq); -// } -// } -// catch (Exception valE) -// { -// HttpContext.Current.Trace.Warn("contentControl", -// "EditorControl (" + dt.DataTypeName + ") does not support validation", -// valE); -// } -// } - -// // RegExp Validation -// if (p.PropertyType.ValidationRegExp != "") -// { -// try -// { -// var rv = new RegularExpressionValidator -// { -// ControlToValidate = dt.DataEditor.Editor.ID, -// CssClass = "error" -// }; -// rv.Style.Add(HtmlTextWriterStyle.Display, "block"); -// rv.Style.Add(HtmlTextWriterStyle.Padding, "2px"); -// var component = dt.DataEditor.Editor; // holder.FindControl(rq.ControlToValidate); -// var attribute = (ValidationPropertyAttribute)TypeDescriptor.GetAttributes(component)[typeof(ValidationPropertyAttribute)]; -// PropertyDescriptor pd = null; -// if (attribute != null) -// { -// pd = TypeDescriptor.GetProperties(component, null)[attribute.Name]; -// } -// if (pd != null) -// { -// rv.ValidationExpression = p.PropertyType.ValidationRegExp; -// rv.EnableClientScript = false; -// rv.Display = ValidatorDisplay.Dynamic; -// string[] errorVars = { p.PropertyType.Name, cap }; -// rv.ErrorMessage = ui.Text("errorHandling", "errorRegExp", errorVars) + "
"; -// holder.Controls.AddAt(0, rv); -// } -// } -// catch (Exception valE) -// { -// HttpContext.Current.Trace.Warn("contentControl", -// "EditorControl (" + dt.DataTypeName + ") does not support validation", -// valE); -// } -// } - -// // This is once again a nasty nasty hack to fix gui when rendering wysiwygeditor -// if (dt.DataEditor.TreatAsRichTextEditor) -// { -// tp.Controls.Add(dt.DataEditor.Editor); -// } -// else -// { -// Panel ph = new Panel(); -// ph.Attributes.Add("style", "padding: 0; position: relative;"); // NH 4.7.1, latest styles added to support CP item: 30363 -// ph.Controls.Add(pp); - -// tp.Controls.Add(ph); -// } -// } -// else -// { - -// var ph = new Panel(); - -// var pp = new Pane(); - -// var missingPropertyEditorLabel = new Literal -// { -// Text = Services.TextService.Localize("errors/missingPropertyEditorErrorMessage") -// }; - -// pp.addProperty(p.PropertyType.Name, missingPropertyEditorLabel); - -// ph.Attributes.Add("style", "padding: 0; position: relative;"); - -// ph.Controls.Add(pp); - -// tp.Controls.Add(ph); -// } - - -// } - -// public enum publishModes -// { -// Publish, -// SendToPublish, -// NoPublish -// } - -// // EVENTS -// public delegate void BeforeContentControlLoadEventHandler(ContentControl contentControl, ContentControlLoadEventArgs e); -// public delegate void AfterContentControlLoadEventHandler(ContentControl contentControl, ContentControlLoadEventArgs e); - - -// /// -// /// Occurs when [before content control load]. -// /// -// public static event BeforeContentControlLoadEventHandler BeforeContentControlLoad; -// /// -// /// Fires the before content control load. -// /// -// /// The instance containing the event data. -// protected virtual void FireBeforeContentControlLoad(ContentControlLoadEventArgs e) -// { -// if (BeforeContentControlLoad != null) -// BeforeContentControlLoad(this, e); -// } - -// /// -// /// Occurs when [before content control load]. -// /// -// public static event AfterContentControlLoadEventHandler AfterContentControlLoad; -// /// -// /// Fires the before content control load. -// /// -// /// The instance containing the event data. -// protected virtual void FireAfterContentControlLoad(ContentControlLoadEventArgs e) -// { -// if (AfterContentControlLoad != null) -// AfterContentControlLoad(this, e); -// } -// } -//}