public SortNode GetNodes(int ParentId, string App) { if (BasePage.ValidateUserContextID(BasePage.umbracoUserContextID)) { var parent = new SortNode { Id = ParentId }; var nodes = new ArrayList(); var cmsNode = new cms.businesslogic.CMSNode(ParentId); // Root nodes? if (ParentId == -1) { if (App == "media") { foreach (cms.businesslogic.media.Media child in cms.businesslogic.media.Media.GetRootMedias()) { nodes.Add(new SortNode(child.Id, child.sortOrder, child.Text, child.CreateDateTime)); } } else { foreach (Document child in Document.GetRootDocuments()) { nodes.Add(new SortNode(child.Id, child.sortOrder, child.Text, child.CreateDateTime)); } } } else { // "hack for stylesheet" if (App == "settings") { var styleSheet = new StyleSheet(cmsNode.Id); foreach (var child in styleSheet.Properties) { nodes.Add(new SortNode(child.Id, child.sortOrder, child.Text, child.CreateDateTime)); } } else { //store children array here because iterating over an Array property object is very inneficient. var children = cmsNode.Children; foreach (cms.businesslogic.CMSNode child in children) { nodes.Add(new SortNode(child.Id, child.sortOrder, child.Text, child.CreateDateTime)); } } } parent.SortNodes = (SortNode[])nodes.ToArray(typeof(SortNode)); return(parent); } throw new ArgumentException("User not logged in"); }
public SortNode GetNodes(int ParentId, string App) { if (BasePage.ValidateUserContextID(BasePage.umbracoUserContextID)) { SortNode parent = new SortNode(); parent.Id = ParentId; ArrayList _nodes = new ArrayList(); cms.businesslogic.CMSNode n = new cms.businesslogic.CMSNode(ParentId); // Root nodes? if (ParentId == -1) { if (App == "media") { foreach (cms.businesslogic.media.Media child in cms.businesslogic.media.Media.GetRootMedias()) _nodes.Add(new SortNode(child.Id, child.sortOrder, child.Text, child.CreateDateTime)); } else foreach (cms.businesslogic.web.Document child in cms.businesslogic.web.Document.GetRootDocuments()) _nodes.Add(new SortNode(child.Id, child.sortOrder, child.Text, child.CreateDateTime)); } else { // "hack for stylesheet" if (App == "settings") { StyleSheet ss = new StyleSheet(n.Id); foreach (cms.businesslogic.web.StylesheetProperty child in ss.Properties) _nodes.Add(new SortNode(child.Id, child.sortOrder, child.Text, child.CreateDateTime)); } else { //store children array here because iterating over an Array property object is very inneficient. var children = n.Children; foreach (cms.businesslogic.CMSNode child in children) { _nodes.Add(new SortNode(child.Id, child.sortOrder, child.Text, child.CreateDateTime)); } } } parent.SortNodes = (SortNode[])_nodes.ToArray(typeof(SortNode)); return parent; } throw new ArgumentException("User not logged in"); }
public SortNode GetNodes(int ParentId, string App) { if (BasePage.ValidateUserContextID(BasePage.umbracoUserContextID)) { var parent = new SortNode { Id = ParentId }; var nodes = new List <SortNode>(); var entityService = base.ApplicationContext.Services.EntityService; // Root nodes? if (ParentId == -1) { if (App == "media") { var rootMedia = entityService.GetRootEntities(UmbracoObjectTypes.Media); nodes.AddRange(rootMedia.Select(media => new SortNode(media.Id, media.SortOrder, media.Name, media.CreateDate))); } else { var rootContent = entityService.GetRootEntities(UmbracoObjectTypes.Document); nodes.AddRange(rootContent.Select(content => new SortNode(content.Id, content.SortOrder, content.Name, content.CreateDate))); } } else { // "hack for stylesheet" if (App == "settings") { var cmsNode = new cms.businesslogic.CMSNode(ParentId); var styleSheet = new StyleSheet(cmsNode.Id); nodes.AddRange(styleSheet.Properties.Select(child => new SortNode(child.Id, child.sortOrder, child.Text, child.CreateDateTime))); } else { var children = entityService.GetChildren(ParentId); nodes.AddRange(children.Select(child => new SortNode(child.Id, child.SortOrder, child.Name, child.CreateDate))); } } parent.SortNodes = nodes.ToArray(); return(parent); } throw new ArgumentException("User not logged in"); }
public SortNode GetNodes(int ParentId, string App) { if (BasePage.ValidateUserContextID(BasePage.umbracoUserContextID)) { var parent = new SortNode { Id = ParentId }; var nodes = new List<SortNode>(); var entityService = base.ApplicationContext.Services.EntityService; // Root nodes? if (ParentId == -1) { if (App == "media") { var rootMedia = entityService.GetRootEntities(UmbracoObjectTypes.Media); nodes.AddRange(rootMedia.Select(media => new SortNode(media.Id, media.SortOrder, media.Name, media.CreateDate))); } else { var rootContent = entityService.GetRootEntities(UmbracoObjectTypes.Document); nodes.AddRange(rootContent.Select(content => new SortNode(content.Id, content.SortOrder, content.Name, content.CreateDate))); } } else { // "hack for stylesheet" if (App == "settings") { var cmsNode = new cms.businesslogic.CMSNode(ParentId); var styleSheet = new StyleSheet(cmsNode.Id); nodes.AddRange(styleSheet.Properties.Select(child => new SortNode(child.Id, child.sortOrder, child.Text, child.CreateDateTime))); } else { var children = entityService.GetChildren(ParentId); nodes.AddRange(children.Select(child => new SortNode(child.Id, child.SortOrder, child.Name, child.CreateDate))); } } parent.SortNodes = nodes.ToArray(); return parent; } throw new ArgumentException("User not logged in"); }
public SortNode GetNodes(string ParentId, string App) { if (BasePage.ValidateUserContextID(BasePage.umbracoUserContextID)) { var nodes = new List <SortNode>(); // "hack for stylesheet" if (App == "settings") { var stylesheet = Services.FileService.GetStylesheetByName(ParentId.EnsureEndsWith(".css")); if (stylesheet == null) { throw new InvalidOperationException("No stylesheet found by name " + ParentId); } var sort = 0; foreach (var child in stylesheet.Properties) { nodes.Add(new SortNode(child.Name.GetHashCode(), sort, child.Name, DateTime.Now)); sort++; } return(new SortNode() { SortNodes = nodes.ToArray() }); } else { var asInt = int.Parse(ParentId); var parent = new SortNode { Id = asInt }; var entityService = base.ApplicationContext.Services.EntityService; // Root nodes? if (asInt == -1) { if (App == "media") { var rootMedia = entityService.GetRootEntities(UmbracoObjectTypes.Media); nodes.AddRange(rootMedia.Select(media => new SortNode(media.Id, media.SortOrder, media.Name, media.CreateDate))); } else { var rootContent = entityService.GetRootEntities(UmbracoObjectTypes.Document); nodes.AddRange(rootContent.Select(content => new SortNode(content.Id, content.SortOrder, content.Name, content.CreateDate))); } } else { var children = entityService.GetChildren(asInt); nodes.AddRange(children.Select(child => new SortNode(child.Id, child.SortOrder, child.Name, child.CreateDate))); } parent.SortNodes = nodes.ToArray(); return(parent); } } throw new ArgumentException("User not logged in"); }