makes HasContainerInPath public

This commit is contained in:
Shannon
2017-03-28 15:55:45 +11:00
parent fe11d4770d
commit a9fe46da0c
6 changed files with 30 additions and 5 deletions

View File

@@ -1251,7 +1251,12 @@ WHERE cmsContentType." + aliasColumn + @" LIKE @pattern",
return test;
}
internal bool HasContainerInPath(string contentPath)
/// <summary>
/// Given the path of a content item, this will return true if the content item exists underneath a list view content item
/// </summary>
/// <param name="contentPath"></param>
/// <returns></returns>
public bool HasContainerInPath(string contentPath)
{
var ids = contentPath.Split(',').Select(int.Parse);
var sql = new Sql(@"SELECT COUNT(pk) FROM cmsContentType

View File

@@ -8,6 +8,13 @@ namespace Umbraco.Core.Persistence.Repositories
{
public interface IContentTypeRepository : IContentTypeCompositionRepository<IContentType>
{
/// <summary>
/// Given the path of a content item, this will return true if the content item exists underneath a list view content item
/// </summary>
/// <param name="contentPath"></param>
/// <returns></returns>
bool HasContainerInPath(string contentPath);
/// <summary>
/// Gets all entities of the specified <see cref="PropertyType"/> query
/// </summary>

View File

@@ -72,12 +72,17 @@ namespace Umbraco.Core.Services
}
internal bool HasContainerInPath(string contentPath)
/// <summary>
/// Given the path of a content item, this will return true if the content item exists underneath a list view content item
/// </summary>
/// <param name="contentPath"></param>
/// <returns></returns>
public bool HasContainerInPath(string contentPath)
{
using (var uow = UowProvider.GetUnitOfWork())
{
// can use same repo for both content and media
var repository = (ContentTypeRepository) RepositoryFactory.CreateContentTypeRepository(uow);
var repository = RepositoryFactory.CreateContentTypeRepository(uow);
return repository.HasContainerInPath(contentPath);
}
}

View File

@@ -11,6 +11,13 @@ namespace Umbraco.Core.Services
/// </summary>
public interface IContentTypeService : IService
{
/// <summary>
/// Given the path of a content item, this will return true if the content item exists underneath a list view content item
/// </summary>
/// <param name="contentPath"></param>
/// <returns></returns>
bool HasContainerInPath(string contentPath);
int CountContentTypes();
int CountMediaTypes();

View File

@@ -88,7 +88,7 @@ namespace Umbraco.Web.Models.Mapping
{
// map the IsChildOfListView (this is actually if it is a descendant of a list view!)
var parent = content.Parent();
display.IsChildOfListView = parent != null && (parent.ContentType.IsContainer || ((ContentTypeService) contentTypeService).HasContainerInPath(parent.Path));
display.IsChildOfListView = parent != null && (parent.ContentType.IsContainer || contentTypeService.HasContainerInPath(parent.Path));
//map the tree node url
if (HttpContext.Current != null)
@@ -214,6 +214,7 @@ namespace Umbraco.Web.Models.Mapping
}
if (content.HasPublishedVersion)
{
//TODO: This is horribly inneficient
var published = applicationContext.Services.ContentService.GetPublishedVersion(content.Id);
return published.UpdateDate;
}

View File

@@ -69,7 +69,7 @@ namespace Umbraco.Web.Models.Mapping
// Adapted from ContentModelMapper
//map the IsChildOfListView (this is actually if it is a descendant of a list view!)
var parent = media.Parent();
display.IsChildOfListView = parent != null && (parent.ContentType.IsContainer || ((ContentTypeService) contentTypeService).HasContainerInPath(parent.Path));
display.IsChildOfListView = parent != null && (parent.ContentType.IsContainer || contentTypeService.HasContainerInPath(parent.Path));
//map the tree node url
if (HttpContext.Current != null)