Ejemplo n.º 1
0
        /// <summary>
        /// Renders the specified tree item.
        /// </summary>        
        /// <param name="Tree">The tree.</param>
        public override void Render(ref XmlTree Tree)
        {
            //get documents to render
            Document[] docs = Document.GetChildrenForTree(m_id);

            var args = new TreeEventArgs(Tree);
            OnBeforeTreeRender(docs, args);

            foreach (Document dd in docs)
            {
                List<IAction> allowedUserOptions = GetUserActionsForNode(dd);
                if (CanUserAccessNode(dd, allowedUserOptions))
                {

                    XmlTreeNode node = CreateNode(dd, allowedUserOptions);

                    OnRenderNode(ref node, dd);

                    OnBeforeNodeRender(ref Tree, ref node, EventArgs.Empty);
                    if (node != null)
                    {
                        Tree.Add(node);
                        OnAfterNodeRender(ref Tree, ref node, EventArgs.Empty);
                    }
                }
            }
            //args = new TreeEventArgs(Tree);
            OnAfterTreeRender(docs, args);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Renders the specified tree item.
        /// </summary>
        /// <param name="Tree">The tree.</param>

        /*public override void Render(ref XmlTree Tree)
         * {
         *  //get documents to render
         *  Document[] docs = Document.GetChildrenForTree(m_id);
         *
         *  var args = new TreeEventArgs(Tree);
         *  OnBeforeTreeRender(docs, args);
         *
         *  foreach (Document dd in docs)
         *  {
         *      List<IAction> allowedUserOptions = GetUserActionsForNode(dd);
         *      if (CanUserAccessNode(dd, allowedUserOptions))
         *      {
         *
         *          XmlTreeNode node = CreateNode(dd, allowedUserOptions);
         *
         *          OnRenderNode(ref node, dd);
         *
         *          OnBeforeNodeRender(ref Tree, ref node, EventArgs.Empty);
         *          if (node != null)
         *          {
         *              Tree.Add(node);
         *              OnAfterNodeRender(ref Tree, ref node, EventArgs.Empty);
         *          }
         *      }
         *  }
         *  OnAfterTreeRender(docs, args);
         * }*/
        public override void Render(ref XmlTree Tree)
        {
            //get documents to render
            var entities = Services.EntityService.GetChildren(m_id, UmbracoObjectTypes.Document).ToArray();

            var args = new TreeEventArgs(Tree);

            OnBeforeTreeRender(entities, args, true);

            foreach (var entity in entities)
            {
                var            e = entity as UmbracoEntity;
                List <IAction> allowedUserOptions = GetUserActionsForNode(e);
                if (CanUserAccessNode(e, allowedUserOptions))
                {
                    XmlTreeNode node = CreateNode(e, allowedUserOptions);

                    OnRenderNode(ref node, new Document(entity, LoadMinimalDocument));

                    OnBeforeNodeRender(ref Tree, ref node, EventArgs.Empty);
                    if (node != null)
                    {
                        Tree.Add(node);
                        OnAfterNodeRender(ref Tree, ref node, EventArgs.Empty);
                    }
                }
            }
            OnAfterTreeRender(entities, args, true);
        }
 protected virtual void OnBeforeTreeRender(object sender, TreeEventArgs e)
 {
     if (BeforeTreeRender != null)
     {
         BeforeTreeRender(sender, e);
     }
 }
 protected virtual void OnAfterTreeRender(object sender, TreeEventArgs e)
 {
     if (AfterTreeRender != null)
     {
         AfterTreeRender(sender, e);
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Renders the specified tree item.
        /// </summary>
        /// <param name="Tree">The tree.</param>
        public override void Render(ref XmlTree Tree)
        {
            //get documents to render
            Document[] docs = Document.GetChildrenForTree(m_id);

            var args = new TreeEventArgs(Tree);

            OnBeforeTreeRender(docs, args);

            foreach (Document dd in docs)
            {
                List <IAction> allowedUserOptions = GetUserActionsForNode(dd);
                if (CanUserAccessNode(dd, allowedUserOptions))
                {
                    XmlTreeNode node = CreateNode(dd, allowedUserOptions);

                    OnRenderNode(ref node, dd);

                    OnBeforeNodeRender(ref Tree, ref node, EventArgs.Empty);
                    if (node != null)
                    {
                        Tree.Add(node);
                        OnAfterNodeRender(ref Tree, ref node, EventArgs.Empty);
                    }
                }
            }
            //args = new TreeEventArgs(Tree);
            OnAfterTreeRender(docs, args);
        }
Ejemplo n.º 6
0
        public override void Render(ref XmlTree tree)
        {

            if (UseOptimizedRendering == false)
            {
                //We cannot run optimized mode since there are subscribers to events/methods that require document instances
                // so we'll render the original way by looking up the docs.

                var docs = new Media(m_id).Children;

                var args = new TreeEventArgs(tree);
                OnBeforeTreeRender(docs, args);

                foreach (var dd in docs)
                {
                    var e = dd;
                    var xNode = PerformNodeRender(e.Id, e.Text, e.HasChildren, e.ContentType.IconUrl, e.ContentType.Alias, () => GetLinkValue(e, e.Id.ToString(CultureInfo.InvariantCulture)));


                    OnBeforeNodeRender(ref tree, ref xNode, EventArgs.Empty);
                    if (xNode != null)
                    {
                        tree.Add(xNode);
                        OnAfterNodeRender(ref tree, ref xNode, EventArgs.Empty);
                    }
                }

                OnAfterTreeRender(docs, args);
            }
            else
            {
                //We ARE running in optmized mode, this means we will NOT be raising the BeforeTreeRender or AfterTreeRender 
                // events  - we've already detected that there are not subscribers or implementations
                // to call so that is fine.

                var entities = Services.EntityService.GetChildren(m_id, UmbracoObjectTypes.Media).ToArray();
                
                foreach (UmbracoEntity entity in entities)
                {
                    var e = entity;
                    var xNode = PerformNodeRender(e.Id, entity.Name, e.HasChildren, e.ContentTypeIcon, e.ContentTypeAlias, () => GetLinkValue(e));
                    
                    OnBeforeNodeRender(ref tree, ref xNode, EventArgs.Empty);
                    if (xNode != null)
                    {
                        tree.Add(xNode);
                        OnAfterNodeRender(ref tree, ref xNode, EventArgs.Empty);
                    }
                }
            }            
        }
Ejemplo n.º 7
0
        public override void Render(ref XmlTree tree)
        {
            if (UseOptimizedRendering == false)
            {
                //We cannot run optimized mode since there are subscribers to events/methods that require document instances
                // so we'll render the original way by looking up the docs.

                var docs = new Media(m_id).Children;

                var args = new TreeEventArgs(tree);
                OnBeforeTreeRender(docs, args);

                foreach (var dd in docs)
                {
                    var e     = dd;
                    var xNode = PerformNodeRender(e.Id, e.Text, e.HasChildren, e.ContentType.IconUrl, e.ContentType.Alias, () => GetLinkValue(e, e.Id.ToString(CultureInfo.InvariantCulture)));


                    OnBeforeNodeRender(ref tree, ref xNode, EventArgs.Empty);
                    if (xNode != null)
                    {
                        tree.Add(xNode);
                        OnAfterNodeRender(ref tree, ref xNode, EventArgs.Empty);
                    }
                }

                OnAfterTreeRender(docs, args);
            }
            else
            {
                //We ARE running in optmized mode, this means we will NOT be raising the BeforeTreeRender or AfterTreeRender
                // events  - we've already detected that there are not subscribers or implementations
                // to call so that is fine.

                var entities = Services.EntityService.GetChildren(m_id, UmbracoObjectTypes.Media).ToArray();

                foreach (UmbracoEntity entity in entities)
                {
                    var e     = entity;
                    var xNode = PerformNodeRender(e.Id, entity.Name, e.HasChildren, e.ContentTypeIcon, e.ContentTypeAlias, () => GetLinkValue(e));

                    OnBeforeNodeRender(ref tree, ref xNode, EventArgs.Empty);
                    if (xNode != null)
                    {
                        tree.Add(xNode);
                        OnAfterNodeRender(ref tree, ref xNode, EventArgs.Empty);
                    }
                }
            }
        }
Ejemplo n.º 8
0
        //Updated Render method for improved performance, but currently not usable because of backwards compatibility
        //with the OnBeforeTreeRender/OnAfterTreeRender events, which sends an array for legacy Media items.
        public override void Render(ref XmlTree tree)
        {
            //_timer = DisposableTimer.Start(x => LogHelper.Debug<BaseMediaTree>("Media tree loaded" + " (took " + x + "ms)"));

            var entities = Services.EntityService.GetChildren(m_id, UmbracoObjectTypes.Media).ToArray();

            var args = new TreeEventArgs(tree);

            OnBeforeTreeRender(entities, args, false);

            foreach (UmbracoEntity entity in entities)
            {
                XmlTreeNode xNode = XmlTreeNode.Create(this);
                xNode.NodeID = entity.Id.ToString(CultureInfo.InvariantCulture);
                xNode.Text   = entity.Name;

                xNode.HasChildren = entity.HasChildren;
                xNode.Source      = this.IsDialog ? GetTreeDialogUrl(entity.Id) : GetTreeServiceUrl(entity.Id);

                xNode.Icon     = entity.ContentTypeIcon;
                xNode.OpenIcon = entity.ContentTypeIcon;

                if (IsDialog == false)
                {
                    if (this.ShowContextMenu == false)
                    {
                        xNode.Menu = null;
                    }
                    xNode.Action = "javascript:openMedia(" + entity.Id + ");";
                }
                else
                {
                    xNode.Menu = this.ShowContextMenu ? new List <IAction>(new IAction[] { ActionRefresh.Instance }) : null;
                    if (this.DialogMode == TreeDialogModes.fulllink)
                    {
                        string nodeLink = GetLinkValue(entity);
                        if (string.IsNullOrEmpty(nodeLink) == false)
                        {
                            xNode.Action = "javascript:openMedia('" + nodeLink + "');";
                        }
                        else
                        {
                            if (string.Equals(entity.ContentTypeAlias, Constants.Conventions.MediaTypes.Folder, StringComparison.OrdinalIgnoreCase))
                            {
                                //#U4-2254 - Inspiration to use void from here: http://stackoverflow.com/questions/4924383/jquery-object-object-error
                                xNode.Action = "javascript:void jQuery('.umbTree #" + entity.Id.ToString(CultureInfo.InvariantCulture) + "').click();";
                            }
                            else
                            {
                                xNode.Action = null;
                                xNode.Style.DimNode();
                            }
                        }
                    }
                    else
                    {
                        xNode.Action = "javascript:openMedia('" + entity.Id.ToString(CultureInfo.InvariantCulture) + "');";
                    }
                }

                OnBeforeNodeRender(ref tree, ref xNode, EventArgs.Empty);
                if (xNode != null)
                {
                    tree.Add(xNode);
                    OnAfterNodeRender(ref tree, ref xNode, EventArgs.Empty);
                }
            }

            //stop the timer and log the output
            //_timer.Dispose();

            OnAfterTreeRender(entities, args, false);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Renders the specified tree item.
        /// </summary>
        /// <param name="Tree">The tree.</param>
        public override void Render(ref XmlTree Tree)
        {
            if (UseOptimizedRendering == false)
            {
                //We cannot run optimized mode since there are subscribers to events/methods that require document instances
                // so we'll render the original way by looking up the docs.

                //get documents to render
                var docs = Document.GetChildrenForTree(m_id);

                var args = new TreeEventArgs(Tree);
                OnBeforeTreeRender(docs, args);

                foreach (var dd in docs)
                {
                    var allowedUserOptions = GetUserActionsForNode(dd);
                    if (CanUserAccessNode(dd, allowedUserOptions))
                    {
                        var node = CreateNode(dd, allowedUserOptions);

                        OnRenderNode(ref node, dd);

                        OnBeforeNodeRender(ref Tree, ref node, EventArgs.Empty);
                        if (node != null)
                        {
                            Tree.Add(node);
                            OnAfterNodeRender(ref Tree, ref node, EventArgs.Empty);
                        }
                    }
                }
                OnAfterTreeRender(docs, args);
            }
            else
            {
                //We ARE running in optmized mode, this means we will NOT be raising the BeforeTreeRender or AfterTreeRender
                // events and NOT calling the OnRenderNode method - we've already detected that there are not subscribers or implementations
                // to call so that is fine.

                var entities = Services.EntityService.GetChildren(m_id, UmbracoObjectTypes.Document).ToArray();
                foreach (var entity in entities)
                {
                    var e = entity as UmbracoEntity;
                    var allowedUserOptions = GetUserActionsForNode(e);
                    if (CanUserAccessNode(e, allowedUserOptions))
                    {
                        var node = CreateNode(e, allowedUserOptions);

                        //in optimized mode the LoadMinimalDocument will ALWAYS be true, if it is not true then we will
                        // be rendering in non-optimized mode and this code will not get executed so we don't need to worry
                        // about performance here.
                        OnRenderNode(ref node, new Document(e, LoadMinimalDocument));

                        OnBeforeNodeRender(ref Tree, ref node, EventArgs.Empty);
                        if (node != null)
                        {
                            Tree.Add(node);
                            OnAfterNodeRender(ref Tree, ref node, EventArgs.Empty);
                        }
                    }
                }
            }
        }
Ejemplo n.º 10
0
 protected virtual void OnAfterTreeRender(object sender, TreeEventArgs e)
 {
     if (AfterTreeRender != null)
         AfterTreeRender(sender, e);
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Renders the specified tree item.
        /// </summary>        
        /// <param name="Tree">The tree.</param>
        public override void Render(ref XmlTree Tree)
        {
            if (UseOptimizedRendering == false)
            {
                //We cannot run optimized mode since there are subscribers to events/methods that require document instances
                // so we'll render the original way by looking up the docs.

                //get documents to render
                var docs = Document.GetChildrenForTree(m_id);

                var args = new TreeEventArgs(Tree);
                OnBeforeTreeRender(docs, args);

                foreach (var dd in docs)
                {
                    var allowedUserOptions = GetUserActionsForNode(dd);
                    if (CanUserAccessNode(dd, allowedUserOptions))
                    {

                        var node = CreateNode(dd, allowedUserOptions);

                        OnRenderNode(ref node, dd);

                        OnBeforeNodeRender(ref Tree, ref node, EventArgs.Empty);
                        if (node != null)
                        {
                            Tree.Add(node);
                            OnAfterNodeRender(ref Tree, ref node, EventArgs.Empty);
                        }
                    }
                }
                OnAfterTreeRender(docs, args);
            }
            else
            {

                //We ARE running in optmized mode, this means we will NOT be raising the BeforeTreeRender or AfterTreeRender 
                // events and NOT calling the OnRenderNode method - we've already detected that there are not subscribers or implementations
                // to call so that is fine.

                var entities = Services.EntityService.GetChildren(m_id, UmbracoObjectTypes.Document).ToArray();
                foreach (var entity in entities)
                {
                    var e = entity as UmbracoEntity;
                    var allowedUserOptions = GetUserActionsForNode(e);
                    if (CanUserAccessNode(e, allowedUserOptions))
                    {
                        var node = CreateNode(e, allowedUserOptions);

                        //in optimized mode the LoadMinimalDocument will ALWAYS be true, if it is not true then we will
                        // be rendering in non-optimized mode and this code will not get executed so we don't need to worry
                        // about performance here.
                        OnRenderNode(ref node, new Document(e, LoadMinimalDocument));
                        
                        OnBeforeNodeRender(ref Tree, ref node, EventArgs.Empty);
                        if (node != null)
                        {
                            Tree.Add(node);
                            OnAfterNodeRender(ref Tree, ref node, EventArgs.Empty);
                        }
                    }
                }
            }
        }
Ejemplo n.º 12
0
 protected override void OnAfterTreeRender(object sender, TreeEventArgs e)
 {
     base.OnAfterTreeRender(sender, e);
 }
Ejemplo n.º 13
0
 protected virtual void OnBeforeTreeRender(object sender, TreeEventArgs e)
 {
     if (BeforeTreeRender != null)
         BeforeTreeRender(sender, e);
 }
        public override void Render(ref XmlTree tree)
        {
            string FilePath = TranslatorType == Enums.TranslatorType.StyleSheet ? "/css/" : "/scripts/";
            string orgPath = String.Empty;
            string path = String.Empty;

            if (!string.IsNullOrEmpty(this.NodeKey))
            {
                orgPath = this.NodeKey;
                path = IOHelper.MapPath(FilePath + orgPath);
                orgPath += "/";
            }
            else
            {
                path = IOHelper.MapPath(FilePath);
            }

            DirectoryInfo dirInfo = new DirectoryInfo(path);
            DirectoryInfo[] dirInfos = dirInfo.GetDirectories();
            var allowedExts = new Translation.Core().GetPossibleExtensions(TranslatorType).ToArray();

            var args = new TreeEventArgs(tree);
            OnBeforeTreeRender(dirInfo, args);

            foreach (DirectoryInfo dir in dirInfos)
            {
                if ((dir.Attributes & FileAttributes.Hidden) == 0)
                {
                    XmlTreeNode xDirNode = XmlTreeNode.Create(this);
                    xDirNode.NodeID = orgPath + dir.Name;
                    xDirNode.NodeType = TranslatorType == Enums.TranslatorType.StyleSheet ? "initstylesheetsNew" : "initscriptsNew";
                    xDirNode.Menu = new List<IAction>(new IAction[] { ActionDelete.Instance, ContextMenuSeperator.Instance, ActionNew.Instance, ContextMenuSeperator.Instance, ActionRefresh.Instance });
                    xDirNode.Text = dir.Name;
                    xDirNode.Source = GetTreeServiceUrl(orgPath + dir.Name);
                    if (CompatibilityHelper.IsVersion7OrNewer)
                        xDirNode.Icon = "icon-folder";
                    else
                        xDirNode.Icon = FolderIcon;
                    xDirNode.OpenIcon = FolderIconOpen;
                    xDirNode.HasChildren = dir.GetFiles().Length > 0 || dir.GetDirectories().Length > 0;
                    xDirNode.Action = "#";

                    OnRenderFolderNode(ref xDirNode);
                    OnBeforeNodeRender(ref tree, ref xDirNode, EventArgs.Empty);
                    if (xDirNode != null)
                    {
                        tree.Add(xDirNode);
                        OnAfterNodeRender(ref tree, ref xDirNode, EventArgs.Empty);
                    }
                }
            }

            FileInfo[] fileInfo = dirInfo.GetFiles("*.*");
            foreach (FileInfo file in fileInfo)
            {
                if ((file.Attributes & FileAttributes.Hidden) == 0 && allowedExts.Contains(file.Extension))
                {
                    XmlTreeNode xFileNode = XmlTreeNode.Create(this);
                    xFileNode.NodeID = orgPath + file.Name;
                    xFileNode.Text = file.Name;
                    xFileNode.Icon = new Optimus.Translation.Core().GetTranslatorTreeIconPath(file.Name);
                    xFileNode.OpenIcon = "doc.gif";
                    xFileNode.Menu = new List<IAction> { ActionDelete.Instance };
                    xFileNode.NodeType = TranslatorType == Enums.TranslatorType.StyleSheet ? "initstylesheetsNew" : "initscriptsNew";

                    if (string.IsNullOrEmpty(xFileNode.Action))
                    {
                        if (orgPath != string.Empty)
                        {
                            xFileNode.Action = TranslatorType == Enums.TranslatorType.StyleSheet ?
                                "javascript:openDyanmicCSSFileEditor('" + orgPath + file.Name + "', 'false');" :
                                "javascript:openDyanmicScriptFileEditor('" + orgPath + file.Name + "', 'false');";
                        }
                        else
                        {
                            xFileNode.Action = TranslatorType == Enums.TranslatorType.StyleSheet ?
                                "javascript:openDyanmicCSSFileEditor('" + file.Name + "', 'false');" :
                                "javascript:openDyanmicScriptFileEditor('" + file.Name + "', 'false');";
                        }
                    }

                    OnRenderFileNode(ref xFileNode);
                    OnBeforeNodeRender(ref tree, ref xFileNode, EventArgs.Empty);
                    if (xFileNode != null)
                    {
                        tree.Add(xFileNode);
                        OnAfterNodeRender(ref tree, ref xFileNode, EventArgs.Empty);
                    }
                }
            }
            OnAfterTreeRender(dirInfo, args);
        }
Ejemplo n.º 15
0
        public override void Render(ref XmlTree tree)
        {
            string orgPath = "";
            string path = "";
            if (!string.IsNullOrEmpty(this.NodeKey))
            {
                orgPath = this.NodeKey;
                path = IOHelper.MapPath(FilePath + orgPath);
                orgPath += "/";
            }
            else
            {
                path = IOHelper.MapPath(FilePath);
            }

            DirectoryInfo dirInfo = new DirectoryInfo(path);
            DirectoryInfo[] dirInfos = dirInfo.GetDirectories();

            var args = new TreeEventArgs(tree);
            OnBeforeTreeRender(dirInfo, args);

            foreach (DirectoryInfo dir in dirInfos)
            {
                if ((dir.Attributes & FileAttributes.Hidden) == 0)
                {
                    XmlTreeNode xDirNode = XmlTreeNode.Create(this);
					xDirNode.NodeID = orgPath + dir.Name;
                    xDirNode.Menu.Clear();
                    xDirNode.Text = dir.Name;
                    xDirNode.Action = string.Empty;
                    xDirNode.Source = GetTreeServiceUrl(orgPath + dir.Name);
                    xDirNode.Icon = FolderIcon;
                    xDirNode.OpenIcon = FolderIconOpen;
					xDirNode.HasChildren = dir.GetFiles().Length > 0 || dir.GetDirectories().Length > 0;
                    
                    OnRenderFolderNode(ref xDirNode);
                    OnBeforeNodeRender(ref tree, ref xDirNode, EventArgs.Empty);
                    if (xDirNode != null)
                    {
                        tree.Add(xDirNode);
                        OnAfterNodeRender(ref tree, ref xDirNode, EventArgs.Empty);
                    }
                    
                    
                }
            }
            FileInfo[] fileInfo = dirInfo.GetFiles(FileSearchPattern);
            foreach (FileInfo file in fileInfo)
            {
                if ((file.Attributes & FileAttributes.Hidden) == 0)
                {
                    XmlTreeNode xFileNode = XmlTreeNode.Create(this);
					xFileNode.NodeID = orgPath + file.Name;
                    xFileNode.Text = file.Name;
                    if (!((orgPath == "")))
                        xFileNode.Action = "javascript:openFile('" + orgPath  + file.Name + "');";
                    else
                        xFileNode.Action = "javascript:openFile('" + file.Name + "');";
                    xFileNode.Icon = "doc.gif";
                    xFileNode.OpenIcon = "doc.gif";

                    OnRenderFileNode(ref xFileNode);
                    OnBeforeNodeRender(ref tree, ref xFileNode, EventArgs.Empty);
                    if (xFileNode != null)
                    {
                        tree.Add(xFileNode);
                        OnAfterNodeRender(ref tree, ref xFileNode, EventArgs.Empty);
                    }
                    

                }
            }
            OnAfterTreeRender(dirInfo, args);
        }        
Ejemplo n.º 16
0
        public override void Render(ref XmlTree tree)
        {
            string orgPath = "";
            string path    = "";

            if (!string.IsNullOrEmpty(this.NodeKey))
            {
                orgPath  = this.NodeKey;
                path     = IOHelper.MapPath(FilePath + orgPath);
                orgPath += "/";
            }
            else
            {
                path = IOHelper.MapPath(FilePath);
            }

            DirectoryInfo dirInfo = new DirectoryInfo(path);

            DirectoryInfo[] dirInfos = dirInfo.GetDirectories();

            var args = new TreeEventArgs(tree);

            OnBeforeTreeRender(dirInfo, args);

            foreach (DirectoryInfo dir in dirInfos)
            {
                if ((dir.Attributes & FileAttributes.Hidden) == 0)
                {
                    XmlTreeNode xDirNode = XmlTreeNode.Create(this);
                    xDirNode.NodeID = orgPath + dir.Name;
                    xDirNode.Menu.Clear();
                    xDirNode.Text        = dir.Name;
                    xDirNode.Action      = string.Empty;
                    xDirNode.Source      = GetTreeServiceUrl(orgPath + dir.Name);
                    xDirNode.Icon        = FolderIcon;
                    xDirNode.OpenIcon    = FolderIconOpen;
                    xDirNode.HasChildren = dir.GetFiles().Length > 0 || dir.GetDirectories().Length > 0;

                    OnRenderFolderNode(ref xDirNode);
                    OnBeforeNodeRender(ref tree, ref xDirNode, EventArgs.Empty);
                    if (xDirNode != null)
                    {
                        tree.Add(xDirNode);
                        OnAfterNodeRender(ref tree, ref xDirNode, EventArgs.Empty);
                    }
                }
            }
            FileInfo[] fileInfo = dirInfo.GetFiles(FileSearchPattern);
            foreach (FileInfo file in fileInfo)
            {
                if ((file.Attributes & FileAttributes.Hidden) == 0)
                {
                    XmlTreeNode xFileNode = XmlTreeNode.Create(this);
                    xFileNode.NodeID = orgPath + file.Name;
                    xFileNode.Text   = file.Name;
                    if (!((orgPath == "")))
                    {
                        xFileNode.Action = "javascript:openFile('" + orgPath + file.Name + "');";
                    }
                    else
                    {
                        xFileNode.Action = "javascript:openFile('" + file.Name + "');";
                    }
                    xFileNode.Icon     = "doc.gif";
                    xFileNode.OpenIcon = "doc.gif";

                    OnRenderFileNode(ref xFileNode);
                    OnBeforeNodeRender(ref tree, ref xFileNode, EventArgs.Empty);
                    if (xFileNode != null)
                    {
                        tree.Add(xFileNode);
                        OnAfterNodeRender(ref tree, ref xFileNode, EventArgs.Empty);
                    }
                }
            }
            OnAfterTreeRender(dirInfo, args);
        }
Ejemplo n.º 17
0
        public override void Render(ref XmlTree tree)
        {
            string orgPath = "";
            string path = "";
            if (!string.IsNullOrEmpty(this.NodeKey))
            {
                orgPath = this.NodeKey;
                path = IOHelper.MapPath(FilePath + orgPath);
                orgPath += "/";
            }
            else
            {
                path = IOHelper.MapPath(FilePath);
            }

            DirectoryInfo dirInfo = new DirectoryInfo(path);
            DirectoryInfo[] dirInfos = dirInfo.GetDirectories();

            var args = new TreeEventArgs(tree);
            OnBeforeTreeRender(dirInfo, args);

            foreach (DirectoryInfo dir in dirInfos)
            {
                if ((dir.Attributes & FileAttributes.Hidden) == 0)
                {
                    XmlTreeNode xDirNode = XmlTreeNode.Create(this);
					xDirNode.NodeID = orgPath + dir.Name;
                    xDirNode.Menu.Clear();
                    xDirNode.Text = dir.Name;
                    xDirNode.Action = string.Empty;
                    xDirNode.Source = GetTreeServiceUrl(orgPath + dir.Name);
                    xDirNode.Icon = FolderIcon;
                    xDirNode.OpenIcon = FolderIconOpen;
					xDirNode.HasChildren = dir.GetFiles().Length > 0 || dir.GetDirectories().Length > 0;
                    
                    OnRenderFolderNode(ref xDirNode);
                    OnBeforeNodeRender(ref tree, ref xDirNode, EventArgs.Empty);
                    if (xDirNode != null)
                    {
                        tree.Add(xDirNode);
                        OnAfterNodeRender(ref tree, ref xDirNode, EventArgs.Empty);
                    }
                    
                    
                }
            }

            //this is a hack to enable file system tree to support multiple file extension look-up
            //so the pattern both support *.* *.xml and xml,js,vb for lookups
            string[] allowedExtensions = new string[0];
            bool filterByMultipleExtensions = FileSearchPattern.Contains(",");
            FileInfo[] fileInfo;

            if (filterByMultipleExtensions){
                fileInfo = dirInfo.GetFiles();
                allowedExtensions = FileSearchPattern.ToLower().Split(',');
            }else
                fileInfo = dirInfo.GetFiles(FileSearchPattern);
            
            foreach (FileInfo file in fileInfo)
            {
                if ((file.Attributes & FileAttributes.Hidden) == 0)
                {
                    if (filterByMultipleExtensions && Array.IndexOf<string>(allowedExtensions, file.Extension.ToLower().Trim('.')) < 0)
                        continue;
                    
                    XmlTreeNode xFileNode = XmlTreeNode.Create(this);
					xFileNode.NodeID = orgPath + file.Name;
                    xFileNode.Text = file.Name;
                    if (!((orgPath == "")))
                        xFileNode.Action = "javascript:openFile('" + orgPath  + file.Name + "');";
                    else
                        xFileNode.Action = "javascript:openFile('" + file.Name + "');";
                    xFileNode.Icon = "doc.gif";
                    xFileNode.OpenIcon = "doc.gif";

                    OnRenderFileNode(ref xFileNode);
                    OnBeforeNodeRender(ref tree, ref xFileNode, EventArgs.Empty);
                    if (xFileNode != null)
                    {
                        tree.Add(xFileNode);
                        OnAfterNodeRender(ref tree, ref xFileNode, EventArgs.Empty);
                    }
                    

                }
            }
            OnAfterTreeRender(dirInfo, args);
        }        
Ejemplo n.º 18
0
        //Updated Render method for improved performance, but currently not usable because of backwards compatibility 
        //with the OnBeforeTreeRender/OnAfterTreeRender events, which sends an array for legacy Media items.
        public override void Render(ref XmlTree tree)
        {
            //_timer = DisposableTimer.Start(x => LogHelper.Debug<BaseMediaTree>("Media tree loaded" + " (took " + x + "ms)"));

            var entities = Services.EntityService.GetChildren(m_id, UmbracoObjectTypes.Media).ToArray();
            
            var args = new TreeEventArgs(tree);
            OnBeforeTreeRender(entities, args, false);

            foreach (UmbracoEntity entity in entities)
            {
                XmlTreeNode xNode = XmlTreeNode.Create(this);
                xNode.NodeID = entity.Id.ToString(CultureInfo.InvariantCulture);
                xNode.Text = entity.Name;

                xNode.HasChildren = entity.HasChildren;
                xNode.Source = this.IsDialog ? GetTreeDialogUrl(entity.Id) : GetTreeServiceUrl(entity.Id);

                xNode.Icon = entity.ContentTypeIcon;
                xNode.OpenIcon = entity.ContentTypeIcon;
                        
                if (IsDialog == false)
                {
                    if(this.ShowContextMenu == false)
                        xNode.Menu = null;
                    xNode.Action = "javascript:openMedia(" + entity.Id + ");";
                }
                else
                {
                    xNode.Menu = this.ShowContextMenu ? new List<IAction>(new IAction[] { ActionRefresh.Instance }) : null;
                    if (this.DialogMode == TreeDialogModes.fulllink)
                    {
                        string nodeLink = GetLinkValue(entity);
                        if (string.IsNullOrEmpty(nodeLink) == false)
                        {
                            xNode.Action = "javascript:openMedia('" + nodeLink + "');";
                        }
                        else
                        {
                            if (string.Equals(entity.ContentTypeAlias, Constants.Conventions.MediaTypes.Folder, StringComparison.OrdinalIgnoreCase))
                            {
                                //#U4-2254 - Inspiration to use void from here: http://stackoverflow.com/questions/4924383/jquery-object-object-error
                                xNode.Action = "javascript:void jQuery('.umbTree #" + entity.Id.ToString(CultureInfo.InvariantCulture) + "').click();";
                            }
                            else
                            {
                                xNode.Action = null;
                                xNode.Style.DimNode();
                            }
                        }
                    }
                    else
                    {
                        xNode.Action = "javascript:openMedia('" + entity.Id.ToString(CultureInfo.InvariantCulture) + "');";
                    }
                }

                OnBeforeNodeRender(ref tree, ref xNode, EventArgs.Empty);
                if (xNode != null)
                {
                    tree.Add(xNode);
                    OnAfterNodeRender(ref tree, ref xNode, EventArgs.Empty);
                }
            }

            //stop the timer and log the output
            //_timer.Dispose();

            OnAfterTreeRender(entities, args, false);
        }
Ejemplo n.º 19
0
        public override void Render(ref XmlTree tree)
        {
			Media[] docs = new Media(m_id).Children;

            var args = new TreeEventArgs(tree);
            OnBeforeTreeRender(docs, args);

            foreach (Media dd in docs)
            {
                XmlTreeNode xNode = XmlTreeNode.Create(this);
                xNode.NodeID = dd.Id.ToString();
                xNode.Text = dd.Text;

                // Check for dialog behaviour
                if (!this.IsDialog)
                {
                    if (!this.ShowContextMenu)
                        xNode.Menu = null;
                    xNode.Action = "javascript:openMedia(" + dd.Id + ");";
                }
                else
                {
                    if (this.ShowContextMenu)
                        xNode.Menu = new List<IAction>(new IAction[] { ActionRefresh.Instance });
                    else
                        xNode.Menu = null;
                    if (this.DialogMode == TreeDialogModes.fulllink)
                    {
                        string nodeLink = GetLinkValue(dd, dd.Id.ToString());
                        if (!String.IsNullOrEmpty(nodeLink))
                        {
                            xNode.Action = "javascript:openMedia('" + nodeLink + "');";
                        }
                        else
                        {
                            if (dd.ContentType.Alias.ToLower() == "folder")
                            {
                                xNode.Action = "javascript:jQuery('.umbTree #" + dd.Id.ToString() + "').click();";
                            }
                            else
                            {
                                xNode.Action = null;
                                xNode.Style.DimNode();
                            }
                        }
                    }
                    else
                    {
                        xNode.Action = "javascript:openMedia('" + dd.Id.ToString() + "');";
                    }
                }

				xNode.HasChildren = dd.HasChildren;
                if (this.IsDialog)
                    xNode.Source = GetTreeDialogUrl(dd.Id);
                else
                    xNode.Source = GetTreeServiceUrl(dd.Id);                    

                if (dd.ContentType != null)
                {
                    xNode.Icon = dd.ContentType.IconUrl;
                    xNode.OpenIcon = dd.ContentType.IconUrl;                    
                }

                OnBeforeNodeRender(ref tree, ref xNode, EventArgs.Empty);
                if (xNode != null)
                {
                    tree.Add(xNode);
                    OnAfterNodeRender(ref tree, ref xNode, EventArgs.Empty);
                }
            }
            OnAfterTreeRender(docs, args);
        }
Ejemplo n.º 20
0
 protected internal virtual void OnAfterTreeRender(IEnumerable<IUmbracoEntity> sender, TreeEventArgs e, bool isContent)
 {
     if (AfterTreeRender != null)
     {
         if (isContent)
         {
             AfterTreeRender(sender.Select(x => new Document(x, false)).ToArray(), e);
         }
         else
         {
             AfterTreeRender(sender.Select(x => new Media(x, false)).ToArray(), e);
         }
     }
 }
Ejemplo n.º 21
0
 protected internal virtual void OnAfterTreeRender(IEnumerable <IUmbracoEntity> sender, TreeEventArgs e, bool isContent)
 {
     if (AfterTreeRender != null)
     {
         if (isContent)
         {
             AfterTreeRender(sender.Select(x => new Document(x, false)).ToArray(), e);
         }
         else
         {
             AfterTreeRender(sender.Select(x => new Media(x, false)).ToArray(), e);
         }
     }
 }
Ejemplo n.º 22
0
        public override void Render(ref XmlTree tree)
        {
            Media[] docs = new Media(m_id).Children;

            var args = new TreeEventArgs(tree);

            OnBeforeTreeRender(docs, args);

            foreach (Media dd in docs)
            {
                XmlTreeNode xNode = XmlTreeNode.Create(this);
                xNode.NodeID = dd.Id.ToString();
                xNode.Text   = dd.Text;

                // Check for dialog behaviour
                if (!this.IsDialog)
                {
                    if (!this.ShowContextMenu)
                    {
                        xNode.Menu = null;
                    }
                    xNode.Action = "javascript:openMedia(" + dd.Id + ");";
                }
                else
                {
                    if (this.ShowContextMenu)
                    {
                        xNode.Menu = new List <IAction>(new IAction[] { ActionRefresh.Instance });
                    }
                    else
                    {
                        xNode.Menu = null;
                    }
                    if (this.DialogMode == TreeDialogModes.fulllink)
                    {
                        string nodeLink = GetLinkValue(dd, dd.Id.ToString());
                        if (!String.IsNullOrEmpty(nodeLink))
                        {
                            xNode.Action = "javascript:openMedia('" + nodeLink + "');";
                        }
                        else
                        {
                            xNode.Action = null;
                            xNode.DimNode();
                        }
                    }
                    else
                    {
                        xNode.Action = "javascript:openMedia('" + dd.Id.ToString() + "');";
                    }
                }

                xNode.HasChildren = dd.HasChildren;
                if (this.IsDialog)
                {
                    xNode.Source = GetTreeDialogUrl(dd.Id);
                }
                else
                {
                    xNode.Source = GetTreeServiceUrl(dd.Id);
                }

                if (dd.ContentType != null)
                {
                    xNode.Icon     = dd.ContentType.IconUrl;
                    xNode.OpenIcon = dd.ContentType.IconUrl;
                }

                OnBeforeNodeRender(ref tree, ref xNode, EventArgs.Empty);
                if (xNode != null)
                {
                    tree.Add(xNode);
                    OnAfterNodeRender(ref tree, ref xNode, EventArgs.Empty);
                }
            }
            OnAfterTreeRender(docs, args);
        }
Ejemplo n.º 23
0
        public override void Render(ref XmlTree tree)
        {
            string orgPath = "";
            string path    = "";

            if (!string.IsNullOrEmpty(this.NodeKey))
            {
                orgPath = this.NodeKey.EnsureEndsWith('/');
                path    = IOHelper.MapPath($"{FilePath.EnsureEndsWith('/')}{orgPath}");
            }
            else
            {
                path = IOHelper.MapPath(FilePath);
            }

            DirectoryInfo dirInfo = new DirectoryInfo(path);


            DirectoryInfo[] dirInfos = dirInfo.Exists ? dirInfo.GetDirectories() : new DirectoryInfo[] { };

            var args = new TreeEventArgs(tree);

            OnBeforeTreeRender(dirInfo, args);

            foreach (DirectoryInfo dir in dirInfos)
            {
                if ((dir.Attributes & FileAttributes.Hidden) == 0)
                {
                    XmlTreeNode xDirNode = XmlTreeNode.Create(this);
                    xDirNode.NodeID = orgPath + dir.Name;
                    xDirNode.Menu.Clear();
                    xDirNode.Text        = dir.Name;
                    xDirNode.Action      = string.Empty;
                    xDirNode.Source      = GetTreeServiceUrl(orgPath + dir.Name);
                    xDirNode.Icon        = FolderIcon;
                    xDirNode.OpenIcon    = FolderIconOpen;
                    xDirNode.HasChildren = dir.GetFiles().Length > 0 || dir.GetDirectories().Length > 0;

                    OnRenderFolderNode(ref xDirNode);
                    OnBeforeNodeRender(ref tree, ref xDirNode, EventArgs.Empty);
                    if (xDirNode != null)
                    {
                        tree.Add(xDirNode);
                        OnAfterNodeRender(ref tree, ref xDirNode, EventArgs.Empty);
                    }
                }
            }

            //this is a hack to enable file system tree to support multiple file extension look-up
            //so the pattern both support *.* *.xml and xml,js,vb for lookups
            string[] allowedExtensions          = new string[0];
            bool     filterByMultipleExtensions = FileSearchPattern.Contains(",");

            FileInfo[] fileInfo;

            if (filterByMultipleExtensions)
            {
                fileInfo          = dirInfo.Exists ? dirInfo.GetFiles() : new FileInfo[] {};
                allowedExtensions = FileSearchPattern.ToLower().Split(',');
            }
            else
            {
                fileInfo = dirInfo.Exists ? dirInfo.GetFiles(FileSearchPattern) : new FileInfo[] { };
            }

            foreach (FileInfo file in fileInfo)
            {
                if ((file.Attributes & FileAttributes.Hidden) == 0)
                {
                    if (filterByMultipleExtensions && Array.IndexOf <string>(allowedExtensions, file.Extension.ToLower().Trim('.')) < 0)
                    {
                        continue;
                    }

                    XmlTreeNode xFileNode = XmlTreeNode.Create(this);
                    xFileNode.NodeID = orgPath + file.Name;
                    xFileNode.Text   = file.Name;
                    if (!((orgPath == "")))
                    {
                        xFileNode.Action = "javascript:openFile('" + orgPath + file.Name + "');";
                    }
                    else
                    {
                        xFileNode.Action = "javascript:openFile('" + file.Name + "');";
                    }
                    xFileNode.Icon     = "doc.gif";
                    xFileNode.OpenIcon = "doc.gif";

                    OnRenderFileNode(ref xFileNode);
                    OnBeforeNodeRender(ref tree, ref xFileNode, EventArgs.Empty);
                    if (xFileNode != null)
                    {
                        tree.Add(xFileNode);
                        OnAfterNodeRender(ref tree, ref xFileNode, EventArgs.Empty);
                    }
                }
            }
            OnAfterTreeRender(dirInfo, args);
        }
Ejemplo n.º 24
0
        private void EventHandler(object sender, TreeEventArgs treeEventArgs)
        {

        }
Ejemplo n.º 25
0
        /// <summary>
        /// Renders the specified tree item.
        /// </summary>        
        /// <param name="Tree">The tree.</param>
        /*public override void Render(ref XmlTree Tree)
        {
            //get documents to render
            Document[] docs = Document.GetChildrenForTree(m_id);

            var args = new TreeEventArgs(Tree);
            OnBeforeTreeRender(docs, args);

            foreach (Document dd in docs)
            {
                List<IAction> allowedUserOptions = GetUserActionsForNode(dd);
                if (CanUserAccessNode(dd, allowedUserOptions))
                {

                    XmlTreeNode node = CreateNode(dd, allowedUserOptions);

                    OnRenderNode(ref node, dd);

                    OnBeforeNodeRender(ref Tree, ref node, EventArgs.Empty);
                    if (node != null)
                    {
                        Tree.Add(node);
                        OnAfterNodeRender(ref Tree, ref node, EventArgs.Empty);
                    }
                }
            }
            OnAfterTreeRender(docs, args);
        }*/
        public override void Render(ref XmlTree Tree)
        {
            //get documents to render
            var entities = Services.EntityService.GetChildren(m_id, UmbracoObjectTypes.Document).ToArray();

            var args = new TreeEventArgs(Tree);
            OnBeforeTreeRender(entities, args, true);

            foreach (var entity in entities)
            {
                var e = entity as UmbracoEntity;
                List<IAction> allowedUserOptions = GetUserActionsForNode(e);
                if (CanUserAccessNode(e, allowedUserOptions))
                {
                    XmlTreeNode node = CreateNode(e, allowedUserOptions);

                    OnRenderNode(ref node, new Document(entity, LoadMinimalDocument));

                    OnBeforeNodeRender(ref Tree, ref node, EventArgs.Empty);
                    if (node != null)
                    {
                        Tree.Add(node);
                        OnAfterNodeRender(ref Tree, ref node, EventArgs.Empty);
                    }
                }
            }
            OnAfterTreeRender(entities, args, true);
        }
Ejemplo n.º 26
0
 protected override void OnAfterTreeRender(object sender, TreeEventArgs e)
 {
     var x = sender;
     var z = x.GetType();
     base.OnAfterTreeRender(sender, e);
 }