예제 #1
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);
        }