public override SiteMapNodeCollection GetChildNodes(System.Web.SiteMapNode node) { PortalSiteMapNode pNode = node as PortalSiteMapNode; if (pNode != null) { if (pNode.Type == NodeTypes.Area) { SiteMapNodeCollection nodeColl = new SiteMapNodeCollection(); //get and add each node List <MenuItem> menuItems = GetMenuItemsForCurrentUser(); //get the top level nodes var topNodes = from m in menuItems where String.IsNullOrEmpty(m.ParentItem) orderby m.SortOrder ascending select m; //add topNodes foreach (MenuItem menu in topNodes) { SiteMapNode cNode = new SiteMapNode(this, menu.Name, menu.URL, menu.Name); cNode.ChildNodes = GetSubNodes(menuItems, menu); nodeColl.Add(cNode); } return(nodeColl); } else { return(base.GetChildNodes(pNode)); } } else { return(new SiteMapNodeCollection()); } }
protected override void CreateChildControls() { return; SPQuery query = new SPQuery(); // supports less than 130,000 records // query.Query = "<Where><Eq><FieldRef Name='_x804c__x4f4d_'/><Value Type='Text'>J</Value></Eq></Where>"; query.Query = "<Where><And><Eq><FieldRef Name='_x6027__x522b_'/><Value Type='Text'>男</Value></Eq><Eq><FieldRef Name='_x804c__x4f4d_'/><Value Type='Text'>J</Value></Eq></And></Where>"; SPWeb web = SPContext.Current.Web; PortalSiteMapProvider ps = PortalSiteMapProvider.WebSiteMapProvider; PortalWebSiteMapNode psNode = (PortalWebSiteMapNode)ps.FindSiteMapNode(web.ServerRelativeUrl); if (psNode != null) { Stopwatch timer = new Stopwatch(); timer.Start(); SiteMapNodeCollection items = ps.GetCachedListItemsByQuery(psNode, "人物列表", query, web); StringBuilder sb = new StringBuilder(); foreach (PortalListItemSiteMapNode item in items) { sb.Append(item["性别"]); sb.Append(","); } timer.Stop(); sb.Append("<hr>"); sb.Append(string.Format("{0:N}", timer.Elapsed.Ticks / 10m)); LiteralControl lc = new LiteralControl(); lc.Text = sb.ToString(); this.Controls.Add(lc); } }
public override IEnumerable GetDesignTimeData(int minimumRows, out bool isSampleData) { string siteMapProvider = null; string startingNodeUrl = null; SiteMapNodeCollection nodes = null; siteMapProvider = this._siteMapDataSource.SiteMapProvider; startingNodeUrl = this._siteMapDataSource.StartingNodeUrl; this._siteMapDataSource.Provider = this._owner.DesignTimeSiteMapProvider; try { this._siteMapDataSource.StartingNodeUrl = null; nodes = ((SiteMapDataSourceView)((IDataSource)this._siteMapDataSource).GetView(base.Name)).Select(DataSourceSelectArguments.Empty) as SiteMapNodeCollection; isSampleData = false; } finally { this._siteMapDataSource.StartingNodeUrl = startingNodeUrl; this._siteMapDataSource.SiteMapProvider = siteMapProvider; } if ((nodes != null) && (nodes.Count == 0)) { isSampleData = true; return(DesignTimeData.GetDesignTimeDataSource(DesignTimeData.CreateDummyDataBoundDataTable(), minimumRows)); } return(nodes); }
private void Page_Load(object sender, System.EventArgs e) { // <snippet1> // The LoadSiteMapData() method loads site navigation // data from persistent storage into a DataTable. DataTable siteMap = LoadSiteMapData(); // Create a SiteMapNodeCollection. SiteMapNodeCollection nodes = new SiteMapNodeCollection(); // Create a SiteMapNode and add it to the collection. SiteMapNode tempNode; DataRow row; int index = 0; while (index < siteMap.Rows.Count) { row = siteMap.Rows[index]; // Create a node based on the data in the DataRow. tempNode = new SiteMapNode(SiteMap.Provider, row["Key"].ToString(), row["Url"].ToString()); // Add the node to the collection. nodes.Add(tempNode); ++index; } // </snippet1> }
private static string GetTreeJson() { StringBuilder jsonAppend = new StringBuilder(); SiteMapNodeCollection nodes = SiteMap.RootNode.ChildNodes; jsonAppend.Append("["); int index = -1; foreach (SiteMapNode node in nodes) { if (!IsInRole(node.Roles)) { continue; } if (node.Description == "hide") { continue; } index++; if (index > 0) { jsonAppend.Append(","); } jsonAppend.Append("{\"id\":\"" + node.Url + "\",\"text\":\"" + node.Title + "\",\"state\":\"open\""); CreateTreeJson(node, ref jsonAppend); jsonAppend.Append("}"); } jsonAppend.Append("]"); return(jsonAppend.ToString()); }
public SiteMapNodeCollection ObtenerPrimerGeneracion(SiteMapNode nodoPadre) { var hijos = nodoPadre.ChildNodes; var listaHijos = new SiteMapNodeCollection(); foreach (var hijoObj in hijos) { var hijo = (SiteMapNode)hijoObj; if (hijo.ParentNode != nodoPadre) { continue; } if (!hijo.Url.Contains("javascript")) { var url = hijo.Url.Split('/'); var accion = url[2]; var controlador = url[1]; if (SesionUsuario.PermitirMenu(accion, controlador)) { listaHijos.Add(hijo); } } else { listaHijos.Add(hijo); } } return(listaHijos); }
//Get the existing collection of site nodes public override SiteMapNodeCollection GetChildNodes(SiteMapNode node) { //Store the node passed to the method and the current node and PortalSiteMapNodes PortalSiteMapNode pNode = node as PortalSiteMapNode; PortalSiteMapNode currentNode = CurrentNode as PortalSiteMapNode; if ((pNode != null) && (currentNode != null)) { //Check that we the node passed in is a SharePoint Site (SPWeb) if (pNode.Type == NodeTypes.Area) { //Get the site's node collection SiteMapNodeCollection nodeCollection = base.GetChildNodes(pNode); //Create two new nodes PortalSiteMapNode newChildNode1 = new PortalSiteMapNode(currentNode.WebNode, "customnodemsdn", NodeTypes.Custom, "http://msdn.microsoft.com", "MSDN", "Microsoft Solution Developer Network"); PortalSiteMapNode newChildNode2 = new PortalSiteMapNode(currentNode.WebNode, "customnodetechnet", NodeTypes.Custom, "http://technet.microsoft.com", "TechNet", "Microsoft IT Pro documentation"); //Add them nodeCollection.Add(newChildNode1); nodeCollection.Add(newChildNode2); //Return the collection return(nodeCollection); } else { //The node passed into this method is not a SharePoint site so we take no action return(base.GetChildNodes(pNode)); } } else { //Couldn't find either the node passed in or the current node. Return an empty collection return(new SiteMapNodeCollection()); } }
/// <summary> /// Creates the <see cref="NodeViewModel"/> from the SiteMapNode and populates recursive their child nodes. /// </summary> /// <param name="node"> /// The original site map node. /// </param> /// <param name="levelsToInclude"> /// The levels to include. /// </param> /// <returns> /// The <see cref="NodeViewModel"/>. /// </returns> private NodeViewModel CreateNodeViewModelRecursive(SiteMapNode node, int?levelsToInclude) { if (levelsToInclude != 0 && this.CheckSiteMapNode(node)) { this.viewModelNodeIds.Add(node.Key); if (node is PageSiteNode) { this.pageSiteNodes.Add((PageSiteNode)node); } var nodeViewModel = this.InstantiateNodeViewModel(node); levelsToInclude--; SiteMapNodeCollection directChildren = node.ChildNodes; foreach (SiteMapNode childNode in directChildren) { NodeViewModel childViewModel = this.CreateNodeViewModelRecursive(childNode, levelsToInclude); if (childViewModel != null) { nodeViewModel.ChildNodes.Add(childViewModel); } } return(nodeViewModel); } return(null); }
/// <summary> /// When overridden in a derived class, retrieves the child nodes of a specific <see cref="T:System.Web.SiteMapNode"></see>. /// </summary> /// <param name="node">The <see cref="T:System.Web.SiteMapNode"></see> for which to retrieve all child nodes.</param> /// <returns> /// A read-only <see cref="T:System.Web.SiteMapNodeCollection"></see> that contains the immediate child nodes of the specified <see cref="T:System.Web.SiteMapNode"></see>; otherwise, null or an empty collection, if no child nodes exist. /// </returns> public override SiteMapNodeCollection GetChildNodes(SiteMapNode node) { SiteMapNodeCollection col = new SiteMapNodeCollection(); if (node != null) { lock (_lock) { DataTable dt = GetDataSource(); DataView dv = dt.DefaultView; dv.RowFilter = String.Format("MenuItemId = {0}", node.Key); if (dv.Count > 0) { int outlineLevel = (int)dv[0]["OutlineLevel"]; string outline = (string)dv[0]["Outline"] + node.Key + "."; dv.RowFilter = String.Format("OutlineLevel = {0} AND Outline LIKE '{1}%' AND IsRoot = 0", outlineLevel + 1, outline); for (int i = 0; i < dv.Count; i++) { col.Add(CreateSiteMapNode(dv[i])); } } } } return(col); }
public ActionResult LoadPages(string node) { NodeCollection result = null; if (node == "_root") { result = SiteMapModel.CreateNode(SiteMap.RootNode).Children; } else { SiteMapNode siteMapNode = SiteMap.Provider.FindSiteMapNodeFromKey(node); SiteMapNodeCollection children = siteMapNode.ChildNodes; result = new NodeCollection(); if (children != null && children.Count > 0) { foreach (SiteMapNode mapNode in siteMapNode.ChildNodes) { result.Add(SiteMapModel.CreateNodeWithOutChildren(mapNode)); } } } return(this.Store(result)); }
//static node creation with children public static Node CreateNode(SiteMapNode siteMapNode) { Node treeNode = new Node(); if (!string.IsNullOrEmpty(siteMapNode.Url)) { treeNode.Href = siteMapNode.Url.StartsWith("~/") ? siteMapNode.Url.Replace("~/", "http://examples.ext.net/") : ("http://examples.ext.net" + siteMapNode.Url); } treeNode.NodeID = siteMapNode.Key; treeNode.Text = siteMapNode.Title; treeNode.Qtip = siteMapNode.Description; SiteMapNodeCollection children = siteMapNode.ChildNodes; if (children != null && children.Count > 0) { foreach (SiteMapNode mapNode in siteMapNode.ChildNodes) { treeNode.Children.Add(SiteMapModel.CreateNode(mapNode)); } } else { treeNode.Leaf = true; } return(treeNode); }
public ActionResult GetNodes(string node) { if (!string.IsNullOrEmpty(node)) { NodeCollection nodes = new NodeCollection(); SiteMapNode siteMapNode = SiteMap.Provider.FindSiteMapNodeFromKey(node); if (siteMapNode == null) { return(this.Store(nodes)); } SiteMapNodeCollection children = siteMapNode.ChildNodes; if (children != null && children.Count > 0) { foreach (SiteMapNode mapNode in siteMapNode.ChildNodes) { nodes.Add(NodeHelper.CreateNodeWithOutChildren(mapNode)); } } return(this.Store(nodes)); } return(new HttpStatusCodeResult(500)); }
/// <exclude /> public override SiteMapNodeCollection GetChildNodes(SiteMapNode node) { Verify.ArgumentNotNull(node, "node"); SiteMapNodeCollection childNodes; var culture = ((CompositeC1SiteMapNode)node).Culture; var container = GetContainer(culture); container.ChildCollectionsMap.TryGetValue(node.Key, out childNodes); if (childNodes == null) { return(SiteMapNodeCollection.ReadOnly(new SiteMapNodeCollection())); } if (!SecurityTrimmingEnabled) { return(SiteMapNodeCollection.ReadOnly(childNodes)); } var context = HttpContext.Current; var returnList = new SiteMapNodeCollection(childNodes.Count); foreach (SiteMapNode child in childNodes) { if (child.IsAccessibleToUser(context)) { returnList.Add(child); } } return(SiteMapNodeCollection.ReadOnly(returnList)); }
public static void SiteMapChildNode(Page p) { PokerSiteMapPath smp = new PokerSiteMapPath(); SiteMapNodeCollection myCol = smp.Provider.GetChildNodes(smp.Provider.RootNode); Assert.AreEqual(1, myCol.Count, "SiteMapChildNode#1"); }
private HierarchicalDataSourceView GetTreeView(string viewPath) { SiteMapNode node = null; // When querying for the whole view, returns the view starting from the designated node. if (String.IsNullOrEmpty(viewPath)) { SiteMapNodeCollection nodes = GetNodes(); if (nodes != null) { return(nodes.GetHierarchicalDataSourceView()); } } // Otherwise, return the child nodes specified by the key (viewPath) else { node = Provider.FindSiteMapNodeFromKey(viewPath); if (node != null) { return(node.ChildNodes.GetHierarchicalDataSourceView()); } } // return the view of an empty readonly collection return(SiteMapNodeCollection.Empty.GetHierarchicalDataSourceView()); }
protected void treeElem_TreeNodePopulate(object sender, TreeNodeEventArgs e) { e.Node.ChildNodes.Clear(); e.Node.PopulateOnDemand = false; int nodeId = ValidationHelper.GetInteger(e.Node.Value, 0); TreeNode node = TreeProvider.SelectSingleNode(nodeId); // Check explore tree permission for current node bool userHasExploreTreePermission = (MembershipContext.AuthenticatedUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.ExploreTree) == AuthorizationResultEnum.Allowed); if (userHasExploreTreePermission) { SiteMapNodeCollection childNodes = MapProvider.GetChildNodes(nodeId); int index = 0; foreach (TreeSiteMapNode childNode in childNodes) { int childNodeId = (int)childNode.NodeData["NodeID"]; if (childNodeId != nodeId) { System.Web.UI.WebControls.TreeNode newNode = CreateNode(childNode, index, true); e.Node.ChildNodes.Add(newNode); index++; } } } else { // Add 'access denied node' System.Web.UI.WebControls.TreeNode tempNode = new System.Web.UI.WebControls.TreeNode(); tempNode.Text = GetString("ContentTree.ExploreChildsDenied"); tempNode.NavigateUrl = (DeniedNodePostback ? mBasePath + "#" : string.Empty); e.Node.ChildNodes.Add(tempNode); } }
void runQueryButton_Click(object sender, EventArgs e) { //The PortalSiteMapProvider class provides high-performance queries for //data that changes infrequently because it makes use of SharePoint's //query caches. If you frequently query for the same dataset that changes rarely, //you should consider using this object to run your queries. //A PortalSiteMapProvider object is large and takes lots of resources to set //up. You should not create a new one for your queries but instead use one of //the examples SharePoint provides by default. If you need to create your own //PortalSiteMapProvider you should configure the web application with web.config. //We'll get the example that SharePoint uses to build the breadcrumb trail PortalSiteMapProvider portalProvider = PortalSiteMapProvider.CurrentNavSiteMapProviderNoEncode; //Write a introductory results line resultsLabel.Text = "Sites: <br />"; //Run a query. This example gets all the child sites. SiteMapNodeCollection children = portalProvider.GetChildNodes(((PortalSiteMapNode)portalProvider.CurrentNode).WebNode, Microsoft.SharePoint.Publishing.NodeTypes.Area, Microsoft.SharePoint.Publishing.NodeTypes.Area); //Loop through the results and display the site title. foreach (SiteMapNode node in children) { resultsLabel.Text += node.Title + "<br />"; } }
// Helper method to get the non-hierarhical path view. ie. from BaseNode to currentNode. // if currentNode is not in the subtree rooted at basenode, returns empty collection. internal SiteMapNodeCollection GetPathNodeCollection(string viewPath) { SiteMapNodeCollection collection = null; if (String.IsNullOrEmpty(viewPath)) { collection = GetNodes(); } else { // Otherwise, return the child nodes specified by the key (viewPath) SiteMapNode node = Provider.FindSiteMapNodeFromKey(viewPath); if (node != null) { collection = node.ChildNodes; } } if (collection == null) { collection = SiteMapNodeCollection.Empty; } return(collection); }
public override SiteMapNodeCollection GetChildNodes(SiteMapNode node) { TraceInfo("GetChildNodes({0})", node.Key); var children = new SiteMapNodeCollection(); var entityNode = node as CrmSiteMapNode; if (entityNode == null || !entityNode.HasCrmEntityName("adx_webpage")) { return(children); } var portal = PortalContext; var context = portal.ServiceContext; var website = portal.Website; var entity = context.MergeClone(entityNode.Entity); var blogs = FindBlogs(context, website, entity); foreach (var blog in blogs) { var blogNode = GetBlogNode(context, blog); if (ChildNodeValidator.Validate(context, blogNode)) { children.Add(blogNode); } } return(children); }
public override SiteMapNodeCollection GetChildNodes(System.Web.SiteMapNode node) { PortalSiteMapNode pNode = node as PortalSiteMapNode; if (pNode != null) { if (pNode.Type == NodeTypes.Area) { SiteMapNodeCollection nodeColl = base.GetChildNodes(pNode); SiteMapNode childNode = new SiteMapNode(this, "<http://www.microsoft.com>", "<http://www.microsoft.com>", "Microsoft"); SiteMapNode childNode1 = new SiteMapNode(this, "<http://support.microsoft.com>", "<http://support.microsoft.com>", "Support"); nodeColl.Add(childNode); SiteMapNodeCollection test = new SiteMapNodeCollection(); test.Add(childNode1); childNode.ChildNodes = test; return(nodeColl); } else { return(base.GetChildNodes(pNode)); } } else { return(new SiteMapNodeCollection()); } }
public override SiteMapNodeCollection GetChildNodes(SiteMapNode node) { PortalSiteMapNode pNode = node as PortalSiteMapNode; if (pNode != null) { if (pNode.Type == NodeTypes.Area && pNode.WebId == SPContext.Current.Site.RootWeb.ID) { SiteMapNodeCollection nodeColl = base.GetChildNodes(pNode); SiteMapNode childNode = new SiteMapNode(this, "<http://www.google.com>", "http://www.google.com", "Google"); SiteMapNode childNode1 = new SiteMapNode(this, "<http://www.bing.com>", "http://www.bing.com", "Bing"); SiteMapNode childNode2 = new SiteMapNode(this, "<http://www.hardocp.com>", "http://www.hardocp.com", "hardocp"); nodeColl.Add(childNode); SiteMapNodeCollection test = new SiteMapNodeCollection(); test.Add(childNode1); test.Add(childNode2); childNode.ChildNodes = test; return(nodeColl); } return(base.GetChildNodes(pNode)); } return(new SiteMapNodeCollection()); }
// Implement the GetChildNodes method. public override SiteMapNodeCollection GetChildNodes(SiteMapNode node) { SiteMapNodeCollection children = new SiteMapNodeCollection(); // Iterate through the ArrayList and find all nodes that have the specified node as a parent. lock (this) { for (int i = 0; i < childParentRelationship.Count; i++) { string nodeUrl = ((DictionaryEntry)childParentRelationship[i]).Key as string; SiteMapNode parent = GetNode(childParentRelationship, nodeUrl); if (parent != null && node.Url == parent.Url) { // The SiteMapNode with the Url that corresponds to nodeUrl // is a child of the specified node. Get the SiteMapNode for // the nodeUrl. SiteMapNode child = FindSiteMapNode(nodeUrl); if (child != null) { children.Add(child as SiteMapNode); } else { throw new Exception("ArrayLists not in sync."); } } } } return(children); }
public override SiteMapNodeCollection GetChildNodes(SiteMapNode node) { SiteMapNodeCollection nodes = new SiteMapNodeCollection(); if (Directory.Exists(node.Key)) { foreach (string path in Directory.GetDirectories(node.Key)) { if (filter.ShowDirectory(path)) { nodes.Add(directoryFactory.CreateNodeFromPath(path)); } } foreach (string path in Directory.GetFiles(node.Key)) { if (filter.ShowFile(path)) { nodes.Add(fileFactory.CreateNodeFromPath(path)); } } } return(nodes); }
private void PopulateControls() { if (HttpContext.Current == null) { return; } if (rootNode == null) { return; } XmlDocument doc = new XmlDocument(); doc.LoadXml("<ZoneList></ZoneList>"); XmlElement root = doc.DocumentElement; XmlHelper.AddNode(doc, root, "ModuleTitle", this.Title); XmlHelper.AddNode(doc, root, "ZoneTitle", CurrentZone.Name); XmlHelper.AddNode(doc, root, "Title", GetZoneTitle(currentNode)); XmlHelper.AddNode(doc, root, "Url", FormatUrl(currentNode)); XmlHelper.AddNode(doc, root, "Target", (currentNode.OpenInNewWindow == true ? "_blank" : "_self")); XmlHelper.AddNode(doc, root, "ImageUrl", (currentNode != null ? currentNode.PrimaryImage : string.Empty)); XmlHelper.AddNode(doc, root, "SecondImageUrl", (currentNode != null ? currentNode.SecondImage : string.Empty)); if (ModuleConfiguration.ResourceFileDef.Length > 0 && ModuleConfiguration.ResourceKeyDef.Length > 0) { List <string> lstResourceKeys = ModuleConfiguration.ResourceKeyDef.SplitOnCharAndTrim(';'); foreach (string item in lstResourceKeys) { XmlHelper.AddNode(doc, root, item, ResourceHelper.GetResourceString(ModuleConfiguration.ResourceFileDef, item)); } } SiteMapNodeCollection allNodes = null; if (config.IsSubZone) { allNodes = startingNode.ChildNodes; } else { allNodes = startingNode.GetAllNodes(); } foreach (SiteMapNode childNode in allNodes) { gbSiteMapNode gbNode = childNode as gbSiteMapNode; if (gbNode == null) { continue; } RenderNode(doc, root, gbNode); } XmlHelper.XMLTransform(xmlTransformer, SiteUtils.GetXsltBasePath("product", ModuleConfiguration.XsltFileName), doc); }
private void LoadTreeView(string roleName) { TreeView1.Nodes.Clear(); SiteMapNodeCollection siteNodeList = SiteMap.RootNode.ChildNodes; foreach (SiteMapNode sNode in siteNodeList) { TreeNode FirstLevelNode = new TreeNode(); FirstLevelNode.Text = sNode.Title; FirstLevelNode.Value = sNode.Title; if (sNode.Roles.Contains(roleName) || sNode.Roles.Contains("*")) { FirstLevelNode.Checked = true; } if (sNode.ChildNodes.Count > 0) { foreach (SiteMapNode s2Node in sNode.ChildNodes) { TreeNode SecondLevelNode = new TreeNode(); SecondLevelNode.Text = s2Node.Title; SecondLevelNode.Value = s2Node.Title; if (s2Node.Roles.Contains(roleName) || s2Node.Roles.Contains("*")) { SecondLevelNode.Checked = true; } FirstLevelNode.ChildNodes.Add(SecondLevelNode); } } TreeView1.Nodes.Add(FirstLevelNode); } }
public override SiteMapNodeCollection GetChildNodes(SiteMapNode node) { SiteMapNodeCollection siteMapNodes = new SiteMapNodeCollection(); // cast from .net node to portalnode PortalSiteMapNode portalNode = node as PortalSiteMapNode; // check it if (portalNode == null) { return(siteMapNodes); } TaxonomySession taxonomySession = new TaxonomySession(SPContext.Current.Site); TermStore termStore = taxonomySession.TermStores[0]; Group termGroup = termStore.Groups["BeckyTermGroup"]; TermSet termSet = termGroup.TermSets["BeckyTermSet"]; // root if (node.Key.ToLower() == SPContext.Current.Web.ServerRelativeUrl.ToLower()) { foreach (var term in termSet.Terms) { siteMapNodes.Add(SetNavNode(portalNode, term)); } } else { var subTerm = termSet.GetTerm(new Guid(node.Key)); foreach (var term in subTerm.Terms) { siteMapNodes.Add(SetNavNode(portalNode, term)); } } return(siteMapNodes); }
private void LoadBreadCrumb() { SiteMapProvider siteMapProvider = SiteMap.Providers["cms"]; SiteMapNodeCollection collection = new SiteMapNodeCollection(); string stt2s = siteMapProvider.RootNode.Title; SiteMapNode currentNode = siteMapProvider.CurrentNode; if (currentNode == null) { currentNode = siteMapProvider.RootNode; } string stts = currentNode.Url; string stt1s = Page.Request.Url.AbsolutePath; if (string.Compare(currentNode.Url, Page.Request.Url.AbsolutePath, true) == 0) { collection.Add(currentNode); } while (currentNode.ParentNode != null) { currentNode = currentNode.ParentNode; collection.Add(currentNode); } StringBuilder html = new StringBuilder(); html.Append("<ul class='page-breadcrumb breadcrumb'>"); for (int count = collection.Count - 1; count > -1; count--) { string title = collection[count].Title; if (count == 0) { if ((collection[count].Url == "/Admin/UserRoles.aspx")) { html.AppendFormat("<li>{1}</li>", collection[count].Url, title); } else { html.AppendFormat("<li><a href=\"{0}\">{1}</a></li>", collection[count].Url, title); } } else if (count == collection.Count - 1) { html.AppendFormat("<li><i class=\"icon-home\"></i><a href=\"{0}\">Home</a> <i class='fa fa-angle-right'></i></li>", collection[count].Url); } else { html.AppendFormat("<li><a href=\"{0}\">{1}</a><i class='fa fa-angle-right'></i></li>", collection[count].Url, title); } } html.Append("</ul>"); this.ltrlBreadCrumb.Text = html.ToString(); }
/// <summary> /// Initializes a new instance of the <see cref="SiteMapNode"/> class. /// </summary> public SiteMapNode() { Visible = true; RouteValues = new RouteValueDictionary(); IncludeInSearchEngineIndex = true; Attributes = new RouteValueDictionary(); ChildNodes = new SiteMapNodeCollection(this); }
public override SiteMapNodeCollection GetChildNodes(SiteMapNode node) { if (node.Title == "Quick launch" || node.Title == "Top Nav") { List <int> appGlobalNodeIds = null; SiteMapNodeCollection result = new SiteMapNodeCollection(); SiteMapNodeCollection childNodes = base.GetChildNodes(node); //if (HttpContext.Current.Request.Cookies["CurrentAppId_" + _webId.ToString("N")] != null) //{ // HttpCookie cookieAppId = HttpContext.Current.Request.Cookies["CurrentAppId_" + _webId.ToString("N")]; // int id = -1; // try // { // id = int.Parse(cookieAppId.Value); // } // catch { } // if (id != -1) // { // appHelper.CurrentAppId = id; // appHelper.VerifyCookieId(); // } //} //else //{ // appHelper.GetMyCurrentAppId(); //} appHelper.GetMyCurrentAppId(); if (appHelper.CurrentAppId != -1) { appGlobalNodeIds = appHelper.TryGetMyAppGlobalNodes(); if (appGlobalNodeIds != null && appGlobalNodeIds.Count > 0) { foreach (SiteMapNode childNode in childNodes) { if (CanShowChildNode(childNode, appGlobalNodeIds)) { result.Add(childNode); } } } return(result); } else { return(base.GetChildNodes(node)); } } else { return(base.GetChildNodes(node)); } }
private void LoopBranch(SiteMapNodeCollection nodeCollection, ref StringBuilder sb, bool isSub, string[] userroles) { string menuclass = "cssMenui0"; if (isSub) { menuclass = "cssMenui"; } foreach (SiteMapNode node in nodeCollection) { bool nodeDisplayStatus = false; foreach (var role in node.Roles) { if (role.Equals("*") || userroles.Contains(role)) { nodeDisplayStatus = true; break; } } if (nodeDisplayStatus) { sb.AppendLine("<li class=\"" + menuclass + "\">"); //if (SiteMap.CurrentNode == node) //{ // if (node.ChildNodes.Count > 0) // sb.AppendFormat("<a class=\"cssMenui0\" href='{0}'>{1}</a>", node.Url, helper.Encode(node.Title)); // else // sb.AppendFormat("<a class=\"cssMenui0\" href='{0}'>{1}</a>", node.Url, helper.Encode(node.Title)); //} //else //{ if (node.ChildNodes.Count > 0) { sb.AppendFormat("<a class=\"" + menuclass + "\" href='{0}'><span>{1}</span><![if gt IE 6]></a><![endif]><!--[if lte IE 6]><table><tr><td><![endif]-->", node.Url, node.Title); } else { sb.AppendFormat("<a class=\"" + menuclass + "\" href='{0}'>{1}</a>", node.Url, node.Title); } //} if (node.ChildNodes.Count > 0) { sb.Append("<ul class=\"cssMenum\">"); LoopBranch(node.ChildNodes, ref sb, true, userroles); sb.Append("</ul>"); } sb.AppendLine("<!--[if lte IE 6]></td></tr></table></a><![endif]--></li>"); } } }
private static void LoopBranch(SiteMapNodeCollection nodeCollection, ref StringBuilder sb, ref HtmlHelper helper) { IRoleRepository db = new RoleRepository(); string User_CAI = HttpContext.Current.User.Identity.Name.ToUpper().Replace("CT\\", ""); string User_Role = db.GetUserRolesByUser(User_CAI); foreach (SiteMapNode node in nodeCollection) { string newUrl = HttpRuntime.AppDomainAppVirtualPath.TrimEnd('/'); bool nodeDisplayStatus = false; foreach (var role in node.Roles) { if (role.Equals("*") || role.Equals(User_Role)) { nodeDisplayStatus = true; break; } } if (nodeDisplayStatus) { sb.AppendLine("<li>"); if (SiteMap.CurrentNode == node) { newUrl += node.Url; if (node.ChildNodes.Count > 0) { sb.AppendFormat("<a class='selectedMenuItem' href='{0}'>{1}</a>", newUrl, helper.Encode(node.Title)); } else { sb.AppendFormat("<a class='selectedMenuItem' href='{0}'>{1}</a>", newUrl, helper.Encode(node.Title)); } } else { newUrl += node.Url; if (node.ChildNodes.Count > 0) { sb.AppendFormat("<a href='{0}'>{1}</a>", newUrl, helper.Encode(node.Title)); } else { sb.AppendFormat("<a href='{0}'>{1}</a>", newUrl, helper.Encode(node.Title)); } } if (node.ChildNodes.Count > 0) { sb.Append("<ul>"); LoopBranch(node.ChildNodes, ref sb, ref helper); sb.Append("</ul>"); } sb.AppendLine("</li>"); } } }
private void LoopBranch(SiteMapNodeCollection nodeCollection, ref StringBuilder sb, bool isSub, string[] userroles) { string menuclass = "cssMenui0"; if (isSub) menuclass = "cssMenui"; foreach (SiteMapNode node in nodeCollection) { bool nodeDisplayStatus = false; foreach (var role in node.Roles) { if (role.Equals("*") || userroles.Contains(role)) { nodeDisplayStatus = true; break; } } if (nodeDisplayStatus) { sb.AppendLine("<li class=\"" + menuclass + "\">"); //if (SiteMap.CurrentNode == node) //{ // if (node.ChildNodes.Count > 0) // sb.AppendFormat("<a class=\"cssMenui0\" href='{0}'>{1}</a>", node.Url, helper.Encode(node.Title)); // else // sb.AppendFormat("<a class=\"cssMenui0\" href='{0}'>{1}</a>", node.Url, helper.Encode(node.Title)); //} //else //{ if (node.ChildNodes.Count > 0) sb.AppendFormat("<a class=\"" + menuclass + "\" href='{0}'><span>{1}</span><![if gt IE 6]></a><![endif]><!--[if lte IE 6]><table><tr><td><![endif]-->", node.Url, node.Title); else sb.AppendFormat("<a class=\"" + menuclass + "\" href='{0}'>{1}</a>", node.Url, node.Title); //} if (node.ChildNodes.Count > 0) { sb.Append("<ul class=\"cssMenum\">"); LoopBranch(node.ChildNodes, ref sb, true, userroles); sb.Append("</ul>"); } sb.AppendLine("<!--[if lte IE 6]></td></tr></table></a><![endif]--></li>"); } } }
protected override void RenderContents(HtmlTextWriter writer) { SiteMapPath path = Control as SiteMapPath; SiteMapProvider Provider = ((SiteMapPath)(Control)).Provider; SiteMapNodeCollection collection = new SiteMapNodeCollection(); SiteMapNode node = Provider.CurrentNode; while(node != null && node != Provider.RootNode) { collection.Add(node); node = node.ParentNode; } for (int i = collection.Count - 1; i > 0; i--) { RenderSiteMapNode(writer, path, collection[i]); writer.Write(" " + path.PathSeparator + " "); } if (collection.Count > 0) { RenderSiteMapNode(writer, path, collection[0]); } }
public SiteMapNodeCollection(SiteMapNodeCollection value) { }
public static SiteMapNodeCollection ReadOnly(SiteMapNodeCollection collection) { }
public virtual void AddRange(SiteMapNodeCollection value) { }
// Implement the GetChildNodes method. public override SiteMapNodeCollection GetChildNodes(SiteMapNode node) { SiteMapNodeCollection children = new SiteMapNodeCollection(); int nodeID = int.Parse(node.Key); // Iterate through the ArrayList and find all nodes that have the specified node as a parent. lock (this) { if (nodeID > 0) { for (int i = 0; i < childParentRelationship.Count; i++) { DictionaryEntry item = (DictionaryEntry)childParentRelationship[i]; int pid = (int)item.Value; if (pid == nodeID) { // The SiteMapNode with the Url that corresponds to nodeUrl // is a child of the specified node. Get the SiteMapNode for // the nodeUrl. int cid = (int)item.Key; SiteMapNode child = GetNodeByID(cid); if (child != null) { children.Add(child as SiteMapNode); } else { throw new Exception("ArrayLists not in sync."); } } } } } return children; }
public SiteMapDataSourceView (SiteMapDataSource owner, string viewName, SiteMapNodeCollection collection) : base (owner, viewName) { this.collection = collection; }
public SiteMapHierarchicalDataSourceView (SiteMapNodeCollection collection) { this.collection = collection; }