protected void treeMenu1_TreeNodeDataBound(object sender, TreeNodeEventArgs e) { if (sender == null) { return; } if (e == null) { return; } TreeView menu = (TreeView)sender; mojoSiteMapNode mapNode = (mojoSiteMapNode)e.Node.DataItem; if (mapNode.MenuImage.Length > 0) { e.Node.ImageUrl = mapNode.MenuImage; } if ((useMenuTooltipForCustomCss) && (mapNode.MenuCssClass.Length > 0)) { e.Node.ToolTip = mapNode.MenuCssClass; } if (treeViewShowExpandCollapse) { if (e.Node is mojoTreeNode) { mojoTreeNode tn = e.Node as mojoTreeNode; tn.HasVisibleChildren = mapNode.HasVisibleChildren(); } } if (resolveFullUrlsForMenuItemProtocolDifferences) { if (isSecureRequest) { if ((!mapNode.UseSsl) && (!siteSettings.UseSslOnAllPages) && (mapNode.Url.StartsWith("~/"))) { e.Node.NavigateUrl = insecureSiteRoot + mapNode.Url.Replace("~/", "/"); } } else { if ((mapNode.UseSsl) || (siteSettings.UseSslOnAllPages)) { if (mapNode.Url.StartsWith("~/")) { e.Node.NavigateUrl = secureSiteRoot + mapNode.Url.Replace("~/", "/"); } } } } if (mapNode.OpenInNewWindow) { e.Node.Target = "_blank"; } // added this 2007-09-07 // to solve treeview expand issue when page name is the same // as Page Name was used for value if not set explicitly e.Node.Value = mapNode.PageGuid.ToString(); //log.Info("databound tree node with value path " + e.Node.ValuePath); bool remove = false; if (mapNode.Roles == null) { if ((!isAdmin) && (!isContentAdmin) && (!isSiteEditor)) { remove = true; } } else { if ((!isAdmin) && (mapNode.Roles.Count == 1) && (mapNode.Roles[0].ToString() == "Admins")) { remove = true; } if ((!isAdmin) && (!isContentAdmin) && (!isSiteEditor) && (!WebUser.IsInRoles(mapNode.Roles))) { remove = true; } } if ((!isAdmin) && (!isContentAdmin) && (!isSiteEditor) && (!WebUser.IsInRoles(mapNode.ViewRoles))) { remove = true; } if (!mapNode.IncludeInMenu) { remove = true; } //if (mapNode.IsPending && !WebUser.IsAdminOrContentAdminOrContentPublisherOrContentAuthor) remove = true; if (mapNode.IsPending) { if ( (!isAdmin) && (!isContentAdmin) && (!isSiteEditor) && (!WebUser.IsInRoles(mapNode.EditRoles)) && (!WebUser.IsInRoles(mapNode.DraftEditRoles)) ) { remove = true; } } if ((mapNode.HideAfterLogin) && (Request.IsAuthenticated)) { remove = true; } if (isMobileSkin) { if (mapNode.PublishMode == webOnly) { remove = true; } } else { if (mapNode.PublishMode == mobileOnly) { remove = true; } } if (remove) { if (e.Node.Depth == 0) { menu.Nodes.Remove(e.Node); } else { TreeNode parent = e.Node.Parent; if (parent != null) { parent.ChildNodes.Remove(e.Node); } } } else { if (mapNode.HasVisibleChildren()) { e.Node.PopulateOnDemand = treeViewPopulateOnDemand; } else { e.Node.PopulateOnDemand = false; } } }
void tree_TreeNodeDataBound(object sender, TreeNodeEventArgs e) { if (sender == null) { return; } if (e == null) { return; } TreeView menu = (TreeView)sender; if (menu == null) { return; } mojoSiteMapNode mapNode = (mojoSiteMapNode)e.Node.DataItem; if (mapNode == null) { return; } e.Node.NavigateUrl = "javascript:top.window.SetPage('" + mapNode.PageId + "','" + mapNode.Title + "');"; e.Node.Value = mapNode.PageGuid.ToString(); if (e.Node is mojoTreeNode) { mojoTreeNode tn = e.Node as mojoTreeNode; tn.HasVisibleChildren = mapNode.HasVisibleChildren(); } bool remove = false; if ((!isAdmin) && (!isContentAdmin) && (!isSiteEditor) && (!WebUser.IsInRoles(mapNode.CreateChildPageRoles))) { remove = true; } if ((!isAdmin) && (mapNode.ViewRoles == "Admins")) { remove = true; } // don't let children of this page be a choice for this page parent, its circular and causes an error // dont let a page be it's own parent if (((mapNode.ParentId == pageId) && (pageId > -1)) || (mapNode.PageId == pageId)) { remove = true; } if (remove) { if (e.Node.Depth == 0) { menu.Nodes.Remove(e.Node); } else { TreeNode parent = e.Node.Parent; if (parent != null) { parent.ChildNodes.Remove(e.Node); } } } else { #if !MONO if (mapNode.HasChildNodes) { e.Node.PopulateOnDemand = true; } #endif } }
void SiteMap2_TreeNodeDataBound(object sender, TreeNodeEventArgs e) { if (sender == null) { return; } if (e == null) { return; } TreeView menu = (TreeView)sender; mojoSiteMapNode mapNode = (mojoSiteMapNode)e.Node.DataItem; if (e.Node is mojoTreeNode) { mojoTreeNode tn = e.Node as mojoTreeNode; tn.HasVisibleChildren = mapNode.HasVisibleChildren(); } e.Node.Value = mapNode.PageGuid.ToString(); bool remove = false; if (mapNode.Roles == null) { if ((!isAdmin) && (!isContentAdmin) && (!isSiteEditor)) { remove = true; } } else { if ((!isAdmin) && (mapNode.Roles.Count == 1) && (mapNode.Roles[0].ToString() == "Admins")) { remove = true; } if ((!isAdmin) && (!isContentAdmin) && (!isSiteEditor) && (!WebUser.IsInRoles(mapNode.Roles))) { remove = true; } } //if (!mapNode.IncludeInMenu) remove = true; if (!mapNode.IncludeInChildSiteMap) { remove = true; } //if (mapNode.IsPending && !WebUser.IsAdminOrContentAdminOrContentPublisherOrContentAuthor) remove = true; if (mapNode.IsPending) { if ( (!isAdmin) && (!isContentAdmin) && (!isSiteEditor) && (!WebUser.IsInRoles(mapNode.EditRoles)) && (!WebUser.IsInRoles(mapNode.DraftEditRoles)) ) { remove = true; } } if ((mapNode.HideAfterLogin) && (Request.IsAuthenticated)) { remove = true; } if (isMobileSkin) { if (mapNode.PublishMode == webOnly) { remove = true; } } else { if (mapNode.PublishMode == mobileOnly) { remove = true; } } if (maxRenderDepth > -1) { if (e.Node.Depth > maxRenderDepth) { remove = true; } } if (remove) { if (e.Node.Depth == 0) { menu.Nodes.Remove(e.Node); } else { TreeNode parent = e.Node.Parent; if (parent != null) { parent.ChildNodes.Remove(e.Node); } } } else { if (honorSiteMapExpandSettings && menu.ShowExpandCollapse) { e.Node.Expanded = mapNode.ExpandOnSiteMap; } } }