public override void Bind(DNNNodeCollection objNodes)
        {
            DNNNode  objNode = null;
            MenuNode objMenuItem;
            DNNNode  objPrevNode = null;
            bool     RootFlag    = false;
            int      intIndex;

            if (IndicateChildren == false)
            {
                IndicateChildImageSub  = "";
                IndicateChildImageRoot = "";
            }
            if (!String.IsNullOrEmpty(CSSNodeSelectedRoot) && CSSNodeSelectedRoot == CSSNodeSelectedSub)
            {
                Menu.DefaultNodeCssClassSelected = CSSNodeSelectedRoot; //set on parent, thus decreasing overall payload
            }

            //JH - 2/5/07 - support for custom attributes
            foreach (CustomAttribute objAttr in CustomAttributes)
            {
                switch (objAttr.Name.ToLower())
                {
                case "submenuorientation":
                    Menu.SubMenuOrientation = (UI.WebControls.Orientation)Enum.Parse(Menu.SubMenuOrientation.GetType(), objAttr.Value);
                    break;

                case "usetables":
                    Menu.RenderMode = DNNMenu.MenuRenderMode.Normal;
                    break;

                case "rendermode":
                    Menu.RenderMode = (DNNMenu.MenuRenderMode)Enum.Parse(typeof(DNNMenu.MenuRenderMode), objAttr.Value);
                    break;

                case "animationtype":
                    Menu.Animation.AnimationType = (AnimationType)Enum.Parse(typeof(AnimationType), objAttr.Value);
                    break;

                case "easingdirection":
                    Menu.Animation.EasingDirection = (EasingDirection)Enum.Parse(typeof(EasingDirection), objAttr.Value);
                    break;

                case "easingtype":
                    Menu.Animation.EasingType = (EasingType)Enum.Parse(typeof(EasingType), objAttr.Value);
                    break;

                case "animationinterval":
                    Menu.Animation.Interval = int.Parse(objAttr.Value);
                    break;

                case "animationlength":
                    Menu.Animation.Length = int.Parse(objAttr.Value);
                    break;
                }
            }
            foreach (DNNNode node in objNodes)
            {
                objNode = node;
                if (objNode.Level == 0) //root menu
                {
                    intIndex    = Menu.MenuNodes.Import(objNode, false);
                    objMenuItem = Menu.MenuNodes[intIndex];
                    if (objNode.BreadCrumb && string.IsNullOrEmpty(NodeRightHTMLBreadCrumbRoot) == false)
                    {
                        objMenuItem.RightHTML += NodeRightHTMLBreadCrumbRoot;
                    }
                    else if (string.IsNullOrEmpty(NodeRightHTMLRoot) == false)
                    {
                        objMenuItem.RightHTML = NodeRightHTMLRoot;
                    }
                    if (RootFlag) //first root item has already been entered
                    {
                        AddSeparator("All", objPrevNode, objNode, objMenuItem);
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(SeparatorLeftHTML) == false || string.IsNullOrEmpty(SeparatorLeftHTMLBreadCrumb) == false || string.IsNullOrEmpty(SeparatorLeftHTMLActive) == false)
                        {
                            AddSeparator("Left", objPrevNode, objNode, objMenuItem);
                        }
                        RootFlag = true;
                    }
                    if (objNode.BreadCrumb && string.IsNullOrEmpty(NodeLeftHTMLBreadCrumbRoot) == false)
                    {
                        objMenuItem.LeftHTML += NodeLeftHTMLBreadCrumbRoot;
                    }
                    else if (string.IsNullOrEmpty(NodeLeftHTMLRoot) == false)
                    {
                        objMenuItem.LeftHTML += NodeLeftHTMLRoot;
                    }
                    if (!String.IsNullOrEmpty(CSSNodeRoot))
                    {
                        objMenuItem.CSSClass = CSSNodeRoot;
                    }
                    if (!String.IsNullOrEmpty(CSSNodeHoverRoot) && CSSNodeHoverRoot != CSSNodeHoverSub)
                    {
                        objMenuItem.CSSClassHover = CSSNodeHoverRoot;
                    }
                    objMenuItem.CSSIcon = " "; //< ignore for root...???
                    if (objNode.BreadCrumb)
                    {
                        if (!String.IsNullOrEmpty(CSSBreadCrumbRoot))
                        {
                            objMenuItem.CSSClass = CSSBreadCrumbRoot;
                        }
                        if (objNode.Selected && String.IsNullOrEmpty(Menu.DefaultNodeCssClassSelected))
                        {
                            objMenuItem.CSSClassSelected = CSSNodeSelectedRoot;
                        }
                    }
                }
                else //If Not blnRootOnly Then
                {
                    try
                    {
                        MenuNode objParent = Menu.MenuNodes.FindNode(objNode.ParentNode.ID);
                        if (objParent == null) //POD
                        {
                            objParent = Menu.MenuNodes[Menu.MenuNodes.Import(objNode.ParentNode.Clone(), true)];
                        }
                        objMenuItem = objParent.MenuNodes.FindNode(objNode.ID);
                        if (objMenuItem == null) //POD
                        {
                            objMenuItem = objParent.MenuNodes[objParent.MenuNodes.Import(objNode.Clone(), true)];
                        }
                        if (!String.IsNullOrEmpty(NodeLeftHTMLSub))
                        {
                            objMenuItem.LeftHTML = NodeLeftHTMLSub;
                        }
                        if (!String.IsNullOrEmpty(NodeRightHTMLSub))
                        {
                            objMenuItem.RightHTML = NodeRightHTMLSub;
                        }
                        if (!String.IsNullOrEmpty(CSSNodeHoverSub) && CSSNodeHoverRoot != CSSNodeHoverSub)
                        {
                            objMenuItem.CSSClassHover = CSSNodeHoverSub;
                        }
                        if (objNode.BreadCrumb)
                        {
                            if (!String.IsNullOrEmpty(CSSBreadCrumbSub))
                            {
                                objMenuItem.CSSClass = CSSBreadCrumbSub;
                            }
                            if (!String.IsNullOrEmpty(NodeLeftHTMLBreadCrumbSub))
                            {
                                objMenuItem.LeftHTML = NodeLeftHTMLBreadCrumbSub;
                            }
                            if (!String.IsNullOrEmpty(NodeRightHTMLBreadCrumbSub))
                            {
                                objMenuItem.RightHTML = NodeRightHTMLBreadCrumbSub;
                            }
                            if (objNode.Selected && String.IsNullOrEmpty(Menu.DefaultNodeCssClassSelected))
                            {
                                objMenuItem.CSSClass = CSSNodeSelectedSub;
                            }
                        }
                    }
                    catch
                    {
                        //throws exception if the parent tab has not been loaded ( may be related to user role security not allowing access to a parent tab )
                        objMenuItem = null;
                    }
                }
                if (!String.IsNullOrEmpty(objNode.Image))
                {
                    if (objNode.Image.StartsWith("~/images/"))
                    {
                        objNode.Image = objNode.Image.Replace("~/images/", PathSystemImage);
                    }
                    else if (objNode.Image.StartsWith("~/"))
                    {
                        objNode.Image = Globals.ResolveUrl(objNode.Image);
                    }
                    else if (!objNode.Image.Contains("://") && objNode.Image.StartsWith("/") == false && !String.IsNullOrEmpty(PathImage))
                    {
                        objNode.Image = PathImage + objNode.Image;
                    }
                    objMenuItem.Image = objNode.Image;
                }
                if (objMenuItem.IsBreak)
                {
                    objMenuItem.CSSClass = CSSBreak;
                }
                objMenuItem.ToolTip = objNode.ToolTip;
                Bind(objNode.DNNNodes);
                objPrevNode = objNode;
            }
            if (objNode != null && objNode.Level == 0) //root menu
            {
                //solpartactions has a hardcoded image with no path information.  Assume if value is present and no path we need to add one.
                if (!String.IsNullOrEmpty(IndicateChildImageSub) && IndicateChildImageSub.IndexOf("/") == -1)
                {
                    IndicateChildImageSub = PathSystemImage + IndicateChildImageSub;
                }
                if (!String.IsNullOrEmpty(IndicateChildImageRoot) && IndicateChildImageRoot.IndexOf("/") == -1)
                {
                    IndicateChildImageRoot = PathSystemImage + IndicateChildImageRoot;
                }
            }
        }
Ejemplo n.º 2
0
        public override void Bind(DNNNodeCollection objNodes)
        {
            DNNNode objNode     = null;
            DNNNode objPrevNode = null;
            bool    isRoot      = false;

            if (IndicateChildren == false)
            {
                IndicateChildImageSub  = "";
                IndicateChildImageRoot = "";
            }

            if (this.CSSNodeSelectedRoot.Length > 0 && this.CSSNodeSelectedRoot == this.CSSNodeSelectedSub)
            {
                Menu.DefaultNodeCssClassSelected = this.CSSNodeSelectedRoot; //set on parent, thus decreasing overall payload
            }

            //For i = 0 To objNodes.Count - 1
            foreach (DNNNode dnnNode in objNodes)
            {
                objNode = dnnNode;
                //objNode = objNodes(i)
                MenuNode objMenuItem;
                if (objNode.Level == 0) // root menu
                {
                    if (isRoot)         //first root item has already been entered
                    {
                        AddSeparator("All", objPrevNode, objNode);
                    }
                    else
                    {
                        if (!String.IsNullOrEmpty(SeparatorLeftHTML) || !String.IsNullOrEmpty(SeparatorLeftHTMLBreadCrumb) || !String.IsNullOrEmpty(this.SeparatorLeftHTMLActive))
                        {
                            AddSeparator("Left", objPrevNode, objNode);
                        }
                        isRoot = true;
                    }

                    //If objNode.Enabled = False Then
                    //	intIndex = Menu.MenuNodes.Add(objNode.ID.ToString, objNode.Key, objNode.Text & "&nbsp;", "")						 'TODO:  Do we want to space &nbsp; here???
                    //Else
                    //	intIndex = Menu.MenuNodes.Add(objNode.ID.ToString, objNode.Key, objNode.Text & "&nbsp;", objNode.NavigateURL)
                    //End If
                    int intIndex = Menu.MenuNodes.Import(objNode, false);
                    objMenuItem = Menu.MenuNodes[intIndex];
                    if (!String.IsNullOrEmpty(this.CSSNodeRoot))
                    {
                        objMenuItem.CSSClass = this.CSSNodeRoot;
                    }
                    if (!String.IsNullOrEmpty(this.CSSNodeHoverRoot) && this.CSSNodeHoverRoot != this.CSSNodeHoverSub)
                    {
                        objMenuItem.CSSClassHover = this.CSSNodeHoverRoot;
                    }

                    if (!String.IsNullOrEmpty(this.NodeLeftHTMLRoot))
                    {
                        objMenuItem.LeftHTML = this.NodeLeftHTMLRoot;
                    }

                    objMenuItem.CSSIcon = " "; //< ignore for root...???
                    if (objNode.BreadCrumb)
                    {
                        if (!String.IsNullOrEmpty(CSSBreadCrumbRoot))
                        {
                            objMenuItem.CSSClass = CSSBreadCrumbRoot;
                        }
                        if (!String.IsNullOrEmpty(NodeLeftHTMLBreadCrumbRoot))
                        {
                            objMenuItem.LeftHTML = NodeLeftHTMLBreadCrumbRoot;
                        }
                        if (!String.IsNullOrEmpty(NodeRightHTMLBreadCrumbRoot))
                        {
                            objMenuItem.RightHTML = NodeRightHTMLBreadCrumbRoot;
                        }
                        if (objNode.Selected && String.IsNullOrEmpty(Menu.DefaultNodeCssClassSelected)) //<--- not necessary when both are the same
                        {
                            objMenuItem.CSSClassSelected = this.CSSNodeSelectedRoot;
                        }
                    }

                    if (!String.IsNullOrEmpty(this.NodeRightHTMLRoot))
                    {
                        objMenuItem.RightHTML = NodeRightHTMLRoot;
                    }
                }
                else //If Not blnRootOnly Then
                {
                    try
                    {
                        MenuNode objParent = Menu.MenuNodes.FindNode(objNode.ParentNode.ID);

                        if (objParent == null)  //POD
                        {
                            objParent = Menu.MenuNodes[Menu.MenuNodes.Import(objNode.ParentNode.Clone(), true)];
                        }
                        objMenuItem = objParent.MenuNodes.FindNode(objNode.ID);
                        if (objMenuItem == null)  //POD
                        {
                            objMenuItem = objParent.MenuNodes[objParent.MenuNodes.Import(objNode.Clone(), true)];
                        }

                        //If objNode.Enabled = False Then
                        //	intIndex = objParent.MenuNodes.Add(objNode.ID.ToString, objNode.Key, objNode.Text, "")
                        //Else
                        //	intIndex = objParent.MenuNodes.Add(objNode.ID.ToString, objNode.Key, objNode.Text, objNode.NavigateURL)
                        //End If

                        if (!String.IsNullOrEmpty(CSSNodeHoverSub) && this.CSSNodeHoverRoot != this.CSSNodeHoverSub)
                        {
                            objMenuItem.CSSClassHover = CSSNodeHoverSub;
                        }
                        if (!String.IsNullOrEmpty(NodeLeftHTMLSub))
                        {
                            objMenuItem.LeftHTML = NodeLeftHTMLSub;
                        }

                        if (objNode.BreadCrumb)
                        {
                            if (!String.IsNullOrEmpty(CSSBreadCrumbSub))
                            {
                                objMenuItem.CSSClass = this.CSSBreadCrumbSub;
                            }
                            if (!String.IsNullOrEmpty(NodeLeftHTMLBreadCrumbSub))
                            {
                                objMenuItem.LeftHTML = NodeLeftHTMLBreadCrumbSub;
                            }
                            if (!String.IsNullOrEmpty(NodeRightHTMLBreadCrumbSub))
                            {
                                objMenuItem.RightHTML = NodeRightHTMLBreadCrumbSub;
                            }
                            if (objNode.Selected && String.IsNullOrEmpty(Menu.DefaultNodeCssClassSelected))
                            {
                                objMenuItem.CSSClass = this.CSSNodeSelectedSub;
                            }
                        }

                        if (!String.IsNullOrEmpty(this.NodeRightHTMLSub))
                        {
                            objMenuItem.RightHTML = this.NodeRightHTMLSub;
                        }
                    }
                    catch
                    {
                        // throws exception if the parent tab has not been loaded ( may be related to user role security not allowing access to a parent tab )
                        objMenuItem = null;
                    }
                    //Else
                    //	objMenuItem = Nothing
                }
                if (objMenuItem != null)
                {
                    if (objNode.Image.Length > 0)
                    {
                        if (objNode.Image.StartsWith("/") == false && this.PathImage.Length > 0)
                        {
                            objNode.Image = this.PathImage + objNode.Image;
                        }
                        objMenuItem.Image = objNode.Image;
                    }

                    if (objMenuItem.IsBreak)
                    {
                        objMenuItem.CSSClass = this.CSSBreak;
                    }

                    objMenuItem.ToolTip = objNode.ToolTip;
                }
                Bind(objNode.DNNNodes);
                objPrevNode = objNode;
            }

            if (objNode != null && objNode.Level == 0)  // root menu
            {
                if (!String.IsNullOrEmpty(SeparatorRightHTML) || !String.IsNullOrEmpty(SeparatorRightHTMLBreadCrumb) || !String.IsNullOrEmpty(this.SeparatorRightHTMLActive))
                {
                    AddSeparator("Right", objPrevNode, null);
                }
                //solpartactions has a hardcoded image with no path information.  Assume if value is present and no path we need to add one.
                if (IndicateChildImageSub.Length > 0 && IndicateChildImageSub.IndexOf("/") == -1)
                {
                    IndicateChildImageSub = this.PathSystemImage + IndicateChildImageSub;
                }
                if (IndicateChildImageRoot.Length > 0 && IndicateChildImageRoot.IndexOf("/") == -1)
                {
                    IndicateChildImageRoot = this.PathSystemImage + IndicateChildImageRoot;
                }
            }
        }