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; }
public override SiteMapNodeCollection GetChildNodes(SiteMapNode node) { SiteMapNodeCollection nodes = new SiteMapNodeCollection(); foreach (string topic in DocSiteNavigator.GetSubTopics(node.Key)) nodes.Add(CreateSiteMapNode(topic)); return nodes; }
/// <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; }
/// <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; }
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; }
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 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 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); }
/// <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; }
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); }
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)); }
public override SiteMapNodeCollection GetChildNodes (SiteMapNode node) { if (node == null) throw new ArgumentNullException ("node"); this.BuildSiteMap(); SiteMapNodeCollection col = (SiteMapNodeCollection) NodeToChildren [node]; if (col == null) 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) { if (ret.Count > 0) return SiteMapNodeCollection.ReadOnly (ret); } else return SiteMapNodeCollection.ReadOnly (col); return null; }
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; } } } }
/// <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); }
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; } } } } }
private void FillOneMenuType(string rootUrl, CatalogItemMenuType _mit) { var curMenuTypeHelper = new OneMenuTypeHashHelper(_mit); curMenuTypeHelper.HashUrl.Add(rootUrl.ToLower(), _root); curMenuTypeHelper.HashUrl.Add(rootUrl.ToLower() + "/", _root); curMenuTypeHelper.HashUrl.Add((rootUrl + "/default.aspx").ToLower(), _root); curMenuTypeHelper.HashParent.Add(_root, null); Stack<KeyValuePair<SiteMapNode, int?>> stack = new Stack<KeyValuePair<SiteMapNode, int?>>(); stack.Push(new KeyValuePair<SiteMapNode, int?>(_root, null)); while (stack.Count != 0) { KeyValuePair<SiteMapNode, int?> pair = stack.Pop(); SiteMapNodeCollection childs = new SiteMapNodeCollection(); curMenuTypeHelper.HashChilds[pair.Key] = childs; IEnumerable<CatalogItem> catalogItems = UrlManager.CatalogItems.GetCatalogItems(pair.Value??UrlManager.CatalogItems.RootCatalogItem.CatalogItemID, _mit); foreach (CatalogItem catalogItem in catalogItems) { string url = UrlManager.GetCatalogUrl(catalogItem.CatalogItemID); SiteMapNode node = new SiteMapNode( this, url, url, catalogItem.CatalogItemName, string.IsNullOrEmpty(catalogItem.CssClass) ? "" : catalogItem.CssClass /*прокидываем название css-ника через св-во узла Description*/); try { curMenuTypeHelper.HashParent.Add(node, pair.Key); } catch { continue; } childs.Add(node); curMenuTypeHelper.HashUrl.Add(node.Url.ToLower(), node); curMenuTypeHelper.CatalogItemHash.Add(node, catalogItem); curMenuTypeHelper.CatalogItemRevHash.Add(catalogItem, node); stack.Push(new KeyValuePair<SiteMapNode, int?>(node, catalogItem.CatalogItemID)); } } _menuHashes.Add(_mit, curMenuTypeHelper); }
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; }
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); }
// 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; }
/// <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) { if (Context.User.Identity.IsAuthenticated) { NdiPrincipal principal = (NdiPrincipal)Context.User; m_organisationIdentifier = principal.OrganisationID; } else { m_organisationIdentifier = Guid.Empty; } m_programIdentifier = Guid.Empty; if (Session[Context.User.Identity.Name + "programIdentifier"] != null) { try { m_programIdentifier = new Guid(Session[Context.User.Identity.Name + "programIdentifier"].ToString()); } catch { Session[Context.User.Identity.Name + "programIdentifier"] = null; m_programIdentifier = Guid.Empty; } } m_joboIdentifier = Guid.Empty; if (Session[Context.User.Identity.Name + "joboIdentifier"] != null) { try { m_joboIdentifier = new Guid(Session[Context.User.Identity.Name + "joboIdentifier"].ToString()); } catch { Session[Context.User.Identity.Name + "joboIdentifier"] = null; m_joboIdentifier = Guid.Empty; } } m_jobfIdentifier = Guid.Empty; if (Session[Context.User.Identity.Name + "jobfIdentifier"] != null) { try { m_jobfIdentifier = new Guid(Session[Context.User.Identity.Name + "jobfIdentifier"].ToString()); } catch { Session[Context.User.Identity.Name + "jobfIdentifier"] = null; m_jobfIdentifier = Guid.Empty; } } //hány elem van egy oszlopban if (ConfigurationManager.AppSettings["MenuRowCount"] != null && ConfigurationManager.AppSettings["MenuRowCountGuest"] != null) { if ((!int.TryParse(ConfigurationManager.AppSettings["MenuRowCount"], out m_menuSize)) || (!int.TryParse(ConfigurationManager.AppSettings["MenuRowCountGuest"], out m_menuSizeGuest))) { m_menuSize = 5; m_menuSizeGuest = 4; } } bool registered = false; if (Context.User is NdiPrincipal) { string role1 = ((NdiPrincipal)Context.User).OrganisationID + ".Writer"; string role2 = ((NdiPrincipal)Context.User).OrganisationID + ".Reader"; registered = !Context.User.IsInRole(role1) && !Context.User.IsInRole(role2); } if (!Context.User.Identity.IsAuthenticated || registered) m_menuSize = m_menuSizeGuest; //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(); 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 ? m_menuSize : m_prov.RootNode.ChildNodes.Count; for (int i = 0; i < last; i++) { SiteMapNode node = ExpandUrl(m_prov.RootNode.ChildNodes[i]); if (node["ProgramSelected"] == null) { nodesLeft.Add(node); } else { if (m_programIdentifier != Guid.Empty) { nodesLeft.Add(node); } } } RepeaterLeft.DataSource = nodesLeft; RepeaterLeft.DataBind(); //van középső oszlopunk if (m_prov.RootNode.ChildNodes.Count > m_menuSize) { for (int i = last; i < m_prov.RootNode.ChildNodes.Count; i++) { if (!GetMenuVisibility("DictionaryMenu.Visibility") && m_prov.RootNode.ChildNodes[i].Title == "Szótár") { } else { SiteMapNode node = ExpandUrl(m_prov.RootNode.ChildNodes[i]); if (node["ProgramSelected"] == null) { nodesMiddle.Add(node); } else { if (m_programIdentifier != Guid.Empty) { nodesMiddle.Add(node); } } } } RepeaterCenter.DataSource = nodesMiddle; RepeaterCenter.DataBind(); } else { RepeaterCenter.Visible = false; } //jobb menu if (m_selectedNode != null) { //almenü van kiválasztva if (nodesLeft.Contains(m_selectedNode) || nodesMiddle.Contains(m_selectedNode)) { RepeaterRight.DataSource = (m_selectedNode.ChildNodes); RepeaterRight.DataBind(); } else { //ha nem akarjuk, hoyg az összes főmenü itt legyen if (m_selectedNode.ParentNode != m_selectedNode.RootNode) { RepeaterRight.DataSource = (m_selectedNode.ParentNode.ChildNodes); RepeaterRight.DataBind(); } } } }
/// <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 }
/// <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; }
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; }
// Implement the GetChildNodes method. public override SiteMapNodeCollection GetChildNodes(SiteMapNode node) { // pid string pid = node.Key; SiteMapNodeCollection children = new SiteMapNodeCollection(); if (PortalConfiguration.Site.Pages.ContainsKey(pid)) { // fill collection foreach (PortalPage page in PortalConfiguration.Site.Pages[pid].Pages) { if (page.Hidden) continue; SiteMapNode childNode = CreateNodeFromPage(page); if (childNode != null) children.Add(childNode); } } else { // check if this is a root node if (node.Key == ROOT_NODE_KEY) { foreach (PortalPage page in PortalConfiguration.Site.Pages.Values) { if (page.ParentPage == null && !page.Hidden) { SiteMapNode childNode = CreateNodeFromPage(page); if (childNode != null) children.Add(childNode); } } } } return children; }
public override SiteMapNodeCollection GetChildNodes(SiteMapNode node) { SiteMapNodeCollection nodeCollection = new SiteMapNodeCollection(); foreach (KeyValuePair<string,SiteMapNode> smNode in siteMapTable) { // Exclude root node if (smNode.Value.ParentNode != null) { if (smNode.Value.ParentNode == node) { nodeCollection.Add(smNode.Value); } } } return nodeCollection; }