-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2bcbac4
commit 627224d
Showing
9 changed files
with
120 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/Xperience.Core.Breadcrumbs/Services/DefaultBreadcrumbItemMapper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using CMS; | ||
using CMS.Core; | ||
using CMS.DocumentEngine; | ||
using CMS.SiteProvider; | ||
|
||
using Kentico.Content.Web.Mvc; | ||
|
||
using System; | ||
|
||
using Xperience.Core.Breadcrumbs; | ||
|
||
[assembly: RegisterImplementation(typeof(IBreadcrumbItemMapper), typeof(DefaultBreadcrumbItemMapper), Lifestyle = Lifestyle.Singleton, Priority = RegistrationPriority.SystemDefault)] | ||
namespace Xperience.Core.Breadcrumbs | ||
{ | ||
/// <summary> | ||
/// Default implementation of <see cref="IBreadcrumbItemMapper"/>. | ||
/// </summary> | ||
internal class DefaultBreadcrumbItemMapper : IBreadcrumbItemMapper | ||
{ | ||
private readonly IPageUrlRetriever pageUrlRetriever; | ||
|
||
|
||
public DefaultBreadcrumbItemMapper(IPageUrlRetriever pageUrlRetriever) | ||
{ | ||
this.pageUrlRetriever = pageUrlRetriever; | ||
} | ||
|
||
|
||
public BreadcrumbItem MapPage(TreeNode page, bool isCurrent = false) | ||
{ | ||
var url = String.Empty; | ||
if (!isCurrent) | ||
{ | ||
url = pageUrlRetriever.Retrieve(page).AbsoluteUrl; | ||
} | ||
|
||
return new BreadcrumbItem | ||
{ | ||
Name = page.DocumentName, | ||
Url = url, | ||
IsCurrentPage = isCurrent | ||
}; | ||
} | ||
|
||
public BreadcrumbItem MapSite(SiteInfo site) | ||
{ | ||
return new BreadcrumbItem | ||
{ | ||
IsSiteLink = true, | ||
Name = site.DisplayName, | ||
Url = site.SitePresentationURL | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/Xperience.Core.Breadcrumbs/Services/Interfaces/IBreadcrumbItemMapper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using CMS.DocumentEngine; | ||
using CMS.SiteProvider; | ||
|
||
namespace Xperience.Core.Breadcrumbs | ||
{ | ||
/// <summary> | ||
/// Converts Xperience objects into <see cref="BreadcrumbItem"/>s. | ||
/// </summary> | ||
public interface IBreadcrumbItemMapper | ||
{ | ||
/// <summary> | ||
/// Generates a <see cref="BreadcrumbItem"/> for an Xperience content tree page. | ||
/// </summary> | ||
/// <param name="page">The page to generate the breadcrumb for.</param> | ||
/// <param name="isCurrent">If <c>true</c>, the <paramref name="page"/> is what the visitor is currently viewing.</param> | ||
public BreadcrumbItem MapPage(TreeNode page, bool isCurrent = false); | ||
|
||
|
||
/// <summary> | ||
/// Generates a <see cref="BreadcrumbItem"/> for the current site. | ||
/// </summary> | ||
/// <param name="site">The current Xperience site.</param> | ||
public BreadcrumbItem MapSite(SiteInfo site); | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters