From 727fd3aa17e0750d37d53edb7aa52b36497a3300 Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 15 Dec 2015 15:12:22 +0100 Subject: [PATCH] U4-7537 File cleanup for old content type editor --- src/Umbraco.Core/Strings/Notes.txt | 40 - src/Umbraco.Core/Umbraco.Core.csproj | 3 - src/Umbraco.Web.UI/Umbraco.Web.UI.csproj | 22 - .../controls/ContentTypeControlNew.ascx | 240 --- .../controls/ContentTypeControlNew.ascx.cs | 59 - .../ContentTypeControlNew.ascx.designer.cs | 24 - .../GenericProperties/GenericProperty.ascx | 80 - .../umbraco/members/EditMemberType.aspx | 37 - .../umbraco/settings/EditMediaType.aspx | 15 - .../umbraco/settings/EditNodeTypeNew.aspx | 57 - .../umbraco/settings/EditNodeTypeNew.aspx.cs | 11 - .../settings/EditNodeTypeNew.aspx.designer.cs | 33 - .../umbraco_client/Editors/EditContentType.js | 108 - .../GenericProperty/genericProperty.js | 53 - .../GenericProperty/genericproperty.css | 107 - src/Umbraco.Web/Umbraco.Web.csproj | 30 - .../controls/ContentTypeControlNew.ascx.cs | 1879 ----------------- .../GenericProperties/GenericProperty.ascx.cs | 456 ---- .../GenericPropertyWrapper.cs | 131 -- .../umbraco/members/EditMemberType.aspx | 35 - .../umbraco/members/EditMemberType.aspx.cs | 142 -- .../members/EditMemberType.aspx.designer.cs | 34 - .../umbraco/settings/EditMediaType.aspx | 15 - .../umbraco/settings/EditMediaType.aspx.cs | 52 - .../settings/EditMediaType.aspx.designer.cs | 24 - .../umbraco/settings/EditNodeTypeNew.aspx.cs | 167 -- 26 files changed, 3854 deletions(-) delete mode 100644 src/Umbraco.Core/Strings/Notes.txt delete mode 100644 src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx delete mode 100644 src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx.cs delete mode 100644 src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx.designer.cs delete mode 100644 src/Umbraco.Web.UI/umbraco/controls/GenericProperties/GenericProperty.ascx delete mode 100644 src/Umbraco.Web.UI/umbraco/members/EditMemberType.aspx delete mode 100644 src/Umbraco.Web.UI/umbraco/settings/EditMediaType.aspx delete mode 100644 src/Umbraco.Web.UI/umbraco/settings/EditNodeTypeNew.aspx delete mode 100644 src/Umbraco.Web.UI/umbraco/settings/EditNodeTypeNew.aspx.cs delete mode 100644 src/Umbraco.Web.UI/umbraco/settings/EditNodeTypeNew.aspx.designer.cs delete mode 100644 src/Umbraco.Web.UI/umbraco_client/Editors/EditContentType.js delete mode 100644 src/Umbraco.Web.UI/umbraco_client/GenericProperty/genericProperty.js delete mode 100644 src/Umbraco.Web.UI/umbraco_client/GenericProperty/genericproperty.css delete mode 100644 src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs delete mode 100644 src/Umbraco.Web/umbraco.presentation/umbraco/controls/GenericProperties/GenericProperty.ascx.cs delete mode 100644 src/Umbraco.Web/umbraco.presentation/umbraco/controls/GenericProperties/GenericPropertyWrapper.cs delete mode 100644 src/Umbraco.Web/umbraco.presentation/umbraco/members/EditMemberType.aspx delete mode 100644 src/Umbraco.Web/umbraco.presentation/umbraco/members/EditMemberType.aspx.cs delete mode 100644 src/Umbraco.Web/umbraco.presentation/umbraco/members/EditMemberType.aspx.designer.cs delete mode 100644 src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditMediaType.aspx delete mode 100644 src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditMediaType.aspx.cs delete mode 100644 src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditMediaType.aspx.designer.cs delete mode 100644 src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditNodeTypeNew.aspx.cs diff --git a/src/Umbraco.Core/Strings/Notes.txt b/src/Umbraco.Core/Strings/Notes.txt deleted file mode 100644 index b1f82636cd..0000000000 --- a/src/Umbraco.Core/Strings/Notes.txt +++ /dev/null @@ -1,40 +0,0 @@ -Two constants are defined in StringExtensions: -UmbracoValidAliasCharacters -UmbracoInvalidFirstCharacters - -They were used exclusively by umbraco/js/UmbracoCasingRules.aspx.cs to define some JavaScript variables -which in turn were used by genericProperty.js to provide validation for aliases. - -UmbracoCasingRules.aspx and genericProperty.js are used in: - Umbraco.Web\umbraco.presentation\umbraco\controls\ContentTypeControlNew.ascx - Umbraco.Web\umbraco.presentation\umbraco\controls\GenericProperties\GenericProperty.ascx - -genericProperty.js defined the following functions: - safeAlias(alias) : provides a safe alias version of alias - isValidAlias(alias) : whether an alias is safe - checkAlias(id) : plugs a safe alias validator / corrector on an element - duplicatePropertyNameAsSafeAlias(propertyId, aliasId) : creates the alias from the prop. name - -These are used to validate the alias of the content type, and of properties. No other alias in -Umbraco back-end seem to be validated in UI at that point. And, there seem to be no server-side -validation so the server just seems trust the UI. - -Whereas in theory, we should only accept that the casing required by the user is different -from what our "toSafeAlias" method would provide, anything else is a validation error. - -Legacy safe aliases accept leading and trailing dashes and underscores. - -REFACTOR - -Abstract string methods into IShortStringHelper, and create a new DefaultShortStringHelper which -re-implements methods in a clean nice way. The new aliases do not accepts dashes, nor leading -underscores. - -Entirely refactor StringExtensions to rely on IShortStringHelper (via a resolver). - -The constants in StringExtensions should go, but we keep them for backward compatility. -The legacy helper is 100% backward compatible even at JavaScript level, but the new helper -is NOT, it does server-side validation of aliases, all sorts of things, using an api service. - -UmbracoCasingRules.aspx.cs is _gone_ in all cases, replaced by the JavaScript served by -the api service. diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 997f57b0ca..fb00485640 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -1402,9 +1402,6 @@ umbraco.interfaces - - - ResXFileCodeGenerator diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index c000bf51d1..03f50a4e65 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -363,13 +363,6 @@ True Settings.settings - - ContentTypeControlNew.ascx - ASPXCodeBehind - - - ContentTypeControlNew.ascx - ImageViewer.ascx ASPXCodeBehind @@ -530,13 +523,6 @@ QuickSearch.ascx - - EditNodeTypeNew.aspx - ASPXCodeBehind - - - EditNodeTypeNew.aspx - ASPXCodeBehind @@ -596,7 +582,6 @@ - umbraco.aspx @@ -1652,8 +1637,6 @@ - - @@ -2022,7 +2005,6 @@ UserControl - @@ -2231,7 +2213,6 @@ - @@ -2243,12 +2224,9 @@ Form - - - diff --git a/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx b/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx deleted file mode 100644 index 21230a343d..0000000000 --- a/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx +++ /dev/null @@ -1,240 +0,0 @@ -<%@ Control Language="c#" AutoEventWireup="True" Codebehind="ContentTypeControlNew.ascx.cs" - Inherits="Umbraco.Web.UI.Umbraco.Controls.ContentTypeControlNew" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %> -<%@ Import Namespace="umbraco" %> -<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %> -<%@ Register TagPrefix="cc2" Namespace="umbraco.uicontrols" Assembly="controls" %> -<%@ Register TagPrefix="cdf" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %> - - - - - - - - - - -

<%=ui.GetText("settings", "contentTypeEnabled")%>
<%=umbraco.ui.GetText("settings", "contentTypeUses")%> <%=umbraco.ui.GetText("settings", "asAContentMasterType")%>

-
- - - -   - - - - - - - - - - - - - - - - - -

-

-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - - <%if (cb_isContainer.Checked) { %> - -
- -
-
-
-
- - -
- - -  (<%=ui.Text("general", "default", Security.CurrentUser) %>) - -
- - <%=ui.Text("general", "edit", Security.CurrentUser) %> - -
- -
- - -
- -
-
-
- -
-
- - <%--Scripting to for configuring a list view--%> - - - <%} %> - -
- -
- - - - - - - - - - - - - - -
- - - - -

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

-
- - -
- - -
-
-
-<%-- cannot put a <%= block here 'cos it prevents the Controls collection from being modified = use a literal --%> - \ No newline at end of file diff --git a/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx.cs b/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx.cs deleted file mode 100644 index fef17e6e2e..0000000000 --- a/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Web; -using System.Web.UI.WebControls; -using AutoMapper; -using Umbraco.Core; -using Umbraco.Core.Models; -using Umbraco.Web.Editors; -using Umbraco.Web.Models.ContentEditing; - -namespace Umbraco.Web.UI.Umbraco.Controls -{ - public partial class ContentTypeControlNew : global::umbraco.controls.ContentTypeControlNew - { - protected string DataTypeControllerUrl { get; private set; } - protected string ContentTypeControllerUrl { get; private set; } - - /// - /// Raises the event. - /// - /// The object that contains the event data. - protected override void OnLoad(EventArgs e) - { - base.OnLoad(e); - - DataTypeControllerUrl = Url.GetUmbracoApiServiceBaseUrl(x => x.GetById(0)); - ContentTypeControllerUrl = Url.GetUmbracoApiServiceBaseUrl(x => x.GetAssignedListViewDataType(0)); - } - - protected void dgTabs_PreRender(object sender, EventArgs e) - { - dgTabs.UseAccessibleHeader = true; //to make sure we render th, not td - - Table table = dgTabs.Controls[0] as Table; - if (table != null && table.Rows.Count > 0) - { - // here we render and - if (dgTabs.ShowHeader) - table.Rows[0].TableSection = TableRowSection.TableHeader; - if (dgTabs.ShowFooter) - table.Rows[table.Rows.Count - 1].TableSection = TableRowSection.TableFooter; - } - } - - protected void dgTabs_ItemDataBound(object sender, DataGridItemEventArgs e) - { - Table table = dgTabs.Controls[0] as Table; - if (table != null && table.Rows.Count > 0) - { - if (dgTabs.ShowHeader) - table.Rows[0].TableSection = TableRowSection.TableHeader; - if (dgTabs.ShowFooter) - table.Rows[table.Rows.Count - 1].TableSection = TableRowSection.TableFooter; - } - } - } -} \ No newline at end of file diff --git a/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx.designer.cs b/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx.designer.cs deleted file mode 100644 index 2ad0b89587..0000000000 --- a/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx.designer.cs +++ /dev/null @@ -1,24 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Umbraco.Web.UI.Umbraco.Controls { - - - public partial class ContentTypeControlNew { - - /// - /// JsInclude control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::ClientDependency.Core.Controls.JsInclude JsInclude; - } -} diff --git a/src/Umbraco.Web.UI/umbraco/controls/GenericProperties/GenericProperty.ascx b/src/Umbraco.Web.UI/umbraco/controls/GenericProperties/GenericProperty.ascx deleted file mode 100644 index 9ec9bbaca7..0000000000 --- a/src/Umbraco.Web.UI/umbraco/controls/GenericProperties/GenericProperty.ascx +++ /dev/null @@ -1,80 +0,0 @@ -<%@ Control Language="c#" AutoEventWireup="True" Inherits="umbraco.controls.GenericProperties.GenericProperty" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %> -<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %> - -
  • -
    -
    -
    - - - - - - - - - - - - -
    -
    - - -
    -
  • - \ No newline at end of file diff --git a/src/Umbraco.Web.UI/umbraco/members/EditMemberType.aspx b/src/Umbraco.Web.UI/umbraco/members/EditMemberType.aspx deleted file mode 100644 index 80b8313be3..0000000000 --- a/src/Umbraco.Web.UI/umbraco/members/EditMemberType.aspx +++ /dev/null @@ -1,37 +0,0 @@ -<%@ Page Async="true" language="c#" MasterPageFile="../masterpages/umbracoPage.Master" AutoEventWireup="True" Inherits="umbraco.cms.presentation.members.EditMemberType" %> -<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %> -<%@ Register TagPrefix="uc1" TagName="ContentTypeControlNew" Src="../controls/ContentTypeControlNew.ascx" %> -<%@ Register Namespace="umbraco" TagPrefix="umb" Assembly="umbraco" %> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Umbraco.Web.UI/umbraco/settings/EditMediaType.aspx b/src/Umbraco.Web.UI/umbraco/settings/EditMediaType.aspx deleted file mode 100644 index ab35ae3a63..0000000000 --- a/src/Umbraco.Web.UI/umbraco/settings/EditMediaType.aspx +++ /dev/null @@ -1,15 +0,0 @@ -<%@ Register TagPrefix="cc2" Namespace="umbraco.uicontrols" Assembly="controls" %> - -<%@ Page Language="c#" CodeBehind="EditMediaType.aspx.cs" MasterPageFile="../masterpages/umbracoPage.Master" - Async="true" AsyncTimeOut="300" - AutoEventWireup="True" Inherits="umbraco.cms.presentation.settings.EditMediaType" %> - -<%@ Register TagPrefix="uc1" TagName="ContentTypeControlNew" Src="../controls/ContentTypeControlNew.ascx" %> - - - - diff --git a/src/Umbraco.Web.UI/umbraco/settings/EditNodeTypeNew.aspx b/src/Umbraco.Web.UI/umbraco/settings/EditNodeTypeNew.aspx deleted file mode 100644 index b2ed9df718..0000000000 --- a/src/Umbraco.Web.UI/umbraco/settings/EditNodeTypeNew.aspx +++ /dev/null @@ -1,57 +0,0 @@ -<%@ Page Language="c#" CodeBehind="EditNodeTypeNew.aspx.cs" AutoEventWireup="True" ValidateRequest="false" - Async="true" AsyncTimeOut="300" Trace="false" Inherits="Umbraco.Web.UI.Umbraco.Settings.EditNodeTypeNew" MasterPageFile="../masterpages/umbracoPage.Master" %> - -<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %> -<%@ Register TagPrefix="uc1" TagName="ContentTypeControlNew" Src="../controls/ContentTypeControlNew.ascx" %> - - - - - - - - - - -
    - -
    -
    - - - -
    -
    diff --git a/src/Umbraco.Web.UI/umbraco/settings/EditNodeTypeNew.aspx.cs b/src/Umbraco.Web.UI/umbraco/settings/EditNodeTypeNew.aspx.cs deleted file mode 100644 index f5705d25de..0000000000 --- a/src/Umbraco.Web.UI/umbraco/settings/EditNodeTypeNew.aspx.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; - -namespace Umbraco.Web.UI.Umbraco.Settings -{ - public partial class EditNodeTypeNew : global::umbraco.settings.EditContentTypeNew - { - } -} \ No newline at end of file diff --git a/src/Umbraco.Web.UI/umbraco/settings/EditNodeTypeNew.aspx.designer.cs b/src/Umbraco.Web.UI/umbraco/settings/EditNodeTypeNew.aspx.designer.cs deleted file mode 100644 index e322b494bd..0000000000 --- a/src/Umbraco.Web.UI/umbraco/settings/EditNodeTypeNew.aspx.designer.cs +++ /dev/null @@ -1,33 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Umbraco.Web.UI.Umbraco.Settings { - - - public partial class EditNodeTypeNew { - - /// - /// allowedTemplates control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel allowedTemplates; - - /// - /// defaultTemplate control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel defaultTemplate; - } -} diff --git a/src/Umbraco.Web.UI/umbraco_client/Editors/EditContentType.js b/src/Umbraco.Web.UI/umbraco_client/Editors/EditContentType.js deleted file mode 100644 index 18f47196b8..0000000000 --- a/src/Umbraco.Web.UI/umbraco_client/Editors/EditContentType.js +++ /dev/null @@ -1,108 +0,0 @@ -Umbraco.Sys.registerNamespace("Umbraco.Editors"); - -(function ($) { - - var _model = {}; - var _opts = null; - - //updates the UI elements - function updateElements() { - _opts.configPanel.find("strong").html(_model.listViewName); - if (_model.isSystem) { - _opts.createListViewButton.show(); - _opts.removeListViewButton.hide(); - _opts.configPanel.find("em").show(); - } - else { - _opts.createListViewButton.hide(); - _opts.removeListViewButton.show(); - _opts.configPanel.find("em").hide(); - } - } - - function populateData() { - //get init data - - $.get(_opts.contentTypeServiceBaseUrl + "GetAssignedListViewDataType?contentTypeId=" + _opts.contentTypeId, function (result) { - _model.isSystem = result.isSystem; - _model.listViewName = result.name; - _model.listViewId = result.id; - updateElements(); - }); - } - - $.ajaxSetup({ - beforeSend: function (xhr) { - xhr.setRequestHeader("X-XSRF-TOKEN", $.cookie("XSRF-TOKEN")); - }, - contentType: 'application/json;charset=utf-8', - dataType: "json", - dataFilter: function (data, dataType) { - if ((typeof data) === "string") { - //trim the csrf bits off - data = data.replace(/^\)\]\}\'\,\n/, ""); - } - return data; - } - }); - - Umbraco.Editors.EditContentType = base2.Base.extend({ - - // Constructor - constructor: function(opts) { - // Merge options with default - _opts = $.extend({ - // Default options go here - }, opts); - }, - - init: function () { - //wire up handlers - - _opts.configPanel.find("a").click(function() { - UmbClientMgr.contentFrame('#/developer/datatype/edit/' + _model.listViewId); - }); - - _opts.isContainerChk.on("change", function () { - if ($(this).is(":checked")) { - _opts.configPanel.slideDown(); - } - else { - _opts.configPanel.slideUp(); - } - }); - - _opts.createListViewButton.click(function (event) { - event.preventDefault(); - - var data = { - parentId: -1, - id: 0, - preValues: [], - action: "SaveNew", - name: "List View - " + _opts.contentTypeAlias, - selectedEditor: "Umbraco.ListView" - }; - - $.post(_opts.dataTypeServiceBaseUrl + "PostSave", JSON.stringify(data), function (result) { - _model.isSystem = result.isSystem; - _model.listViewName = result.name; - _model.listViewId = result.id; - updateElements(); - }); - }); - - _opts.removeListViewButton.click(function (event) { - event.preventDefault(); - - $.post(_opts.dataTypeServiceBaseUrl + "DeleteById?id=" + _model.listViewId, function (result) { - //re-get the data - populateData(); - }); - }); - - populateData(); - - } - }); -})(jQuery); \ No newline at end of file diff --git a/src/Umbraco.Web.UI/umbraco_client/GenericProperty/genericProperty.js b/src/Umbraco.Web.UI/umbraco_client/GenericProperty/genericProperty.js deleted file mode 100644 index 4ca59e82de..0000000000 --- a/src/Umbraco.Web.UI/umbraco_client/GenericProperty/genericProperty.js +++ /dev/null @@ -1,53 +0,0 @@ -var activeDragId = ""; -function expandCollapse(theId) { - - var edit = document.getElementById("edit" + theId); - - if (edit.style.display == 'none') { - edit.style.display = 'block'; - document.getElementById("desc" + theId).style.display = 'none'; - } - else { - edit.style.display = 'none'; - document.getElementById("desc" + theId).style.display = 'block'; - } -} -function duplicatePropertyNameAsSafeAlias(propertySelector) { - $(propertySelector).each(function() { - var prop = $(this); - var inputName = prop.find('.prop-name'); - var inputAlias = prop.find('.prop-alias'); - inputName.on('input blur', function (event) { - getSafeAlias(inputAlias, inputName.val(), false, function (alias) { - if (!inputAlias.data('dirty')) - inputAlias.val(alias); - }); - }); - inputAlias.on('input', function(event) { - inputName.off('input blur'); - }); - }); -} - -function checkAlias(aliasSelector) { - $(aliasSelector).on('input', function (event) { - var input = $(this); - input.data('dirty', true); - var value = input.val(); - validateSafeAlias(input, value, false, function (isSafe) { - input.toggleClass('highlight-error', !isSafe); - }); - }).on('blur', function(event) { - var input = $(this); - if (!input.data('dirty')) return; - input.removeData('dirty'); - var value = input.val(); - getSafeAlias(input, value, true, function (alias) { - if (value.toLowerCase() != alias.toLowerCase()) - input.val(alias); - input.removeClass('highlight-error'); - }); - }); -} - -// validateSafeAlias and getSafeAlias are defined by UmbracoCasingRules.aspx diff --git a/src/Umbraco.Web.UI/umbraco_client/GenericProperty/genericproperty.css b/src/Umbraco.Web.UI/umbraco_client/GenericProperty/genericproperty.css deleted file mode 100644 index 5183a9bccd..0000000000 --- a/src/Umbraco.Web.UI/umbraco_client/GenericProperty/genericproperty.css +++ /dev/null @@ -1,107 +0,0 @@ - -.genericPropertyForm { - -} -.genericPropertyForm h2 { - font-size: 16px; - line-height: 20px; - margin-bottom: 2px; -} - -.genericPropertyList .header{ - padding: 4px; -} -.genericPropertyList .umb-pane{ - margin: 10px; -} - -.genericPropertyList { - margin: 0px 0px 30px 0px; - list-style: none; -} - -.genericPropertyList .delete-button, .genericPropertyList .toggle-button{ - float: right; - margin-left: 3px; - border: none; - background: none; - text-decoration: none; -} - -.genericPropertyList .delete-button i { - background: none; - border: none; -} - -.handle{ - color: #ccc; - font-size: 12px; -} - -.addNewProperty .handle { - display: none; -} - -.genericPropertyList li { - display: block; - position: relative; - border-bottom: 1px solid #eee; - margin-bottom: 3px; - cursor: move; -} - -.genericPropertyList li .delete-button i { - color: #b94a48; -} - -.addNewProperty li { - cursor: default; -} - -.genericPropertyList li table { - display: block; - margin-top: 10px; -} - -.genericPropertyList li table th { - width: 140px; - padding: 5px; -} - -.propertyFormInput { - width: 300px; - z-index: 9999; -} - -.propertyForm SELECT { - width: 300px; -} - -.propertyForm h3 a { - color: #000; - text-decoration: none; - font-size: 14px; - font-weight: normal; -} - - - -.genericPropertyList li img { - background: red; - z-index: 9999; - position: relative; - border-right: medium none; - border-top: medium none; - border-left: medium none; - margin-right: 5px; - border-bottom: medium none; -} -.genericPropertyList li h3 input { - position: relative; -} - -.aliasValidationError -{ - background-color: #ff9999; - border: 1px solid: red; -} \ No newline at end of file diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 0ef5b3b115..9e340bd47f 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -617,9 +617,6 @@ - - ASPXCodeBehind - ASPXCodeBehind @@ -847,9 +844,6 @@ ASPXCodeBehind - - ASPXCodeBehind - ASPXCodeBehind @@ -1083,9 +1077,6 @@ ASPXCodeBehind - - ASPXCodeBehind - ASPXCodeBehind @@ -1263,7 +1254,6 @@ UploadMediaImage.ascx - @@ -1600,13 +1590,6 @@ EditMemberGroup.aspx - - EditMemberType.aspx - ASPXCodeBehind - - - EditMemberType.aspx - search.aspx ASPXCodeBehind @@ -1697,13 +1680,6 @@ editLanguage.aspx - - EditMediaType.aspx - ASPXCodeBehind - - - EditMediaType.aspx - editScript.aspx ASPXCodeBehind @@ -2118,9 +2094,6 @@ Form - - ASPXCodeBehind - Designer @@ -2128,9 +2101,6 @@ ASPXCodeBehind
    - - 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 deleted file mode 100644 index 24694ad706..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs +++ /dev/null @@ -1,1879 +0,0 @@ -using System; -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; -using System.Threading.Tasks; -using System.Web; -using System.Web.Routing; -using System.Web.UI; -using System.Web.UI.HtmlControls; -using System.Web.UI.WebControls; -using ClientDependency.Core; -using Umbraco.Core; -using Umbraco.Core.Configuration; -using Umbraco.Core.Exceptions; -using Umbraco.Core.Logging; -using Umbraco.Core.Models; -using Umbraco.Core.Strings; -using Umbraco.Web.UI.Controls; -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.Core.IO; -using umbraco.presentation; -using umbraco.BasePages; -using Constants = Umbraco.Core.Constants; -using ContentType = umbraco.cms.businesslogic.ContentType; -using PropertyType = Umbraco.Core.Models.PropertyType; - -namespace umbraco.controls -{ - - [ClientDependency(ClientDependencyType.Javascript, "ui/jqueryui.js", "UmbracoClient")] - [ClientDependency(ClientDependencyType.Javascript, "ui/jquery.dd.js", "UmbracoClient")] - [ClientDependency(ClientDependencyType.Css, "ui/dd.css", "UmbracoClient")] - [ClientDependency(ClientDependencyType.Css, "GenericProperty/genericproperty.css", "UmbracoClient")] - [ClientDependency(ClientDependencyType.Javascript, "GenericProperty/genericproperty.js", "UmbracoClient")] - public partial class ContentTypeControlNew : UmbracoUserControl - { - // General Private members - private ContentType _contentType; - private static string UmbracoPath = SystemDirectories.Umbraco; - public bool HideStructure { get; set; } - public Func DocumentTypeCallback { get; set; } - - protected string ContentTypeAlias - { - get { return _contentType.Alias; } - } - protected int ContentTypeId - { - get { return _contentType.Id; } - } - - // "Tab" tab - protected uicontrols.Pane Pane8; - - // "Structure" tab - protected DualSelectbox DualAllowedContentTypes = new DualSelectbox(); - - // "Structure" tab - Compositions - protected DualSelectbox DualContentTypeCompositions = new DualSelectbox(); - - // "Info" tab - public uicontrols.TabPage InfoTabPage; - - // "Generic properties" tab - public uicontrols.TabPage GenericPropertiesTabPage; - - public GenericPropertyWrapper gp; - private DataTable _dataTypeTable; - private ArrayList _genericProperties = new ArrayList(); - private ArrayList _sortLists = new ArrayList(); - - //the async saving task - private Action _asyncSaveTask; - //the async delete property task - private Action _asyncDeleteTask; - - internal event SavingContentTypeEventHandler SavingContentType; - internal delegate void SavingContentTypeEventHandler(ContentType e); - - override protected void OnInit(EventArgs e) - { - base.OnInit(e); - - LoadContentType(); - - SetupInfoPane(); - - if (HideStructure) - { - pnlStructure.Visible = false; - } - else - { - SetupStructurePane(); - SetupCompositionsPane(); - } - - SetupGenericPropertiesPane(); - SetupTabPane(); - - // [ClientDependency(ClientDependencyType.Javascript, "js/UmbracoCasingRules.aspx", "UmbracoRoot")] - var loader = ClientDependency.Core.Controls.ClientDependencyLoader.GetInstance(new HttpContextWrapper(Context)); - var helper = new UrlHelper(new RequestContext(new HttpContextWrapper(Context), new RouteData())); - loader.RegisterDependency(helper.GetCoreStringsControllerPath() + "ServicesJavaScript", ClientDependencyType.Javascript); - } - - protected void Page_Load(object sender, EventArgs e) - { - pp_newTab.Text = ui.Text("newtab", Security.CurrentUser); - pp_alias.Text = ui.Text("alias", Security.CurrentUser); - pp_name.Text = ui.Text("name", Security.CurrentUser); - pp_allowedChildren.Text = ui.Text("allowedchildnodetypes", Security.CurrentUser); - pp_compositions.Text = ui.Text("contenttypecompositions", Security.CurrentUser); - pp_description.Text = ui.Text("editcontenttype", "description", Security.CurrentUser); - pp_icon.Text = ui.Text("icon", Security.CurrentUser); - pp_Root.Text = ui.Text("editcontenttype", "allowAtRoot", Security.CurrentUser) + "
    " + ui.Text("editcontenttype", "allowAtRootDesc", Security.CurrentUser) + ""; - pp_isContainer.Text = ui.Text("editcontenttype", "hasListView", Security.CurrentUser) + "
    " + ui.Text("editcontenttype", "hasListViewDesc", Security.CurrentUser) + ""; - - // we'll disable this... - if (!Page.IsPostBack && _contentType.MasterContentType != 0) - { - string masterName = ContentType.GetContentType(_contentType.MasterContentType).Text; - tabsMasterContentTypeName.Text = masterName; - propertiesMasterContentTypeName.Text = masterName; - PaneTabsInherited.Visible = true; - PanePropertiesInherited.Visible = true; - } - - if (string.IsNullOrEmpty(_contentType.IconUrl)) - lt_icon.Text = "icon-document"; - else - lt_icon.Text = _contentType.IconUrl.TrimStart('.'); - - checkTxtAliasJs.Text = string.Format("checkAlias('#{0}');", txtAlias.ClientID); - - } - - /// - /// A class to track the async state for deleting a doc type property - /// - private class DeleteAsyncState - { - public Umbraco.Web.UmbracoContext UmbracoContext { get; private set; } - public GenericPropertyWrapper GenericPropertyWrapper { get; private set; } - - public DeleteAsyncState( - Umbraco.Web.UmbracoContext umbracoContext, - GenericPropertyWrapper genericPropertyWrapper) - { - UmbracoContext = umbracoContext; - GenericPropertyWrapper = genericPropertyWrapper; - } - } - - /// - /// A class to track the async state for saving the doc type - /// - private class SaveAsyncState - { - public SaveAsyncState( - Umbraco.Web.UmbracoContext umbracoContext, - SaveClickEventArgs saveArgs, - string originalAlias, - string originalName, - string newAlias, - string newName, - string[] originalPropertyAliases) - { - UmbracoContext = umbracoContext; - SaveArgs = saveArgs; - _originalAlias = originalAlias; - _originalName = originalName; - _newAlias = newAlias; - _originalPropertyAliases = originalPropertyAliases; - _newName = newName; - } - - public Umbraco.Web.UmbracoContext UmbracoContext { get; private set; } - public SaveClickEventArgs SaveArgs { get; private set; } - private readonly string _originalAlias; - private readonly string _originalName; - private readonly string _newAlias; - private readonly string _newName; - private readonly string[] _originalPropertyAliases; - - - public bool HasAliasChanged() - { - return (string.Compare(_originalAlias, _newAlias, StringComparison.OrdinalIgnoreCase) != 0); - } - public bool HasNameChanged() - { - return (string.Compare(_originalName, _newName, StringComparison.OrdinalIgnoreCase) != 0); - } - - /// - /// Returns true if any property has been removed or if any alias has changed - /// - /// - /// - public bool HasAnyPropertyAliasChanged(ContentType contentType) - { - var newAliases = contentType.PropertyTypes.Select(x => x.Alias).ToArray(); - //if any have been removed, return true - if (newAliases.Length < _originalPropertyAliases.Count()) - { - return true; - } - //otherwise ensure that all of the original aliases are still existing - return newAliases.ContainsAll(_originalPropertyAliases) == false; - } - } - - /// - /// Called asynchronously in order to persist all of the data to the database - /// - /// - /// - /// - /// - /// - /// - /// This can be a long running operation depending on how many content nodes exist and if the node type alias - /// has changed as this will need to regenerate XML for all of the nodes. - /// - private IAsyncResult BeginAsyncSaveOperation(object sender, EventArgs e, AsyncCallback cb, object state) - { - Trace.Write("ContentTypeControlNew", "Start async operation"); - - //get the args from the async state - var args = (SaveAsyncState)state; - - //start the task - var result = _asyncSaveTask.BeginInvoke(args, cb, args); - return result; - } - - /// - /// Occurs once the async database save operation has completed - /// - /// - /// - /// This updates the UI elements - /// - private void EndAsyncSaveOperation(IAsyncResult ar) - { - Trace.Write("ContentTypeControlNew", "ending async operation"); - - //get the args from the async state - var state = (SaveAsyncState)ar.AsyncState; - - // reload content type (due to caching) - LoadContentType(); - BindTabs(); - BindDataGenericProperties(true); - - // we need to re-bind the alias as the SafeAlias method can have changed it - txtAlias.Text = _contentType.Alias; - - //Notify the parent control - RaiseBubbleEvent(new object(), state.SaveArgs); - - if (state.HasNameChanged()) - UpdateTreeNode(); - - Trace.Write("ContentTypeControlNew", "async operation ended"); - - //complete it - _asyncSaveTask.EndInvoke(ar); - } - - /// - /// The save button click event handlers - /// - /// - /// - protected void save_click(object sender, EventArgs e) - { - - //sync state betweet lt and hidden value - lt_icon.Text = tb_icon.Value; - - var state = new SaveAsyncState( - UmbracoContext, - new SaveClickEventArgs("Saved") - { - IconType = BasePage.speechBubbleIcon.success - }, _contentType.Alias, _contentType.Text, txtAlias.Text, txtName.Text, _contentType.PropertyTypes.Select(x => x.Alias).ToArray()); - - var isMediaType = Request.Path.ToLowerInvariant().Contains("editmediatype.aspx"); - - //Add the async operation to the page - //NOTE: Must pass in a null and do not pass in a true to the 'executeInParallel', this is changed in .net 4.5 for the better, otherwise you'll get a ysod. - Page.RegisterAsyncTask(new PageAsyncTask(BeginAsyncSaveOperation, EndAsyncSaveOperation, null, state)); - - //create the save task to be executed async - _asyncSaveTask = asyncState => - { - Trace.Write("ContentTypeControlNew", "executing task"); - - //we need to re-set the UmbracoContext since it will be nulled and our cache handlers need it - global::Umbraco.Web.UmbracoContext.Current = asyncState.UmbracoContext; - - _contentType.ContentTypeItem.Name = txtName.Text; - _contentType.ContentTypeItem.Alias = txtAlias.Text; // raw, contentType.Alias takes care of it - _contentType.ContentTypeItem.Icon = tb_icon.Value; - _contentType.ContentTypeItem.Description = description.Text; - //_contentType.ContentTypeItem.Thumbnail = ddlThumbnails.SelectedValue; - _contentType.ContentTypeItem.AllowedAsRoot = allowAtRoot.Checked; - _contentType.ContentTypeItem.IsContainer = cb_isContainer.Checked; - - int i = 0; - var ids = SaveAllowedChildTypes(); - _contentType.ContentTypeItem.AllowedContentTypes = ids.Select(x => new ContentTypeSort(x, i++)); - - // figure out whether compositions are locked - var allContentTypes = Request.Path.ToLowerInvariant().Contains("editmediatype.aspx") - ? ApplicationContext.Services.ContentTypeService.GetAllMediaTypes().Cast().ToArray() - : ApplicationContext.Services.ContentTypeService.GetAllContentTypes().Cast().ToArray(); - var isUsing = allContentTypes.Where(x => x.ContentTypeComposition.Any(y => y.Id == _contentType.Id)).ToArray(); - - // if compositions are locked, do nothing (leave them as they are) - // else process the checkbox list and add/remove compositions accordingly - - if (isUsing.Length == 0) - { - //Saving ContentType Compositions - var compositionIds = SaveCompositionContentTypes(); - var existingCompsitionIds = _contentType.ContentTypeItem.CompositionIds().ToList(); - if (compositionIds.Any()) - { - // if some compositions were checked in the list, iterate over them - foreach (var compositionId in compositionIds) - { - // ignore if it is the current content type - if (_contentType.Id.Equals(compositionId)) continue; - - // ignore if it is already a composition of the content type - if (existingCompsitionIds.Any(x => x.Equals(compositionId))) continue; - - // add to the content type compositions - var compositionType = isMediaType - ? Services.ContentTypeService.GetMediaType(compositionId).SafeCast() - : Services.ContentTypeService.GetContentType(compositionId).SafeCast(); - try - { - //TODO if added=false then return error message - var added = _contentType.ContentTypeItem.AddContentType(compositionType); - } - catch (InvalidCompositionException ex) - { - state.SaveArgs.IconType = BasePage.speechBubbleIcon.error; - state.SaveArgs.Message = ex.Message; - } - } - - // then iterate over removed = existing except checked - var removeIds = existingCompsitionIds.Except(compositionIds); - foreach (var removeId in removeIds) - { - // and remove from the content type composition - var compositionType = isMediaType - ? Services.ContentTypeService.GetMediaType(removeId).SafeCast() - : Services.ContentTypeService.GetContentType(removeId).SafeCast(); - var removed = _contentType.ContentTypeItem.RemoveContentType(compositionType.Alias); - } - } - else if (existingCompsitionIds.Any()) - { - // else none were checked - if the content type had compositions, - // iterate over them all and remove them - var removeIds = existingCompsitionIds.Except(compositionIds); // except here makes no sense? - foreach (var removeId in removeIds) - { - // remove existing - var compositionType = isMediaType - ? Services.ContentTypeService.GetMediaType(removeId).SafeCast() - : Services.ContentTypeService.GetContentType(removeId).SafeCast(); - var removed = _contentType.ContentTypeItem.RemoveContentType(compositionType.Alias); - } - } - } - - var tabs = SaveTabs(); // returns { TabId, TabName, TabSortOrder } - foreach (var tab in tabs) - { - var group = _contentType.ContentTypeItem.PropertyGroups.FirstOrDefault(x => x.Id == tab.Item1); - if (group == null) - { - // creating a group - group = new PropertyGroup {Id = tab.Item1, Name = tab.Item2, SortOrder = tab.Item3}; - _contentType.ContentTypeItem.PropertyGroups.Add(group); - } - else - { - // updating an existing group - group.Name = tab.Item2; - group.SortOrder = tab.Item3; - } - } - - SavePropertyType(asyncState.SaveArgs, _contentType.ContentTypeItem); - //SavePropertyType(state.SaveArgs, _contentType.ContentTypeItem); - UpdatePropertyTypes(_contentType.ContentTypeItem); - - if (DocumentTypeCallback != null) - { - var documentType = _contentType as DocumentType; - if (documentType != null) - { - var result = DocumentTypeCallback(documentType); - } - } - - if (SavingContentType != null) - { - SavingContentType(_contentType); - } - - try - { - _contentType.Save(); - } - catch (DuplicateNameException ex) - { - DuplicateAliasValidator.IsValid = false; - //asyncState.SaveArgs.IconType = BasePage.speechBubbleIcon.error; - state.SaveArgs.IconType = BasePage.speechBubbleIcon.error; - //asyncState.SaveArgs.Message = ex.Message; - state.SaveArgs.Message = ex.Message; - return; - } - catch (Exception ex) - { - state.SaveArgs.IconType = BasePage.speechBubbleIcon.error; - state.SaveArgs.Message = ex.Message; - } - - Trace.Write("ContentTypeControlNew", "task completing"); - }; - - //execute the async tasks - Page.ExecuteRegisteredAsyncTasks(); - } - - /// - /// Loads the current ContentType from the id found in the querystring. - /// The correct type is loaded based on editing location (DocumentType, MediaType or MemberType). - /// - private void LoadContentType() - { - int docTypeId = int.Parse(Request.QueryString["id"]); - LoadContentType(docTypeId); - } - - private void LoadContentType(int docTypeId) - { - //Fairly hacky code to load the ContentType as the real type instead of its base type, so it can be properly saved. - if (Request.Path.ToLowerInvariant().Contains("editnodetypenew.aspx")) - { - _contentType = new DocumentType(docTypeId); - } - else if (Request.Path.ToLowerInvariant().Contains("editmediatype.aspx")) - { - _contentType = new cms.businesslogic.media.MediaType(docTypeId); - } - else if (Request.Path.ToLowerInvariant().Contains("editmembertype.aspx")) - { - _contentType = new cms.businesslogic.member.MemberType(docTypeId); - } - else - { - _contentType = new ContentType(docTypeId); - } - } - - /// - /// Updates the Node in the Tree - /// - private void UpdateTreeNode() - { - var clientTools = new ClientTools(this.Page); - clientTools - .SyncTree(_contentType.Path, true); - } - - #region "Info" Pane - - private void SetupInfoPane() - { - InfoTabPage = TabView1.NewTabPage("Info"); - InfoTabPage.Controls.Add(pnlInfo); - - var Save = TabView1.Menu.NewButton(); - Save.Click += save_click; - Save.Text = ui.Text("save", Security.CurrentUser); - Save.ID = "save"; - Save.ButtonType = uicontrols.MenuButtonType.Primary; - - txtName.Text = _contentType.GetRawText(); - txtAlias.Text = _contentType.Alias; - description.Text = _contentType.GetRawDescription(); - tb_icon.Value = _contentType.IconUrl; - - if(string.IsNullOrEmpty(_contentType.IconUrl)) - lt_icon.Text = "icon-document"; - 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 AddListItem(ICollection listOfIcons, ListItem li) - { - if (this.Page.IsPostBack == false && li.Value == _contentType.IconUrl) - li.Selected = true; - - listOfIcons.Add(li); - } - - #endregion - - #region "Structure" Pane - - private void SetupStructurePane() - { - DualAllowedContentTypes.ID = "allowedContentTypes"; - DualAllowedContentTypes.Width = 175; - - uicontrols.TabPage tp = TabView1.NewTabPage("Structure"); - tp.Controls.Add(pnlStructure); - - int[] allowedIds = _contentType.AllowedChildContentTypeIDs; - if (!Page.IsPostBack) - { - string chosenContentTypeIDs = ""; - ContentType[] contentTypes = _contentType.GetAll(); - foreach (ContentType ct in contentTypes.OrderBy(x => x.Text)) - { - ListItem li = new ListItem(ct.Text, ct.Id.ToString()); - DualAllowedContentTypes.Items.Add(li); - lstAllowedContentTypes.Items.Add(li); - foreach (int i in allowedIds) - { - if (i == ct.Id) - { - li.Selected = true; - chosenContentTypeIDs += ct.Id + ","; - } - } - } - DualAllowedContentTypes.Value = chosenContentTypeIDs; - } - - allowAtRoot.Checked = _contentType.AllowAtRoot; - cb_isContainer.Checked = _contentType.IsContainerContentType; - } - - private int[] SaveAllowedChildTypes() - { - var tmp = new ArrayList(); - foreach (ListItem li in lstAllowedContentTypes.Items) - { - if (li.Selected) - tmp.Add(int.Parse(li.Value)); - } - var ids = new int[tmp.Count]; - for (int i = 0; i < tmp.Count; i++) ids[i] = (int)tmp[i]; - - return ids; - } - - #endregion - - #region Compositions Pane - - // returns content type compositions, recursively - // return each content type once and only once - private IEnumerable GetIndirect(IContentTypeComposition ctype) - { - // hashset guarantees unicity on Id - var all = new HashSet(new DelegateEqualityComparer( - (x, y) => x.Id == y.Id, - x => x.Id)); - - var stack = new Stack(); - - foreach (var x in ctype.ContentTypeComposition) - stack.Push(x); - - while (stack.Count > 0) - { - var x = stack.Pop(); - all.Add(x); - foreach (var y in x.ContentTypeComposition) - stack.Push(y); - } - - return all; - } - - private void SetupCompositionsPane() - { - DualContentTypeCompositions.ID = "compositionContentTypes"; - DualContentTypeCompositions.Width = 175; - - // fix for 7.2 - only top-level content types can be used as mixins - - if (Page.IsPostBack == false) - { - var allContentTypes = Request.Path.ToLowerInvariant().Contains("editmediatype.aspx") - ? ApplicationContext.Services.ContentTypeService.GetAllMediaTypes().Cast().ToArray() - : ApplicationContext.Services.ContentTypeService.GetAllContentTypes().Cast().ToArray(); - - // note: there are many sanity checks missing here and there ;-(( - // make sure once and for all - //if (allContentTypes.Any(x => x.ParentId > 0 && x.ContentTypeComposition.Any(y => y.Id == x.ParentId) == false)) - // throw new Exception("A parent does not belong to a composition."); - - // find out if any content type uses this content type - var isUsing = allContentTypes.Where(x => x.ContentTypeComposition.Any(y => y.Id == _contentType.Id)).ToArray(); - if (isUsing.Length > 0) - { - // if it is used then it has to remain top-level - - // no composition is possible at all - DualContentTypeCompositions.Items.Clear(); - lstContentTypeCompositions.Items.Clear(); - DualContentTypeCompositions.Value = ""; - - PlaceHolderContentTypeCompositions.Controls.Add(new Literal { Text = "This content type is used as a parent and/or in " - + "a composition, and therefore cannot be composed itself.

    Used by: " - + string.Join(", ", isUsing.Select(x => x.Name)) - + "
    " }); - } - else - { - // if it is not used then composition is possible - - // hashset guarantees unicity on Id - var list = new HashSet(new DelegateEqualityComparer( - (x, y) => x.Id == y.Id, - x => x.Id)); - - // usable types are those that are top-level - var usableContentTypes = allContentTypes - .Where(x => x.ContentTypeComposition.Any() == false).ToArray(); - foreach (var x in usableContentTypes) - list.Add(x); - - // indirect types are those that we use, directly or indirectly - var indirectContentTypes = GetIndirect(_contentType.ContentTypeItem).ToArray(); - foreach (var x in indirectContentTypes) - list.Add(x); - - // directContentTypes are those we use directly - // they are already in indirectContentTypes, no need to add to the list - var directContentTypes = _contentType.ContentTypeItem.ContentTypeComposition.ToArray(); - - var enabled = usableContentTypes.Select(x => x.Id) // those we can use - .Except(indirectContentTypes.Select(x => x.Id)) // except those that are indirectly used - .Union(directContentTypes.Select(x => x.Id)) // but those that are directly used - .Where(x => x != _contentType.ParentId) // but not the parent - .Distinct() - .ToArray(); - - var wtf = new List(); - foreach (var contentType in list.OrderBy(x => x.Name).Where(x => x.Id != _contentType.Id)) - { - var li = new ListItem(contentType.Name, contentType.Id.ToInvariantString()) - { - // disable parent and anything that's not usable - Enabled = enabled.Contains(contentType.Id), - // select - Selected = indirectContentTypes.Any(x => x.Id == contentType.Id) - }; - - DualContentTypeCompositions.Items.Add(li); - lstContentTypeCompositions.Items.Add(li); - - if (li.Selected) - wtf.Add(contentType.Id); - } - DualContentTypeCompositions.Value = string.Join(",", wtf); - } - } - - //int[] compositionIds = _contentType.ContentTypeItem.CompositionIds().ToArray(); - //if (!Page.IsPostBack) - //{ - // string chosenContentTypeIDs = ""; - // ContentType[] contentTypes = _contentType.GetAll(); - // foreach (ContentType ct in contentTypes.OrderBy(x => x.Text)) - // { - // ListItem li = new ListItem(ct.Text, ct.Id.ToString()); - // if (ct.Id == _contentType.Id) - // li.Enabled = false; - - // DualContentTypeCompositions.Items.Add(li); - // lstContentTypeCompositions.Items.Add(li); - - // foreach (int i in compositionIds) - // { - // if (i == ct.Id) - // { - // li.Selected = true; - // chosenContentTypeIDs += ct.Id + ","; - // } - // } - // } - // DualContentTypeCompositions.Value = chosenContentTypeIDs; - //} - } - - private int[] SaveCompositionContentTypes() - { - return lstContentTypeCompositions.Items.Cast() - .Where(x => x.Selected) - .Select(x => int.Parse(x.Value)) - .ToArray(); - } - - #endregion - - #region "Generic properties" Pane - - private void SetupGenericPropertiesPane() - { - GenericPropertiesTabPage = TabView1.NewTabPage("Generic properties"); - GenericPropertiesTabPage.Controls.Add(pnlProperties); - BindDataGenericProperties(false); - } - - private void BindDataGenericProperties(bool refresh) - { - var tabs = _contentType.getVirtualTabs; - var propertyTypeGroups = _contentType.PropertyTypeGroups.ToList(); - var dtds = cms.businesslogic.datatype.DataTypeDefinition.GetAll().OrderBy(d => d.Text).ToArray(); - - PropertyTypes.Controls.Clear(); - - // Add new property - if (PropertyTypeNew.Controls.Count == 0) - { - PropertyTypeNew.Controls.Add(new LiteralControl("

    Add New Property

      ")); - gp = new GenericPropertyWrapper(); - gp.ID = "GenericPropertyNew"; - gp.Tabs = tabs; - gp.DataTypeDefinitions = dtds; - PropertyTypeNew.Controls.Add(gp); - PropertyTypeNew.Controls.Add(new LiteralControl("
    ")); - } - else if (refresh) - { - gp = (GenericPropertyWrapper)PropertyTypeNew.Controls[1]; - gp.ID = "GenericPropertyNew"; - gp.Tabs = tabs; - gp.DataTypeDefinitions = dtds; - gp.UpdateEditControl(); - gp.GenricPropertyControl.UpdateInterface(); - gp.GenricPropertyControl.Clear(); - } - - _genericProperties.Clear(); - var inTab = new Hashtable(); - int counter = 0; - - PropertyTypes.Controls.Add(new LiteralControl("
    ")); // opens draggable container for properties on tabs - - foreach (var tab in tabs) - { - string tabName = tab.GetRawCaption(); - string tabCaption = tabName; - if (tab.ContentType != _contentType.Id) - { - tabCaption += " (inherited from " + new ContentType(tab.ContentType).Text + ")"; - } - - PropertyTypes.Controls.Add(new LiteralControl("

    Tab: " + tabCaption + "

    ")); - - // fixme - cannot use ParentId anymore - and I have no idea what we are trying to do here ;-( - //var propertyGroup = propertyTypeGroups.SingleOrDefault(x => x.ParentId == tab.Id); - //var propertyTypes = (propertyGroup == null - // ? tab.GetPropertyTypes(_contentType.Id, false) - // : propertyGroup.GetPropertyTypes()).ToArray(); - var propertyTypes = tab.GetPropertyTypes(_contentType.Id, false).ToArray(); - - var propertyGroupId = tab.Id; - - var propSort = new HtmlInputHidden(); - propSort.ID = "propSort_" + propertyGroupId + "_Content"; - PropertyTypes.Controls.Add(propSort); - _sortLists.Add(propSort); - - if (propertyTypes.Any(x => x.ContentTypeId == _contentType.Id)) - { - PropertyTypes.Controls.Add(new LiteralControl("
      ")); - - foreach (var pt in propertyTypes) - { - //If the PropertyType doesn't belong on this ContentType skip it and continue to the next one - if (pt.ContentTypeId != _contentType.Id) continue; - - cms.businesslogic.datatype.DataTypeDefinition[] filteredDtds; - var gpw = GetPropertyWrapperForPropertyType(pt, dtds, out filteredDtds); - gpw.ID = "gpw_" + pt.Id; - gpw.PropertyType = pt; - gpw.Tabs = tabs; - gpw.TabId = propertyGroupId; - gpw.DataTypeDefinitions = filteredDtds; - gpw.Delete += gpw_Delete; - gpw.FullId = "t_" + propertyGroupId + "_Contents_" + +pt.Id; - - PropertyTypes.Controls.Add(gpw); - _genericProperties.Add(gpw); - if (refresh) - gpw.GenricPropertyControl.UpdateInterface(); - - inTab.Add(pt.Id.ToString(CultureInfo.InvariantCulture), ""); - counter++; - } - - PropertyTypes.Controls.Add(new LiteralControl("
    ")); - } - else - { - AddNoPropertiesDefinedMessage(); - } - - var jsSortable = GetJavaScriptForPropertySorting(propSort.ClientID); - Page.ClientScript.RegisterStartupScript(this.GetType(), propSort.ClientID, jsSortable, true); - - PropertyTypes.Controls.Add(new LiteralControl("
    ")); - } - - // Generic properties tab - counter = 0; - bool propertyTabHasProperties = false; - var propertiesPh = new PlaceHolder(); - propertiesPh.ID = "propertiesPH"; - PropertyTypes.Controls.Add(new LiteralControl("

    Tab: Generic Properties

    ")); - PropertyTypes.Controls.Add(propertiesPh); - - var propSortGp = new HtmlInputHidden(); - propSortGp.ID = "propSort_general_Content"; - PropertyTypes.Controls.Add(propSortGp); - _sortLists.Add(propSortGp); - - propertiesPh.Controls.Add(new LiteralControl("
      ")); - foreach (var pt in _contentType.PropertyTypes) - { - //This use to be: - if (pt.ContentTypeId == _contentType.Id && inTab.ContainsKey(pt.Id.ToString(CultureInfo.InvariantCulture)) == false) - //But seriously, if it's not on a tab the tabId is 0, it's a lot easier to read IMO - //if (pt.ContentTypeId == _contentType.Id && pt.TabId == 0) - { - cms.businesslogic.datatype.DataTypeDefinition[] filteredDtds; - var gpw = GetPropertyWrapperForPropertyType(pt, dtds, out filteredDtds); - - // Changed by duckie, was: - // gpw.ID = "gpw_" + editPropertyType.Alias; - // Which is NOT unique! - gpw.ID = "gpw_" + pt.Id; - - gpw.PropertyType = pt; - gpw.Tabs = tabs; - gpw.DataTypeDefinitions = filteredDtds; - gpw.Delete += new EventHandler(gpw_Delete); - gpw.FullId = "t_general_Contents_" + pt.Id; - - propertiesPh.Controls.Add(gpw); - _genericProperties.Add(gpw); - if (refresh) - gpw.GenricPropertyControl.UpdateInterface(); - inTab.Add(pt.Id, ""); - propertyTabHasProperties = true; - counter++; - } - } - - propertiesPh.Controls.Add(new LiteralControl("
    ")); - - var jsSortable_gp = GetJavaScriptForPropertySorting(propSortGp.ClientID); - - Page.ClientScript.RegisterStartupScript(this.GetType(), "propSort_gp", jsSortable_gp, true); - - - if (!propertyTabHasProperties) - { - AddNoPropertiesDefinedMessage(); - PropertyTypes.Controls.Remove(PropertyTypes.FindControl("propertiesPH")); - } - else - { - PropertyTypes.Controls.Add(propertiesPh); - } - - PropertyTypes.Controls.Add(new LiteralControl("
    ")); // closes draggable container for properties on tabs - - } - - /// - /// Returns a generic property wrapper for a given property - this determines if the property type should be - /// allowed to be editable. - /// - /// - private GenericPropertyWrapper GetPropertyWrapperForPropertyType( - cms.businesslogic.propertytype.PropertyType pt, - cms.businesslogic.datatype.DataTypeDefinition[] allDtds, - out cms.businesslogic.datatype.DataTypeDefinition[] filteredDefinitions) - { - filteredDefinitions = allDtds; - - //not editable if any of the built in member types - if (_contentType.ContentTypeItem is IMemberType) - { - var builtInAliases = global::Umbraco.Core.Constants.Conventions.Member.GetStandardPropertyTypeStubs().Select(x => x.Key).ToArray(); - var gpw = new GenericPropertyWrapper(builtInAliases.Contains(pt.Alias) == false); - return gpw; - } - - //not editable if prefixed with the special internal prefix - if (pt.Alias.StartsWith(Constants.PropertyEditors.InternalGenericPropertiesPrefix)) - { - var gpw = new GenericPropertyWrapper(false); - return gpw; - } - - //the rest are editable - return new GenericPropertyWrapper(); - } - - private string GetJavaScriptForPropertySorting(string propSortClientId) - { - return @"(function($) { - var propSortId = ""#" + propSortClientId + @"""; - $(document).ready(function() { - $(propSortId).next("".genericPropertyList"").sortable({ - containment: '#tabs-container', - connectWith: '.genericPropertyList', - cancel: 'li.no-properties-on-tab, .propertyForm div[id^=""editbody""]', - tolerance: 'pointer', - start: function() { - $('#tabs-container').addClass('doc-type-property-drop-zone'); - }, - stop: function() { - $('#tabs-container').removeClass('doc-type-property-drop-zone'); - }, - update: function(event, ui) { - - // Save new sort details for tab - $(propSortId).val($(this).sortable('serialize')); - - // Handle move to new tab - // - find tab name - var tabName = $(this).siblings('h2').attr('data-tabname'); - - // - find tab drop-down for item and set option selected that matches tab name - var tabDropDownList = $(""select[name$='ddlTab']"", ui.item); - $('option', tabDropDownList).each(function() { - if ($(this).text() == tabName) { - $(this).attr('selected', 'selected'); - } - }); - - // Remove any no properties messages for tabs that now have a property - $('li.no-properties-on-tab', $(this)).remove(); - - // Add a no properties message for tabs that now have no properties - $('#tabs-container ul.genericPropertyList:not(:has(li))').append('" + GetHtmlForNoPropertiesMessageListItem() + @"'); - - }}); - }); - })(jQuery);"; - } - - private void AddNoPropertiesDefinedMessage() - { - // Create no properties message as a ul in order to allow dragging of properties to it from other tabs - PropertyTypes.Controls.Add(new LiteralControl("
      " + GetHtmlForNoPropertiesMessageListItem() + "
    ")); - } - - private string GetHtmlForNoPropertiesMessageListItem() - { - return @"
  • " + ui.Text("settings", "noPropertiesDefinedOnTab", Security.CurrentUser) + "
  • "; - } - - private void SavePropertyType(SaveClickEventArgs e, IContentTypeComposition contentTypeItem) - { - this.CreateChildControls(); - - //The GenericPropertyWrapper control, which contains the details for the PropertyType being added - GenericProperty gpData = gp.GenricPropertyControl; - if (string.IsNullOrEmpty(gpData.Name.Trim()) == false && string.IsNullOrEmpty(gpData.Alias.Trim()) == false) - { - // when creating a property don't do anything special, propertyType.Alias will take care of it - // don't enforce camel here because the user might have changed what the CoreStringsController returned - var propertyTypeAlias = gpData.Alias; - if (contentTypeItem.PropertyTypeExists(propertyTypeAlias) == false) - { - //Find the DataTypeDefinition that the PropertyType should be based on - var dataTypeDefinition = ApplicationContext.Current.Services.DataTypeService.GetDataTypeDefinitionById(gpData.Type); - var propertyType = new PropertyType(dataTypeDefinition) - { - Alias = propertyTypeAlias, - Name = gpData.Name.Trim(), - Mandatory = gpData.Mandatory, - ValidationRegExp = gpData.Validation, - Description = gpData.Description, - Key = Guid.NewGuid() - }; - //gpData.Tab == 0 Generic Properties / No Group - if (gpData.Tab == 0) - { - contentTypeItem.AddPropertyType(propertyType); - } - else - { - //Find the PropertyGroup by its Id and then set the PropertyType on that group - var existing = contentTypeItem.CompositionPropertyGroups.FirstOrDefault(x => x.Id == gpData.Tab); - if (existing != null) - { - contentTypeItem.AddPropertyType(propertyType, existing.Name); - } - else - { - // if the tab we picked is gone, re-create it - var tab = gpData.Tabs.FirstOrDefault(x => x.Id == gpData.Tab); - if (tab != null) - { - var caption = tab.GetRawCaption(); - contentTypeItem.AddPropertyType(propertyType, caption); - } - } - } - gpData.Clear(); - } - else - { - e.Message = ui.Text("contentTypeDublicatePropertyType", Security.CurrentUser); - e.IconType = BasePage.speechBubbleIcon.warning; - } - } - } - - private void UpdatePropertyTypes(IContentTypeComposition contentTypeItem) - { - //Loop through the _genericProperties ArrayList and update all existing PropertyTypes - foreach (GenericPropertyWrapper gpw in _genericProperties) - { - if (gpw.PropertyType == null) continue; - if (contentTypeItem.PropertyTypes == null || contentTypeItem.PropertyTypes.Any(x => x.Alias == gpw.PropertyType.Alias) == false) continue; - var propertyType = contentTypeItem.PropertyTypes.First(x => x.Alias == gpw.PropertyType.Alias); - if (propertyType == null) continue; - var dataTypeDefinition = ApplicationContext.Current.Services.DataTypeService.GetDataTypeDefinitionById(gpw.GenricPropertyControl.Type); - // when saving, respect user's casing, so do nothing here as propertyType takes care of it - propertyType.Alias = gpw.GenricPropertyControl.Alias; - propertyType.Name = gpw.GenricPropertyControl.Name; - propertyType.Description = gpw.GenricPropertyControl.Description; - propertyType.ValidationRegExp = gpw.GenricPropertyControl.Validation; - propertyType.Mandatory = gpw.GenricPropertyControl.Mandatory; - propertyType.DataTypeDatabaseType = dataTypeDefinition.DatabaseType; - propertyType.DataTypeDefinitionId = dataTypeDefinition.Id; - propertyType.PropertyEditorAlias = dataTypeDefinition.PropertyEditorAlias; - - if (propertyType.PropertyGroupId == null - || propertyType.PropertyGroupId.Value != gpw.GenricPropertyControl.Tab) - { - if (gpw.GenricPropertyControl.Tab == 0) - { - // moving to generic properties - propertyType.PropertyGroupId = new Lazy(() => 0); - } - else if (contentTypeItem.PropertyGroups.Any(x => x.Id == gpw.GenricPropertyControl.Tab)) - { - // moving to a tab that is local to the content type - propertyType.PropertyGroupId = new Lazy(() => gpw.GenricPropertyControl.Tab); - } - else - { - // moving to a tab that is not local, ie an inherited tab - // get the tab from the composition tabs, just so we have its name, - // and add the property with that tab name, and this will create the local tab - var propertyGroup = contentTypeItem.CompositionPropertyGroups.First(x => x.Id == gpw.GenricPropertyControl.Tab); - contentTypeItem.AddPropertyGroup(propertyGroup.Name); - contentTypeItem.MovePropertyType(propertyType.Alias, propertyGroup.Name); - } - } - } - - //Update the SortOrder of the PropertyTypes - foreach (HtmlInputHidden propSorter in _sortLists) - { - if (propSorter.Value.Trim() != "") - { - string[] newSortOrders = propSorter.Value.Split("&".ToCharArray()); - for (int i = 0; i < newSortOrders.Length; i++) - { - var propertyTypeId = int.Parse(newSortOrders[i].Split("=".ToCharArray())[1]); - if (contentTypeItem.PropertyTypes != null && - contentTypeItem.PropertyTypes.Any(x => x.Id == propertyTypeId)) - { - var propertyType = contentTypeItem.PropertyTypes.First(x => x.Id == propertyTypeId); - propertyType.SortOrder = i; - } - } - } - } - } - - 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 - /// - /// - /// - /// - /// - /// - private IAsyncResult BeginAsyncDeleteOperation(object sender, EventArgs e, AsyncCallback cb, object state) - { - Trace.Write("ContentTypeControlNew", "Start async operation"); - - //get the args from the async state - var args = (DeleteAsyncState)state; - - //start the task - var result = _asyncDeleteTask.BeginInvoke(args, cb, args); - return result; - } - - /// - /// Occurs once the async database delete operation has completed - /// - /// - /// - /// This updates the UI elements - /// - private void EndAsyncDeleteOperation(IAsyncResult ar) - { - Trace.Write("ContentTypeControlNew", "ending async operation"); - - // reload content type (due to caching) - LoadContentType(_contentType.Id); - BindDataGenericProperties(true); - - Trace.Write("ContentTypeControlNew", "async operation ended"); - - //complete it - _asyncDeleteTask.EndInvoke(ar); - } - - /// - /// Removes a PropertyType from the current ContentType when user clicks "red x" - /// - /// - /// - protected void gpw_Delete(object sender, EventArgs e) - { - var state = new DeleteAsyncState( - UmbracoContext, - (GenericPropertyWrapper)sender); - - //Add the async operation to the page - //NOTE: Must pass in a null and do not pass in a true to the 'executeInParallel', this is changed in .net 4.5 for the better, otherwise you'll get a ysod. - Page.RegisterAsyncTask(new PageAsyncTask(BeginAsyncDeleteOperation, EndAsyncDeleteOperation, null, state)); - - //create the save task to be executed async - _asyncDeleteTask = asyncState => - { - Trace.Write("ContentTypeControlNew", "executing task"); - - //we need to re-set the UmbracoContext since it will be nulled and our cache handlers need it - global::Umbraco.Web.UmbracoContext.Current = asyncState.UmbracoContext; - - //if (_contentType.ContentTypeItem is IContentType - // || _contentType.ContentTypeItem is IMediaType - // || _contentType.ContentTypeItem is IMemberType) - //{ - _contentType.ContentTypeItem.RemovePropertyType(asyncState.GenericPropertyWrapper.PropertyType.Alias); - _contentType.Save(); - //} - //else - //{ - // //if it is not a document type or a media type, then continue to call the legacy delete() method. - // //the new API for document type and media type's will ensure that the data is removed correctly and that - // //the cache is flushed correctly (using events). If it is not one of these types, we'll rever to the - // //legacy operation (... like for members i suppose ?) - // asyncState.GenericPropertyWrapper.GenricPropertyControl.PropertyType.delete(); - - //} - - Trace.Write("ContentTypeControlNew", "task completing"); - }; - - //execute the async tasks - Page.ExecuteRegisteredAsyncTasks(); - } - - #endregion - - #region "Tab" Pane - - private void SetupTabPane() - { - uicontrols.TabPage tp = TabView1.NewTabPage("Tabs"); - tp.Controls.Add(pnlTab); - BindTabs(); - } - - private IEnumerable> SaveTabs() - { - var tabs = new List>();//TabId, TabName, TabSortOrder - foreach (DataGridItem dgi in dgTabs.Items) - { - int tabid = int.Parse(dgi.Cells[0].Text); - string tabName = ((TextBox) dgi.FindControl("txtTab")).Text; - int tabSortOrder; - if (Int32.TryParse(((TextBox)dgi.FindControl("txtSortOrder")).Text, out tabSortOrder)) - { - tabs.Add(new Tuple(tabid, tabName, tabSortOrder)); - } - } - return tabs; - } - - private void BindTabs() - { - DataTable dt = new DataTable(); - dt.Columns.Add("name"); - dt.Columns.Add("id"); - dt.Columns.Add("order"); - - // working on the LOCAL groups only... - // and I guess the ParentId thing was to prevent renaming inherited tabs?! - // nothing makes sense here - foreach (var grp in _contentType.PropertyTypeGroups.OrderBy(p => p.SortOrder)) - { - if (grp.ContentTypeId == _contentType.Id /*&& grp.ParentId == 0*/) - { - DataRow dr = dt.NewRow(); - dr["name"] = grp.Name; - dr["id"] = grp.Id; - dr["order"] = grp.SortOrder; - dt.Rows.Add(dr); - } - } - - if (dt.Rows.Count == 0) - { - lttNoTabs.Text = "No custom tabs defined"; - dgTabs.Visible = false; - } - else - { - lttNoTabs.Text = ""; - dgTabs.Visible = true; - } - dgTabs.DataSource = dt; - dgTabs.DataBind(); - } - - public DataTable DataTypeTable - { - get - { - if (_dataTypeTable == null) - { - _dataTypeTable = new DataTable(); - _dataTypeTable.Columns.Add("name"); - _dataTypeTable.Columns.Add("id"); - - foreach (var dataType in cms.businesslogic.datatype.DataTypeDefinition.GetAll()) - { - DataRow dr = _dataTypeTable.NewRow(); - dr["name"] = dataType.Text; - dr["id"] = dataType.Id.ToString(); - _dataTypeTable.Rows.Add(dr); - } - } - return _dataTypeTable; - } - } - - public DataTable TabTable - { - get - { - if (dgTabs.DataSource == null) - BindTabs(); - - DataTable dt = new DataTable(); - dt.Columns.Add("name"); - dt.Columns.Add("id"); - - foreach (DataRow dr in ((DataTable)dgTabs.DataSource).Rows) - { - DataRow dr2 = dt.NewRow(); - dr2["name"] = dr["name"]; - dr2["id"] = dr["id"]; - dt.Rows.Add(dr2); - } - - DataRow dr1 = dt.NewRow(); - dr1["name"] = "General properties"; - dr1["id"] = 0; - dt.Rows.Add(dr1); - - return dt; - } - } - - /// - /// Adds a new Tab to current ContentType when user clicks 'New Tab'-button - /// - /// - /// - protected void btnNewTab_Click(object sender, EventArgs e) - { - if (txtNewTab.Text.Trim() != "") - { - //if (_contentType.ContentTypeItem is IContentType - // || _contentType.ContentTypeItem is IMediaType - // || _contentType.ContentTypeItem is IMemberType) - //{ - _contentType.ContentTypeItem.AddPropertyGroup(txtNewTab.Text); - _contentType.Save(); - //} - //else - //{ - // _contentType.AddVirtualTab(txtNewTab.Text); - //} - - LoadContentType(); - - var ea = new SaveClickEventArgs(ui.Text("contentTypeTabCreated", Security.CurrentUser)); - ea.IconType = BasePage.speechBubbleIcon.success; - - RaiseBubbleEvent(new object(), ea); - - txtNewTab.Text = ""; - - BindTabs(); - BindDataGenericProperties(true); - } - - } - - /// - /// Removes a Tab from current ContentType when user clicks Delete button - /// - /// - /// - protected void dgTabs_ItemCommand(object source, DataGridCommandEventArgs e) - { - if (e.CommandName == "Delete") - { - int propertyGroupId = int.Parse(e.Item.Cells[0].Text); - //if (_contentType.ContentTypeItem is IContentType - // || _contentType.ContentTypeItem is IMediaType - // || _contentType.ContentTypeItem is IMemberType) - //{ - var propertyGroup = _contentType.ContentTypeItem.PropertyGroups.FirstOrDefault(x => x.Id == propertyGroupId); - if (propertyGroup != null && string.IsNullOrEmpty(propertyGroup.Name) == false) - { - // use RemovePropertyGroup so properties become generic - _contentType.ContentTypeItem.RemovePropertyGroup(propertyGroup.Name); - _contentType.Save(); - } - //} - - _contentType.DeleteVirtualTab(propertyGroupId); - - LoadContentType(); - - var ea = new SaveClickEventArgs(ui.Text("contentTypeTabDeleted", Security.CurrentUser)); - ea.IconType = BasePage.speechBubbleIcon.success; - - RaiseBubbleEvent(new object(), ea); - - } - - BindTabs(); - BindDataGenericProperties(true); - } - - protected void dgTabs_itemdatabound(object sender, DataGridItemEventArgs e) - { - if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) - { - ((DropDownList)e.Item.FindControl("dllTab")).SelectedValue = - ((DataRowView)e.Item.DataItem).Row["propertyTypeGroupId"].ToString(); - ((DropDownList)e.Item.FindControl("ddlType")).SelectedValue = - ((DataRowView)e.Item.DataItem).Row["type"].ToString(); - } - - } - - #endregion - - /// - /// TabView1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.TabView TabView1; - - /// - /// pnlGeneral control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Panel pnlGeneral; - - /// - /// pnlTab control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Panel pnlTab; - - /// - /// PaneTabsInherited control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.Pane PaneTabsInherited; - - /// - /// tabsMasterContentTypeName control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Literal tabsMasterContentTypeName; - - /// - /// Pane2 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.Pane Pane2; - - /// - /// pp_newTab control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel pp_newTab; - - protected global::umbraco.uicontrols.PropertyPanel pp_isContainer; - protected global::System.Web.UI.WebControls.CheckBox cb_isContainer; - - /// - /// txtNewTab control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.TextBox txtNewTab; - - /// - /// btnNewTab control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Button btnNewTab; - - /// - /// Pane1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.Pane Pane1; - - /// - /// dgTabs control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.DataGrid dgTabs; - - /// - /// lttNoTabs control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Literal lttNoTabs; - - /// - /// pnlInfo control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Panel pnlInfo; - - /// - /// Pane3 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.Pane Pane3; - - /// - /// pp_name control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel pp_name; - - /// - /// txtName control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.TextBox txtName; - - /// - /// RequiredFieldValidator1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1; - - /// - /// pp_alias control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel pp_alias; - - /// - /// txtAlias control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.TextBox txtAlias; - - /// - /// pp_icon control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel pp_icon; - - /// - /// ddlIcons control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.HiddenField tb_icon; - protected global::System.Web.UI.WebControls.Literal lt_icon; - - - /// - /// pp_description control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel pp_description; - - /// - /// description control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.TextBox description; - - /// - /// pnlStructure control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Panel pnlStructure; - - /// - /// Pane6 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.Pane Pane6; - - /// - /// 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; - - /// - /// 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. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel pp_allowedChildren; - - /// - /// lstAllowedContentTypes control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.CheckBoxList lstAllowedContentTypes; - - /// - /// PlaceHolderAllowedContentTypes control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.PlaceHolder PlaceHolderAllowedContentTypes; - - /// - /// pnlProperties control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Panel pnlProperties; - - /// - /// PanePropertiesInherited control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.Pane PanePropertiesInherited; - - /// - /// propertiesMasterContentTypeName control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Literal propertiesMasterContentTypeName; - - /// - /// Pane4 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.Pane Pane4; - - /// - /// PropertyTypeNew control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.PlaceHolder PropertyTypeNew; - - /// - /// PropertyTypes control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.PlaceHolder PropertyTypes; - - /// - /// checkTxtAliasJs control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Literal checkTxtAliasJs; - - /// - /// DuplicateAliasValidator control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.CustomValidator DuplicateAliasValidator; - - /// - /// Pane9 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.Pane Pane9; - - /// - /// pp_compositions control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel pp_compositions; - - /// - /// lstContentTypeCompositions control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.CheckBoxList lstContentTypeCompositions; - - /// - /// PlaceHolderContentTypeCompositions control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.PlaceHolder PlaceHolderContentTypeCompositions; - } -} \ No newline at end of file diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/GenericProperties/GenericProperty.ascx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/GenericProperties/GenericProperty.ascx.cs deleted file mode 100644 index bffdb8b475..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/GenericProperties/GenericProperty.ascx.cs +++ /dev/null @@ -1,456 +0,0 @@ -using System; -using System.Globalization; -using System.Linq; -using System.Web; -using System.Web.Mvc; -using System.Web.Routing; -using System.Web.UI.WebControls; -using ClientDependency.Core; -using umbraco.BasePages; -using umbraco.BusinessLogic; -using umbraco.cms.businesslogic; -using umbraco.cms.businesslogic.propertytype; -using Umbraco.Core; -using Umbraco.Core.Configuration; - -namespace umbraco.controls.GenericProperties -{ - /// - /// Summary description for GenericProperty. - /// - [ClientDependency(ClientDependencyType.Css, "GenericProperty/genericproperty.css", "UmbracoClient")] - [ClientDependency(ClientDependencyType.Javascript, "GenericProperty/genericproperty.js", "UmbracoClient")] - public partial class GenericProperty : System.Web.UI.UserControl - { - - /// - /// Constructor - /// - public GenericProperty() - { - FullId = ""; - AllowPropertyEdit = true; - } - - private cms.businesslogic.datatype.DataTypeDefinition[] _dataTypeDefinitions; - private int _tabId = 0; - - public event EventHandler Delete; - - /// - /// Defines whether the property can be edited in the UI - /// - [Obsolete("Use the combination of AllowAliasEdit,AllowValidationEdit,AllowDelete,AllowDataTypeEdit instead")] - public bool AllowPropertyEdit - { - get { return AllowAliasEdit && AllowValidationEdit && AllowDelete && AllowDataTypeEdit; } - set { AllowAliasEdit = AllowValidationEdit = AllowDelete = AllowDataTypeEdit = true; } - } - - /// - /// Defines whether the property's name can be edited in the UI - /// - public bool AllowNameEdit { get; set; } - public bool AllowAliasEdit { get; set; } - public bool AllowDataTypeEdit { get; set; } - public bool AllowTabEdit { get; set; } - public bool AllowValidationEdit { get; set; } - public bool AllowDescriptionEdit { get; set; } - public bool AllowDelete { get; set; } - - public cms.businesslogic.datatype.DataTypeDefinition[] DataTypeDefinitions - { - set { _dataTypeDefinitions = value; } - } - - public int TabId - { - set { _tabId = value; } - } - - public PropertyType PropertyType { get; set; } - - public ContentType.TabI[] Tabs { get; set; } - - public string Name - { - get { return tbName.Text; } - } - - public string Alias - { - get { return tbAlias.Text; } // FIXME so we blindly trust the UI for safe aliases?! - } - - public string Description - { - get { return tbDescription.Text; } - } - public string Validation - { - get { return tbValidation.Text; } - } - public bool Mandatory - { - get { return checkMandatory.Checked; } - } - public int Tab - { - get { return int.Parse(ddlTab.SelectedValue); } - } - - public string FullId { get; set; } - - public int Id { get; set; } - - public int Type - { - get { return int.Parse(ddlTypes.SelectedValue); } - } - - public void Clear() - { - tbName.Text = ""; - tbAlias.Text = ""; - tbValidation.Text = ""; - tbDescription.Text = ""; - ddlTab.SelectedIndex = 0; - SetDefaultDocumentTypeProperty(); - checkMandatory.Checked = false; - } - - protected void Page_Load(object sender, System.EventArgs e) - { - if (!IsPostBack) - { - UpdateInterface(); - } - } - - //SD: this is temporary in v4, in v6 we have a proper user control hierarchy - //containing this property. - //this is required due to this issue: http://issues.umbraco.org/issue/u4-493 - //because we need to execute some code in async but due to the localization - //framework requiring an httpcontext.current, it will not work. - //http://issues.umbraco.org/issue/u4-2143 - //so, we are going to make a property here and ensure that the basepage has - //resolved the user before we execute the async task so that in this method - //our calls to ui.text will include the current user and not rely on the - //httpcontext.current. This also makes it perform better: - // http://issues.umbraco.org/issue/U4-2142 - private User CurrentUser - { - get { return ((BasePage)Page).getUser(); } - } - - public void UpdateInterface() - { - // Name and alias - if (PropertyType != null) - { - Id = PropertyType.Id; - //form.Attributes.Add("style", "display: none;"); - tbName.Text = PropertyType.GetRawName(); - tbAlias.Text = PropertyType.Alias; - FullHeader.Text = PropertyType.GetRawName() + " (" + PropertyType.Alias + "), Type: " + PropertyType.DataTypeDefinition.Text; ; - Header.Text = PropertyType.GetRawName(); - - DeleteButton.CssClass = "delete-button"; - DeleteButton.Attributes.Add("onclick", "return confirm('" + ui.Text("areyousure", CurrentUser) + "');"); - - DeleteButton2.CssClass = "delete-button"; - DeleteButton2.Attributes.Add("onclick", "return confirm('" + ui.Text("areyousure", CurrentUser) + "');"); - - DeleteButton.Visible = AllowDelete; - DeleteButton2.Visible = AllowDelete; - - //alias visibility - PropertyPanel2.Visible = AllowAliasEdit; - //chk mandatory visibility - PropertyPanel5.Visible = AllowValidationEdit; - // validation visibility - PropertyPanel6.Visible = AllowValidationEdit; - // drop down data types visibility - PropertyPanel3.Visible = AllowDataTypeEdit; - // name visibility - PropertyPanel1.Visible = AllowNameEdit; - // desc visibility - PropertyPanel7.Visible = AllowDescriptionEdit; - } - else - { - // Add new header - FullHeader.Text = "Click here to add a new property"; - Header.Text = "Create new property"; - - // Hide image button - DeleteButton.Visible = false; - DeleteButton2.Visible = false; - } - validationLink.NavigateUrl = "#"; - validationLink.Attributes["onclick"] = ClientTools.Scripts.OpenModalWindow("dialogs/regexWs.aspx?target=" + tbValidation.ClientID, "Search for regular expression", 600, 500) + ";return false;"; - - // Data type definitions - if (_dataTypeDefinitions != null) - { - ddlTypes.Items.Clear(); - var itemSelected = false; - foreach (cms.businesslogic.datatype.DataTypeDefinition dt in _dataTypeDefinitions) - { - var li = new ListItem(dt.Text, dt.Id.ToString(CultureInfo.InvariantCulture)); - if ((PropertyType != null && PropertyType.DataTypeDefinition.Id == dt.Id)) - { - li.Selected = true; - itemSelected = true; - } - - ddlTypes.Items.Add(li); - } - - // If item not selected from previous edit or load, set to default according to settings - if (!itemSelected) - { - SetDefaultDocumentTypeProperty(); - } - } - - // tabs - if (Tabs != null) - { - ddlTab.Items.Clear(); - for (int i = 0; i < Tabs.Length; i++) - { - ListItem li = new ListItem(Tabs[i].Caption, Tabs[i].Id.ToString()); - if (Tabs[i].Id == _tabId) - li.Selected = true; - ddlTab.Items.Add(li); - } - } - ListItem liGeneral = new ListItem("Generic Properties", "0"); - if (_tabId == 0) - liGeneral.Selected = true; - ddlTab.Items.Add(liGeneral); - - // mandatory - if (PropertyType != null && PropertyType.Mandatory) - checkMandatory.Checked = true; - - // validation - if (PropertyType != null && string.IsNullOrEmpty(PropertyType.ValidationRegExp) == false) - tbValidation.Text = PropertyType.ValidationRegExp; - - // description - if (PropertyType != null && PropertyType.Description != "") - tbDescription.Text = PropertyType.GetRawDescription(); - } - - private void SetDefaultDocumentTypeProperty() - { - var itemToSelect = ddlTypes.Items.Cast() - .FirstOrDefault(item => item.Text.ToLowerInvariant() == UmbracoConfig.For.UmbracoSettings().Content.DefaultDocumentTypeProperty.ToLowerInvariant()); - - if (itemToSelect != null) - { - itemToSelect.Selected = true; - } - else - { - ddlTypes.SelectedIndex = -1; - } - } - - protected void defaultDeleteHandler(object sender, EventArgs e) - { - - } - - override protected void OnInit(EventArgs e) - { - base.OnInit(e); - - DeleteButton.Click += DeleteButton_Click; - DeleteButton2.Click += DeleteButton2_Click; - Delete += defaultDeleteHandler; - - // [ClientDependency(ClientDependencyType.Javascript, "js/UmbracoCasingRules.aspx", "UmbracoRoot")] - var loader = ClientDependency.Core.Controls.ClientDependencyLoader.GetInstance(new HttpContextWrapper(Context)); - var helper = new UrlHelper(new RequestContext(new HttpContextWrapper(Context), new RouteData())); - loader.RegisterDependency(helper.GetCoreStringsControllerPath() + "ServicesJavaScript", ClientDependencyType.Javascript); - } - - void DeleteButton2_Click(object sender, EventArgs e) - { - Delete(this, new EventArgs()); - } - - void DeleteButton_Click(object sender, EventArgs e) - { - Delete(this, new EventArgs()); - } - - /// - /// DeleteButton2 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.LinkButton DeleteButton2; - - /// - /// FullHeader control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Literal FullHeader; - - /// - /// DeleteButton control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.LinkButton DeleteButton; - - /// - /// Header control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Literal Header; - - /// - /// tbName control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.TextBox tbName; - - /// - /// PropertyPanel1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel PropertyPanel1; - - /// - /// tbAlias control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.TextBox tbAlias; - - /// - /// PropertyPanel2 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel PropertyPanel2; - - /// - /// ddlTypes control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.DropDownList ddlTypes; - - /// - /// PropertyPanel3 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel PropertyPanel3; - - /// - /// ddlTab control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.DropDownList ddlTab; - - /// - /// PropertyPanel4 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel PropertyPanel4; - - /// - /// checkMandatory control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.CheckBox checkMandatory; - - /// - /// PropertyPanel5 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel PropertyPanel5; - - /// - /// tbValidation control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.TextBox tbValidation; - - /// - /// validationLink control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.HyperLink validationLink; - - /// - /// PropertyPanel6 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel PropertyPanel6; - - /// - /// tbDescription control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.TextBox tbDescription; - - protected global::umbraco.uicontrols.PropertyPanel PropertyPanel7; - - } -} \ No newline at end of file diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/GenericProperties/GenericPropertyWrapper.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/GenericProperties/GenericPropertyWrapper.cs deleted file mode 100644 index b76bfe452f..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/GenericProperties/GenericPropertyWrapper.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System; -using System.Collections.Generic; -using Umbraco.Core.IO; -using umbraco.cms.businesslogic.propertytype; - -namespace umbraco.controls.GenericProperties -{ - /// - /// Summary description for GenericPropertyWrapper. - /// - public class GenericPropertyWrapper : System.Web.UI.WebControls.PlaceHolder - { - private readonly bool _allowNameEdit = true; - private readonly bool _allowDataTypeEdit = true; - private readonly bool _allowAliasEdit = true; - private readonly bool _allowTabEdit = true; - private readonly bool _allowValidationEdit = true; - private readonly bool _allowDescEdit = true; - private readonly bool _allowDelete = true; - - private GenericProperty _gp; - private cms.businesslogic.ContentType.TabI[] _tabs; - private cms.businesslogic.datatype.DataTypeDefinition[] _dtds; - private int _tabId; - private string _fullId = ""; - - public event EventHandler Delete; - - public PropertyType PropertyType { get; set; } - - public int TabId - { - set { _tabId = value; } - } - - public cms.businesslogic.datatype.DataTypeDefinition[] DataTypeDefinitions - { - set { _dtds = value; } - } - - public cms.businesslogic.web.DocumentType.TabI[] Tabs - { - set { _tabs = value; } - } - - public string FullId - { - set { _fullId = value; } - } - - public GenericProperty GenricPropertyControl - { - get { return _gp; } - } - - public GenericPropertyWrapper() - : this(true) - { - - } - - public GenericPropertyWrapper(bool allowModification) - { - if (allowModification == false) - { - _allowAliasEdit = false; - _allowValidationEdit = false; - _allowDelete = false; - _allowDataTypeEdit = false; - } - } - - public GenericPropertyWrapper(bool allowNameEdit, bool allowDataTypeEdit, bool allowAliasEdit, bool allowTabEdit, bool allowValidationEdit, bool allowDescEdit, bool allowDelete) - { - _allowNameEdit = allowNameEdit; - _allowDataTypeEdit = allowDataTypeEdit; - _allowAliasEdit = allowAliasEdit; - _allowTabEdit = allowTabEdit; - _allowValidationEdit = allowValidationEdit; - _allowDescEdit = allowDescEdit; - _allowDelete = allowDelete; - } - - public void UpdateEditControl() - { - if (Controls.Count == 1) - { - var u = Controls[0]; - u.ID = ID + "_control"; - _gp = (GenericProperty)u; - _gp.PropertyType = PropertyType; - _gp.DataTypeDefinitions = _dtds; - _gp.Tabs = _tabs; - _gp.TabId = _tabId; - _gp.FullId = _fullId; - } - } - - protected void GenericPropertyWrapper_Delete(object sender, EventArgs e) - { - Delete(this, new EventArgs()); - } - - protected override void OnInit(EventArgs e) - { - base.OnInit(e); - var u = (GenericProperty)Page.LoadControl(SystemDirectories.Umbraco + "/controls/genericProperties/GenericProperty.ascx"); - - u.AllowAliasEdit = _allowAliasEdit; - u.AllowDataTypeEdit = _allowDataTypeEdit; - u.AllowDelete = _allowDelete; - u.AllowDescriptionEdit = _allowDescEdit; - u.AllowNameEdit = _allowNameEdit; - u.AllowTabEdit = _allowTabEdit; - u.AllowValidationEdit = _allowValidationEdit; - - u.ID = ID + "_control"; - - if (_allowDelete) - { - u.Delete += GenericPropertyWrapper_Delete; - } - - u.FullId = _fullId; - Controls.Add(u); - UpdateEditControl(); - } - - - } -} diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/members/EditMemberType.aspx b/src/Umbraco.Web/umbraco.presentation/umbraco/members/EditMemberType.aspx deleted file mode 100644 index eb9cc90070..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/members/EditMemberType.aspx +++ /dev/null @@ -1,35 +0,0 @@ - -<%@ Page language="c#" MasterPageFile="../masterpages/umbracoPage.Master" Codebehind="EditMemberType.aspx.cs" AutoEventWireup="True" Inherits="umbraco.cms.presentation.members.EditMemberType" %> -<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %> -<%@ Register TagPrefix="uc1" TagName="ContentTypeControlNew" Src="../controls/ContentTypeControlNew.ascx" %> -<%@ Register Namespace="umbraco" TagPrefix="umb" Assembly="umbraco" %> - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/members/EditMemberType.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/members/EditMemberType.aspx.cs deleted file mode 100644 index c4ca7ba095..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/members/EditMemberType.aspx.cs +++ /dev/null @@ -1,142 +0,0 @@ -using System; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Globalization; -using System.Linq; -using System.Web; -using System.Web.SessionState; -using System.Web.UI; -using System.Web.UI.WebControls; -using System.Web.UI.HtmlControls; -using ClientDependency.Core; -using umbraco.cms.businesslogic.member; -using umbraco.cms.presentation.Trees; -using umbraco.controls; - -namespace umbraco.cms.presentation.members -{ - public partial class EditMemberType : BasePages.UmbracoEnsuredPage - { - - public EditMemberType() - { - CurrentApp = BusinessLogic.DefaultApps.member.ToString(); - - } - protected PlaceHolder plc; - private businesslogic.member.MemberType _memberType; - - protected ContentTypeControlNew ContentTypeControlNew1; - - protected override void OnInit(EventArgs e) - { - base.OnInit(e); - - ContentTypeControlNew1.SavingContentType += ContentTypeControlNew1_SavingContentType; - } - - protected override void OnLoad(EventArgs e) - { - base.OnLoad(e); - - _memberType = new businesslogic.member.MemberType(int.Parse(Request.QueryString["id"])); - - ContentTypeControlNew1.InfoTabPage.Controls.Add(Pane1andmore); - - if (!IsPostBack) - { - SetupExtraEditorControls(); - - ClientTools - .SetActiveTreeType(TreeDefinitionCollection.Instance.FindTree().Tree.Alias) - .SyncTree(_memberType.Id.ToString(CultureInfo.InvariantCulture), false); - } - } - - protected override bool OnBubbleEvent(object source, EventArgs args) - { - var handled = false; - var eventArgs = args as SaveClickEventArgs; - if (eventArgs != null) - { - var e = eventArgs; - if (e.Message == "Saved") - { - SetupExtraEditorControls(); - - ClientTools - .ShowSpeechBubble(speechBubbleIcon.save, "Membertype saved", "") - .SyncTree(_memberType.Id.ToString(CultureInfo.InvariantCulture), true); - - } - else - { - ClientTools - .ShowSpeechBubble(e.IconType, e.Message, "") - .SyncTree(_memberType.Id.ToString(CultureInfo.InvariantCulture), true); - - } - handled = true; - } - - return handled; - } - - private void SetupExtraEditorControls() - { - var dt1 = new DataTable(); - dt1.Columns.Add("id"); - dt1.Columns.Add("name"); - dt1.Columns.Add("canedit"); - dt1.Columns.Add("canview"); - - //filter out the 'built-in' property types as we don't want to display these options for them - var builtIns = Umbraco.Core.Constants.Conventions.Member.GetStandardPropertyTypeStubs().Select(x => x.Key).ToArray(); - var propTypes = _memberType.PropertyTypes.Where(x => builtIns.Contains(x.Alias) == false); - - foreach (var pt in propTypes) - { - var dr = dt1.NewRow(); - dr["name"] = pt.Name; - dr["id"] = pt.Id; - dt1.Rows.Add(dr); - } - dgEditExtras.DataSource = dt1; - dgEditExtras.DataBind(); - } - - /// - /// Executes some code before the member type is saved, this allows us to save the member can edit/member can view information - /// before the Save() command is executed. - /// - /// - void ContentTypeControlNew1_SavingContentType(businesslogic.ContentType e) - { - var mt = e as MemberType; - if (mt == null) return; //This should not happen! - foreach (DataGridItem dgi in dgEditExtras.Items) - { - if (dgi.ItemType == ListItemType.Item || dgi.ItemType == ListItemType.AlternatingItem) - { - var pt = cms.businesslogic.propertytype.PropertyType.GetPropertyType(int.Parse(dgi.Cells[0].Text)); - mt.setMemberCanEdit(pt, ((CheckBox)dgi.FindControl("ckbMemberCanEdit")).Checked); - mt.setMemberViewOnProfile(pt, ((CheckBox)dgi.FindControl("ckbMemberCanView")).Checked); - } - } - } - - protected void dgEditExtras_itemdatabound(object sender,DataGridItemEventArgs e) - { - if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) - { - var pt = cms.businesslogic.propertytype.PropertyType.GetPropertyType(int.Parse(((DataRowView)e.Item.DataItem).Row["id"].ToString())); - ((CheckBox)e.Item.FindControl("ckbMemberCanEdit")).Checked = _memberType.MemberCanEdit(pt); - ((CheckBox)e.Item.FindControl("ckbMemberCanView")).Checked = _memberType.ViewOnProfile(pt); - } - } - - } - - -} diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/members/EditMemberType.aspx.designer.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/members/EditMemberType.aspx.designer.cs deleted file mode 100644 index f976022cbb..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/members/EditMemberType.aspx.designer.cs +++ /dev/null @@ -1,34 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.3074 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace umbraco.cms.presentation.members { - - - public partial class EditMemberType { - - /// - /// Pane1andmore control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.Pane Pane1andmore; - - /// - /// dgEditExtras control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.DataGrid dgEditExtras; - } -} diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditMediaType.aspx b/src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditMediaType.aspx deleted file mode 100644 index ab35ae3a63..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditMediaType.aspx +++ /dev/null @@ -1,15 +0,0 @@ -<%@ Register TagPrefix="cc2" Namespace="umbraco.uicontrols" Assembly="controls" %> - -<%@ Page Language="c#" CodeBehind="EditMediaType.aspx.cs" MasterPageFile="../masterpages/umbracoPage.Master" - Async="true" AsyncTimeOut="300" - AutoEventWireup="True" Inherits="umbraco.cms.presentation.settings.EditMediaType" %> - -<%@ Register TagPrefix="uc1" TagName="ContentTypeControlNew" Src="../controls/ContentTypeControlNew.ascx" %> - - - - diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditMediaType.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditMediaType.aspx.cs deleted file mode 100644 index 93e060c01d..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditMediaType.aspx.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using umbraco.cms.presentation.Trees; - -namespace umbraco.cms.presentation.settings -{ - /// - /// Summary description for EditMediaType. - /// - public partial class EditMediaType : BasePages.UmbracoEnsuredPage - { - public EditMediaType() - { - CurrentApp = BusinessLogic.DefaultApps.settings.ToString(); - } - - protected void Page_Load(object sender, EventArgs e) - { - if (!IsPostBack) - { - ClientTools - .SetActiveTreeType(TreeDefinitionCollection.Instance.FindTree().Tree.Alias) - .SyncTree("-1,init," + helper.Request("id"), false); - } - } - - protected override bool OnBubbleEvent(object source, EventArgs e) - { - if (e is controls.SaveClickEventArgs) - { - var sce = (controls.SaveClickEventArgs)e; - - if (sce.Message == "Saved") - { - ClientTools.ShowSpeechBubble(speechBubbleIcon.save, "Mediatype saved", "Mediatype was successfully saved"); - } - else if (sce.Message.Contains("Tab")) - { - ClientTools.ShowSpeechBubble(sce.IconType, sce.Message, ""); - } - else - { - ClientTools.ShowSpeechBubble(sce.IconType, sce.Message, ""); - } - - return true; - } - - return false; - } - - } -} diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditMediaType.aspx.designer.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditMediaType.aspx.designer.cs deleted file mode 100644 index 3bf60caa2c..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditMediaType.aspx.designer.cs +++ /dev/null @@ -1,24 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace umbraco.cms.presentation.settings { - - - public partial class EditMediaType { - - /// - /// ContentTypeControlNew1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.UserControl ContentTypeControlNew1; - } -} diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditNodeTypeNew.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditNodeTypeNew.aspx.cs deleted file mode 100644 index 493bce0d48..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditNodeTypeNew.aspx.cs +++ /dev/null @@ -1,167 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Globalization; -using System.Web.UI.WebControls; -using umbraco.cms.presentation.Trees; -using umbraco.cms.businesslogic.web; -using System.Linq; -using umbraco.controls; -using Umbraco.Core; - -namespace umbraco.settings -{ - public partial class EditContentTypeNew : BasePages.UmbracoEnsuredPage - { - public EditContentTypeNew() - { - CurrentApp = BusinessLogic.DefaultApps.settings.ToString(); - } - - protected controls.ContentTypeControlNew ContentTypeControlNew1; - private DocumentType _dt; - - override protected void OnInit(EventArgs e) - { - ContentTypeControlNew1.DocumentTypeCallback = new Func(UpdateAllowedTemplates); - ContentTypeControlNew1.InfoTabPage.Controls.Add(tmpPane); - base.OnInit(e); - } - - protected void Page_Load(object sender, EventArgs e) - { - _dt = new DocumentType(int.Parse(Request.QueryString["id"])); - if (!Page.IsPostBack) - { - BindTemplates(); - - ClientTools - .SetActiveTreeType(TreeDefinitionCollection.Instance.FindTree().Tree.Alias) - .SyncTree("-1,init," + _dt.Path.Replace("-1,", ""), false); - } - } - - protected override bool OnBubbleEvent(object source, EventArgs args) - { - bool handled = false; - var eventArgs = args as SaveClickEventArgs; - if (eventArgs != null) - { - var e = eventArgs; - if (e.Message == "Saved") - { - ClientTools.ShowSpeechBubble(e.IconType, ui.Text("contentTypeSavedHeader"), ""); - - BindTemplates(); - } - else - { - ClientTools.ShowSpeechBubble(e.IconType, e.Message, ""); - } - handled = true; - } - return handled; - } - - protected void dgTemplate_itemdatabound(object sender, DataGridItemEventArgs e) - { - if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) - { - ((CheckBox)e.Item.FindControl("ckbAllowTemplate")).Checked = true; - } - } - - private DocumentType UpdateAllowedTemplates(DocumentType documentType) - { - var tmp = new ArrayList(); - - foreach (ListItem li in templateList.Items) - { - if (li.Selected) - tmp.Add(new cms.businesslogic.template.Template(int.Parse(li.Value))); - } - - var tt = new cms.businesslogic.template.Template[tmp.Count]; - for (int i = 0; i < tt.Length; i++) - { - tt[i] = (cms.businesslogic.template.Template)tmp[i]; - } - - documentType.allowedTemplates = tt; - - if (documentType.allowedTemplates.Length > 0 && ddlTemplates.SelectedIndex >= 0) - { - documentType.DefaultTemplate = int.Parse(ddlTemplates.SelectedValue); - } - else - { - documentType.RemoveDefaultTemplate(); - } - - _dt = documentType; - - return documentType; - } - - private void BindTemplates() - { - var templates = (from t in cms.businesslogic.template.Template.GetAllAsList() - join at in _dt.allowedTemplates on t.Id equals at.Id into at_l - from at in at_l.DefaultIfEmpty() - select new - { - Id = t.Id, - Name = t.Text, - Selected = at != null - }).ToList(); - - templateList.Items.Clear(); - templateList.Items.AddRange(templates.ConvertAll(item => - { - var li = new ListItem { Text = Server.HtmlEncode(item.Name), Value = item.Id.ToString(CultureInfo.InvariantCulture), Selected = item.Selected }; - return li; - }).ToArray()); - - - ddlTemplates.Enabled = templates.Any(); - ddlTemplates.Items.Clear(); - ddlTemplates.Items.Insert(0, new ListItem(ui.Text("choose") + "...", "0")); - ddlTemplates.Items.AddRange(templates.ConvertAll(item => - { - var li = new ListItem { Text = Server.HtmlEncode(item.Name), Value = item.Id.ToString(CultureInfo.InvariantCulture) }; - return li; - }).ToArray()); - - var ddlTemplatesSelect = ddlTemplates.Items.FindByValue(_dt.DefaultTemplate.ToString(CultureInfo.InvariantCulture)); - if (ddlTemplatesSelect != null) - ddlTemplatesSelect.Selected = true; - } - - /// - /// tmpPane control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.Pane tmpPane; - - /// - /// templateList control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.CheckBoxList templateList; - - /// - /// ddlTemplates control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.DropDownList ddlTemplates; - } -}