protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings) { //get the parent id from the query strings var parentId = queryStrings.GetRequiredString("parentId"); var tree = GetTree(queryStrings); var rootIds = new[] { Core.Constants.System.Root.ToString(CultureInfo.InvariantCulture), Core.Constants.System.RecycleBinContent.ToString(CultureInfo.InvariantCulture), Core.Constants.System.RecycleBinMedia.ToString(CultureInfo.InvariantCulture) }; //if the id and the parentId are both -1 then we need to get the menu for the root node if (rootIds.Contains(id) && parentId == "-1") { var attempt = tree.TryGetMenuFromLegacyTreeRootNode(queryStrings, Url); if (attempt.Success == false) { var msg = "Could not render menu for root node for treeType " + queryStrings.GetRequiredString("treeType"); LogHelper.Error <LegacyTreeController>(msg, attempt.Exception); throw new ApplicationException(msg); } foreach (var menuItem in attempt.Result.Items) { menuItem.Name = global::umbraco.ui.Text("actions", menuItem.Alias); } return(attempt.Result); } else { var attempt = tree.TryGetMenuFromLegacyTreeNode(parentId, id, queryStrings, Url); if (attempt.Success == false) { var msg = "Could not render menu for treeType " + queryStrings.GetRequiredString("treeType") + " for node id " + parentId; LogHelper.Error <LegacyTreeController>(msg, attempt.Exception); throw new ApplicationException(msg); } foreach (var menuItem in attempt.Result.Items) { menuItem.Name = global::umbraco.ui.Text("actions", menuItem.Alias); } return(attempt.Result); } }
protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings) { var tree = GetTree(queryStrings); var attempt = tree.TryLoadFromLegacyTree(id, queryStrings, Url, tree.ApplicationAlias); if (attempt.Success == false) { var msg = "Could not render tree " + queryStrings.GetRequiredString("treeType") + " for node id " + id; LogHelper.Error<LegacyTreeController>(msg, attempt.Exception); throw new ApplicationException(msg); } return attempt.Result; }
private ApplicationTree GetTree(FormDataCollection queryStrings) { //need to ensure we have a tree type var treeType = queryStrings.GetRequiredString("treeType"); //now we'll look up that tree var tree = Services.ApplicationTreeService.GetByAlias(treeType); if (tree == null) { throw new InvalidOperationException("No tree found with alias " + treeType); } return(tree); }
protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings) { var tree = GetTree(queryStrings); var attempt = tree.TryLoadFromLegacyTree(id, queryStrings, Url, tree.ApplicationAlias); if (attempt.Success == false) { var msg = "Could not render tree " + queryStrings.GetRequiredString("treeType") + " for node id " + id; LogHelper.Error <LegacyTreeController>(msg, attempt.Exception); throw new ApplicationException(msg); } return(attempt.Result); }
internal static Attempt <MenuItemCollection> TryGetMenuFromLegacyTreeRootNode(this ApplicationTree appTree, FormDataCollection formCollection, UrlHelper urlHelper) { var rootAttempt = appTree.TryGetRootXmlNodeFromLegacyTree(formCollection, urlHelper); if (rootAttempt.Success == false) { return(Attempt <MenuItemCollection> .Fail(rootAttempt.Exception)); } var currentSection = formCollection.GetRequiredString("section"); var result = LegacyTreeDataConverter.ConvertFromLegacyMenu(rootAttempt.Result, currentSection); return(Attempt.Succeed(result)); }
protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings) { //get the parent id from the query strings var parentId = queryStrings.GetRequiredString("parentId"); var tree = GetTree(queryStrings); var rootIds = new[] { Core.Constants.System.Root.ToString(CultureInfo.InvariantCulture), Core.Constants.System.RecycleBinContent.ToString(CultureInfo.InvariantCulture), Core.Constants.System.RecycleBinMedia.ToString(CultureInfo.InvariantCulture) }; //if the id and the parentId are both -1 then we need to get the menu for the root node if (rootIds.Contains(id) && parentId == "-1") { var attempt = tree.TryGetMenuFromLegacyTreeRootNode(queryStrings, Url); if (attempt.Success == false) { var msg = "Could not render menu for root node for treeType " + queryStrings.GetRequiredString("treeType"); LogHelper.Error<LegacyTreeController>(msg, attempt.Exception); throw new ApplicationException(msg); } foreach (var menuItem in attempt.Result.Items) { menuItem.Name = global::umbraco.ui.Text("actions", menuItem.Alias); } return attempt.Result; } else { var attempt = tree.TryGetMenuFromLegacyTreeNode(parentId, id, queryStrings, Url); if (attempt.Success == false) { var msg = "Could not render menu for treeType " + queryStrings.GetRequiredString("treeType") + " for node id " + parentId; LogHelper.Error<LegacyTreeController>(msg, attempt.Exception); throw new ApplicationException(msg); } foreach (var menuItem in attempt.Result.Items) { menuItem.Name = global::umbraco.ui.Text("actions", menuItem.Alias); } return attempt.Result; } }
internal static Attempt <MenuItemCollection> TryGetMenuFromLegacyTreeNode(this ApplicationTree appTree, string parentId, string nodeId, FormDataCollection formCollection, UrlHelper urlHelper) { var xTreeAttempt = appTree.TryGetXmlTree(parentId, formCollection); if (xTreeAttempt.Success == false) { return(Attempt <MenuItemCollection> .Fail(xTreeAttempt.Exception)); } var currentSection = formCollection.GetRequiredString("section"); var result = LegacyTreeDataConverter.ConvertFromLegacyMenu(nodeId, xTreeAttempt.Result, currentSection); if (result == null) { return(Attempt <MenuItemCollection> .Fail(new ApplicationException("Could not find the node with id " + nodeId + " in the collection of nodes contained with parent id " + parentId))); } return(Attempt.Succeed(result)); }
private ApplicationTree GetTree(FormDataCollection queryStrings) { //need to ensure we have a tree type var treeType = queryStrings.GetRequiredString("treeType"); //now we'll look up that tree var tree = Services.ApplicationTreeService.GetByAlias(treeType); if (tree == null) throw new InvalidOperationException("No tree found with alias " + treeType); return tree; }
internal static Attempt<MenuItemCollection> TryGetMenuFromLegacyTreeNode(this ApplicationTree appTree, string parentId, string nodeId, FormDataCollection formCollection, UrlHelper urlHelper) { var xTreeAttempt = appTree.TryGetXmlTree(parentId, formCollection); if (xTreeAttempt.Success == false) { return Attempt<MenuItemCollection>.Fail(xTreeAttempt.Exception); } var currentSection = formCollection.GetRequiredString("section"); var result = LegacyTreeDataConverter.ConvertFromLegacyMenu(nodeId, xTreeAttempt.Result, currentSection); if (result == null) { return Attempt<MenuItemCollection>.Fail(new ApplicationException("Could not find the node with id " + nodeId + " in the collection of nodes contained with parent id " + parentId)); } return Attempt.Succeed(result); }
internal static Attempt<MenuItemCollection> TryGetMenuFromLegacyTreeRootNode(this ApplicationTree appTree, FormDataCollection formCollection, UrlHelper urlHelper) { var rootAttempt = appTree.TryGetRootXmlNodeFromLegacyTree(formCollection, urlHelper); if (rootAttempt.Success == false) { return Attempt<MenuItemCollection>.Fail(rootAttempt.Exception); } var currentSection = formCollection.GetRequiredString("section"); var result = LegacyTreeDataConverter.ConvertFromLegacyMenu(rootAttempt.Result, currentSection); return Attempt.Succeed(result); }