/// <summary> /// Returns the an XmlTree based on the current http request /// </summary> /// <returns></returns> public XmlTree GetXmlTree(HttpContext context) { var treeParams = TreeRequestParams.FromQueryStrings(); //validate the current user for the request app! AuthorizeRequest(treeParams.Application, true); if (string.IsNullOrEmpty(treeParams.TreeType)) { if (!string.IsNullOrEmpty(treeParams.Application)) { LoadAppTrees(treeParams, context); } else { return(new XmlTree()); //returns an empty tree } } else { LoadTree(treeParams, context); } return(_xTree); }
/// <summary> /// Load an empty tree structure to show the end user that there was a problem loading the tree. /// </summary> private void LoadNullTree(TreeRequestParams treeParams) { BaseTree nullTree = new NullTree(treeParams.Application); nullTree.SetTreeParameters(treeParams); nullTree.Render(ref _xTree); }
/// <summary> /// Initializes the control and looks up the tree structures that are required to be rendered. /// Properties of the control (or SetTreeService) need to be set before pre render or calling /// GetJSONContextMenu or GetJSONNode /// </summary> protected void Initialize() { //use the query strings if the TreeParams isn't explicitly set if (m_TreeService == null) { m_TreeService = TreeRequestParams.FromQueryStrings().CreateTreeService(); } m_TreeService.App = GetCurrentApp(); // Validate permissions if (!BasePages.BasePage.ValidateUserContextID(BasePages.BasePage.umbracoUserContextID)) { return; } UmbracoEnsuredPage page = new UmbracoEnsuredPage(); if (!page.ValidateUserApp(GetCurrentApp())) { throw new ArgumentException("The current user doesn't have access to this application. Please contact the system administrator."); } //find all tree definitions that have the current application alias that are ACTIVE. //if an explicit tree has been requested, then only load that tree in. //m_ActiveTreeDefs = TreeDefinitionCollection.Instance.FindActiveTrees(GetCurrentApp()); m_ActiveTreeDefs = Services.ApplicationTreeService.GetApplicationTrees(GetCurrentApp(), true).ToList(); if (!string.IsNullOrEmpty(this.TreeType)) { m_ActiveTreeDefs = m_ActiveTreeDefs .Where(x => x.Alias == this.TreeType) .ToList(); //this will only return 1 } //find all tree defs that exists for the current application regardless of if they are active var appTreeDefs = Services.ApplicationTreeService.GetApplicationTrees(GetCurrentApp()).ToList(); //Create the BaseTree's based on the tree definitions found foreach (var treeDef in appTreeDefs) { //create the tree and initialize it var bTree = LegacyTreeDataConverter.GetLegacyTreeForLegacyServices(treeDef); //BaseTree bTree = treeDef.CreateInstance(); bTree.SetTreeParameters(m_TreeService); //store the created tree m_AllAppTrees.Add(bTree); if (treeDef.Initialize) { m_ActiveTrees.Add(bTree); } } m_IsInit = true; }
public LegacyTreeParams(IEnumerable <KeyValuePair <string, string> > formCollection) { var p = TreeRequestParams.FromDictionary(formCollection.ToDictionary(x => x.Key, x => x.Value)); NodeKey = p.NodeKey; StartNodeID = p.StartNodeID; ShowContextMenu = p.ShowContextMenu; IsDialog = p.IsDialog; DialogMode = p.DialogMode; FunctionToCall = p.FunctionToCall; }
/// <summary> /// If the application supports multiple trees, then this function iterates over all of the trees assigned to it /// and creates their top level nodes and context menus. /// </summary> /// <param name="treeParams"></param> private void LoadAppTrees(TreeRequestParams treeParams) { //find all tree definitions that have the current application alias List <TreeDefinition> treeDefs = TreeDefinitionCollection.Instance.FindActiveTrees(treeParams.Application); foreach (TreeDefinition treeDef in treeDefs) { BaseTree bTree = treeDef.CreateInstance(); bTree.SetTreeParameters(treeParams); _xTree.Add(bTree.RootNode); } }
/// <summary> /// If the application supports multiple trees, then this function iterates over all of the trees assigned to it /// and creates their top level nodes and context menus. /// </summary> /// <param name="treeParams"></param> /// <param name="context"></param> private void LoadAppTrees(TreeRequestParams treeParams, HttpContext context) { var appTrees = Services.ApplicationTreeService.GetApplicationTrees(treeParams.Application, true); foreach (var appTree in appTrees) { var tree = LegacyTreeDataConverter.GetLegacyTreeForLegacyServices(Services.ApplicationTreeService, appTree.Alias); if (tree != null) { tree.SetTreeParameters(treeParams); _xTree.Add(tree.RootNode); } } }
/// <summary> /// This will load the particular ITree object and call it's render method to get the nodes that need to be rendered. /// </summary> /// <param name="treeParams"></param> /// <param name="httpContext"></param> private void LoadTree(TreeRequestParams treeParams, HttpContext httpContext) { var tree = LegacyTreeDataConverter.GetLegacyTreeForLegacyServices(Services.ApplicationTreeService, treeParams.TreeType); if (tree != null) { tree.SetTreeParameters(treeParams); tree.Render(ref _xTree); } else { LoadNullTree(treeParams); } }
/// <summary> /// This will load the particular ITree object and call it's render method to get the nodes that need to be rendered. /// </summary> /// <param name="treeParams"></param> private void LoadTree(TreeRequestParams treeParams) { TreeDefinition treeDef = TreeDefinitionCollection.Instance.FindTree(treeParams.TreeType); if (treeDef != null) { BaseTree bTree = treeDef.CreateInstance(); bTree.SetTreeParameters(treeParams); bTree.Render(ref _xTree); } else { LoadNullTree(treeParams); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); TreeParams = TreeRequestParams.FromQueryStrings().CreateTreeService(); DataBind(); if (Request.QueryString["selected"] != null && TreeParams.TreeType == "content") { var currContent = Services.ContentService.GetById(int.Parse(Request.QueryString["selected"])); if (currContent != null) { if (currContent.ParentId > 0) { DialogTree.SelectedNodePath = currContent.Path; } } } }
/// <summary> /// Returns the an XmlTree based on the current http request /// </summary> /// <returns></returns> public XmlTree GetXmlTree() { TreeRequestParams treeParams = TreeRequestParams.FromQueryStrings(); if (string.IsNullOrEmpty(treeParams.TreeType)) { if (!string.IsNullOrEmpty(treeParams.Application)) { LoadAppTrees(treeParams); } else { return(new XmlTree()); //returns an empty tree } } else { LoadTree(treeParams); } return(xTree); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); TreeParams = TreeRequestParams.FromQueryStrings().CreateTreeService(); DataBind(); }
public static TreeRequestParams FromDictionary(Dictionary<string, string> items) { TreeRequestParams treeRequestParams = new TreeRequestParams(); treeRequestParams.m_params = items; return treeRequestParams; }