Fixes U4-1386 structure problem where the same DocType would show up multiple times.
Re-wired the tree to use the new api as its simply used for loading availab doc types.
This commit is contained in:
@@ -3,6 +3,8 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Services;
|
||||
using umbraco.BusinessLogic;
|
||||
using umbraco.BusinessLogic.Actions;
|
||||
using umbraco.interfaces;
|
||||
@@ -192,6 +194,14 @@ namespace umbraco.cms.presentation.Trees
|
||||
|
||||
private XmlTree m_xTree = new XmlTree();
|
||||
|
||||
/// <summary>
|
||||
/// Provides easy access to the ServiceContext
|
||||
/// </summary>
|
||||
protected internal ServiceContext Services
|
||||
{
|
||||
get { return ApplicationContext.Current.Services; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the class if it hasn't been done already
|
||||
/// </summary>
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using Umbraco.Core.Services;
|
||||
using umbraco.businesslogic;
|
||||
using umbraco.cms.businesslogic.media;
|
||||
using umbraco.cms.presentation.Trees;
|
||||
|
||||
namespace umbraco
|
||||
@@ -29,14 +30,25 @@ function openMediaType(id) {
|
||||
|
||||
public override void Render(ref XmlTree tree)
|
||||
{
|
||||
foreach (var dt in MediaType.GetAllAsList())
|
||||
var mediaTypes = Service.GetMediaTypeChildren(base.m_id);
|
||||
|
||||
foreach (var mediaType in mediaTypes)
|
||||
{
|
||||
var hasChildren = Service.MediaTypeHasChildren(mediaType.Id);
|
||||
|
||||
XmlTreeNode xNode = XmlTreeNode.Create(this);
|
||||
xNode.NodeID = dt.Id.ToString();
|
||||
xNode.Text = dt.Text;
|
||||
xNode.Action = string.Format("javascript:openMediaType({0});", dt.Id);
|
||||
xNode.NodeID = mediaType.Id.ToString(CultureInfo.InvariantCulture);
|
||||
xNode.Text = mediaType.Name;
|
||||
xNode.Action = string.Format("javascript:openMediaType({0});", mediaType.Id);
|
||||
xNode.Icon = "settingDataType.gif";
|
||||
xNode.OpenIcon = "settingDataType.gif";
|
||||
xNode.Source = GetTreeServiceUrl(mediaType.Id);
|
||||
xNode.HasChildren = hasChildren;
|
||||
if (hasChildren)
|
||||
{
|
||||
xNode.Icon = "settingMasterDataType.gif";
|
||||
xNode.OpenIcon = "settingMasterDataType.gif";
|
||||
}
|
||||
|
||||
OnBeforeNodeRender(ref tree, ref xNode, EventArgs.Empty);
|
||||
if (xNode != null)
|
||||
@@ -48,6 +60,9 @@ function openMediaType(id) {
|
||||
}
|
||||
}
|
||||
|
||||
private IContentTypeService Service
|
||||
{
|
||||
get { return Services.ContentTypeService; }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,28 +1,11 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Xml;
|
||||
using System.Configuration;
|
||||
using umbraco.BasePages;
|
||||
using umbraco.BusinessLogic;
|
||||
using Umbraco.Core.Services;
|
||||
using umbraco.businesslogic;
|
||||
using umbraco.cms.businesslogic;
|
||||
using umbraco.cms.businesslogic.cache;
|
||||
using umbraco.cms.businesslogic.contentitem;
|
||||
using umbraco.cms.businesslogic.datatype;
|
||||
using umbraco.cms.businesslogic.language;
|
||||
using umbraco.cms.businesslogic.media;
|
||||
using umbraco.cms.businesslogic.member;
|
||||
using umbraco.cms.businesslogic.property;
|
||||
using umbraco.cms.businesslogic.web;
|
||||
using umbraco.interfaces;
|
||||
using umbraco.DataLayer;
|
||||
using umbraco.BusinessLogic.Actions;
|
||||
using umbraco.BusinessLogic.Utils;
|
||||
using umbraco.cms.presentation.Trees;
|
||||
|
||||
|
||||
@@ -74,23 +57,22 @@ function openNodeType(id) {
|
||||
|
||||
public override void Render(ref XmlTree tree)
|
||||
{
|
||||
List<DocumentType> docTypes;
|
||||
docTypes = base.m_id == -1
|
||||
? DocumentType.GetAllAsList().FindAll(dt => dt.MasterContentType == 0)
|
||||
: DocumentType.GetAllAsList().FindAll(dt => dt.MasterContentTypes.Contains(base.m_id));
|
||||
var docTypes = Service.GetContentTypeChildren(base.m_id);
|
||||
|
||||
|
||||
foreach (DocumentType dt in docTypes)
|
||||
foreach (var docType in docTypes)
|
||||
{
|
||||
var hasChildren = Service.HasChildren(docType.Id);
|
||||
|
||||
XmlTreeNode xNode = XmlTreeNode.Create(this);
|
||||
xNode.NodeID = dt.Id.ToString();
|
||||
xNode.Text = dt.Text;
|
||||
xNode.Action = "javascript:openNodeType(" + dt.Id + ");";
|
||||
xNode.NodeID = docType.Id.ToString(CultureInfo.InvariantCulture);
|
||||
xNode.Text = docType.Name;
|
||||
xNode.Action = "javascript:openNodeType(" + docType.Id + ");";
|
||||
xNode.Icon = "settingDataType.gif";
|
||||
xNode.OpenIcon = "settingDataType.gif";
|
||||
xNode.Source = GetTreeServiceUrl(dt.Id);
|
||||
xNode.HasChildren = dt.HasChildren;
|
||||
if (dt.HasChildren) {
|
||||
xNode.Source = GetTreeServiceUrl(docType.Id);
|
||||
xNode.HasChildren = hasChildren;
|
||||
if (hasChildren)
|
||||
{
|
||||
xNode.Icon = "settingMasterDataType.gif";
|
||||
xNode.OpenIcon = "settingMasterDataType.gif";
|
||||
}
|
||||
@@ -101,9 +83,12 @@ function openNodeType(id) {
|
||||
tree.Add(xNode);
|
||||
OnAfterNodeRender(ref tree, ref xNode, EventArgs.Empty);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private IContentTypeService Service
|
||||
{
|
||||
get { return Services.ContentTypeService; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user