示例#1
0
    public void GetNodes()
    {
        XmlTree        xTree      = new XmlTree();
        ITreeService   treeParams = new TreeService(1099, "content", false, false, TreeDialogModes.none, null);
        TreeDefinition tree       = TreeDefinitionCollection.Instance.FindTree("content");
        BaseTree       instance   = tree.CreateInstance();

        instance.SetTreeParameters((ITreeService)treeParams);
        instance.Render(ref xTree);
        Response.ContentType = "application/json";
        Response.Write(((object)xTree).ToString());
    }
示例#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="appAlias"></param>
        private void LoadAppTrees(string appAlias)
        {
            //find all tree definitions that have the current application alias
            List <TreeDefinition> treeDefs = TreeDefinitionCollection.Instance.FindActiveTrees(appAlias);

            foreach (TreeDefinition treeDef in treeDefs)
            {
                BaseTree bTree = treeDef.CreateInstance();
                bTree.SetTreeParameters(m_treeParams);
                m_xTree.Add(bTree.RootNode);
            }
        }
示例#3
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());
            if (!string.IsNullOrEmpty(this.TreeType))
            {
                m_ActiveTreeDefs = m_ActiveTreeDefs
                                   .Where(x => x.Tree.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
            List <TreeDefinition> appTreeDefs = TreeDefinitionCollection.Instance.FindTrees(GetCurrentApp());

            //Create the BaseTree's based on the tree definitions found
            foreach (TreeDefinition treeDef in appTreeDefs)
            {
                //create the tree and initialize it
                BaseTree bTree = treeDef.CreateInstance();
                bTree.SetTreeParameters(m_TreeService);

                //store the created tree
                m_AllAppTrees.Add(bTree);
                if (treeDef.Tree.Initialize)
                {
                    m_ActiveTrees.Add(bTree);
                }
            }

            m_IsInit = true;
        }
示例#4
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="appAlias"></param>
        /// <param name="treeAlias"></param>
        private void LoadTree(string treeAlias)
        {
            TreeDefinition treeDef = TreeDefinitionCollection.Instance.FindTree(treeAlias);

            if (treeDef != null)
            {
                BaseTree bTree = treeDef.CreateInstance();
                bTree.SetTreeParameters(m_treeParams);
                bTree.Render(ref m_xTree);
            }
            else
            {
                LoadNullTree();
            }
        }
示例#5
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>
        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);
            }
        }