private void PopulateListControl( ListControl listBox, SiteMapNode siteMapNode, string pagePrefix) { mojoSiteMapNode mojoNode = (mojoSiteMapNode)siteMapNode; if (!mojoNode.IsRootNode) { if ((isAdmin) || ((isContentAdmin) && (mojoNode.ViewRoles != "Admins;")) || ((isSiteEditor) && (mojoNode.ViewRoles != "Admins;")) || (WebUser.IsInRoles(mojoNode.CreateChildPageRoles)) ) { if (mojoNode.ParentId > -1) { pagePrefix += "-"; } ListItem listItem = new ListItem(); listItem.Text = pagePrefix + Server.HtmlDecode(mojoNode.Title); listItem.Value = mojoNode.PageId.ToInvariantString(); listBox.Items.Add(listItem); userCanAddPages = true; } } foreach (SiteMapNode childNode in mojoNode.ChildNodes) { //recurse to populate children PopulateListControl(listBox, childNode, pagePrefix); } }
private string FormatUrl(mojoSiteMapNode mapNode) { string itemUrl = Page.ResolveUrl(mapNode.Url); if (resolveFullUrlsForMenuItemProtocolDifferences) { if (isSecureRequest) { if ( (!mapNode.UseSsl) && (!siteSettings.UseSslOnAllPages) && (mapNode.Url.StartsWith("~/")) ) { itemUrl = insecureSiteRoot + mapNode.Url.Replace("~/", "/"); } } else { if ((mapNode.UseSsl) || (siteSettings.UseSslOnAllPages)) { if (mapNode.Url.StartsWith("~/")) { itemUrl = secureSiteRoot + mapNode.Url.Replace("~/", "/"); } } } } return(itemUrl); }
private void RenderSiteMapNodes( HttpContext context, SiteMapNode siteMapNode, string pagePrefix) { mojoSiteMapNode mojoNode = (mojoSiteMapNode)siteMapNode; if (!mojoNode.IsRootNode) { if (WebUser.IsInRoles(mojoNode.ViewRoles)) { if (mojoNode.ParentId > -1) { pagePrefix += "-"; } context.Response.Write("\t<li class=\"file ext_txt\"><a href=\"#\" rel=\"" + page.ResolveUrl(mojoNode.Url) + "\">" + pagePrefix + mojoNode.Title + "</a></li>\n"); } } foreach (SiteMapNode childNode in mojoNode.ChildNodes) { //recurse to populate children RenderSiteMapNodes(context, childNode, pagePrefix); } }
private void PopulatePageDictionary( Collection <DictionaryEntry> deCollection, SiteMapNode siteMapNode, string pagePrefix) { mojoSiteMapNode mojoNode = (mojoSiteMapNode)siteMapNode; if (!mojoNode.IsRootNode) { if (mojoNode.ParentId > -1) { pagePrefix += "-"; } deCollection.Add(new DictionaryEntry( mojoNode.Title, mojoNode.PageId.ToString()) ); } foreach (SiteMapNode childNode in mojoNode.ChildNodes) { //recurse to populate children PopulatePageDictionary(deCollection, childNode, pagePrefix); } }
void breadCrumbsControl_ItemDataBound(object sender, SiteMapNodeItemEventArgs e) { if (enableUnclickableLinks) { mojoSiteMapNode mapNode = (mojoSiteMapNode)e.Item.SiteMapNode; if ((mapNode != null) && (!mapNode.IsClickable)) { e.Item.Enabled = false; } } }
private bool ShouldAdd(mojoSiteMapNode mapNode) { if (mapNode == null) { return(false); } 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.HideAfterLogin) && (WebUser.IsInRole("Authenticated"))) { remove = true; } { return(!remove); } }
private void RenderChildNodes(HtmlTextWriter writer, SiteMapNode node) { writer.Write("<ul"); writer.Write(BuildUlClass((mojoSiteMapNode)node)); writer.Write(">"); int itemsAdded = 0; int trueItemsAdded = 0; int nodePos = 0; bool renderDivider = false; foreach (SiteMapNode childNode in node.ChildNodes) { mojoSiteMapNode mojoNode = childNode as mojoSiteMapNode; if (mojoNode == null) { continue; } if (!ShouldRender(mojoNode)) { continue; } renderDivider = !String.IsNullOrEmpty(dividerElement) && (nodePos < startingNode.ChildNodes.Count); //RenderNode(writer, mojoNode); RenderNode(writer, mojoNode, renderDivider); nodePos += 1; itemsAdded += 1; trueItemsAdded += 1; if (childNodesPerUl > -1) { if ((itemsAdded == childNodesPerUl) && (trueItemsAdded < node.ChildNodes.Count)) { //writer.Write("</ul><ul>"); writer.Write("</ul><ul" + BuildUlClass((mojoSiteMapNode)childNode) + ">"); itemsAdded = 0; } } } writer.Write("</ul>"); }
private bool IsValidUrl(mojoSiteMapNode mojoNode) { bool result = true; if (mojoNode.Url.ToLower().Contains("default.aspx?pageid=")) { result = false; } if (mojoNode.Url.Contains("#")) { result = false; } return(result); }
public MenuList() { siteSettings = CacheHelper.GetCurrentSiteSettings(); isAdmin = WebUser.IsAdmin; if (!isAdmin) { isContentAdmin = WebUser.IsContentAdmin; } if ((!isAdmin) && (!isContentAdmin)) { isSiteEditor = SiteUtils.UserIsSiteEditor(); } resolveFullUrlsForMenuItemProtocolDifferences = WebConfigSettings.ResolveFullUrlsForMenuItemProtocolDifferences; if (resolveFullUrlsForMenuItemProtocolDifferences) { secureSiteRoot = WebUtils.GetSecureSiteRoot(); insecureSiteRoot = WebUtils.GetInSecureSiteRoot(); } isSecureRequest = SiteUtils.IsSecureRequest(); siteMapDataSource = new SiteMapDataSource(); siteMapDataSource.SiteMapProvider = "mojosite" + siteSettings.SiteId.ToInvariantString(); rootNode = siteMapDataSource.Provider.RootNode; currentNode = SiteUtils.GetCurrentPageSiteMapNode(rootNode); startingNode = rootNode; //if (startingNodePageId > -1) //{ // startingNode = SiteUtils.GetSiteMapNodeForPage(rootNode, startingNodePageId); //} //else if (startingNodeOffset > -1) //{ // startingNode = SiteUtils.GetOffsetNode(currentNode, startingNodeOffset); //} //else if (isSubMenu) //{ // startingNode = SiteUtils.GetTopLevelParentNode(currentNode); //} Items = AddNodes(startingNode); }
private string BuildAnchorClass(mojoSiteMapNode mojoNode) { string result = string.Empty; string spacer = string.Empty; if (anchorCssClass.Length > 0) { result += anchorCssClass; spacer = " "; } if ((anchorChildSelectedCssClass.Length > 0) && (currentNode != null) && (currentNode.IsDescendantOf(mojoNode)) ) { result += spacer + anchorChildSelectedCssClass; spacer = " "; } if ((anchorSelectedCssClass.Length > 0) && (currentNode != null) && (currentNode.PageGuid == mojoNode.PageGuid) ) { result += spacer + anchorSelectedCssClass; spacer = " "; } if ((renderCustomClassOnAnchor) && (mojoNode.MenuCssClass.Length > 0)) { result += spacer + mojoNode.MenuCssClass; spacer = " "; } if (!mojoNode.IsClickable) { result += spacer + "unclickable"; } if (result.Length > 0) { return(" class='" + result + "'"); } return(result); }
private bool HasVisibleChildNodes(mojoSiteMapNode mapNode) { foreach (SiteMapNode childNode in mapNode.ChildNodes) { mojoSiteMapNode mojoNode = childNode as mojoSiteMapNode; if (mojoNode == null) { return(false); } if (ShouldRender(mojoNode)) { return(true); } } return(false); }
private List <mojoMenuItem> AddNodes(SiteMapNode startingNode) { List <mojoMenuItem> items = new List <mojoMenuItem>(); foreach (SiteMapNode childNode in startingNode.ChildNodes) { mojoSiteMapNode mojoNode = childNode as mojoSiteMapNode; if (mojoNode == null) { continue; } if (!ShouldAdd(mojoNode)) { continue; } mojoMenuItem item = new mojoMenuItem { PageId = mojoNode.PageId, Name = mojoNode.Title, Description = mojoNode.MenuDescription, URL = mojoNode.Url, CSSClass = mojoNode.MenuCssClass, Rel = mojoNode.LinkRel, Clickable = mojoNode.IsClickable, OpenInNewTab = mojoNode.OpenInNewWindow, PublishMode = mojoNode.PublishMode, LastModDate = mojoNode.LastModifiedUtc, Children = AddNodes(childNode) }; //todo: figure out the current page and set current=true if we are } return(items); }
private string BuildUlClass(mojoSiteMapNode mojoNode) { string result = string.Empty; string spacer = string.Empty; //added 2013-11-08 https://www.mojoportal.com/Forums/Thread.aspx?pageid=5&t=12214~1#post50717 if (childUlCssClass.Length > 0) { result += spacer + childUlCssClass; spacer = " "; } if ((ulChildSelectedCssClass.Length > 0) && (currentNode != null) && (currentNode.IsDescendantOf(mojoNode)) ) { result += spacer + ulChildSelectedCssClass; spacer = " "; } if ((ulSelectedCssClass.Length > 0) && (currentNode != null) && (currentNode.PageGuid == mojoNode.PageGuid) ) { result += spacer + ulSelectedCssClass; spacer = " "; } if (result.Length > 0) { return(" class='" + result + "'"); } return(result); }
void menu_TreeNodeDataBound(object sender, TreeNodeEventArgs e) { TreeView menu = (TreeView)sender; mojoSiteMapNode mapNode = (mojoSiteMapNode)e.Node.DataItem; if ((useImagesInSiteMap) && (mapNode.MenuImage.Length > 0)) { e.Node.ImageUrl = mapNode.MenuImage; } if (mapNode.OpenInNewWindow) { e.Node.Target = "_blank"; } if (useMenuTooltipForCustomCss) { e.Node.ToolTip = mapNode.MenuCssClass; } //if (treeViewPopulateOnDemand) //{ if (e.Node is mojoTreeNode) { mojoTreeNode tn = e.Node as mojoTreeNode; tn.HasVisibleChildren = mapNode.HasVisibleChildren(); } // } // 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(); 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("~/", "/"); } } } } 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.IncludeInSiteMap) { 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; e.Node.PopulateOnDemand = menu.PopulateNodesFromClient; } if (menu.ShowExpandCollapse) { e.Node.Expanded = mapNode.ExpandOnSiteMap; } } }
private void RenderNode(HtmlTextWriter writer, mojoSiteMapNode mojoNode, bool renderDivider) { if (!ShouldRender(mojoNode)) { return; } writer.Write("<li"); writer.Write(BuildLiClass(mojoNode)); writer.Write(">"); writer.Write("<a"); writer.Write(BuildAnchorClass(mojoNode)); if (mojoNode.OpenInNewWindow) { writer.Write(" target='_blank'"); } if (mojoNode.LinkRel.Length > 0) { writer.Write(" rel='" + mojoNode.LinkRel + "'"); } if (mojoNode.IsClickable || (renderHrefWhenUnclickable && !mojoNode.IsClickable)) { writer.Write(" href='" + FormatUrl(mojoNode) + "'>"); } else { writer.Write(">"); } if ((anchorInnerHtmlTop.Length > 0) && (anchorInnerHtmlBottom.Length > 0)) { writer.Write(anchorInnerHtmlTop); } writer.Write(mojoNode.Title); if ((anchorInnerHtmlTop.Length > 0) && (anchorInnerHtmlBottom.Length > 0)) { writer.Write(anchorInnerHtmlBottom); } writer.Write("</a>"); if ((renderDescription) && (mojoNode.MenuDescription.Length > 0)) { writer.Write("<span"); if (descriptionCssClass.Length > 0) { writer.Write(" class='" + descriptionCssClass + "'"); } writer.Write(">"); writer.Write(mojoNode.MenuDescription); writer.Write("</span>"); } //if (mojoNode.ChildNodes.Count > 0) if (HasVisibleChildNodes(mojoNode)) { if (childContainerElement.Length > 0) { writer.Write("<" + childContainerElement); if (childContainerCssClass.Length > 0) { writer.Write(" class='" + childContainerCssClass + "'"); } writer.Write(">"); } RenderChildNodes(writer, mojoNode); if (childContainerElement.Length > 0) { writer.Write("</" + childContainerElement + ">"); } } writer.Write("</li>"); if (renderDivider) { writer.Write("<" + dividerElement); if (!String.IsNullOrEmpty(dividerCssClass)) { writer.Write(" class='" + dividerCssClass + "'"); } writer.Write("></" + dividerElement + ">"); } }
protected override void Render(HtmlTextWriter writer) { if (HttpContext.Current == null) { return; } if (rootNode == null) { return; } if ((maxDataRenderDepth > -1) && (startingNode.ChildNodes.Count > 0)) { mojoSiteMapNode firstChildNode = startingNode.ChildNodes[0] as mojoSiteMapNode; if (firstChildNode == null) { return; } if (firstChildNode.Depth > maxDataRenderDepth) { return; } } if (containerElement.Length > 0) { writer.Write("<" + containerElement); if (containerCssClass.Length > 0) { writer.Write(" class='" + containerCssClass + "'"); } writer.Write(">"); } if (extraTopMarkup.Length > 0) { writer.Write(extraTopMarkup); } writer.Write("<ul"); if (rootUlCssClass.Length > 0) { writer.Write(" class='" + rootUlCssClass + "'"); } writer.Write(">"); int nodePos = 0; bool renderDivider = false; foreach (SiteMapNode childNode in startingNode.ChildNodes) { mojoSiteMapNode mojoNode = childNode as mojoSiteMapNode; if (mojoNode == null) { continue; } renderDivider = !String.IsNullOrEmpty(dividerElement) && (nodePos < startingNode.ChildNodes.Count); //RenderNode(writer, mojoNode); RenderNode(writer, mojoNode, renderDivider); nodePos += 1; } writer.WriteLine("</ul>"); if (extraBottomMarkup.Length > 0) { writer.Write(extraBottomMarkup); } if (containerElement.Length > 0) { writer.WriteLine("</" + containerElement + ">"); } // writer.WriteLine(" "); }
private string BuildLiClass(mojoSiteMapNode mojoNode) { string result = string.Empty; string spacer = string.Empty; if (((mojoNode.Depth == 0) || (mojoNode.Depth == startingNodeOffset) //|| ((startingNodeOffset > 0) &&(isSubMenu) &&(mojoNode.Depth == startingNodeOffset + 1))) || ((startingNodeOffset > -1) && (mojoNode.Depth == startingNodeOffset + 1))) && (rootLevelLiCssClass.Length > 0)) { result = rootLevelLiCssClass; spacer = " "; } else if (liCssClass.Length > 0) { result = liCssClass; spacer = " "; } if (itemDepthCssPrefix.Length > 0) { result += spacer + itemDepthCssPrefix + mojoNode.Depth.ToInvariantString(); spacer = " "; } //if ((parentLiCssClass.Length > 0) && (mojoNode.ChildNodes.Count > 0)) if ((parentLiCssClass.Length > 0) && (mojoNode.HasVisibleChildren())) { result += spacer + parentLiCssClass; spacer = " "; } if ((liChildSelectedCssClass.Length > 0) && (currentNode != null) && (currentNode.IsDescendantOf(mojoNode)) ) { result += spacer + liChildSelectedCssClass; spacer = " "; } if ((liSelectedCssClass.Length > 0) && (currentNode != null) && (currentNode.PageGuid == mojoNode.PageGuid) ) { result += spacer + liSelectedCssClass; spacer = " "; } if ((renderCustomClassOnLi) && (mojoNode.MenuCssClass.Length > 0)) { result += spacer + mojoNode.MenuCssClass; } if (result.Length > 0) { return(" class='" + result + "'"); } return(result); }
void SiteMap_MenuItemDataBound(object sender, MenuEventArgs e) { Menu menu = (Menu)sender; mojoSiteMapNode mapNode = (mojoSiteMapNode)e.Item.DataItem; if ((usePageImages) && (mapNode.MenuImage.Length > 0)) { e.Item.ImageUrl = mapNode.MenuImage; } 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 ((treatChildPageIndexAsSiteMap) || (hidePagesNotInSiteMap)) { if (!mapNode.IncludeInSiteMap) { remove = true; } } else { if (!mapNode.IncludeInMenu) { 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.Item.Depth == 0) { menu.Items.Remove(e.Item); } else { MenuItem parent = e.Item.Parent; if (parent != null) { parent.ChildItems.Remove(e.Item); } } } }
private void HandleMove() { PageActionResult result = new PageActionResult(); if (!context.Request.IsAuthenticated) { result.Success = false; result.Message = PageManagerResources.InvalidRequest; RenderPageActionResult(result); log.Info("rejected page move request for anonymous user"); return; } int movedNodeId = -1; int targetNodeId = -1; string position = string.Empty; if (context.Request.Form["position"] != null) { position = context.Request.Form["position"]; } if (context.Request.Form["movedNode"] != null) { int.TryParse(context.Request.Form["movedNode"], out movedNodeId); } if (context.Request.Form["targetNode"] != null) { int.TryParse(context.Request.Form["targetNode"], out targetNodeId); } //log.Info("movedNode = " + movedNodeId); //log.Info("targetNode = " + targetNodeId); //log.Info("position = " + position); if ((movedNodeId == -1) || (targetNodeId == -1) || (string.IsNullOrEmpty(position))) { result.Success = false; result.Message = PageManagerResources.InvalidRequest; RenderPageActionResult(result); log.Info("rejected page move request due to invalid page parameters for user " + currentUserName); return; } LoadSiteMapSettings(); mojoSiteMapNode movedNode = SiteUtils.GetSiteMapNodeForPage(rootNode, movedNodeId); mojoSiteMapNode targetNode = SiteUtils.GetSiteMapNodeForPage(rootNode, targetNodeId); if ((movedNode == null) || (targetNode == null)) { result.Success = false; result.Message = PageManagerResources.InvalidRequest; RenderPageActionResult(result); log.Error("movedNode or targetNode was null for user " + currentUserName); return; } if ( (!isAdmin && !isContentAdmin && !isSiteEditor) && (!WebUser.IsInRoles(movedNode.EditRoles)) ) { result.Success = false; result.Message = string.Format( CultureInfo.InvariantCulture, PageManagerResources.MovePageNotAllowedFormat, movedNode.Title); RenderPageActionResult(result); if (logAllActions) { log.Info( string.Format( CultureInfo.InvariantCulture, PageManagerResources.MoveNodeRequestDeniedFormat, currentUserName, movedNode.Title, movedNode.PageId, position, targetNode.Title, targetNode.PageId ) ); } return; } mojoSiteMapNode selectedParentNode = null; PageSettings movedPage; PageSettings targetPage; switch (position) { case "inside": // this case is when moving to a new parent node that doesn't have any children yet // target is the new parent // or when momving to the first position of the current parent if ( (!isAdmin && !isContentAdmin && !isSiteEditor) && (!WebUser.IsInRoles(targetNode.CreateChildPageRoles)) ) { result.Success = false; result.Message = string.Format( CultureInfo.InvariantCulture, PageManagerResources.MoveToNewParentNotAllowedFormat, targetNode.Title); RenderPageActionResult(result); if (logAllActions) { log.Info( string.Format( CultureInfo.InvariantCulture, PageManagerResources.MoveNodeRequestDeniedFormat, currentUserName, movedNode.Title, movedNode.PageId, position, targetNode.Title, targetNode.PageId ) ); } return; } // change parent page id movedPage = new PageSettings(siteSettings.SiteId, movedNode.PageId); targetPage = new PageSettings(siteSettings.SiteId, targetNode.PageId); movedPage.ParentId = targetPage.PageId; movedPage.ParentGuid = targetPage.PageGuid; movedPage.PageOrder = 0; //reset site map cache movedPage.Save(); ResortChildPages(movedPage.ParentId); CacheHelper.ResetSiteMapCache(); result.Success = true; result.Message = "Success"; // no message is shown for success in the ui RenderPageActionResult(result); if (logAllActions) { log.Info( string.Format( CultureInfo.InvariantCulture, PageManagerResources.MoveNodeRequestLogFormat, currentUserName, movedNode.Title, movedNode.PageId, position, targetNode.Title, targetNode.PageId ) ); } return; //break; case "before": // put this page before the target page beneath the same parent as the target if (targetNode.ParentId != movedNode.ParentId) { if (targetNode.ParentId == -1) { //trying to move a page to root if ((!isAdmin && !isContentAdmin && !isSiteEditor) && (!WebUser.IsInRoles(siteSettings.RolesThatCanCreateRootPages)) ) { result.Success = false; result.Message = PageManagerResources.MoveToRootNotAllowed; RenderPageActionResult(result); if (logAllActions) { log.Info( string.Format( CultureInfo.InvariantCulture, PageManagerResources.MoveNodeRequestDeniedFormat, currentUserName, movedNode.Title, movedNode.PageId, position, targetNode.Title, targetNode.PageId ) ); } return; } } else { selectedParentNode = SiteUtils.GetSiteMapNodeForPage(rootNode, targetNode.ParentId); if ( (!isAdmin && !isContentAdmin && !isSiteEditor) && (!WebUser.IsInRoles(selectedParentNode.CreateChildPageRoles)) ) { result.Success = false; result.Message = string.Format( CultureInfo.InvariantCulture, PageManagerResources.MoveToNewParentNotAllowedFormat, targetNode.Title); RenderPageActionResult(result); if (logAllActions) { log.Info( string.Format( CultureInfo.InvariantCulture, PageManagerResources.MoveNodeRequestDeniedFormat, currentUserName, movedNode.Title, movedNode.PageId, position, targetNode.Title, targetNode.PageId ) ); } return; } } movedPage = new PageSettings(siteSettings.SiteId, movedNode.PageId); targetPage = new PageSettings(siteSettings.SiteId, targetNode.PageId); movedPage.ParentId = targetPage.ParentId; movedPage.ParentGuid = targetPage.ParentGuid; // set sort and re-sort movedPage.PageOrder = targetPage.PageOrder - 1; movedPage.Save(); ResortChildPages(targetNode.ParentId); CacheHelper.ResetSiteMapCache(); result.Success = true; result.Message = "Success"; // no message is shown for success in the ui RenderPageActionResult(result); if (logAllActions) { log.Info( string.Format( CultureInfo.InvariantCulture, PageManagerResources.MoveNodeRequestLogFormat, currentUserName, movedNode.Title, movedNode.PageId, position, targetNode.Title, targetNode.PageId ) ); } return; } else { //parent did not change just sort if allowed to edit movedPage = new PageSettings(siteSettings.SiteId, movedNode.PageId); targetPage = new PageSettings(siteSettings.SiteId, targetNode.PageId); // set sort and re-sort movedPage.PageOrder = targetPage.PageOrder - 1; movedPage.Save(); ResortChildPages(targetNode.ParentId); CacheHelper.ResetSiteMapCache(); result.Success = true; result.Message = "Success"; // no message is shown for success in the ui RenderPageActionResult(result); if (logAllActions) { log.Info( string.Format( CultureInfo.InvariantCulture, PageManagerResources.MoveNodeRequestLogFormat, currentUserName, movedNode.Title, movedNode.PageId, position, targetNode.Title, targetNode.PageId ) ); } return; } //break; case "after": default: // put this page after the target page beneath the same parent as the target if (targetNode.ParentId != movedNode.ParentId) { if (targetNode.ParentId == -1) { //trying to move a page to root if ( (!isAdmin && !isContentAdmin && !isSiteEditor) && (!WebUser.IsInRoles(siteSettings.RolesThatCanCreateRootPages)) ) { result.Success = false; result.Message = PageManagerResources.MoveToRootNotAllowed; RenderPageActionResult(result); if (logAllActions) { log.Info( string.Format( CultureInfo.InvariantCulture, PageManagerResources.MoveNodeRequestDeniedFormat, currentUserName, movedNode.Title, movedNode.PageId, position, targetNode.Title, targetNode.PageId ) ); } return; } } else { selectedParentNode = SiteUtils.GetSiteMapNodeForPage(rootNode, targetNode.ParentId); if ( (!isAdmin && !isContentAdmin && !isSiteEditor) && (!WebUser.IsInRoles(selectedParentNode.CreateChildPageRoles)) ) { result.Success = false; result.Message = string.Format( CultureInfo.InvariantCulture, PageManagerResources.MoveToNewParentNotAllowedFormat, targetNode.Title); RenderPageActionResult(result); if (logAllActions) { log.Info( string.Format( CultureInfo.InvariantCulture, PageManagerResources.MoveNodeRequestDeniedFormat, currentUserName, movedNode.Title, movedNode.PageId, position, targetNode.Title, targetNode.PageId ) ); } return; } } // change parent page id movedPage = new PageSettings(siteSettings.SiteId, movedNode.PageId); targetPage = new PageSettings(siteSettings.SiteId, targetNode.PageId); movedPage.ParentId = targetPage.ParentId; movedPage.ParentGuid = targetPage.ParentGuid; // set sort and re-sort movedPage.PageOrder = targetPage.PageOrder + 1; movedPage.Save(); ResortChildPages(targetNode.ParentId); CacheHelper.ResetSiteMapCache(); result.Success = true; result.Message = "Success"; // no message is shown for success in the ui RenderPageActionResult(result); if (logAllActions) { log.Info( string.Format( CultureInfo.InvariantCulture, PageManagerResources.MoveNodeRequestLogFormat, currentUserName, movedNode.Title, movedNode.PageId, position, targetNode.Title, targetNode.PageId ) ); } return; } else { //parent did not change just sort movedPage = new PageSettings(siteSettings.SiteId, movedNode.PageId); targetPage = new PageSettings(siteSettings.SiteId, targetNode.PageId); // set sort and re-sort movedPage.PageOrder = targetPage.PageOrder + 1; movedPage.Save(); ResortChildPages(targetNode.ParentId); CacheHelper.ResetSiteMapCache(); result.Success = true; result.Message = "Success"; // no message is shown for success in the ui RenderPageActionResult(result); if (logAllActions) { log.Info( string.Format( CultureInfo.InvariantCulture, PageManagerResources.MoveNodeRequestLogFormat, currentUserName, movedNode.Title, movedNode.PageId, position, targetNode.Title, targetNode.PageId ) ); } return; } //break; } }
private void BuildChildPages(StringBuilder script, mojoSiteMapNode currentPageNode) { if (currentPageNode == null) { return; } string comma = string.Empty; foreach (SiteMapNode childNode in currentPageNode.ChildNodes) { mojoSiteMapNode mapNode = (mojoSiteMapNode)childNode; bool remove = false; bool canEdit = isAdmin || isContentAdmin || isSiteEditor || WebUser.IsInRoles(mapNode.EditRoles); bool canDelete = canEdit; bool canCreateChildPages = isAdmin || isContentAdmin || isSiteEditor || WebUser.IsInRoles(mapNode.CreateChildPageRoles); if (mapNode.Roles == null) { if ((!isAdmin) && (!isContentAdmin) && (!isSiteEditor)) { remove = true; } } else { // filter out content locked down to admins only unless admin if ((!isAdmin) && (mapNode.Roles.Count == 1) && (mapNode.Roles[0].ToString() == "Admins")) { remove = true; } // if the user is not an editor filter out nodes where user is not in view roles if ((!isAdmin) && (!isContentAdmin) && (!isSiteEditor) && (!WebUser.IsInRoles(mapNode.ViewRoles))) { remove = true; } } //if (!mapNode.IncludeInMenu) { remove = true; } if (mapNode.IsPending && !WebUser.IsAdminOrContentAdminOrContentPublisherOrContentAuthor) { remove = true; } if (!remove) { script.Append(comma); script.Append("{"); script.Append("\"id\":" + mapNode.PageId.ToInvariantString()); script.Append(",\"label\":\"" + Encode(mapNode.Title) + "\""); script.Append(",\"Url\":\"" + FormatUrl(mapNode) + "\""); script.Append(",\"RelativeUrl\":\"" + mapNode.Url.Replace("~/", "/") + "\""); script.Append(",\"IsRoot\":false"); script.Append(",\"ParentId\":" + mapNode.ParentId.ToInvariantString()); script.Append(",\"childcount\":" + mapNode.ChildNodes.Count.ToInvariantString()); script.Append(",\"children\":["); if (renderChildren && mapNode.ChildNodes.Count > 0) { BuildChildPages(script, mapNode); } script.Append("]"); if (mapNode.ChildNodes.Count > 0) { script.Append(",\"load_on_demand\":true"); } if (canEdit) { script.Append(",\"canEdit\":true"); } else { script.Append(",\"canEdit\":false"); } if (canDelete) { script.Append(",\"canDelete\":true"); } else { script.Append(",\"canDelete\":false"); } if (canCreateChildPages) { script.Append(",\"canCreateChild\":true"); } else { script.Append(",\"canCreateChild\":false"); } if (mapNode.ViewRoles.Contains("All Users;")) { script.Append(",\"protection\":\"" + PageManagerResources.Public + "\""); } else { script.Append(",\"protection\":\"" + PageManagerResources.Protected + "\""); } script.Append("}"); comma = ","; } } }
private void HandleDelete() { PageActionResult result = new PageActionResult(); if (!context.Request.IsAuthenticated) { result.Success = false; result.Message = PageManagerResources.InvalidRequest; RenderPageActionResult(result); log.Info("rejected page delete request for anonymous user"); return; } int delNodeId = -1; if (context.Request.Form["delNode"] != null) { int.TryParse(context.Request.Form["delNode"], out delNodeId); } if (delNodeId == -1) { result.Success = false; result.Message = PageManagerResources.InvalidRequest; RenderPageActionResult(result); log.Info("no pageid provided for delete command"); return; } //log.Info("node to delete " + delNodeId); LoadSiteMapSettings(); mojoSiteMapNode deleteNode = SiteUtils.GetSiteMapNodeForPage(rootNode, delNodeId); if (deleteNode == null) { result.Success = false; result.Message = PageManagerResources.InvalidRequest; RenderPageActionResult(result); log.Info("node not found for delete command"); return; } if (!WebUser.IsInRoles(deleteNode.EditRoles)) { result.Success = false; result.Message = string.Format( CultureInfo.InvariantCulture, PageManagerResources.DeletePageNotAllowedFormat, deleteNode.Title); RenderPageActionResult(result); if (logAllActions) { log.Info( string.Format( CultureInfo.InvariantCulture, PageManagerResources.DeletePageDeniedLogFormat, currentUserName, deleteNode.Title, deleteNode.PageId ) ); } return; } if (deleteNode.ChildNodes.Count > 0) { if (!WebUser.IsInRoles(siteSettings.RolesThatCanCreateRootPages)) { // child pages would be orphaned to becomne root level // but user does not have permission to create root pages result.Success = false; result.Message = PageManagerResources.CantOrphanPagesWarning; RenderPageActionResult(result); log.Info("delete would orphan child pages to root but user does not have permission"); return; } } ContentMetaRespository metaRepository = new ContentMetaRespository(); PageSettings pageSettings = new PageSettings(siteSettings.SiteId, deleteNode.PageId); metaRepository.DeleteByContent(deleteNode.PageGuid); Module.DeletePageModules(deleteNode.PageId); PageSettings.DeletePage(deleteNode.PageId); FriendlyUrl.DeleteByPageGuid(deleteNode.PageGuid); mojoPortal.SearchIndex.IndexHelper.ClearPageIndexAsync(pageSettings); CacheHelper.ResetSiteMapCache(); result.Success = true; result.Message = "Success"; RenderPageActionResult(result); if (logAllActions) { log.Info( string.Format( CultureInfo.InvariantCulture, PageManagerResources.DeletePageSuccessLogFormat, currentUserName, deleteNode.Title, deleteNode.PageId ) ); } }
private void SortChildPagesAlpha() { PageActionResult result = new PageActionResult(); if (!context.Request.IsAuthenticated) { result.Success = false; result.Message = PageManagerResources.InvalidRequest; RenderPageActionResult(result); log.Info("rejected page sort children request for anonymous user"); return; } int selNodeId = -1; if (context.Request.Form["selNode"] != null) { int.TryParse(context.Request.Form["selNode"], out selNodeId); } if (selNodeId == -1) { result.Success = false; result.Message = PageManagerResources.InvalidRequest; RenderPageActionResult(result); log.Info("no pageid provided for sort children command"); return; } //log.Info("node to sort " + selNodeId); LoadSiteMapSettings(); mojoSiteMapNode sortNode = SiteUtils.GetSiteMapNodeForPage(rootNode, selNodeId); if (sortNode == null) { result.Success = false; result.Message = PageManagerResources.InvalidRequest; RenderPageActionResult(result); log.Info("node not found for sort children command"); return; } if (!WebUser.IsInRoles(sortNode.EditRoles)) { result.Success = false; result.Message = string.Format( CultureInfo.InvariantCulture, PageManagerResources.MovePageNotAllowedFormat, sortNode.Title); RenderPageActionResult(result); if (logAllActions) { log.Info( string.Format( CultureInfo.InvariantCulture, PageManagerResources.SortChildPagesDeniedLogFromat, currentUserName, sortNode.Title, sortNode.PageId ) ); } return; } if (!WebUser.IsInRoles(sortNode.CreateChildPageRoles)) { result.Success = false; result.Message = string.Format( CultureInfo.InvariantCulture, PageManagerResources.MovePageNotAllowedFormat, sortNode.Title); RenderPageActionResult(result); if (logAllActions) { log.Info( string.Format( CultureInfo.InvariantCulture, PageManagerResources.SortChildPagesDeniedLogFromat, currentUserName, sortNode.Title, sortNode.PageId ) ); } return; } PageSettings pageSettings = new PageSettings(siteSettings.SiteId, sortNode.PageId); pageSettings.ResortPagesAlphabetically(); CacheHelper.ResetSiteMapCache(); result.Success = true; result.Message = "Success"; RenderPageActionResult(result); if (logAllActions) { log.Info( string.Format( CultureInfo.InvariantCulture, PageManagerResources.SortChildPagesSuccessLogFormat, currentUserName, sortNode.Title, sortNode.PageId ) ); } }
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; } } }
private bool IsValidUrl(mojoSiteMapNode mojoNode) { bool result = true; if (mojoNode.Url.ToLower().Contains("default.aspx?pageid=")) { result = false; } if (mojoNode.Url.Contains("#")) { result = false; } return result; }
void pageMenu_MenuItemDataBound(object sender, MenuEventArgs e) { if (sender == null) { return; } if (e == null) { return; } Menu menu = (Menu)sender; mojoSiteMapNode mapNode = (mojoSiteMapNode)e.Item.DataItem; if (mapNode.MenuImage.Length > 0) { e.Item.ImageUrl = mapNode.MenuImage; } if (mapNode.OpenInNewWindow) { e.Item.Target = "_blank"; } if ((useMenuTooltipForCustomCss) && (mapNode.MenuCssClass.Length > 0)) { e.Item.ToolTip = mapNode.MenuCssClass; } if (enableUnclickableLinks) { e.Item.Selectable = mapNode.IsClickable; } if (resolveFullUrlsForMenuItemProtocolDifferences) { if (isSecureRequest) { if ((!mapNode.UseSsl) && (!siteSettings.UseSslOnAllPages) && (mapNode.Url.StartsWith("~/"))) { e.Item.NavigateUrl = insecureSiteRoot + mapNode.Url.Replace("~/", "/"); } } else { if ((mapNode.UseSsl) || (siteSettings.UseSslOnAllPages)) { if (mapNode.Url.StartsWith("~/")) { e.Item.NavigateUrl = secureSiteRoot + mapNode.Url.Replace("~/", "/"); } } } } // 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.Item.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 ((!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.Item.Depth == 0) { menu.Items.Remove(e.Item); } else { MenuItem parent = e.Item.Parent; if (parent != null) { parent.ChildItems.Remove(e.Item); } } } }
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 } }
private void RenderNodesToSiteMap( HttpContext context, Page page, XmlTextWriter xmlTextWriter, ArrayList alreadyAddedUrls, SiteMapNode siteMapNode) { mojoSiteMapNode mojoNode = (mojoSiteMapNode)siteMapNode; if (!mojoNode.IsRootNode) { //if ( // ((mojoNode.Roles == null)||(WebUser.IsInRoles(mojoNode.Roles))) // &&(mojoNode.IncludeInSearchMap) // &&(!mojoNode.IsPending) // ) if ( (WebUser.IsInRoles(mojoNode.ViewRoles)) && (mojoNode.IncludeInSearchMap) && (!mojoNode.IsPending) ) { // must use unique urls, google site maps can't have // multiple urls like" // http://SomeSite/Default.aspx?pageid=1 // http://SomeSite/Default.aspx?pageid=2 // where it only differs by query string // google may stop crawling if it encounters this // in a site map if (IsValidUrl(mojoNode)) { string url; if (mojoNode.Url.StartsWith("http")) { url = mojoNode.Url; } else { if ((mojoNode.UseSsl) || (siteSettings.UseSslOnAllPages)) { url = secureSiteRoot + mojoNode.Url.Replace("~/", "/"); } else { url = insecureSiteRoot + mojoNode.Url.Replace("~/", "/"); } } // no duplicate urls allowed in a google site map if (!alreadyAddedUrls.Contains(url)) { alreadyAddedUrls.Add(url); xmlTextWriter.WriteStartElement("url"); xmlTextWriter.WriteElementString("loc", url); // this if is only needed because this is a new datapoint // after it has been implemented in the db // this if could be removed if (mojoNode.LastModifiedUtc > DateTime.MinValue) { xmlTextWriter.WriteElementString( "lastmod", mojoNode.LastModifiedUtc.ToString("u", CultureInfo.InvariantCulture).Replace(" ", "T")); } xmlTextWriter.WriteElementString( "changefreq", mojoNode.ChangeFrequency.ToString().ToLower()); xmlTextWriter.WriteElementString( "priority", mojoNode.SiteMapPriority); xmlTextWriter.WriteEndElement(); //url } } } } foreach (SiteMapNode childNode in mojoNode.ChildNodes) { RenderNodesToSiteMap( context, page, xmlTextWriter, alreadyAddedUrls, childNode); } }
private bool ShouldRender(mojoSiteMapNode mapNode) { if (mapNode == null) { return(false); } 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.HideAfterLogin) && (Page.Request.IsAuthenticated)) { remove = true; } if ((!isMobileSkin) && (mapNode.PublishMode == mobileOnly)) { remove = true; } if ((isMobileSkin) && (mapNode.PublishMode == webOnly)) { remove = true; } if ((maxDataRenderDepth > -1) && (mapNode.Depth > maxDataRenderDepth)) { remove = true; } { return(!remove); } }
private void RenderChildPageBreadcrumbs() { if (HttpContext.Current == null) { return; } if (currentPageNode == null) { currentPageNode = SiteUtils.GetCurrentPageSiteMapNode(siteMapDataSource.Provider.RootNode); } if (currentPageNode == null) { return; } markup = new StringBuilder(); markup.Append(Separator); string childSeparator = string.Empty; int addedChildren = 0; foreach (SiteMapNode childNode in currentPageNode.ChildNodes) { if (!(childNode is mojoSiteMapNode)) { continue; } mojoSiteMapNode node = childNode as mojoSiteMapNode; if (!node.IncludeInMenu) { continue; } bool remove = false; if (node.Roles == null) { if ((!isAdmin) && (!isContentAdmin) && (!isSiteEditor)) { remove = true; } } else { if ((!isAdmin) && (node.Roles.Count == 1) && (node.Roles[0].ToString() == "Admins")) { remove = true; } if ((!isAdmin) && (!isContentAdmin) && (!isSiteEditor) && (!WebUser.IsInRoles(node.Roles))) { remove = true; } } if (!remove) { markup.Append(childSeparator + "<a class='" + this.cssClass + "' href='" + Page.ResolveUrl(node.Url) + "'>" + node.Title + "</a>"); childSeparator = " - "; addedChildren += 1; } } // this gets rid of the initial separator between bread crumbs and child crumbs if no children were rendered if (addedChildren == 0) { markup = null; } }