public override SiteMapNodeCollection GetChildNodes(SiteMapNode node) { List<string> folderPaths = new List<string>(); if (node.Key == "/" || node is RootNode) { foreach (var folder in N2.Context.Current.Resolve<IHost>().CurrentSite.UploadFolders) { if (!folderPaths.Contains(folder.Path)) folderPaths.Add(folder.Path); } foreach (string folderUrl in N2.Context.Current.EditManager.UploadFolders) { if (!folderPaths.Contains(folderUrl)) folderPaths.Add(folderUrl); } } else { foreach(FileData file in FileSystem.GetFiles(node.Url)) folderPaths.Add(VirtualPathUtility.ToAppRelative(file.VirtualPath)); foreach(DirectoryData dir in FileSystem.GetDirectories(node.Url)) folderPaths.Add(VirtualPathUtility.ToAppRelative(dir.VirtualPath)); } SiteMapNodeCollection nodes = new SiteMapNodeCollection(); foreach (string folderPath in folderPaths) nodes.Add(NewNode(folderPath)); return nodes; }
internal protected override void AddNode (SiteMapNode node, SiteMapNode parentNode) { if (node == null) throw new ArgumentNullException ("node"); lock (this) { string url = node.Url; if (url != null && url.Length > 0) { if (UrlUtils.IsRelativeUrl (url)) url = UrlUtils.Combine (HttpRuntime.AppDomainAppVirtualPath, url); else url = UrlUtils.ResolveVirtualPathFromAppAbsolute (url); if (FindSiteMapNode (url) != null) throw new InvalidOperationException (); UrlToNode [url] = node; } if (FindSiteMapNodeFromKey (node.Key) != null) throw new InvalidOperationException (string.Format ("A node with key {0} already exists.",node.Key)); KeyToNode [node.Key] = node; if (parentNode != null) { NodeToParent [node] = parentNode; if (NodeToChildren [parentNode] == null) NodeToChildren [parentNode] = new SiteMapNodeCollection (); ((SiteMapNodeCollection) NodeToChildren [parentNode]).Add (node); } } }
/// <devdoc> /// <para>Add single node to provider tree and sets the parent-child relation.</para> /// </devdoc> protected internal override void AddNode(SiteMapNode node, SiteMapNode parentNode) { if (node == null) { throw new ArgumentNullException("node"); } lock (_lock) { bool validUrl = false; string url = node.Url; if (!String.IsNullOrEmpty(url)) { if (HttpRuntime.AppDomainAppVirtualPath != null) { if (!UrlPath.IsAbsolutePhysicalPath(url)) { url = UrlPath.Combine(HttpRuntime.AppDomainAppVirtualPathString, url); // Normalize url url = UrlPath.MakeVirtualPathAppAbsolute(url); } if (UrlTable[url] != null) { throw new InvalidOperationException( SR.GetString(SR.XmlSiteMapProvider_Multiple_Nodes_With_Identical_Url, url)); } } validUrl = true; } String key = node.Key; Debug.Assert(key != null); if (KeyTable.Contains(key)) { throw new InvalidOperationException( SR.GetString(SR.XmlSiteMapProvider_Multiple_Nodes_With_Identical_Key, key)); } KeyTable[key] = node; if (validUrl) { UrlTable[url] = node; } if (parentNode != null) { ParentNodeTable[node] = parentNode; if (ChildNodeCollectionTable[parentNode] == null) { ChildNodeCollectionTable[parentNode] = new SiteMapNodeCollection(); } ((SiteMapNodeCollection)ChildNodeCollectionTable[parentNode]).Add(node); } } }
private string CreateSubMenu(SiteMapNodeCollection nodes, bool isRoot) { var tempMenu = String.Format("<ul {0}> ", isRoot ? "[VISIBLE] class='adxm menu'" : ""); foreach (SiteMapNode node in nodes) { var showInNav = PermissionHelper.ShouldViewThePageInNav(node); if (!showInNav) continue; var nodeUrl = ResolveClientUrl((node["MenuUrl"] ?? node.Url)); tempMenu += String.Format( @"<li><a href='{0}' title='{1}' {4}> <span>{2}</span> </a> {3} </li>", nodeUrl, node.Description, Server.HtmlEncode((node["MenuTitle"] ?? node.Title)).Replace(" ", " "), node.HasChildNodes ? CreateSubMenu(node.ChildNodes, false) : "", PermissionHelper.UserHasAccessToPage(node) ? String.Empty : "is_valid='not_available'"); } tempMenu += "</ul>"; return tempMenu; }
protected internal override void RemoveNode(SiteMapNode node) { if (node == null) { throw new ArgumentNullException("node"); } lock (base._lock) { SiteMapNode node2 = (SiteMapNode)this.ParentNodeTable[node]; if (this.ParentNodeTable.Contains(node)) { this.ParentNodeTable.Remove(node); } if (node2 != null) { SiteMapNodeCollection nodes = (SiteMapNodeCollection)this.ChildNodeCollectionTable[node2]; if ((nodes != null) && nodes.Contains(node)) { nodes.Remove(node); } } string url = node.Url; if (((url != null) && (url.Length > 0)) && this.UrlTable.Contains(url)) { this.UrlTable.Remove(url); } string key = node.Key; if (this.KeyTable.Contains(key)) { this.KeyTable.Remove(key); } } }
public SiteMapNodeCollection GetAllNodes() { SiteMapNodeCollection collection = new SiteMapNodeCollection(); GetAllNodesRecursive(collection); return(SiteMapNodeCollection.ReadOnly(collection)); }
public override SiteMapNodeCollection GetChildNodes(SiteMapNode node) { SiteMapNodeCollection nodes = new SiteMapNodeCollection(); foreach (string topic in DocSiteNavigator.GetSubTopics(node.Key)) nodes.Add(CreateSiteMapNode(topic)); return nodes; }
public SiteMapNodeCollection GetAllNodes() { SiteMapNodeCollection ret; ret = new SiteMapNodeCollection(); GetAllNodesRecursive(ret); return(SiteMapNodeCollection.ReadOnly(ret)); }
internal ReadOnlySiteMapNodeCollection(SiteMapNodeCollection collection) { if (collection == null) { throw new ArgumentNullException("collection"); } this._internalCollection = collection; }
public SiteMapNodeCollection(SiteMapNodeCollection value) { if (value == null) { throw new ArgumentNullException("value"); } _initialSize = value.Count; AddRangeInternal(value); }
private void AddSectionChildren(SyndicationWriter writer, SiteMapNodeCollection children) { foreach(SiteMapNode node in children) { this.AddSiteMap(writer, node); this.AddSectionChildren(writer, node.ChildNodes); } }
public static SiteMapNodeCollection ReadOnly(SiteMapNodeCollection collection) { if (collection == null) { throw new ArgumentNullException("collection"); } return(new ReadOnlySiteMapNodeCollection(collection)); }
public SiteMapNodeCollection(SiteMapNodeCollection value) { if (value == null) { throw new ArgumentNullException("value"); } _initialSize = value.Count; AddRangeInternal(value); }
/// <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) { var col = new SiteMapNodeCollection(); var id = new Guid(node.Key); foreach (var page in Page.Pages.Where(page => page.IsVisible && page.Parent == id && page.ShowInList)) { col.Add(new SiteMapNode(this, page.Id.ToString(), page.RelativeLink, page.Title, page.Description)); } return col; }
internal protected override void AddNode(SiteMapNode node, SiteMapNode parentNode) { if (node == null) { throw new ArgumentNullException("node"); } lock (this_lock) { string nodeKey = node.Key; if (FindSiteMapNodeFromKey(nodeKey) != null && node.Provider == this) { throw new InvalidOperationException(string.Format("A node with key '{0}' already exists.", nodeKey)); } string nodeUrl = node.Url; if (!String.IsNullOrEmpty(nodeUrl)) { string url = MapUrl(nodeUrl); SiteMapNode foundNode = FindSiteMapNode(url); if (foundNode != null && String.Compare(foundNode.Url, url, RuntimeHelpers.StringComparison) == 0) { throw new InvalidOperationException(String.Format( "Multiple nodes with the same URL '{0}' were found. " + "StaticSiteMapProvider requires that sitemap nodes have unique URLs.", node.Url )); } urlToNode.Add(url, node); } keyToNode.Add(nodeKey, node); if (node == RootNode) { return; } if (parentNode == null) { parentNode = RootNode; } nodeToParent.Add(node, parentNode); SiteMapNodeCollection children; if (!nodeToChildren.TryGetValue(parentNode, out children)) { nodeToChildren.Add(parentNode, children = new SiteMapNodeCollection()); } children.Add(node); } }
/// <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(); Guid id = new Guid(node.Key); foreach (Page page in Page.Pages) { if ((page.IsVisible) && page.Parent == id && page.ShowInList) col.Add(new SiteMapNode(this, page.Id.ToString(), page.RelativeLink.ToString(), page.Title, page.Description)); } return col; }
/// <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(); Guid id = new Guid(node.Key); foreach (Page page in Page.Pages) { if ((page.IsPublished || Thread.CurrentPrincipal.Identity.IsAuthenticated) && page.Parent == id && page.ShowInList) col.Add(new SiteMapNode(this, page.Id.ToString(), page.RelativeLink.ToString(), page.Title, page.Description)); } return col; }
private static bool nodeIsDescendantOfMenu(SiteMapNode node, out SiteMapNodeCollection col) { col = null; if (node == null) return false; foreach (SiteMapNode menuNode in MenuNodes) { if (!node.IsDescendantOf(menuNode)) continue; col = menuNode.ChildNodes; return true; } return false; }
private void GetAllNodesRecursive(SiteMapNodeCollection collection) { SiteMapNodeCollection childNodes = this.ChildNodes; if (childNodes != null && childNodes.Count > 0) { collection.AddRange(childNodes); foreach (SiteMapNode node in childNodes) { node.GetAllNodesRecursive(collection); } } }
void GetAllNodesRecursive(SiteMapNodeCollection c) { SiteMapNodeCollection childNodes = this.ChildNodes; if (childNodes != null && childNodes.Count > 0) { c.AddRange(childNodes); foreach (SiteMapNode n in childNodes) { n.GetAllNodesRecursive(c); } } }
public static SiteMapNodeCollection ReadOnly(SiteMapNodeCollection collection) { SiteMapNodeCollection col = new SiteMapNodeCollection(); if (collection.list != null) { col.list = ArrayList.ReadOnly(collection.list); } else { col.list = ArrayList.ReadOnly(new ArrayList()); } return(col); }
private static void LoopBranch(SiteMapNodeCollection nodeCollection, ref StringBuilder sb, ref HtmlHelper helper, bool isSub, string[] userroles) { string newUrl = HttpRuntime.AppDomainAppVirtualPath.TrimEnd('/'); 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 //{ newUrl += node.Url; 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]-->", newUrl, helper.Encode(node.Title)); else sb.AppendFormat("<a class=\"" + menuclass + "\" href='{0}'>{1}</a>", newUrl, helper.Encode(node.Title)); //} if (node.ChildNodes.Count > 0) { sb.Append("<ul class=\"cssMenum\">"); LoopBranch(node.ChildNodes, ref sb, ref helper, true, userroles); sb.Append("</ul>"); } sb.AppendLine("<!--[if lte IE 6]></td></tr></table></a><![endif]--></li>"); } } }
public override SiteMapNodeCollection GetChildNodes(SiteMapNode node) { SiteMapNodeCollection nodes = new SiteMapNodeCollection(); ContentItem item = (node != null) ? Context.Persister.Get(int.Parse(node.Key)) : null; // Add published nodes that are pages if (item != null) { foreach (ContentItem child in item.GetChildPagesUnfiltered().Where(GetFilter())) nodes.Add(Convert(child)); } return nodes; }
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>"); } } }
public override SiteMapNodeCollection GetChildNodes(SiteMapNode node) { if (node == null) { throw new ArgumentNullException("node"); } BuildSiteMap(); SiteMapNodeCollection col; if (!nodeToChildren.TryGetValue(node, out col)) { return(SiteMapNodeCollection.EmptyCollection); } SiteMapNodeCollection ret = null; for (int n = 0; n < col.Count; n++) { if (!IsAccessibleToUser(HttpContext.Current, col[n])) { if (ret == null) { ret = new SiteMapNodeCollection(); for (int m = 0; m < n; m++) { ret.Add(col[m]); } } } else if (ret != null) { ret.Add(col[n]); } } if (ret == null) { return(SiteMapNodeCollection.ReadOnly(col)); } else if (ret.Count > 0) { return(SiteMapNodeCollection.ReadOnly(ret)); } else { return(SiteMapNodeCollection.EmptyCollection); } }
public override SiteMapNodeCollection GetChildNodes( SiteMapNode node ) { lock ( this ) { var children = new SiteMapNodeCollection(); InternalSiteMapNode repositorySiteMapNode = _rootRepositorySiteMapNode.GetNodeByKey( node.Key ); foreach ( InternalSiteMapNode child in repositorySiteMapNode.Children ) { children.Add( child.SiteMapNode ); } return children; } }
public override SiteMapNodeCollection GetChildNodes(SiteMapNode node) { SiteMapNodeCollection baseCollection = base.GetChildNodes(node); SiteMapNodeCollection newCollection = new SiteMapNodeCollection(); int count = baseCollection.Count; for (int index = 0; index < count; index++) { SiteMapNode oldNode = baseCollection[index]; // TODO: Filter on oldNode.Roles here SiteMapNode newNode = new SiteMapNode(oldNode.Provider, oldNode.Key, oldNode.Url, Localization.LocalizationManager.GetLocalString (oldNode.Description, oldNode.Title), oldNode.Description); newCollection.Add(newNode); } return baseCollection ; //return newCollection; }
// Return readonly child node collection public override SiteMapNodeCollection GetChildNodes(SiteMapNode node) { if (node == null) { throw new ArgumentNullException("node"); } BuildSiteMap(); SiteMapNodeCollection collection = (SiteMapNodeCollection)ChildNodeCollectionTable[node]; if (collection == null) { SiteMapNode childNodeFromKey = (SiteMapNode)KeyTable[node.Key]; if (childNodeFromKey != null) { collection = (SiteMapNodeCollection)ChildNodeCollectionTable[childNodeFromKey]; } } if (collection != null) { if (!SecurityTrimmingEnabled) { return(SiteMapNodeCollection.ReadOnly(collection)); } HttpContext context = HttpContext.Current; SiteMapNodeCollection trimmedCollection = new SiteMapNodeCollection(collection.Count); foreach (SiteMapNode subNode in collection) { if (subNode.IsAccessibleToUser(context)) { trimmedCollection.Add(subNode); } } return(SiteMapNodeCollection.ReadOnly(trimmedCollection)); } return(SiteMapNodeCollection.Empty); }
private string GetSiteMapLevelAsBulletedList(SiteMapNodeCollection nodes) { string output = string.Empty; foreach (SiteMapNode node in nodes) { if (SiteMap.Providers[myProvider].CurrentNode.IsDescendantOf(node) || SiteMap.Providers[myProvider].CurrentNode == node) { output += string.Format("<li><a href=\"{0}\">{1}</a>", node.Url, node.Title); //Add any children levels, if needed (recursively) if (node.HasChildNodes) { output += GetSiteMapLevelAsBulletedList(node.ChildNodes); } output += "</li>"; } } return output; }
public override SiteMapNodeCollection GetChildNodes(SiteMapNode node) { SiteMapNodeCollection subNodes = base.GetChildNodes(node); HttpContext context = HttpContext.Current; // Do nothing if the modifier doesn't apply if (context == null || !context.Response.UsePathModifier || subNodes.Count == 0) { return(subNodes); } // Apply the modifier to the children nodes SiteMapNodeCollection resultNodes = new SiteMapNodeCollection(subNodes.Count); foreach (SiteMapNode n in subNodes) { resultNodes.Add(ApplyModifierIfExists(n)); } return(resultNodes); }
/// <summary> /// The get child nodes. /// </summary> /// <param name="node"> /// The node. /// </param> /// <returns> /// The <see cref="SiteMapNodeCollection"/>. /// </returns> public override SiteMapNodeCollection GetChildNodes(SiteMapNode node) { SiteMapNodeCollection collection = new SiteMapNodeCollection(); var currentLevel = this.GetNodeLevel(node.Key); if (currentLevel < this.SiteMapLevelsToCreate) { currentLevel++; for (int i = 0; i < DummySiteMapProvider.ChildNodesCount; i++) { var key = DummySiteMapProvider.LevelPrefix + currentLevel + DummySiteMapProvider.NodeIndexPrefix + i; var title = string.Format(System.Globalization.CultureInfo.InvariantCulture, DummySiteMapProvider.ChildTitleFormat, i); var url = string.Format(System.Globalization.CultureInfo.InvariantCulture, DummySiteMapProvider.ChildUrlFormat, i); var childnode = new SiteMapNode(this, key, url, title); collection.Add(childnode); } } return collection; }
private void AddNodesToContainerHierarchyRecursive(SiteMapNodeCollection nodes, SiteMapNode currentNode, Control container) { int i = 0; foreach (SiteMapNode node in nodes) { SiteMapNodeItemType type = SiteMapNodeItemType.Parent; if (node == currentNode) { type = SiteMapNodeItemType.Current; } var item = this.CreateItem(i++, container, type, node); if (node.HasChildNodes) { HtmlGenericControl ul = new HtmlGenericControl("ul"); ul.Attributes["class"] = "sidebar-submenu"; item.Controls.Add(ul); AddNodesToContainerHierarchyRecursive(Provider.GetChildNodes(node), currentNode, ul); } } }
public override SiteMapNodeCollection GetChildNodes(SiteMapNode node) { if (node == null) { throw new ArgumentNullException("node"); } this.BuildSiteMap(); SiteMapNodeCollection collection = (SiteMapNodeCollection)this.ChildNodeCollectionTable[node]; if (collection == null) { SiteMapNode node2 = (SiteMapNode)this.KeyTable[node.Key]; if (node2 != null) { collection = (SiteMapNodeCollection)this.ChildNodeCollectionTable[node2]; } } if (collection == null) { return(SiteMapNodeCollection.Empty); } if (!base.SecurityTrimmingEnabled) { return(SiteMapNodeCollection.ReadOnly(collection)); } HttpContext current = HttpContext.Current; SiteMapNodeCollection nodes2 = new SiteMapNodeCollection(collection.Count); foreach (SiteMapNode node3 in collection) { if (node3.IsAccessibleToUser(current)) { nodes2.Add(node3); } } return(SiteMapNodeCollection.ReadOnly(nodes2)); }
protected internal override void RemoveNode(SiteMapNode node) { if (node == null) { throw new ArgumentNullException("node"); } lock (_lock) { SiteMapNode oldParent = (SiteMapNode)ParentNodeTable[node]; if (ParentNodeTable.Contains(node)) { ParentNodeTable.Remove(node); } if (oldParent != null) { SiteMapNodeCollection collection = (SiteMapNodeCollection)ChildNodeCollectionTable[oldParent]; if (collection != null && collection.Contains(node)) { collection.Remove(node); } } string url = node.Url; if (url != null && url.Length > 0 && UrlTable.Contains(url)) { UrlTable.Remove(url); } string key = node.Key; if (KeyTable.Contains(key)) { KeyTable.Remove(key); } } }
public override System.Web.SiteMapNodeCollection GetChildNodes(System.Web.SiteMapNode node) { System.Web.SiteMapNodeCollection children = new System.Web.SiteMapNodeCollection(); IPublishable<Guid> item = _nodes[new Guid(node.Key)]; // We shouldn't show page's child pages, just section's child pages. if (item is Section) { Section s = (Section)item; foreach (Section child in s.Childs) { if (!_nodes.ContainsKey(child.ID)) _nodes.Add(child.ID, child); SiteMapNode nodewrapper = new SiteMapNode(this, child); if (HttpContext.Current.User.IsInRole("Administrator") || (nodewrapper.IsAccessibleToUser(HttpContext.Current) && child.IsVisible)) children.Add(nodewrapper); } foreach (Page child in s.Pages) { if (!_nodes.ContainsKey(child.ID)) _nodes.Add(child.ID, child); SiteMapNode nodewrapper = new SiteMapNode(this, child); if (HttpContext.Current.User.IsInRole("Administrator") || (nodewrapper.IsAccessibleToUser(HttpContext.Current) && child.IsVisible)) children.Add(nodewrapper); } } return children; }
public virtual void AddRange(SiteMapNodeCollection value) { this.AddRangeInternal(value); }
public override SiteMapNodeCollection GetChildNodes(SiteMapNode node) { if (node == null) { throw new ArgumentNullException("node"); } this.BuildSiteMap(); SiteMapNodeCollection collection = (SiteMapNodeCollection) this.ChildNodeCollectionTable[node]; if (collection == null) { SiteMapNode node2 = (SiteMapNode) this.KeyTable[node.Key]; if (node2 != null) { collection = (SiteMapNodeCollection) this.ChildNodeCollectionTable[node2]; } } if (collection == null) { return SiteMapNodeCollection.Empty; } if (!base.SecurityTrimmingEnabled) { return SiteMapNodeCollection.ReadOnly(collection); } HttpContext current = HttpContext.Current; SiteMapNodeCollection nodes2 = new SiteMapNodeCollection(collection.Count); foreach (SiteMapNode node3 in collection) { if (node3.IsAccessibleToUser(current)) { nodes2.Add(node3); } } return SiteMapNodeCollection.ReadOnly(nodes2); }
private void AddNodeInternal(SiteMapNode node, SiteMapNode parentNode, XmlNode xmlNode) { lock (_lock) { String url = node.Url; String key = node.Key; bool isValidUrl = false; // Only add the node to the url table if it's a static node. if (!String.IsNullOrEmpty(url)) { if (UrlTable[url] != null) { if (xmlNode != null) { throw new ConfigurationErrorsException( SR.GetString(SR.XmlSiteMapProvider_Multiple_Nodes_With_Identical_Url, url), xmlNode); } else { throw new InvalidOperationException(SR.GetString( SR.XmlSiteMapProvider_Multiple_Nodes_With_Identical_Url, url)); } } isValidUrl = true; } if (KeyTable.Contains(key)) { if (xmlNode != null) { throw new ConfigurationErrorsException( SR.GetString(SR.XmlSiteMapProvider_Multiple_Nodes_With_Identical_Key, key), xmlNode); } else { throw new InvalidOperationException( SR.GetString(SR.XmlSiteMapProvider_Multiple_Nodes_With_Identical_Key, key)); } } if (isValidUrl) { UrlTable[url] = node; } KeyTable[key] = node; // Add the new node into parentNode collection if (parentNode != null) { ParentNodeTable[node] = parentNode; if (ChildNodeCollectionTable[parentNode] == null) { ChildNodeCollectionTable[parentNode] = new SiteMapNodeCollection(); } ((SiteMapNodeCollection)ChildNodeCollectionTable[parentNode]).Add(node); } } }
public override void AddRange(SiteMapNodeCollection value) { throw new NotSupportedException(SR.GetString(SR.Collection_readonly)); }
private SiteMapNode ConvertFromXmlNode(XmlNode xmlNode) { if ((xmlNode.Attributes.GetNamedItem("provider") != null) || (xmlNode.Attributes.GetNamedItem("siteMapFile") != null)) { return null; } string text = null; string path = null; string attributeFromXmlNode = null; string str4 = null; text = this.GetAttributeFromXmlNode(xmlNode, "title"); attributeFromXmlNode = this.GetAttributeFromXmlNode(xmlNode, "description"); path = this.GetAttributeFromXmlNode(xmlNode, "url"); str4 = this.GetAttributeFromXmlNode(xmlNode, "roles"); text = this.HandleResourceAttribute(text); attributeFromXmlNode = this.HandleResourceAttribute(attributeFromXmlNode); ArrayList list = new ArrayList(); if (str4 != null) { foreach (string str5 in str4.Split(_seperators)) { string str6 = str5.Trim(); if (str6.Length > 0) { list.Add(str6); } } } list = ArrayList.ReadOnly(list); if (path == null) { path = string.Empty; } if ((path.Length != 0) && !IsAppRelativePath(path)) { path = "~/" + path; } string key = path; if (key.Length == 0) { key = Guid.NewGuid().ToString(); } SiteMapNode parentNode = new SiteMapNode(this, key, path, text, attributeFromXmlNode, list, null, null, null); SiteMapNodeCollection nodes = new SiteMapNodeCollection(); foreach (XmlNode node2 in xmlNode.ChildNodes) { if (node2.NodeType == XmlNodeType.Element) { SiteMapNode node3 = this.ConvertFromXmlNode(node2); if (node3 != null) { nodes.Add(node3); this.AddNode(node3, parentNode); } } } if (path.Length != 0) { if (this.UrlTable.Contains(path)) { throw new InvalidOperationException(System.Design.SR.GetString("DesignTimeSiteMapProvider_Duplicate_Url", new object[] { path })); } this.UrlTable[path] = parentNode; } return parentNode; }
static SiteMapNodeCollection() { EmptyList = new SiteMapNodeCollection(); EmptyList.list = ArrayList.ReadOnly(new ArrayList()); }
public SiteMapNodeCollection(SiteMapNodeCollection value) { AddRangeInternal(value); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, EventArgs e) { string rawUrl = Context.Request.RawUrl; m_menuSize = 3; //a menu sitemapomat használom a menu megjelenítéshez m_prov = SiteMap.Providers[SiteMapProviderName]; //Itt át kell szerveznünk az egész menünket //Megcsináljuk a menünket SiteMapNodeCollection nodesLeft = new SiteMapNodeCollection(); SiteMapNodeCollection nodesMiddle = new SiteMapNodeCollection(); SiteMapNodeCollection nodesRight = new SiteMapNodeCollection(); m_selectedNode = m_prov.CurrentNode; if (m_selectedNode != null) { if (m_selectedNode.ParentNode != null && m_selectedNode.ParentNode.ParentNode != null) m_parentNode = m_selectedNode.ParentNode; } //Bal oszlop int last = m_prov.RootNode.ChildNodes.Count > m_menuSize+1 ? m_menuSize+1 : m_prov.RootNode.ChildNodes.Count; for (int i = 0; i < last; i++) { SiteMapNode node = ExpandUrl(m_prov.RootNode.ChildNodes[i]); if (node["KefMenu"] != "True") nodesLeft.Add(node); } RepeaterLeft.DataSource = nodesLeft; RepeaterLeft.DataBind(); int last2 = m_prov.RootNode.ChildNodes.Count > 2 * m_menuSize+1 ? 2 * m_menuSize+1 : m_prov.RootNode.ChildNodes.Count; //van középső oszlopunk if (m_prov.RootNode.ChildNodes.Count > m_menuSize) { for (int i = last; i < last2; i++) { SiteMapNode node = ExpandUrl(m_prov.RootNode.ChildNodes[i]); if (node["KefMenu"] != "True") nodesMiddle.Add(node); } RepeaterCenter.DataSource = nodesMiddle; RepeaterCenter.DataBind(); } if (m_prov.RootNode.ChildNodes.Count > 2 * m_menuSize) { for (int i = last2; i < m_prov.RootNode.ChildNodes.Count; i++) { SiteMapNode node = ExpandUrl(m_prov.RootNode.ChildNodes[i]); if (node["KefMenu"] != "True") nodesRight.Add(node); } RepeaterRight.DataSource = (nodesRight); RepeaterRight.DataBind(); } //Az összesmenu url-jét beállítjuk, ami kef-es }
/// <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 SiteMapNodeCollection (SiteMapNodeCollection values) { AddRangeInternal (values); }
/// <devdoc> /// <para>Add single node to provider tree and sets the parent-child relation.</para> /// </devdoc> protected internal override void AddNode(SiteMapNode node, SiteMapNode parentNode) { if (node == null) { throw new ArgumentNullException("node"); } lock (_lock) { bool validUrl = false; string url = node.Url; if (!String.IsNullOrEmpty(url)) { if (HttpRuntime.AppDomainAppVirtualPath != null) { if (!UrlPath.IsAbsolutePhysicalPath(url)) { url = UrlPath.Combine(HttpRuntime.AppDomainAppVirtualPathString, url); // Normalize url url = UrlPath.MakeVirtualPathAppAbsolute(url); } if (UrlTable[url] != null) throw new InvalidOperationException( SR.GetString(SR.XmlSiteMapProvider_Multiple_Nodes_With_Identical_Url, url)); } validUrl = true; } String key = node.Key; Debug.Assert(key != null); if (KeyTable.Contains(key)) { throw new InvalidOperationException( SR.GetString(SR.XmlSiteMapProvider_Multiple_Nodes_With_Identical_Key, key)); } KeyTable[key] = node; if (validUrl) { UrlTable[url] = node; } if (parentNode != null) { ParentNodeTable[node] = parentNode; if (ChildNodeCollectionTable[parentNode] == null) ChildNodeCollectionTable[parentNode] = new SiteMapNodeCollection(); ((SiteMapNodeCollection)ChildNodeCollectionTable[parentNode]).Add(node); } } }
// Return readonly child node collection public override SiteMapNodeCollection GetChildNodes(SiteMapNode node) { if (node == null) throw new ArgumentNullException("node"); BuildSiteMap(); SiteMapNodeCollection collection = (SiteMapNodeCollection)ChildNodeCollectionTable[node]; if (collection == null) { SiteMapNode childNodeFromKey = (SiteMapNode)KeyTable[node.Key]; if (childNodeFromKey != null) { collection = (SiteMapNodeCollection)ChildNodeCollectionTable[childNodeFromKey]; } } if (collection != null) { if (!SecurityTrimmingEnabled) { return SiteMapNodeCollection.ReadOnly(collection); } HttpContext context = HttpContext.Current; SiteMapNodeCollection trimmedCollection = new SiteMapNodeCollection(collection.Count); foreach (SiteMapNode subNode in collection) { if (subNode.IsAccessibleToUser(context)) { trimmedCollection.Add(subNode); } } return SiteMapNodeCollection.ReadOnly(trimmedCollection); } return SiteMapNodeCollection.Empty; }
static SiteMapNodeCollection () { EmptyList = new SiteMapNodeCollection (); EmptyList.list = ArrayList.ReadOnly (new ArrayList ()); }
/// <summary> /// Получить набор дочерних веток карты сайта /// </summary> /// <param name="node">Текущая ветка карты сайта</param> /// <returns>Набор дочерних веток карты сайта</returns> public override SiteMapNodeCollection GetChildNodes(System.Web.SiteMapNode node) { String xpath = String.Format(CultureInfo.InvariantCulture, "//map:siteMapNode[@url=\"{0}\"]", node.Url); XmlNamespaceManager nsmanager = new XmlNamespaceManager(this.nodes.NameTable); nsmanager.AddNamespace("map", "http://schemas.microsoft.com/AspNet/SiteMap-File-1.0"); XmlNode n = this.nodes.DocumentElement.SelectSingleNode(xpath, nsmanager); SiteMapNodeCollection collection = new SiteMapNodeCollection(n.ChildNodes.Count); foreach (XmlNode item in n.ChildNodes) { SiteMapNode mn = new SiteMapNode(this, item.Attributes["url"].Value) { Url = item.Attributes["url"].Value, Title = item.Attributes["title"].Value, Description = item.Attributes["description"].Value }; if (item.Attributes["unit"] != null) { mn.UnitName = item.Attributes["unit"].Value; } collection.Add(mn); } return collection; }
private void EnsureChildSiteMapProviderUpToDate(SiteMapProvider childProvider) { SiteMapNode oldNode = (SiteMapNode)ChildProviderTable[childProvider]; SiteMapNode newNode = childProvider.GetRootNodeCore(); if (newNode == null) { throw new ProviderException(SR.GetString(SR.XmlSiteMapProvider_invalid_sitemapnode_returned, childProvider.Name)); } // child providers have been updated. if (!oldNode.Equals(newNode)) { // If the child provider table has been updated, simply return null. // This will happen when the current provider's sitemap file is changed or Clear() is called; if (oldNode == null) { return; } lock (_lock) { oldNode = (SiteMapNode)ChildProviderTable[childProvider]; // If the child provider table has been updated, simply return null. See above. if (oldNode == null) { return; } newNode = childProvider.GetRootNodeCore(); if (newNode == null) { throw new ProviderException(SR.GetString(SR.XmlSiteMapProvider_invalid_sitemapnode_returned, childProvider.Name)); } if (!oldNode.Equals(newNode)) { // If the current provider does not contain any nodes but one child provider // ie. _siteMapNode == oldNode // the oldNode needs to be removed from Url table and the new node will be added. if (_siteMapNode.Equals(oldNode)) { UrlTable.Remove(oldNode.Url); KeyTable.Remove(oldNode.Key); UrlTable.Add(newNode.Url, newNode); KeyTable.Add(newNode.Key, newNode); _siteMapNode = newNode; } // First find the parent node SiteMapNode parent = (SiteMapNode)ParentNodeTable[oldNode]; // parent is null when the provider does not contain any static nodes, ie. // it only contains definition to include one child provider. if (parent != null) { // Update the child nodes table SiteMapNodeCollection list = (SiteMapNodeCollection)ChildNodeCollectionTable[parent]; // Add the newNode to where the oldNode is within parent node's collection. int index = list.IndexOf(oldNode); if (index != -1) { list.Remove(oldNode); list.Insert(index, newNode); } else { list.Add(newNode); } // Update the parent table ParentNodeTable[newNode] = parent; ParentNodeTable.Remove(oldNode); // Update the Url table UrlTable.Remove(oldNode.Url); KeyTable.Remove(oldNode.Key); UrlTable.Add(newNode.Url, newNode); KeyTable.Add(newNode.Key, newNode); } else { // Notify the parent provider to update its child provider collection. XmlSiteMapProvider provider = ParentProvider as XmlSiteMapProvider; if (provider != null) { provider.EnsureChildSiteMapProviderUpToDate(this); } } // Update provider nodes; ChildProviderTable[childProvider] = newNode; _childProviderList = null; } } } }
void GetAllNodesRecursive(SiteMapNodeCollection c) { SiteMapNodeCollection childNodes = this.ChildNodes; if (childNodes != null && childNodes.Count > 0) { c.AddRange (childNodes); foreach (SiteMapNode n in childNodes) n.GetAllNodesRecursive (c); } }
public SiteMapNodeCollection GetAllNodes () { SiteMapNodeCollection ret; ret = new SiteMapNodeCollection (); GetAllNodesRecursive (ret); return SiteMapNodeCollection.ReadOnly (ret); }
private void EnsureChildSiteMapProviderUpToDate(SiteMapProvider childProvider) { SiteMapNode node = (SiteMapNode)this.ChildProviderTable[childProvider]; SiteMapNode rootNodeCore = childProvider.GetRootNodeCore(); if (rootNodeCore == null) { throw new ProviderException(System.Web.SR.GetString("XmlSiteMapProvider_invalid_sitemapnode_returned", new object[] { childProvider.Name })); } if (!node.Equals(rootNodeCore) && (node != null)) { lock (base._lock) { node = (SiteMapNode)this.ChildProviderTable[childProvider]; if (node != null) { rootNodeCore = childProvider.GetRootNodeCore(); if (rootNodeCore == null) { throw new ProviderException(System.Web.SR.GetString("XmlSiteMapProvider_invalid_sitemapnode_returned", new object[] { childProvider.Name })); } if (!node.Equals(rootNodeCore)) { if (this._siteMapNode.Equals(node)) { base.UrlTable.Remove(node.Url); base.KeyTable.Remove(node.Key); base.UrlTable.Add(rootNodeCore.Url, rootNodeCore); base.KeyTable.Add(rootNodeCore.Key, rootNodeCore); this._siteMapNode = rootNodeCore; } SiteMapNode node3 = (SiteMapNode)base.ParentNodeTable[node]; if (node3 != null) { SiteMapNodeCollection nodes = (SiteMapNodeCollection)base.ChildNodeCollectionTable[node3]; int index = nodes.IndexOf(node); if (index != -1) { nodes.Remove(node); nodes.Insert(index, rootNodeCore); } else { nodes.Add(rootNodeCore); } base.ParentNodeTable[rootNodeCore] = node3; base.ParentNodeTable.Remove(node); base.UrlTable.Remove(node.Url); base.KeyTable.Remove(node.Key); base.UrlTable.Add(rootNodeCore.Url, rootNodeCore); base.KeyTable.Add(rootNodeCore.Key, rootNodeCore); } else { XmlSiteMapProvider parentProvider = this.ParentProvider as XmlSiteMapProvider; if (parentProvider != null) { parentProvider.EnsureChildSiteMapProviderUpToDate(this); } } this.ChildProviderTable[childProvider] = rootNodeCore; this._childProviderList = null; } } } } }