PageSiteMap.cs :  » Bloggers » BlogEngine.NET » BlogEngine.Core » Web » Controls » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Bloggers » BlogEngine.NET 
BlogEngine.NET » BlogEngine.Core » Web » Controls » PageSiteMap.cs
using System;
using System.Web;
using System.Text;
using System.Threading;

namespace BlogEngine.Core.Web.Controls{
  /// <summary>
  /// A site map provider for the Pages in BlogEngine.
  /// </summary>
  public class PageSiteMap : SiteMapProvider
  {

    /// <summary>
    /// When overridden in a derived class, retrieves a <see cref="T:System.Web.SiteMapNode"></see> object that represents the page at the specified URL.
    /// </summary>
    /// <param name="rawUrl">A URL that identifies the page for which to retrieve a <see cref="T:System.Web.SiteMapNode"></see>.</param>
    /// <returns>
    /// A <see cref="T:System.Web.SiteMapNode"></see> that represents the page identified by rawURL; otherwise, null, if no corresponding <see cref="T:System.Web.SiteMapNode"></see> is found or if security trimming is enabled and the <see cref="T:System.Web.SiteMapNode"></see> cannot be returned for the current user.
    /// </returns>
    public override SiteMapNode FindSiteMapNode(string rawUrl)
    {
      int i = rawUrl.IndexOf('?');
      string url = rawUrl;
      if (i > 0) url = rawUrl.Substring(0, i);
      int start = url.LastIndexOf('/') + 1;
      int stop = url.LastIndexOf('.');
      url = url.Substring(start, stop - start); 

      foreach (Page page in Page.Pages)
      {
        if ((page.IsVisible) 
          && url.Equals(Utils.RemoveIllegalCharacters(page.Title), StringComparison.OrdinalIgnoreCase))
        {
          return new SiteMapNode(this, page.Id.ToString(), page.RelativeLink.ToString(), page.Title, page.Description);
        }
      }

      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();
      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 parent node of a specific <see cref="T:System.Web.SiteMapNode"></see> object.
    /// </summary>
    /// <param name="node">The <see cref="T:System.Web.SiteMapNode"></see> for which to retrieve the parent node.</param>
    /// <returns>
    /// A <see cref="T:System.Web.SiteMapNode"></see> that represents the parent of node; otherwise, null, if the <see cref="T:System.Web.SiteMapNode"></see> has no parent or security trimming is enabled and the parent node is not accessible to the current user.
    /// </returns>
    public override SiteMapNode GetParentNode(SiteMapNode node)
    {
      if (node == null)
        return null;

      Guid id = new Guid(node.Key);
      Guid parentId = Page.GetPage(id).Parent;
      if (parentId != Guid.Empty && parentId != id)
      {
        Page parent = Page.GetPage(parentId);
        if (parent.IsVisible)
        {
          return new SiteMapNode(this, parent.Id.ToString(), parent.RelativeLink.ToString(), parent.Title, parent.Description);
        }
      }

      return null;
    }

    /// <summary>
    /// When overidden in a derived class, retrieves the root node of all the nodes that are currently managed by the current provider.
    /// </summary>
    /// <returns>
    /// A <see cref="T:System.Web.SiteMapNode"></see> that represents the root node of the set of nodes that the current provider manages.
    /// </returns>
    protected override SiteMapNode GetRootNodeCore()
    {
      Page page = Page.GetFrontPage();
      if (page != null)
        return new SiteMapNode(this, page.Id.ToString(), page.RelativeLink.ToString(), page.Title);

      return new SiteMapNode(this, Guid.Empty.ToString(), "~/", "Home");
    }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.