Exemplo n.º 1
0
        /// <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;
        }
Exemplo n.º 2
0
        /// <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);
                }
            }
        }
Exemplo n.º 3
0
        /// <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);
            }
        }
        public Dictionary <string, string> GetInitAppTreeData(string app, string treeType, bool showContextMenu, bool isDialog, TreeDialogModes dialogMode, string functionToCall, string nodeKey)
        {
            AuthorizeRequest(app, true);

            var treeCtl = new TreeControl()
            {
                ShowContextMenu = showContextMenu,
                IsDialog        = isDialog,
                DialogMode      = dialogMode,
                App             = app,
                TreeType        = string.IsNullOrEmpty(treeType) ? "" : treeType, //don't set the tree type unless explicitly set
                NodeKey         = string.IsNullOrEmpty(nodeKey) ? "" : nodeKey,
                StartNodeID     = -1,                                             //TODO: set this based on parameters!
                FunctionToCall  = string.IsNullOrEmpty(functionToCall) ? "" : functionToCall
            };

            var returnVal = new Dictionary <string, string>();

            if (string.IsNullOrEmpty(treeType))
            {
                //if there's not tree type specified, then render out the tree as per normal with the normal
                //way of doing things
                returnVal.Add("json", treeCtl.GetJSONInitNode());
            }
            else
            {
                var tree = LegacyTreeDataConverter.GetLegacyTreeForLegacyServices(Services.ApplicationTreeService, treeType);

                tree.ShowContextMenu = showContextMenu;
                tree.IsDialog        = isDialog;
                tree.DialogMode      = dialogMode;
                tree.NodeKey         = string.IsNullOrEmpty(nodeKey) ? "" : nodeKey;
                tree.FunctionToCall  = string.IsNullOrEmpty(functionToCall) ? "" : functionToCall;
                //this would be nice to set, but no parameters :(
                //tree.StartNodeID =

                //now render it's start node
                var xTree = new XmlTree();
                xTree.Add(tree.RootNode);

                returnVal.Add("json", xTree.ToString());
            }

            returnVal.Add("app", app);
            returnVal.Add("js", treeCtl.JSCurrApp);

            return(returnVal);
        }