Esempio n. 1
0
        /// <summary>
        /// Creates an XmlTreeNode based on the passed in UmbracoEntity
        /// </summary>
        /// <param name="dd"></param>
        /// <param name="allowedUserOptions"></param>
        /// <returns></returns>
        internal XmlTreeNode CreateNode(UmbracoEntity dd, List <IAction> allowedUserOptions)
        {
            XmlTreeNode node = XmlTreeNode.Create(this);

            SetMenuAttribute(ref node, allowedUserOptions);
            node.NodeID = dd.Id.ToString();
            node.Text   = dd.Name;
            SetNonPublishedAttribute(ref node, dd);
            SetProtectedAttribute(ref node, dd);
            SetActionAttribute(ref node, dd);
            SetSourcesAttributes(ref node, dd);
            if (dd.ContentTypeIcon != null)
            {
                node.Icon     = dd.ContentTypeIcon;
                node.OpenIcon = dd.ContentTypeIcon;
            }

            if (dd.IsPublished == false)
            {
                node.Style.DimNode();
            }

            if (dd.HasPendingChanges)
            {
                node.Style.HighlightNode();
            }

            return(node);
        }
Esempio n. 2
0
        private XmlTreeNode PerformNodeRender(int nodeId, string nodeName, bool hasChildren, string icon, string contentTypeAlias, Func <string> getLinkValue)
        {
            var xNode = XmlTreeNode.Create(this);

            xNode.NodeID = nodeId.ToString(CultureInfo.InvariantCulture);
            xNode.Text   = nodeName;

            xNode.HasChildren = hasChildren;
            xNode.Source      = this.IsDialog ? GetTreeDialogUrl(nodeId) : GetTreeServiceUrl(nodeId);

            xNode.Icon     = icon;
            xNode.OpenIcon = icon;

            if (IsDialog == false)
            {
                if (this.ShowContextMenu == false)
                {
                    xNode.Menu = null;
                }
                xNode.Action = "javascript:openMedia(" + nodeId + ");";
            }
            else
            {
                xNode.Menu = this.ShowContextMenu ? new List <IAction>(new IAction[] { ActionRefresh.Instance }) : null;
                if (this.DialogMode == TreeDialogModes.fulllink)
                {
                    string nodeLink = getLinkValue();
                    if (string.IsNullOrEmpty(nodeLink) == false)
                    {
                        xNode.Action = "javascript:openMedia('" + nodeLink + "');";
                    }
                    else
                    {
                        if (string.Equals(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 #" + nodeId.ToString(CultureInfo.InvariantCulture) + "').click();";
                        }
                        else
                        {
                            xNode.Action = null;
                            xNode.Style.DimNode();
                        }
                    }
                }
                else
                {
                    xNode.Action = "javascript:openMedia('" + nodeId.ToString(CultureInfo.InvariantCulture) + "');";
                }
            }

            return(xNode);
        }
Esempio n. 3
0
        public override void Render(ref XmlTree tree)
        {
            XmlTreeNode xNode = XmlTreeNode.Create(this);

            xNode.Text = "Error";
            xNode.Menu = null;

            OnBeforeNodeRender(ref tree, ref xNode, EventArgs.Empty);
            if (xNode != null)
            {
                tree.Add(xNode);
                OnAfterNodeRender(ref tree, ref xNode, EventArgs.Empty);
            }
        }
Esempio n. 4
0
        public override void Render(ref XmlTree tree)
        {
            foreach (umbraco.BusinessLogic.User user in umbraco.BusinessLogic.User.getAll())
            {
                if (user.Id > 0 && !user.Disabled)
                {
                    XmlTreeNode node = XmlTreeNode.Create(this);
                    node.NodeID = user.Id.ToString();
                    node.Text   = user.Name;
                    node.Action = "javascript:openUserPermissions('" + user.Id.ToString() + "');";
                    node.Icon   = "user.gif";

                    OnBeforeNodeRender(ref tree, ref node, EventArgs.Empty);
                    if (node != null)
                    {
                        tree.Add(node);
                        OnAfterNodeRender(ref tree, ref node, EventArgs.Empty);
                    }
                }
            }
        }
Esempio n. 5
0
        protected XmlTreeNode CreateNode(Document dd, List <IAction> allowedUserOptions)
        {
            XmlTreeNode node = XmlTreeNode.Create(this);

            SetMenuAttribute(ref node, allowedUserOptions);
            node.NodeID = dd.Id.ToString();
            node.Text   = dd.Text;
            SetNonPublishedAttribute(ref node, dd);
            SetProtectedAttribute(ref node, dd);
            SetActionAttribute(ref node, dd);
            SetSourcesAttributes(ref node, dd);
            if (dd.ContentTypeIcon != null)
            {
                node.Icon     = dd.ContentTypeIcon;
                node.OpenIcon = dd.ContentTypeIcon;
            }
            if (!dd.Published)
            {
                node.Style.DimNode();
            }
            return(node);
        }
Esempio n. 6
0
        public override void Render(ref XmlTree tree)
        {
            List <UserType> userTypes = UserType.GetAllUserTypes();

            foreach (UserType userType in userTypes)
            {
                if (userType.Id > 1) //don't show the admin user type, they should always have full permissions
                {
                    XmlTreeNode node = XmlTreeNode.Create(this);
                    node.NodeID = userType.Id.ToString();
                    node.Action = string.Format("javascript:openUserTypes({0})", userType.Id.ToString());
                    node.Icon   = "user.gif";
                    node.Text   = userType.Alias;

                    OnBeforeNodeRender(ref tree, ref node, EventArgs.Empty);
                    if (node != null)
                    {
                        tree.Add(node);
                        OnAfterNodeRender(ref tree, ref node, EventArgs.Empty);
                    }
                }
            }
        }
Esempio n. 7
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);
        }
Esempio n. 8
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);
        }
        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);
        }
Esempio n. 10
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);
        }