private void AssignUrlTokens(MenuNodeCollection objNodes, ref Hashtable objTokens, ref ArrayList objUsedTokens) { string strLastToken; if (objTokens == null) { GetUrlTokens(objNodes, ref objTokens); } foreach (MenuNode objNode in objNodes) { //look all nodes strLastToken = ""; foreach (string strToken in ((Hashtable)objTokens.Clone()).Keys) { //loop all tokens (have to clone so we can modify real collection if (!String.IsNullOrEmpty(objNode.NavigateURL) && objNode.NavigateURL.IndexOf(strToken) > -1) { //if url contains token objTokens[strToken] = (int)objTokens[strToken] - 1; //remove token from count if (strToken.Length > strLastToken.Length && ((int)objTokens[strToken] > 0 || objUsedTokens.Contains(strToken))) { //if token is better and not only one with match strLastToken = strToken; //use it } } } if (!String.IsNullOrEmpty(strLastToken)) { if (objUsedTokens.Contains(strLastToken) == false) { objUsedTokens.Add(strLastToken); } objNode.UrlIndex = objUsedTokens.IndexOf(strLastToken); objNode.NavigateURL = objNode.NavigateURL.Substring(strLastToken.Length); } AssignUrlTokens(objNode.MenuNodes, ref objTokens, ref objUsedTokens); } }
private void GetUrlTokens(MenuNodeCollection objNodes, ref Hashtable objTokens) { if (objTokens == null) objTokens = new Hashtable(); foreach (MenuNode objNode in objNodes) { if (!String.IsNullOrEmpty(objNode.NavigateURL)) AddUrlTokens(objNode.NavigateURL, ref objTokens); GetUrlTokens(objNode.MenuNodes, ref objTokens); } }
private void UpdateNodes(MenuNodeCollection objNodes) { //todo: xpath lookup for img attribute so we don't waste time looping. foreach (MenuNode objNode in objNodes) { if (!String.IsNullOrEmpty(objNode.Image)) { if (this.ImageList.Contains(new NodeImage(objNode.Image)) == false) { objNode.ImageIndex = this.ImageList.Add(objNode.Image); } else { objNode.ImageIndex = this.ImageList.IndexOf(new NodeImage(objNode.Image)); } objNode.Image = null; } if (objNode.DNNNodes.Count > 0) UpdateNodes(objNode.MenuNodes); } }
private void GetUrlTokens( MenuNodeCollection objNodes, ref Hashtable objTokens ) { if( objTokens == null ) { objTokens = new Hashtable(); } foreach( MenuNode objNode in objNodes ) { if( objNode.NavigateURL.Length > 0 ) { AddUrlTokens( objNode.NavigateURL, ref objTokens ); } GetUrlTokens( objNode.MenuNodes, ref objTokens ); } }
public void LoadXml(string strXml) { m_objNodes = new MenuNodeCollection(strXml, "", this); }
public string RaiseClientAPICallbackEvent(string eventArgument) { string[] aryArgs = eventArgument.Split(new String[]{ClientAPI.COLUMN_DELIMITER}, StringSplitOptions.None); string strNodeXml = "<root>" + aryArgs[0] + "</root>"; MenuNodeCollection objNodes = new MenuNodeCollection(strNodeXml, "", this); MenuNode objNode = objNodes[0]; if ((objNode != null)) { if (PopulateOnDemand != null) { PopulateOnDemand(this, new DNNMenuEventArgs(objNode)); } MenuNode objTNode = this.FindNode(objNode.ID); //if whole Menu was populated (i.e. LoadXml, then use the node from the Menu if ((objTNode != null)) { return objTNode.XmlNode.InnerXml; } else { //if only passed in node object was updated then use that xml. return objNode.XmlNode.InnerXml; } } else { return null; } }
protected override void OnLoad(System.EventArgs e) { if (IsDownLevel && !String.IsNullOrEmpty(ViewState["xml"].ToString())) m_objNodes = new MenuNodeCollection((string)ViewState["xml"], "", this); //RegisterClientScript() }
protected override void OnLoad( EventArgs e ) { if( IsDownLevel && Strings.Len( ViewState["xml"] ) > 0 ) { m_objNodes = new MenuNodeCollection( ViewState["xml"].ToString(), "", this ); } //RegisterClientScript() }
private void UpdateNodes( MenuNodeCollection objNodes ) { MenuNode objNode; //todo: xpath lookup for img attribute so we don't waste time looping. foreach( MenuNode tempLoopVar_objNode in objNodes ) { objNode = tempLoopVar_objNode; if( objNode.Image.Length > 0 ) { if( this.ImageList.Contains( new NodeImage( objNode.Image ) ) == false ) { objNode.ImageIndex = this.ImageList.Add( objNode.Image ); } else { objNode.ImageIndex = this.ImageList.IndexOf( new NodeImage( objNode.Image ) ); } objNode.Image = null; } if( objNode.DNNNodes.Count > 0 ) { UpdateNodes( objNode.MenuNodes ); } } }