Files
Orchard/src/Orchard.Web/Modules/Orchard.Taxonomies/Helpers/PathExtensions.cs
Matteo Piovanelli 4cb0b3b5c4 Localization improvements (#7596)
Updates to handling of MasterContentItem (as they are in 1.10.x)
Synchronization of CultureNeutral Fields and Parts (based on Cloning)
Support for multi-language Blogs (in its own feature in the Blogs module)
Support for multi-language Taxonomies (in its own feature in the Taxonomies module)
2017-04-03 10:33:14 -07:00

31 lines
1.0 KiB
C#

using System;
using System.Linq;
using Orchard.ContentManagement;
using Orchard.Taxonomies.Models;
using Orchard.Taxonomies.ViewModels;
namespace Orchard.Taxonomies.Helpers {
public static class TermExtensions {
public static int GetLevels(this TermPart term) {
return String.IsNullOrEmpty(term.Path) ? 0 : term.Path.Count(c => c == '/') - 1;
}
public static int GetLevels(this TermEntry term) {
return String.IsNullOrEmpty(term.Path) ? 0 : term.Path.Count(c => c == '/') - 1;
}
public static TermEntry CreateTermEntry(this TermPart term) {
return new TermEntry {
Id = term.Id,
Name = term.Name,
Selectable = term.Selectable,
Count = term.Count,
Path = term.Path,
Weight = term.Weight,
IsChecked = false,
ContentItem = term.ContentItem,
HasDraft = term.ContentItem.HasDraft()
};
}
}
}