From 06519ab238fd6fb373a11225e12b25f1fadfb779 Mon Sep 17 00:00:00 2001 From: "NielsHartvig@UMBRACORATI.localdomain" Date: Thu, 11 Oct 2012 11:38:11 -0200 Subject: [PATCH 1/2] Fixes U4-1018. --- src/umbraco.cms/businesslogic/ContentType.cs | 66 +++----------------- 1 file changed, 8 insertions(+), 58 deletions(-) diff --git a/src/umbraco.cms/businesslogic/ContentType.cs b/src/umbraco.cms/businesslogic/ContentType.cs index 8367e8335b..4e243556db 100644 --- a/src/umbraco.cms/businesslogic/ContentType.cs +++ b/src/umbraco.cms/businesslogic/ContentType.cs @@ -168,74 +168,24 @@ namespace umbraco.cms.businesslogic return _propertyTypeCache[key]; } - //Instead of going via API, run this query to find the control type - //by-passes a lot of queries just to determine if this is a true/false data type - - //This SQL returns a larger recordset than intended - //causing controlId to sometimes be null instead of correct - //because all properties for the type are returned - //side effect of changing inner join to left join when adding masterContentType - //string sql = "select " + - // "cmsDataType.controlId, masterContentType.alias as masterAlias " + - // "from " + - // "cmsContentType " + - // "inner join cmsPropertyType on (cmsContentType.nodeId = cmsPropertyType.contentTypeId) " + - // "left join cmsDataType on (cmsPropertyType.dataTypeId = cmsDataType.nodeId) and cmsPropertyType.Alias = @propertyAlias " + - // "left join cmsContentType masterContentType on masterContentType.nodeid = cmsContentType.masterContentType " + - // "where cmsContentType.alias = @contentTypeAlias"; - - //this SQL correctly returns a single row when the property exists, but still returns masterAlias if it doesn't - string sql = "select cmsDataType.controlId, masterContentType.alias as masterAlias " + - "from " + - "cmsContentType " + - "left join cmsPropertyType on (cmsContentType.nodeId = cmsPropertyType.contentTypeId and cmsPropertyType.Alias = @propertyAlias) " + - "left join cmsDataType on (cmsPropertyType.dataTypeId = cmsDataType.nodeId) " + - "left join cmsContentType masterContentType on masterContentType.nodeid = cmsContentType.masterContentType " + - "where " + - "cmsContentType.alias = @contentTypeAlias"; - - //Ensure that getdatatype doesn't throw an exception - //http://our.umbraco.org/forum/developers/razor/18085-Access-custom-node-properties-with-Razor - - //grab the controlid or test for parent + // With 4.10 we can't do this via direct SQL as we have content type mixins Guid controlId = Guid.Empty; - IRecordsReader reader = null; - try + ContentType ct = GetByAlias(contentTypeAlias); + PropertyType pt = ct.getPropertyType(propertyTypeAlias); + if (pt != null) { - reader = Application.SqlHelper.ExecuteReader(sql, - Application.SqlHelper.CreateParameter("@contentTypeAlias", contentTypeAlias), - Application.SqlHelper.CreateParameter("@propertyAlias", propertyTypeAlias) - ); - if (reader.Read()) - { - if (!reader.IsNull("controlId")) - controlId = reader.GetGuid("controlId"); - else if (!reader.IsNull("masterAlias") && !String.IsNullOrEmpty(reader.GetString("masterAlias"))) - { - controlId = GetDataType(reader.GetString("masterAlias"), propertyTypeAlias); - } - - } - } - catch (UmbracoException) - { - _propertyTypeCache.Add(key, controlId); - } - finally - { - if (reader != null) - { - reader.Close(); - } + controlId = pt.DataTypeDefinition.DataType.Id; } - //add to cache + //add to cache (even if empty!) if (!_propertyTypeCache.ContainsKey(key)) { _propertyTypeCache.Add(key, controlId); } + return controlId; + } From 689fe2a44f0de582b8f576d9f6e1d094c4d4f3a3 Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Fri, 12 Oct 2012 09:15:33 +0500 Subject: [PATCH 2/2] Fixes issue with wrapping the UmbEditor init in doc ready causing template editing not to work. --- src/Umbraco.Web.UI/umbraco_client/Editors/EditView.js | 6 +++--- src/umbraco.controls/CodeArea.cs | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Web.UI/umbraco_client/Editors/EditView.js b/src/Umbraco.Web.UI/umbraco_client/Editors/EditView.js index 48c32e5d8b..db723874e6 100644 --- a/src/Umbraco.Web.UI/umbraco_client/Editors/EditView.js +++ b/src/Umbraco.Web.UI/umbraco_client/Editors/EditView.js @@ -30,7 +30,7 @@ }, doSubmit: function () { - var codeVal = UmbEditor.GetCode(); + var codeVal = UmbClientMgr.contentFrame().UmbEditor.GetCode(); var self = this; umbraco.presentation.webservices.codeEditorSave.SaveTemplate( @@ -59,7 +59,7 @@ changeMasterPageFile: function ( ) { //var editor = document.getElementById(this._opts.sourceEditorId); var templateDropDown = this._opts.masterPageDropDown.get(0); - var templateCode = UmbEditor.GetCode(); + var templateCode = UmbClientMgr.contentFrame().UmbEditor.GetCode(); var newValue = templateDropDown.options[templateDropDown.selectedIndex].id; var layoutDefRegex = new RegExp("(@{[\\s\\S]*?Layout\\s*?=\\s*?)(\"[^\"]*?\"|null)(;[\\s\\S]*?})", "gi"); @@ -80,7 +80,7 @@ } } - UmbEditor.SetCode(templateCode); + UmbClientMgr.contentFrame().UmbEditor.SetCode(templateCode); return false; } diff --git a/src/umbraco.controls/CodeArea.cs b/src/umbraco.controls/CodeArea.cs index ba446b0cea..e93022c0bd 100644 --- a/src/umbraco.controls/CodeArea.cs +++ b/src/umbraco.controls/CodeArea.cs @@ -170,10 +170,13 @@ namespace umbraco.uicontrols OffSetX += 20; } - jsEventCode += @" - $(function () { + jsEventCode += @" + //TODO: for now this is a global var, need to refactor all this so that is using proper js standards + //with correct objects, and proper accessors to these objects. + var UmbEditor; + $(document).ready(function () { //create the editor - var UmbEditor = new Umbraco.Controls.CodeEditor.UmbracoEditor(" + (!CodeMirrorEnabled).ToString().ToLower() + @", '" + this.ClientID + @"'); + UmbEditor = new Umbraco.Controls.CodeEditor.UmbracoEditor(" + (!CodeMirrorEnabled).ToString().ToLower() + @", '" + this.ClientID + @"'); var m_textEditor = jQuery('#" + this.ClientID + @"'); //with codemirror adding divs for line numbers, we need to target a different element