From 81e56bed9efc615158316f7b49c0e24fb3906a45 Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Wed, 11 Jun 2014 07:08:38 +0200 Subject: [PATCH] Implementing Document Type Compositions in the Document Type Editor. Adds changes to the CMSNode and doc type related class which improves the internal usage of the new model based on IUmbracoEntity. --- .../Models/ContentTypeCompositionBase.cs | 11 +- .../Repositories/ContentTypeBaseRepository.cs | 26 +++- src/Umbraco.Web.UI/umbraco/config/lang/en.xml | 1 + .../umbraco/config/lang/en_us.xml | 1 + .../controls/ContentTypeControlNew.ascx | 21 ++- .../controls/ContentTypeControlNew.ascx.cs | 145 +++++++++++++++++- src/umbraco.cms/businesslogic/CMSNode.cs | 30 ++-- src/umbraco.cms/businesslogic/ContentType.cs | 19 ++- .../businesslogic/media/MediaType.cs | 20 ++- .../businesslogic/member/MemberType.cs | 6 +- .../businesslogic/web/DocumentType.cs | 47 +++--- 11 files changed, 258 insertions(+), 69 deletions(-) diff --git a/src/Umbraco.Core/Models/ContentTypeCompositionBase.cs b/src/Umbraco.Core/Models/ContentTypeCompositionBase.cs index c73ae8ee95..ec4b464c8a 100644 --- a/src/Umbraco.Core/Models/ContentTypeCompositionBase.cs +++ b/src/Umbraco.Core/Models/ContentTypeCompositionBase.cs @@ -93,8 +93,17 @@ namespace Umbraco.Core.Models { if (ContentTypeCompositionExists(alias)) { - var contentTypeComposition = ContentTypeComposition.First(x => x.Alias == alias); + var contentTypeComposition = ContentTypeComposition.FirstOrDefault(x => x.Alias == alias); + if (contentTypeComposition == null)//You can't remove a composition from another composition + return false; + RemovedContentTypeKeyTracker.Add(contentTypeComposition.Id); + + //If the ContentType we are removing has Compositions of its own these needs to be removed as well + var compositionIdsToRemove = contentTypeComposition.CompositionIds().ToList(); + if(compositionIdsToRemove.Any()) + RemovedContentTypeKeyTracker.AddRange(compositionIdsToRemove); + OnPropertyChanged(ContentTypeCompositionSelector); return _contentTypeComposition.Remove(contentTypeComposition); } diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs index b88b928e9c..64800f5708 100644 --- a/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs @@ -240,7 +240,7 @@ AND umbracoNode.id <> @id", { var nodeId = contentDto.NodeId; var propertyTypeId = propertyType.Id; - var propertySql = new Sql().Select("*") + var propertySql = new Sql().Select("cmsPropertyData.id") .From() .InnerJoin() .On( @@ -249,7 +249,7 @@ AND umbracoNode.id <> @id", .Where(x => x.Id == propertyTypeId); //Finally delete the properties that match our criteria for removing a ContentType from the composition - Database.Delete(propertySql); + Database.Delete(new Sql("WHERE id IN (" + propertySql.SQL + ")", propertySql.Arguments)); } } } @@ -285,7 +285,8 @@ AND umbracoNode.id <> @id", } } - if (((ICanBeDirty) entity).IsPropertyDirty("PropertyGroups") || entity.PropertyGroups.Any(x => x.IsDirty())) + if (((ICanBeDirty)entity).IsPropertyDirty("PropertyGroups") || + entity.PropertyGroups.Any(x => x.IsDirty())) { //Delete Tabs/Groups by excepting entries from db with entries from collections var dbPropertyGroups = @@ -346,6 +347,25 @@ AND umbracoNode.id <> @id", if (propertyType.HasIdentity == false) propertyType.Id = typePrimaryKey; //Set Id on new PropertyType } + + //If a Composition is removed we need to update/reset references to the PropertyGroups on that ContentType + if (((ICanBeDirty)entity).IsPropertyDirty("ContentTypeComposition") && + compositionBase != null && + compositionBase.RemovedContentTypeKeyTracker != null && + compositionBase.RemovedContentTypeKeyTracker.Any()) + { + foreach (var compositionId in compositionBase.RemovedContentTypeKeyTracker) + { + var dbPropertyGroups = + Database.Fetch("WHERE contenttypeNodeId = @Id", new { Id = compositionId }) + .Select(x => x.Id); + foreach (var propertyGroup in dbPropertyGroups) + { + Database.Update("SET parentGroupId = NULL WHERE parentGroupId = @TabId AND contenttypeNodeId = @ContentTypeNodeId", + new { TabId = propertyGroup, ContentTypeNodeId = entity.Id }); + } + } + } } protected IEnumerable GetAllowedContentTypeIds(int id) diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/en.xml b/src/Umbraco.Web.UI/umbraco/config/lang/en.xml index 16b943481b..945bb24abf 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/en.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/en.xml @@ -245,6 +245,7 @@ Allowed child node types + Document Type Compositions Create Delete tab Description diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml b/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml index ad78006b03..a5f687ecfe 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml @@ -251,6 +251,7 @@ Allowed child nodetypes + Document Type Compositions Create Delete tab Description diff --git a/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx b/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx index 6c8d26b4d6..1caf31bf5f 100644 --- a/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx +++ b/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx @@ -81,13 +81,20 @@
- - - - - - - + + + + + + + + + + + + + + diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs index 0f1fc3a090..15ef6a76e0 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs @@ -54,6 +54,9 @@ namespace umbraco.controls // "Structure" tab protected DualSelectbox DualAllowedContentTypes = new DualSelectbox(); + // "Structure" tab - Compositions + protected DualSelectbox DualContentTypeCompositions = new DualSelectbox(); + // "Info" tab public uicontrols.TabPage InfoTabPage; @@ -88,6 +91,7 @@ namespace umbraco.controls else { SetupStructurePane(); + SetupCompositionsPane(); } SetupGenericPropertiesPane(); @@ -105,7 +109,7 @@ namespace umbraco.controls 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); @@ -291,13 +295,13 @@ namespace umbraco.controls 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; + //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.Thumbnail = ddlThumbnails.SelectedValue; _contentType.ContentTypeItem.AllowedAsRoot = allowAtRoot.Checked; _contentType.ContentTypeItem.IsContainer = cb_isContainer.Checked; @@ -305,6 +309,48 @@ namespace umbraco.controls var ids = SaveAllowedChildTypes(); _contentType.ContentTypeItem.AllowedContentTypes = ids.Select(x => new ContentTypeSort {Id = new Lazy(() => x), SortOrder = i++}); + //Saving ContentType Compositions + var compositionIds = SaveCompositionContentTypes(); + var existingCompsitionIds = _contentType.ContentTypeItem.CompositionIds().ToList(); + if (compositionIds.Any()) + { + //Iterate ContentType Ids from the save-collection + foreach (var compositionId in compositionIds) + { + //If the compositionId is the Id of the current ContentType we skip it + if(_contentType.Id.Equals(compositionId)) continue; + + //If the Id already exists we'll just skip it + if (existingCompsitionIds.Any(x => x.Equals(compositionId))) continue; + + //New Ids will get added to the collection + var compositionType = Services.ContentTypeService.GetContentType(compositionId); + var added = _contentType.ContentTypeItem.AddContentType(compositionType); + //TODO if added=false then return error message + } + + //Iterate the set except of existing and new Ids + var removeIds = existingCompsitionIds.Except(compositionIds); + foreach (var removeId in removeIds) + { + //Remove ContentTypes that was deselected in the list + var compositionType = Services.ContentTypeService.GetContentType(removeId); + var removed = _contentType.ContentTypeItem.RemoveContentType(compositionType.Alias); + } + } + else if (existingCompsitionIds.Any()) + { + //Iterate the set except of existing and new Ids + var removeIds = existingCompsitionIds.Except(compositionIds); + foreach (var removeId in removeIds) + { + //Remove ContentTypes that was deselected in the list + var compositionType = Services.ContentTypeService.GetContentType(removeId); + var removed = _contentType.ContentTypeItem.RemoveContentType(compositionType.Alias); + } + } + + var tabs = SaveTabs(); foreach (var tab in tabs) { @@ -319,6 +365,7 @@ namespace umbraco.controls } SavePropertyType(asyncState.SaveArgs, _contentType.ContentTypeItem); + //SavePropertyType(state.SaveArgs, _contentType.ContentTypeItem); UpdatePropertyTypes(_contentType.ContentTypeItem); if (DocumentTypeCallback != null) @@ -342,8 +389,10 @@ namespace umbraco.controls catch (DuplicateNameException ex) { DuplicateAliasValidator.IsValid = false; - asyncState.SaveArgs.IconType = BasePage.speechBubbleIcon.error; - asyncState.SaveArgs.Message = ex.Message; + //asyncState.SaveArgs.IconType = BasePage.speechBubbleIcon.error; + state.SaveArgs.IconType = BasePage.speechBubbleIcon.error; + //asyncState.SaveArgs.Message = ex.Message; + state.SaveArgs.Message = ex.Message; return; } @@ -580,6 +629,56 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }}); #endregion + #region Compositions Pane + + private void SetupCompositionsPane() + { + DualContentTypeCompositions.ID = "compositionContentTypes"; + DualContentTypeCompositions.Width = 175; + + 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() + { + var tmp = new ArrayList(); + foreach (ListItem li in lstContentTypeCompositions.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 "Generic properties" Pane private void SetupGenericPropertiesPane() @@ -1625,5 +1724,41 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }}); /// 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.cms/businesslogic/CMSNode.cs b/src/umbraco.cms/businesslogic/CMSNode.cs index 9b0712df0e..310439dad9 100644 --- a/src/umbraco.cms/businesslogic/CMSNode.cs +++ b/src/umbraco.cms/businesslogic/CMSNode.cs @@ -54,7 +54,7 @@ namespace umbraco.cms.businesslogic private bool _hasChildrenInitialized; private string m_image = "default.png"; private bool? _isTrashed = null; - private IUmbracoEntity _entity; + protected IUmbracoEntity Entity; #endregion @@ -431,7 +431,7 @@ namespace umbraco.cms.businesslogic protected internal CMSNode(IUmbracoEntity entity) { _id = entity.Id; - _entity = entity; + Entity = entity; } protected internal CMSNode(IEntity entity) @@ -750,8 +750,8 @@ order by level,sortOrder"; _sortOrder = value; SqlHelper.ExecuteNonQuery("update umbracoNode set sortOrder = '" + value + "' where id = " + this.Id.ToString()); - if (_entity != null) - _entity.SortOrder = value; + if (Entity != null) + Entity.SortOrder = value; } } @@ -815,8 +815,8 @@ order by level,sortOrder"; _parentid = value.Id; SqlHelper.ExecuteNonQuery("update umbracoNode set parentId = " + value.Id.ToString() + " where id = " + this.Id.ToString()); - if (_entity != null) - _entity.ParentId = value.Id; + if (Entity != null) + Entity.ParentId = value.Id; } } @@ -833,8 +833,8 @@ order by level,sortOrder"; _path = value; SqlHelper.ExecuteNonQuery("update umbracoNode set path = '" + _path + "' where id = " + this.Id.ToString()); - if (_entity != null) - _entity.Path = value; + if (Entity != null) + Entity.Path = value; } } @@ -851,8 +851,8 @@ order by level,sortOrder"; _level = value; SqlHelper.ExecuteNonQuery("update umbracoNode set level = " + _level.ToString() + " where id = " + this.Id.ToString()); - if (_entity != null) - _entity.Level = value; + if (Entity != null) + Entity.Level = value; } } @@ -972,8 +972,8 @@ order by level,sortOrder"; SqlHelper.CreateParameter("@text", value.Trim()), SqlHelper.CreateParameter("@id", this.Id)); - if (_entity != null) - _entity.Name = value; + if (Entity != null) + Entity.Name = value; } } @@ -1026,8 +1026,8 @@ order by level,sortOrder"; { _text = txt; - if (_entity != null) - _entity.Name = txt; + if (Entity != null) + Entity.Name = txt; } /// @@ -1166,7 +1166,7 @@ order by level,sortOrder"; _userId = content.CreatorId; _createDate = content.CreateDate; _isTrashed = content.Trashed; - _entity = content; + Entity = content; } internal protected void PopulateCMSNodeFromUmbracoEntity(IAggregateRoot content, Guid objectType) diff --git a/src/umbraco.cms/businesslogic/ContentType.cs b/src/umbraco.cms/businesslogic/ContentType.cs index 58dbde48a3..822bc79cc0 100644 --- a/src/umbraco.cms/businesslogic/ContentType.cs +++ b/src/umbraco.cms/businesslogic/ContentType.cs @@ -253,7 +253,11 @@ namespace umbraco.cms.businesslogic private List _allowedChildContentTypeIDs; private List _virtualTabs; - protected internal IContentTypeComposition ContentTypeItem; + protected internal IContentTypeComposition ContentTypeItem + { + get { return base.Entity as IContentTypeComposition; } + set { base.Entity = value; } + } #endregion @@ -632,7 +636,10 @@ namespace umbraco.cms.businesslogic { if (m_masterContentTypes == null) { - m_masterContentTypes = new List(); + m_masterContentTypes = ContentTypeItem == null + ? new List() + : ContentTypeItem.CompositionIds().ToList(); + if (ContentTypeItem == null) { //TODO Make this recursive, so it looks up Masters of the Master ContentType @@ -648,10 +655,6 @@ namespace umbraco.cms.businesslogic } } } - else - { - m_masterContentTypes = ContentTypeItem.CompositionIds().ToList(); - } } return m_masterContentTypes; @@ -1107,8 +1110,8 @@ namespace umbraco.cms.businesslogic _thumbnail = contentType.Thumbnail; _description = contentType.Description; - if (ContentTypeItem == null) - ContentTypeItem = contentType; + /*if (ContentTypeItem == null) + ContentTypeItem = contentType;*/ } protected void PopulateContentTypeNodeFromReader(IRecordsReader dr) diff --git a/src/umbraco.cms/businesslogic/media/MediaType.cs b/src/umbraco.cms/businesslogic/media/MediaType.cs index 5f00c9388a..6923181690 100644 --- a/src/umbraco.cms/businesslogic/media/MediaType.cs +++ b/src/umbraco.cms/businesslogic/media/MediaType.cs @@ -48,7 +48,11 @@ namespace umbraco.cms.businesslogic.media #region Private Members - private IMediaType _mediaType; + private IMediaType MediaTypeItem + { + get { return base.ContentTypeItem as IMediaType; } + set { base.ContentTypeItem = value; } + } #endregion @@ -121,17 +125,17 @@ namespace umbraco.cms.businesslogic.media if (!e.Cancel) { if (MasterContentType != 0) - _mediaType.ParentId = MasterContentType; + MediaTypeItem.ParentId = MasterContentType; foreach (var masterContentType in MasterContentTypes) { var contentType = ApplicationContext.Current.Services.ContentTypeService.GetMediaType(masterContentType); - _mediaType.AddContentType(contentType); + MediaTypeItem.AddContentType(contentType); } var current = User.GetCurrent(); int userId = current == null ? 0 : current.Id; - ApplicationContext.Current.Services.ContentTypeService.Save(_mediaType, userId); + ApplicationContext.Current.Services.ContentTypeService.Save(MediaTypeItem, userId); base.Save(); @@ -155,7 +159,7 @@ namespace umbraco.cms.businesslogic.media throw new ArgumentException("Can't delete a Media Type used as a Master Content Type. Please remove all references first!"); } - ApplicationContext.Current.Services.ContentTypeService.Delete(_mediaType); + ApplicationContext.Current.Services.ContentTypeService.Delete(MediaTypeItem); FireAfterDelete(e); } @@ -175,10 +179,10 @@ namespace umbraco.cms.businesslogic.media #region Private Methods private void SetupNode(IMediaType mediaType) { - _mediaType = mediaType; + MediaTypeItem = mediaType; - base.PopulateContentTypeFromContentTypeBase(_mediaType); - base.PopulateCMSNodeFromUmbracoEntity(_mediaType, _objectType); + base.PopulateContentTypeFromContentTypeBase(MediaTypeItem); + base.PopulateCMSNodeFromUmbracoEntity(MediaTypeItem, _objectType); } #endregion diff --git a/src/umbraco.cms/businesslogic/member/MemberType.cs b/src/umbraco.cms/businesslogic/member/MemberType.cs index e73c69a5ed..52aa756f51 100644 --- a/src/umbraco.cms/businesslogic/member/MemberType.cs +++ b/src/umbraco.cms/businesslogic/member/MemberType.cs @@ -19,7 +19,11 @@ namespace umbraco.cms.businesslogic.member #region Private Members internal static readonly Guid ObjectType = new Guid(Constants.ObjectTypes.MemberType); - internal IMemberType MemberTypeItem; + internal IMemberType MemberTypeItem + { + get { return base.ContentTypeItem as IMemberType; } + set { base.ContentTypeItem = value; } + } #endregion diff --git a/src/umbraco.cms/businesslogic/web/DocumentType.cs b/src/umbraco.cms/businesslogic/web/DocumentType.cs index 2138504539..292bb3379a 100644 --- a/src/umbraco.cms/businesslogic/web/DocumentType.cs +++ b/src/umbraco.cms/businesslogic/web/DocumentType.cs @@ -58,7 +58,12 @@ namespace umbraco.cms.businesslogic.web private int _defaultTemplate; private bool _hasChildrenInitialized = false; private bool _hasChildren; - private IContentType _contentType; + + private IContentType ContentType + { + get { return base.ContentTypeItem as IContentType; } + set { base.ContentTypeItem = value; } + } #endregion @@ -203,7 +208,7 @@ namespace umbraco.cms.businesslogic.web if (_defaultTemplate != 0) { var template = ApplicationContext.Current.Services.FileService.GetTemplate(_defaultTemplate); - _contentType.SetDefaultTemplate(template); + ContentType.SetDefaultTemplate(template); } } } @@ -238,7 +243,7 @@ namespace umbraco.cms.businesslogic.web _templateIds.Add(t.Id); } - _contentType.AllowedTemplates = templates; + ContentType.AllowedTemplates = templates; } } @@ -428,9 +433,9 @@ namespace umbraco.cms.businesslogic.web // remove from list of document type templates if (_templateIds.Contains(templateId)) { - var template = _contentType.AllowedTemplates.FirstOrDefault(x => x.Id == templateId); + var template = ContentType.AllowedTemplates.FirstOrDefault(x => x.Id == templateId); if (template != null) - _contentType.RemoveTemplate(template); + ContentType.RemoveTemplate(template); _templateIds.Remove(templateId); } @@ -454,7 +459,7 @@ namespace umbraco.cms.businesslogic.web throw new ArgumentException("Can't delete a Document Type used as a Master Content Type. Please remove all references first!"); } - ApplicationContext.Current.Services.ContentTypeService.Delete(_contentType); + ApplicationContext.Current.Services.ContentTypeService.Delete(ContentType); clearTemplates(); @@ -464,7 +469,7 @@ namespace umbraco.cms.businesslogic.web public void clearTemplates() { - _contentType.AllowedTemplates = new List(); + ContentType.AllowedTemplates = new List(); _templateIds.Clear(); } @@ -558,7 +563,7 @@ namespace umbraco.cms.businesslogic.web public void RemoveDefaultTemplate() { _defaultTemplate = 0; - _contentType.SetDefaultTemplate(null); + ContentType.SetDefaultTemplate(null); } public bool HasTemplate() @@ -578,17 +583,17 @@ namespace umbraco.cms.businesslogic.web if (!e.Cancel) { if (MasterContentType != 0) - _contentType.ParentId = MasterContentType; + ContentType.ParentId = MasterContentType; - foreach (var masterContentType in MasterContentTypes) + /*foreach (var masterContentType in MasterContentTypes) { var contentType = ApplicationContext.Current.Services.ContentTypeService.GetContentType(masterContentType); - _contentType.AddContentType(contentType); - } + ContentType.AddContentType(contentType); + }*/ var current = User.GetCurrent(); int userId = current == null ? 0 : current.Id; - ApplicationContext.Current.Services.ContentTypeService.Save(_contentType, userId); + ApplicationContext.Current.Services.ContentTypeService.Save(ContentType, userId); base.Save(); FireAfterSave(e); @@ -626,17 +631,17 @@ namespace umbraco.cms.businesslogic.web #region Private Methods private void SetupNode(IContentType contentType) { - _contentType = contentType; - foreach (var template in _contentType.AllowedTemplates.Where(t => t != null)) + ContentType = contentType; + foreach (var template in ContentType.AllowedTemplates.Where(t => t != null)) { _templateIds.Add(template.Id); } - if (_contentType.DefaultTemplate != null) - _defaultTemplate = _contentType.DefaultTemplate.Id; + if (ContentType.DefaultTemplate != null) + _defaultTemplate = ContentType.DefaultTemplate.Id; - base.PopulateContentTypeFromContentTypeBase(_contentType); - base.PopulateCMSNodeFromUmbracoEntity(_contentType, _objectType); + base.PopulateContentTypeFromContentTypeBase(ContentType); + base.PopulateCMSNodeFromUmbracoEntity(ContentType, _objectType); } #endregion @@ -680,9 +685,9 @@ namespace umbraco.cms.businesslogic.web { if (AfterSave != null) { - var updated = this._contentType == null + var updated = this.ContentType == null ? new DocumentType(this.Id) - : new DocumentType(this._contentType); + : new DocumentType(this.ContentType); AfterSave(updated, e); } }