public override void Bind(DNNNodeCollection objNodes) { DNNNode objNode = null; SPMenuItemNode objMenuItem = null; DNNNode objPrevNode = null; bool RootFlag = false; if (IndicateChildren == false) { } else { if (!String.IsNullOrEmpty(IndicateChildImageRoot)) { Menu.RootArrow = true; } } foreach (DNNNode node in objNodes) { objNode = node; try { if (objNode.Level == 0) { if (RootFlag) { AddSeparator("All", objPrevNode, objNode); } else { if (!String.IsNullOrEmpty(SeparatorLeftHTML) || !String.IsNullOrEmpty(SeparatorLeftHTMLBreadCrumb) || !String.IsNullOrEmpty(SeparatorLeftHTMLActive)) { AddSeparator("Left", objPrevNode, objNode); } RootFlag = true; } if (objNode.Enabled == false) { objMenuItem = new SPMenuItemNode(Menu.AddMenuItem(objNode.ID, objNode.Text, "")); } else { if (!String.IsNullOrEmpty(objNode.JSFunction)) { objMenuItem = new SPMenuItemNode(Menu.AddMenuItem(objNode.ID, objNode.Text, GetClientScriptURL(objNode.JSFunction, objNode.ID))); } else { objMenuItem = new SPMenuItemNode(Menu.AddMenuItem(objNode.ID, objNode.Text, objNode.NavigateURL)); } } if (!String.IsNullOrEmpty(StyleRoot)) { objMenuItem.ItemStyle = StyleRoot; } if (!String.IsNullOrEmpty(CSSNodeRoot)) { objMenuItem.ItemCss = CSSNodeRoot; } if (!String.IsNullOrEmpty(CSSNodeHoverRoot)) { objMenuItem.ItemSelectedCss = CSSNodeHoverRoot; } if (!String.IsNullOrEmpty(NodeLeftHTMLRoot)) { objMenuItem.LeftHTML = NodeLeftHTMLRoot; } if (objNode.BreadCrumb) { objMenuItem.ItemCss = objMenuItem.ItemCss + " " + CSSBreadCrumbRoot; if (!String.IsNullOrEmpty(NodeLeftHTMLBreadCrumbRoot)) { objMenuItem.LeftHTML = NodeLeftHTMLBreadCrumbRoot; } if (!String.IsNullOrEmpty(NodeRightHTMLBreadCrumbRoot)) { objMenuItem.RightHTML = NodeRightHTMLBreadCrumbRoot; } if (objNode.Selected) { objMenuItem.ItemCss = objMenuItem.ItemCss + " " + CSSNodeSelectedRoot; } } if (!String.IsNullOrEmpty(NodeRightHTMLRoot)) { objMenuItem.RightHTML = NodeRightHTMLRoot; } } else if (objNode.IsBreak) { Menu.AddBreak(objNode.ParentNode.ID); } else { try { if (objNode.Enabled == false) { objMenuItem = new SPMenuItemNode(Menu.AddMenuItem(objNode.ParentNode.ID, objNode.ID, " " + objNode.Text, "")); } else { if (!String.IsNullOrEmpty(objNode.JSFunction)) { objMenuItem = new SPMenuItemNode(Menu.AddMenuItem(objNode.ParentNode.ID, objNode.ID, " " + objNode.Text, GetClientScriptURL(objNode.JSFunction, objNode.ID))); } else { objMenuItem = new SPMenuItemNode(Menu.AddMenuItem(objNode.ParentNode.ID, objNode.ID, " " + objNode.Text, objNode.NavigateURL)); } } if (objNode.ClickAction == eClickAction.PostBack) { objMenuItem.RunAtServer = true; } if (!String.IsNullOrEmpty(CSSNodeHoverSub)) { objMenuItem.ItemSelectedCss = CSSNodeHoverSub; } if (!String.IsNullOrEmpty(NodeLeftHTMLSub)) { objMenuItem.LeftHTML = NodeLeftHTMLSub; } if (objNode.BreadCrumb) { objMenuItem.ItemCss = CSSBreadCrumbSub; if (!String.IsNullOrEmpty(NodeLeftHTMLBreadCrumbSub)) { objMenuItem.LeftHTML = NodeLeftHTMLBreadCrumbSub; } if (!String.IsNullOrEmpty(NodeRightHTMLBreadCrumbSub)) { objMenuItem.RightHTML = NodeRightHTMLBreadCrumbSub; } if (objNode.Selected) { objMenuItem.ItemCss = CSSNodeSelectedSub; DNNNode objParentNode = objNode; do { objParentNode = objParentNode.ParentNode; Menu.FindMenuItem(objParentNode.ID).ItemCss = CSSNodeSelectedSub; } while (objParentNode.Level != 0); Menu.FindMenuItem(objParentNode.ID).ItemCss = CSSBreadCrumbRoot + " " + CSSNodeSelectedRoot; } } if (!String.IsNullOrEmpty(NodeRightHTMLSub)) { objMenuItem.RightHTML = NodeRightHTMLSub; } } catch { objMenuItem = null; } } if (!String.IsNullOrEmpty(objNode.Image)) { if (objNode.Image.StartsWith("~/images/")) { objMenuItem.Image = objNode.Image.Replace("~/images/", ""); } else if (objNode.Image.IndexOf("/") > -1) { string strImage = objNode.Image; if (strImage.StartsWith(Menu.IconImagesPath)) { strImage = strImage.Substring(Menu.IconImagesPath.Length); } if (strImage.IndexOf("/") > -1) { objMenuItem.Image = strImage.Substring(strImage.LastIndexOf("/") + 1); if (strImage.StartsWith("/")) { objMenuItem.ImagePath = strImage.Substring(0, strImage.LastIndexOf("/") + 1); } else if (strImage.StartsWith("~/")) { objMenuItem.ImagePath = Globals.ResolveUrl(strImage.Substring(0, strImage.LastIndexOf("/") + 1)); } else { objMenuItem.ImagePath = Menu.IconImagesPath + strImage.Substring(0, strImage.LastIndexOf("/") + 1); } } else { objMenuItem.Image = strImage; } } else { objMenuItem.Image = objNode.Image; } } if (!String.IsNullOrEmpty(objNode.ToolTip)) { objMenuItem.ToolTip = objNode.ToolTip; } Bind(objNode.DNNNodes); } catch (Exception ex) { throw ex; } objPrevNode = objNode; } if (objNode != null && objNode.Level == 0) { if (!String.IsNullOrEmpty(SeparatorRightHTML) || !String.IsNullOrEmpty(SeparatorRightHTMLBreadCrumb) || !String.IsNullOrEmpty(SeparatorRightHTMLActive)) { AddSeparator("Right", objPrevNode, null); } } }
public override void Bind(DNNNodeCollection objNodes) { DNNNode objNode = null; SPMenuItemNode objMenuItem = null; DNNNode objPrevNode = null; bool isRootFlag = false; if (IndicateChildren == false) { //should this be spacer.gif??? //IndicateChildImageSub = "" //IndicateChildImageRoot = "" } else { if (!String.IsNullOrEmpty(IndicateChildImageRoot)) { Menu.RootArrow = true; } } foreach (DNNNode dnnNode in objNodes) { objNode = dnnNode; try { if (objNode.Level == 0) // root menu { if (isRootFlag) //first root item has already been entered { AddSeparator("All", objPrevNode, objNode); } else { if (!String.IsNullOrEmpty(SeparatorLeftHTML) || !String.IsNullOrEmpty(SeparatorLeftHTMLBreadCrumb) || !String.IsNullOrEmpty(SeparatorLeftHTMLActive)) { AddSeparator("Left", objPrevNode, objNode); } isRootFlag = true; } if (objNode.Enabled == false) { objMenuItem = new SPMenuItemNode(Menu.AddMenuItem(objNode.ID.ToString(), objNode.Text, "")); } else { string jsFunction = objNode.JSFunction; if ((jsFunction != null) && (jsFunction.Length > 0)) { objMenuItem = new SPMenuItemNode(Menu.AddMenuItem(objNode.ID.ToString(), objNode.Text, GetClientScriptURL(objNode.JSFunction, objNode.ID))); } else { objMenuItem = new SPMenuItemNode(Menu.AddMenuItem(objNode.ID.ToString(), objNode.Text, objNode.NavigateURL)); } } if (StyleRoot != null && StyleRoot.Length > 0) { objMenuItem.ItemStyle = this.StyleRoot; } if (!String.IsNullOrEmpty(CSSNodeRoot)) { objMenuItem.ItemCss = this.CSSNodeRoot; } if (!String.IsNullOrEmpty(CSSNodeHoverRoot)) { objMenuItem.ItemSelectedCss = this.CSSNodeHoverRoot; } if (!String.IsNullOrEmpty(NodeLeftHTMLRoot)) { objMenuItem.LeftHTML = this.NodeLeftHTMLRoot; } if (objNode.BreadCrumb) { objMenuItem.ItemCss = objMenuItem.ItemCss + " " + this.CSSBreadCrumbRoot; if (!String.IsNullOrEmpty(NodeLeftHTMLBreadCrumbRoot)) { objMenuItem.LeftHTML = NodeLeftHTMLBreadCrumbRoot; } if (!String.IsNullOrEmpty(NodeRightHTMLBreadCrumbRoot)) { objMenuItem.RightHTML = NodeRightHTMLBreadCrumbRoot; } if (objNode.Selected) { objMenuItem.ItemCss = objMenuItem.ItemCss + " " + this.CSSNodeSelectedRoot; } } if (!String.IsNullOrEmpty(NodeRightHTMLRoot)) { objMenuItem.RightHTML = NodeRightHTMLRoot; } } else if (objNode.IsBreak) { Menu.AddBreak(objNode.ParentNode.ID.ToString()); } else //If Not blnRootOnly Then { try { if (objNode.Enabled == false) { objMenuItem = new SPMenuItemNode(Menu.AddMenuItem(objNode.ParentNode.ID.ToString(), objNode.ID.ToString(), " " + objNode.Text, "")); } else { string jsFunction = objNode.JSFunction; if (!String.IsNullOrEmpty(jsFunction)) { objMenuItem = new SPMenuItemNode(Menu.AddMenuItem(objNode.ParentNode.ID.ToString(), objNode.ID.ToString(), " " + objNode.Text, GetClientScriptURL(objNode.JSFunction, objNode.ID))); } else { objMenuItem = new SPMenuItemNode(Menu.AddMenuItem(objNode.ParentNode.ID.ToString(), objNode.ID.ToString(), " " + objNode.Text, objNode.NavigateURL)); } } if (objNode.ClickAction == eClickAction.PostBack) { objMenuItem.RunAtServer = true; } if (!String.IsNullOrEmpty(CSSNodeHoverSub)) { objMenuItem.ItemSelectedCss = CSSNodeHoverSub; } if (!String.IsNullOrEmpty(NodeLeftHTMLSub)) { objMenuItem.LeftHTML = NodeLeftHTMLSub; } if (objNode.BreadCrumb) { objMenuItem.ItemCss = this.CSSBreadCrumbSub; if (!String.IsNullOrEmpty(NodeLeftHTMLBreadCrumbSub)) { objMenuItem.LeftHTML = NodeLeftHTMLBreadCrumbSub; } if (!String.IsNullOrEmpty(NodeRightHTMLBreadCrumbSub)) { objMenuItem.RightHTML = NodeRightHTMLBreadCrumbSub; } if (objNode.Selected) { objMenuItem.ItemCss = this.CSSNodeSelectedSub; } } if (!String.IsNullOrEmpty(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 (!String.IsNullOrEmpty(objNode.Image)) { //if image contains a path if (objNode.Image.IndexOf("/") > -1) { string strImage = objNode.Image; //if path (or portion) is already set in header of menu truncate it off if (strImage.StartsWith(Menu.IconImagesPath)) { strImage = strImage.Substring(Menu.IconImagesPath.Length); } if (strImage.IndexOf("/") > -1) //if the image still contains path info assign it { objMenuItem.Image = strImage.Substring(strImage.LastIndexOf("/") + 1); if (strImage.StartsWith("/")) //is absolute path? { objMenuItem.ImagePath = strImage.Substring(0, strImage.LastIndexOf("/") + 1); } else { objMenuItem.ImagePath = Menu.IconImagesPath + strImage.Substring(0, strImage.LastIndexOf("/") + 1); } } else { objMenuItem.Image = strImage; } } else { objMenuItem.Image = objNode.Image; } } if (String.IsNullOrEmpty(objNode.ToolTip)) { objMenuItem.ToolTip = objNode.ToolTip; } } Bind(objNode.DNNNodes); } catch (Exception ex) { throw (ex); } objPrevNode = objNode; } if (objNode != null && objNode.Level == 0) // root menu { if (!String.IsNullOrEmpty(SeparatorRightHTML) || !String.IsNullOrEmpty(SeparatorRightHTMLBreadCrumb) || !String.IsNullOrEmpty(SeparatorRightHTMLActive)) { AddSeparator("Right", objPrevNode, null); } } }
public override void Bind( DNNNodeCollection objNodes ) { DNNNode objNode = null; SPMenuItemNode objMenuItem = null; DNNNode objPrevNode = null; bool isRootFlag = false; if( IndicateChildren == false ) { //should this be spacer.gif??? //IndicateChildImageSub = "" //IndicateChildImageRoot = "" } else { if( !String.IsNullOrEmpty( IndicateChildImageRoot) ) { Menu.RootArrow = true; } } foreach( DNNNode dnnNode in objNodes ) { objNode = dnnNode; try { if( objNode.Level == 0 ) // root menu { if( isRootFlag ) //first root item has already been entered { AddSeparator( "All", objPrevNode, objNode ); } else { if( !String.IsNullOrEmpty(SeparatorLeftHTML) || !String.IsNullOrEmpty(SeparatorLeftHTMLBreadCrumb) || !String.IsNullOrEmpty(SeparatorLeftHTMLActive) ) { AddSeparator( "Left", objPrevNode, objNode ); } isRootFlag = true; } if( objNode.Enabled == false ) { objMenuItem = new SPMenuItemNode( Menu.AddMenuItem( objNode.ID.ToString(), objNode.Text, "" ) ); } else { string jsFunction = objNode.JSFunction; if ((jsFunction != null) && (jsFunction.Length > 0)) { objMenuItem = new SPMenuItemNode( Menu.AddMenuItem( objNode.ID.ToString(), objNode.Text, GetClientScriptURL( objNode.JSFunction, objNode.ID ) ) ); } else { objMenuItem = new SPMenuItemNode( Menu.AddMenuItem( objNode.ID.ToString(), objNode.Text, objNode.NavigateURL ) ); } } if( StyleRoot != null && StyleRoot.Length > 0 ) { objMenuItem.ItemStyle = this.StyleRoot; } if( !String.IsNullOrEmpty(CSSNodeRoot) ) { objMenuItem.ItemCss = this.CSSNodeRoot; } if( !String.IsNullOrEmpty(CSSNodeHoverRoot) ) { objMenuItem.ItemSelectedCss = this.CSSNodeHoverRoot; } if( !String.IsNullOrEmpty(NodeLeftHTMLRoot) ) { objMenuItem.LeftHTML = this.NodeLeftHTMLRoot; } if( objNode.BreadCrumb ) { objMenuItem.ItemCss = objMenuItem.ItemCss + " " + this.CSSBreadCrumbRoot; if( !String.IsNullOrEmpty(NodeLeftHTMLBreadCrumbRoot) ) { objMenuItem.LeftHTML = NodeLeftHTMLBreadCrumbRoot; } if( !String.IsNullOrEmpty(NodeRightHTMLBreadCrumbRoot) ) { objMenuItem.RightHTML = NodeRightHTMLBreadCrumbRoot; } if( objNode.Selected ) { objMenuItem.ItemCss = objMenuItem.ItemCss + " " + this.CSSNodeSelectedRoot; } } if( !String.IsNullOrEmpty(NodeRightHTMLRoot) ) { objMenuItem.RightHTML = NodeRightHTMLRoot; } } else if( objNode.IsBreak ) { Menu.AddBreak( objNode.ParentNode.ID.ToString() ); } else //If Not blnRootOnly Then { try { if( objNode.Enabled == false ) { objMenuItem = new SPMenuItemNode( Menu.AddMenuItem( objNode.ParentNode.ID.ToString(), objNode.ID.ToString(), " " + objNode.Text, "" ) ); } else { string jsFunction = objNode.JSFunction; if(!String.IsNullOrEmpty( jsFunction)) { objMenuItem = new SPMenuItemNode( Menu.AddMenuItem( objNode.ParentNode.ID.ToString(), objNode.ID.ToString(), " " + objNode.Text, GetClientScriptURL( objNode.JSFunction, objNode.ID ) ) ); } else { objMenuItem = new SPMenuItemNode( Menu.AddMenuItem( objNode.ParentNode.ID.ToString(), objNode.ID.ToString(), " " + objNode.Text, objNode.NavigateURL ) ); } } if( objNode.ClickAction == eClickAction.PostBack ) { objMenuItem.RunAtServer = true; } if( !String.IsNullOrEmpty(CSSNodeHoverSub) ) { objMenuItem.ItemSelectedCss = CSSNodeHoverSub; } if( !String.IsNullOrEmpty(NodeLeftHTMLSub) ) { objMenuItem.LeftHTML = NodeLeftHTMLSub; } if( objNode.BreadCrumb ) { objMenuItem.ItemCss = this.CSSBreadCrumbSub; if( !String.IsNullOrEmpty(NodeLeftHTMLBreadCrumbSub) ) { objMenuItem.LeftHTML = NodeLeftHTMLBreadCrumbSub; } if( !String.IsNullOrEmpty(NodeRightHTMLBreadCrumbSub) ) { objMenuItem.RightHTML = NodeRightHTMLBreadCrumbSub; } if( objNode.Selected ) { objMenuItem.ItemCss = this.CSSNodeSelectedSub; } } if( !String.IsNullOrEmpty(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 (!String.IsNullOrEmpty( objNode.Image )) { //if image contains a path if( objNode.Image.IndexOf( "/" ) > - 1 ) { string strImage = objNode.Image; //if path (or portion) is already set in header of menu truncate it off if( strImage.StartsWith( Menu.IconImagesPath ) ) { strImage = strImage.Substring( Menu.IconImagesPath.Length ); } if( strImage.IndexOf( "/" ) > - 1 ) //if the image still contains path info assign it { objMenuItem.Image = strImage.Substring( strImage.LastIndexOf( "/" ) + 1 ); if( strImage.StartsWith( "/" ) ) //is absolute path? { objMenuItem.ImagePath = strImage.Substring( 0, strImage.LastIndexOf( "/" ) + 1 ); } else { objMenuItem.ImagePath = Menu.IconImagesPath + strImage.Substring( 0, strImage.LastIndexOf( "/" ) + 1 ); } } else { objMenuItem.Image = strImage; } } else { objMenuItem.Image = objNode.Image; } } if (String.IsNullOrEmpty(objNode.ToolTip)) { objMenuItem.ToolTip = objNode.ToolTip; } } Bind( objNode.DNNNodes ); } catch( Exception ex ) { throw ( ex ); } objPrevNode = objNode; } if( objNode != null && objNode.Level == 0 ) // root menu { if( !String.IsNullOrEmpty(SeparatorRightHTML) || !String.IsNullOrEmpty(SeparatorRightHTMLBreadCrumb) || !String.IsNullOrEmpty(SeparatorRightHTMLActive) ) { AddSeparator( "Right", objPrevNode, null ); } } }