mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-26 20:16:15 +08:00
Formatting Taxonomies source files
This commit is contained in:
@@ -129,12 +129,12 @@ namespace Orchard.Taxonomies.Controllers {
|
||||
var parents = new Stack<TermPosition>();
|
||||
TermPosition parentTerm = null;
|
||||
while (null != (line = reader.ReadLine())) {
|
||||
|
||||
|
||||
// ignore empty lines
|
||||
if(String.IsNullOrWhiteSpace(line)) {
|
||||
if (String.IsNullOrWhiteSpace(line)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// compute level from tabs
|
||||
var level = 0;
|
||||
while (line[level] == '\t') level++; // number of tabs to know the level
|
||||
@@ -146,20 +146,22 @@ namespace Orchard.Taxonomies.Controllers {
|
||||
if (level == previousLevel + 1) {
|
||||
parentTerm = parents.Peek();
|
||||
parents.Push(new TermPosition { Term = term });
|
||||
} else if (level == previousLevel) {
|
||||
}
|
||||
else if (level == previousLevel) {
|
||||
// same parent term
|
||||
if (parents.Any())
|
||||
parents.Pop();
|
||||
|
||||
parents.Push(new TermPosition { Term = term });
|
||||
} else if (level < previousLevel) {
|
||||
}
|
||||
else if (level < previousLevel) {
|
||||
for (var i = previousLevel; i >= level; i--)
|
||||
parents.Pop();
|
||||
|
||||
parentTerm = parents.Any() ? parents.Peek() : null;
|
||||
parents.Push(new TermPosition { Term = term });
|
||||
}
|
||||
|
||||
|
||||
// increment number of children
|
||||
if (parentTerm == null) {
|
||||
parentTerm = topTerm;
|
||||
@@ -177,7 +179,8 @@ namespace Orchard.Taxonomies.Controllers {
|
||||
if (scIndex != -1) {
|
||||
term.Name = line.Substring(0, scIndex);
|
||||
term.Slug = line.Substring(scIndex + 1);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
term.Name = line;
|
||||
}
|
||||
|
||||
@@ -187,7 +190,7 @@ namespace Orchard.Taxonomies.Controllers {
|
||||
if (existing != null && existing.Container.ContentItem.Record == term.Container.ContentItem.Record) {
|
||||
Services.Notifier.Error(T("The term {0} already exists at this level", term.Name));
|
||||
Services.TransactionManager.Cancel();
|
||||
return View(new ImportViewModel {Taxonomy = taxonomy, Terms = terms});
|
||||
return View(new ImportViewModel { Taxonomy = taxonomy, Terms = terms });
|
||||
}
|
||||
|
||||
_taxonomyService.ProcessPath(term);
|
||||
|
||||
@@ -137,21 +137,21 @@ namespace Orchard.Taxonomies.Controllers {
|
||||
|
||||
var terms = ResolveTermIds(termIds);
|
||||
|
||||
if(!terms.Any())
|
||||
if (!terms.Any())
|
||||
return HttpNotFound();
|
||||
|
||||
var model = new MoveTermViewModel {
|
||||
Terms = (from t in _taxonomyService.GetTerms(taxonomyId)
|
||||
from st in terms
|
||||
where !(t.FullPath + "/").StartsWith(st.FullPath + "/")
|
||||
select t).Distinct().ToList(),
|
||||
from st in terms
|
||||
where !(t.FullPath + "/").StartsWith(st.FullPath + "/")
|
||||
select t).Distinct().ToList(),
|
||||
TermIds = terms.Select(x => x.Id),
|
||||
SelectedTermId = -1
|
||||
};
|
||||
|
||||
return View(model);
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult MoveTerm(int taxonomyId, int selectedTermId, string termIds) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageTerms, T("Not allowed to move terms")))
|
||||
@@ -162,9 +162,9 @@ namespace Orchard.Taxonomies.Controllers {
|
||||
var terms = ResolveTermIds(termIds);
|
||||
|
||||
foreach (var term in terms) {
|
||||
_taxonomyService.MoveTerm(taxonomy, term, parentTerm);
|
||||
_taxonomyService.MoveTerm(taxonomy, term, parentTerm);
|
||||
}
|
||||
|
||||
|
||||
return RedirectToAction("Index", new { taxonomyId });
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ namespace Orchard.Taxonomies.Controllers {
|
||||
var taxonomy = _taxonomyService.GetTaxonomy(taxonomyId);
|
||||
var parentTerm = _taxonomyService.GetTerm(parentTermId);
|
||||
var term = _taxonomyService.NewTerm(taxonomy, parentTerm);
|
||||
|
||||
|
||||
var model = Services.ContentManager.BuildEditor(term);
|
||||
return View(model);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Orchard.Taxonomies.Drivers {
|
||||
public IOrchardServices Services { get; set; }
|
||||
|
||||
public TaxonomyFieldDriver(
|
||||
IOrchardServices services,
|
||||
IOrchardServices services,
|
||||
ITaxonomyService taxonomyService,
|
||||
IRepository<TermContentItem> repository) {
|
||||
_taxonomyService = taxonomyService;
|
||||
@@ -81,9 +81,9 @@ namespace Orchard.Taxonomies.Drivers {
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(ContentPart part, TaxonomyField field, IUpdateModel updater, dynamic shapeHelper) {
|
||||
var viewModel = new TaxonomyFieldViewModel { Terms = new List<TermEntry>() };
|
||||
|
||||
if(updater.TryUpdateModel(viewModel, GetPrefix(field, part), null, null)) {
|
||||
var viewModel = new TaxonomyFieldViewModel { Terms = new List<TermEntry>() };
|
||||
|
||||
if (updater.TryUpdateModel(viewModel, GetPrefix(field, part), null, null)) {
|
||||
var checkedTerms = viewModel.Terms
|
||||
.Where(t => (t.IsChecked || t.Id == viewModel.SingleTermId))
|
||||
.Select(t => GetOrCreateTerm(t, viewModel.TaxonomyId, field))
|
||||
@@ -117,7 +117,7 @@ namespace Orchard.Taxonomies.Drivers {
|
||||
}
|
||||
|
||||
var terms = termIdentities
|
||||
.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(context.GetItemFromSession)
|
||||
.Where(contentItem => contentItem != null)
|
||||
.ToList();
|
||||
@@ -128,9 +128,9 @@ namespace Orchard.Taxonomies.Drivers {
|
||||
private TermPart GetOrCreateTerm(TermEntry entry, int taxonomyId, TaxonomyField field) {
|
||||
var term = default(TermPart);
|
||||
|
||||
if (entry.Id > 0)
|
||||
term = _taxonomyService.GetTerm(entry.Id);
|
||||
|
||||
if (entry.Id > 0)
|
||||
term = _taxonomyService.GetTerm(entry.Id);
|
||||
|
||||
//Prevents creation of existing term
|
||||
if (term == null && !string.IsNullOrEmpty(entry.Name))
|
||||
term = _taxonomyService.GetTermByName(taxonomyId, entry.Name.Trim());
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Orchard.Taxonomies.Drivers {
|
||||
taxonomyShape.Items.Add(child.Shape);
|
||||
}
|
||||
else {
|
||||
|
||||
|
||||
if (parent.Shape == null) {
|
||||
parent.Shape = shapeHelper.TaxonomyItem(Taxonomy: part.ContentItem, ContentPart: parent.TermPart, ContentItem: parent.TermPart.ContentItem);
|
||||
}
|
||||
@@ -51,7 +51,7 @@ namespace Orchard.Taxonomies.Drivers {
|
||||
if (existing != null && existing.Record != part.Record) {
|
||||
updater.AddModelError("Title", T("A taxonomy with the same name already exists"));
|
||||
}
|
||||
|
||||
|
||||
// nothing to display for this part
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Orchard.Taxonomies.Drivers {
|
||||
protected override DriverResult Display(TermPart part, string displayType, dynamic shapeHelper) {
|
||||
return Combined(
|
||||
ContentShape("Parts_TermPart_Feed", () => {
|
||||
|
||||
|
||||
// generates a link to the RSS feed for this term
|
||||
_feedManager.Register(part.Name, "rss", new RouteValueDictionary { { "term", part.Id } });
|
||||
return null;
|
||||
@@ -53,7 +53,7 @@ namespace Orchard.Taxonomies.Drivers {
|
||||
if (httpContext != null) {
|
||||
pagerParameters.Page = Convert.ToInt32(httpContext.Request.QueryString["page"]);
|
||||
}
|
||||
|
||||
|
||||
var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
|
||||
var taxonomy = _taxonomyService.GetTaxonomy(part.TaxonomyId);
|
||||
var totalItemCount = _taxonomyService.GetContentItemsCount(part);
|
||||
@@ -113,8 +113,8 @@ namespace Orchard.Taxonomies.Drivers {
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("TaxonomyId", identity);
|
||||
|
||||
var identityPaths = new List<string>();
|
||||
foreach(var pathPart in part.Path.Split('/')) {
|
||||
if(String.IsNullOrEmpty(pathPart)) {
|
||||
foreach (var pathPart in part.Path.Split('/')) {
|
||||
if (String.IsNullOrEmpty(pathPart)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -132,15 +132,15 @@ namespace Orchard.Taxonomies.Drivers {
|
||||
|
||||
var identity = context.Attribute(part.PartDefinition.Name, "TaxonomyId");
|
||||
var contentItem = context.GetItemFromSession(identity);
|
||||
|
||||
|
||||
if (contentItem == null) {
|
||||
throw new OrchardException(T("Unknown taxonomy: {0}", identity));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
part.TaxonomyId = contentItem.Id;
|
||||
part.Path = "/";
|
||||
|
||||
foreach(var identityPath in context.Attribute(part.PartDefinition.Name, "Path").Split(new [] {','}, StringSplitOptions.RemoveEmptyEntries)) {
|
||||
foreach (var identityPath in context.Attribute(part.PartDefinition.Name, "Path").Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) {
|
||||
var pathContentItem = context.GetItemFromSession(identityPath);
|
||||
part.Path += pathContentItem.Id + "/";
|
||||
}
|
||||
|
||||
@@ -12,16 +12,16 @@ using System;
|
||||
namespace Orchard.Taxonomies.Handlers {
|
||||
public class TaxonomyPartHandler : ContentHandler {
|
||||
public TaxonomyPartHandler(
|
||||
IRepository<TaxonomyPartRecord> repository,
|
||||
IRepository<TaxonomyPartRecord> repository,
|
||||
ITaxonomyService taxonomyService,
|
||||
IContentDefinitionManager contentDefinitionManager) {
|
||||
|
||||
|
||||
string previousName = null;
|
||||
|
||||
Filters.Add(StorageFilter.For(repository));
|
||||
OnPublished<TaxonomyPart>((context, part) => {
|
||||
|
||||
if (part.TermTypeName == null) {
|
||||
|
||||
if (part.TermTypeName == null) {
|
||||
// is it a new taxonomy ?
|
||||
taxonomyService.CreateTermContentType(part);
|
||||
}
|
||||
@@ -29,11 +29,11 @@ namespace Orchard.Taxonomies.Handlers {
|
||||
// update existing fields
|
||||
foreach (var partDefinition in contentDefinitionManager.ListPartDefinitions()) {
|
||||
foreach (var field in partDefinition.Fields) {
|
||||
if (field.FieldDefinition.Name == typeof (TaxonomyField).Name) {
|
||||
if (field.FieldDefinition.Name == typeof(TaxonomyField).Name) {
|
||||
|
||||
if (field.Settings.GetModel<TaxonomyFieldSettings>().Taxonomy == previousName) {
|
||||
contentDefinitionManager.AlterPartDefinition(partDefinition.Name,
|
||||
cfg => cfg.WithField(field.Name,
|
||||
contentDefinitionManager.AlterPartDefinition(partDefinition.Name,
|
||||
cfg => cfg.WithField(field.Name,
|
||||
builder => builder.WithSetting("TaxonomyFieldSettings.Taxonomy", part.Name)));
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ namespace Orchard.Taxonomies.Handlers {
|
||||
}
|
||||
});
|
||||
|
||||
OnLoading<TaxonomyPart>( (context, part) => part.TermsField.Loader(() => taxonomyService.GetTerms(part.Id)));
|
||||
OnLoading<TaxonomyPart>((context, part) => part.TermsField.Loader(() => taxonomyService.GetTerms(part.Id)));
|
||||
|
||||
OnUpdating<TitlePart>((context, part) => {
|
||||
// if altering the title of a taxonomy, save the name
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace Orchard.Taxonomies.Handlers {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Fires off a processing engine task to run the count processing after the request so it's non-blocking.
|
||||
private void RecalculateCount(IProcessingEngine processingEngine, ShellSettings shellSettings, IShellDescriptorManager shellDescriptorManager, TermsPart part) {
|
||||
var termPartRecordIds = part.Terms.Select(t => t.TermRecord.Id).ToArray();
|
||||
|
||||
@@ -6,11 +6,11 @@ using System.Linq;
|
||||
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;
|
||||
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;
|
||||
return String.IsNullOrEmpty(term.Path) ? 0 : term.Path.Count(c => c == '/') - 1;
|
||||
}
|
||||
|
||||
public static TermEntry CreateTermEntry(this TermPart term) {
|
||||
@@ -20,7 +20,7 @@ namespace Orchard.Taxonomies.Helpers {
|
||||
Selectable = term.Selectable,
|
||||
Count = term.Count,
|
||||
Path = term.Path,
|
||||
Weight= term.Weight,
|
||||
Weight = term.Weight,
|
||||
IsChecked = false,
|
||||
ContentItem = term.ContentItem
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Orchard.Taxonomies.Models {
|
||||
/// Represents a relationship between a Term and a Content Item
|
||||
/// </summary>
|
||||
public class TermContentItem {
|
||||
|
||||
|
||||
public virtual int Id { get; set; }
|
||||
public virtual string Field { get; set; }
|
||||
public virtual TermPartRecord TermRecord { get; set; }
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace Orchard.Taxonomies.Models {
|
||||
|
||||
// if same parent path and same weight, compare by name
|
||||
return String.Compare(x.Name, y.Name, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
|
||||
// if two nodes have different parents
|
||||
|
||||
@@ -98,12 +98,12 @@ namespace Orchard.Taxonomies.Models {
|
||||
// /1/2 vs /1/3 => 2 vs 3
|
||||
// /2/3 vs /4 => 2 vs 4
|
||||
|
||||
var xPath = x.FullPath.Split(new [] { '/' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
var yPath = y.FullPath.Split(new [] { '/' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
var xPath = x.FullPath.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
var yPath = y.FullPath.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
string xFullPath = "", yFullPath = "";
|
||||
string xFullPath = "", yFullPath = "";
|
||||
|
||||
for(var i=0; i< Math.Min(xPath.Length, yPath.Length); i++) {
|
||||
for (var i = 0; i < Math.Min(xPath.Length, yPath.Length); i++) {
|
||||
xFullPath += "/" + xPath[i];
|
||||
yFullPath += "/" + yPath[i];
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Orchard.Taxonomies.Models {
|
||||
/// </summary>
|
||||
public class TermsPart : ContentPart<TermsPartRecord> {
|
||||
public IList<TermContentItem> Terms { get { return Record.Terms; } }
|
||||
internal LazyField<IEnumerable<TermContentItemPart>> _termParts;
|
||||
internal LazyField<IEnumerable<TermContentItemPart>> _termParts;
|
||||
public IEnumerable<TermContentItemPart> TermParts { get { return _termParts.Value; } }
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,7 @@ namespace Orchard.Taxonomies.Navigation {
|
||||
var rootLevel = rootTerm != null
|
||||
? rootTerm.GetLevels()
|
||||
: 0;
|
||||
|
||||
|
||||
var menuPosition = item.Position;
|
||||
var rootPath = rootTerm == null || taxonomyNavigationPart.DisplayRootTerm ? "" : rootTerm.FullPath;
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Orchard.Taxonomies.Projections {
|
||||
|
||||
var terms = ids.Select(_taxonomyService.GetTerm).ToList();
|
||||
var allChildren = new List<TermPart>();
|
||||
foreach(var term in terms) {
|
||||
foreach (var term in terms) {
|
||||
allChildren.AddRange(_taxonomyService.GetChildren(term));
|
||||
allChildren.Add(term);
|
||||
}
|
||||
@@ -55,11 +55,11 @@ namespace Orchard.Taxonomies.Projections {
|
||||
|
||||
var allIds = allChildren.Select(x => x.Id).ToList();
|
||||
|
||||
switch(op) {
|
||||
switch (op) {
|
||||
case 0: // is one of
|
||||
// Unique alias so we always get a unique join everytime so can have > 1 HasTerms filter on a query.
|
||||
Action<IAliasFactory> s = alias => alias.ContentPartRecord<TermsPartRecord>().Property("Terms", "terms" + _termsFilterId++);
|
||||
Action<IHqlExpressionFactory> f = x => x.InG("TermRecord.Id", allIds);
|
||||
Action<IAliasFactory> s = alias => alias.ContentPartRecord<TermsPartRecord>().Property("Terms", "terms" + _termsFilterId++);
|
||||
Action<IHqlExpressionFactory> f = x => x.InG("TermRecord.Id", allIds);
|
||||
context.Query.Where(s, f);
|
||||
break;
|
||||
case 1: // is all of
|
||||
|
||||
@@ -55,8 +55,8 @@ namespace Orchard.Taxonomies.Projections {
|
||||
f._Terms.Add(new SelectListItem { Value = String.Empty, Text = taxonomy.Name });
|
||||
foreach (var term in _taxonomyService.GetTerms(taxonomy.Id)) {
|
||||
var gap = new string('-', term.GetLevels());
|
||||
|
||||
if(gap.Length > 0) {
|
||||
|
||||
if (gap.Length > 0) {
|
||||
gap += " ";
|
||||
}
|
||||
|
||||
@@ -67,10 +67,10 @@ namespace Orchard.Taxonomies.Projections {
|
||||
return f;
|
||||
};
|
||||
|
||||
context.Form("SelectTerms",
|
||||
form,
|
||||
(Action<dynamic, ImportContentContext>) Import,
|
||||
(Action<dynamic, ExportContentContext>) Export
|
||||
context.Form("SelectTerms",
|
||||
form,
|
||||
(Action<dynamic, ImportContentContext>)Import,
|
||||
(Action<dynamic, ExportContentContext>)Export
|
||||
);
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Orchard.Taxonomies.Projections {
|
||||
string termIds = Convert.ToString(state.TermIds);
|
||||
|
||||
if (!String.IsNullOrEmpty(termIds)) {
|
||||
var ids = termIds.Split(new[] {','}).Select(Int32.Parse).ToArray();
|
||||
var ids = termIds.Split(new[] { ',' }).Select(Int32.Parse).ToArray();
|
||||
var terms = ids.Select(_taxonomyService.GetTerm).ToList();
|
||||
var identities = terms.Select(context.ContentManager.GetItemMetadata).Select(x => x.Identity.ToString()).ToArray();
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Orchard.Taxonomies.Services {
|
||||
/// </summary>
|
||||
/// <param name="taxonomy">The taxonomy to create a term content type for.</param>
|
||||
void CreateTermContentType(TaxonomyPart taxonomy);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a <see cref="TaxonomyPart"/> content item from the database.
|
||||
/// </summary>
|
||||
@@ -38,7 +38,7 @@ namespace Orchard.Taxonomies.Services {
|
||||
/// <remarks>It will also remove all its terms and delete their content type.</remarks>
|
||||
void DeleteTaxonomy(TaxonomyPart taxonomy);
|
||||
IContentQuery<TaxonomyPart, TaxonomyPartRecord> GetTaxonomiesQuery();
|
||||
|
||||
|
||||
|
||||
IEnumerable<TermPart> GetTerms(int taxonomyId);
|
||||
TermPart GetTerm(int id);
|
||||
|
||||
@@ -37,11 +37,10 @@ namespace Orchard.Taxonomies.Services {
|
||||
INotifier notifier,
|
||||
IContentDefinitionManager contentDefinitionManager,
|
||||
IAuthorizationService authorizationService,
|
||||
IOrchardServices services,
|
||||
IProcessingEngine processingEngine,
|
||||
ShellSettings shellSettings,
|
||||
IShellDescriptorManager shellDescriptorManager)
|
||||
{
|
||||
IOrchardServices services,
|
||||
IProcessingEngine processingEngine,
|
||||
ShellSettings shellSettings,
|
||||
IShellDescriptorManager shellDescriptorManager) {
|
||||
_termContentItemRepository = termContentItemRepository;
|
||||
_contentManager = contentManager;
|
||||
_notifier = notifier;
|
||||
@@ -98,7 +97,7 @@ namespace Orchard.Taxonomies.Services {
|
||||
// create the associated term's content type
|
||||
taxonomy.TermTypeName = GenerateTermTypeName(taxonomy.Name);
|
||||
|
||||
_contentDefinitionManager.AlterTypeDefinition(taxonomy.TermTypeName,
|
||||
_contentDefinitionManager.AlterTypeDefinition(taxonomy.TermTypeName,
|
||||
cfg => cfg
|
||||
.WithSetting("Taxonomy", taxonomy.Name)
|
||||
.WithPart("TermPart")
|
||||
@@ -226,7 +225,7 @@ namespace Orchard.Taxonomies.Services {
|
||||
public void DeleteTerm(TermPart termPart) {
|
||||
_contentManager.Remove(termPart.ContentItem);
|
||||
|
||||
foreach(var childTerm in GetChildren(termPart)) {
|
||||
foreach (var childTerm in GetChildren(termPart)) {
|
||||
_contentManager.Remove(childTerm.ContentItem);
|
||||
}
|
||||
|
||||
@@ -244,7 +243,7 @@ namespace Orchard.Taxonomies.Services {
|
||||
var termsPart = contentItem.As<TermsPart>();
|
||||
|
||||
// removing current terms for specific field
|
||||
var termList = termsPart.Terms.Select((t, i) => new {Term = t, Index = i})
|
||||
var termList = termsPart.Terms.Select((t, i) => new { Term = t, Index = i })
|
||||
.Where(x => x.Term.Field == field)
|
||||
.Select(x => x)
|
||||
.OrderByDescending(i => i.Index)
|
||||
@@ -253,15 +252,16 @@ namespace Orchard.Taxonomies.Services {
|
||||
foreach (var x in termList) {
|
||||
termsPart.Terms.RemoveAt(x.Index);
|
||||
}
|
||||
|
||||
|
||||
// adding new terms list
|
||||
foreach(var term in terms) {
|
||||
foreach (var term in terms) {
|
||||
// Remove the newly added terms because they will get processed by the Published-Event
|
||||
termList.RemoveAll(t => t.Term.Id == term.Id);
|
||||
termsPart.Terms.Add(
|
||||
termsPart.Terms.Add(
|
||||
new TermContentItem {
|
||||
TermsPartRecord = termsPart.Record,
|
||||
TermRecord = term.Record, Field = field
|
||||
TermsPartRecord = termsPart.Record,
|
||||
TermRecord = term.Record,
|
||||
Field = field
|
||||
});
|
||||
}
|
||||
|
||||
@@ -282,7 +282,8 @@ namespace Orchard.Taxonomies.Services {
|
||||
tpr => tpr.Terms.Any(tr =>
|
||||
tr.TermRecord.Id == term.Id
|
||||
|| tr.TermRecord.Path.StartsWith(rootPath)));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
query = query.Where(
|
||||
tpr => tpr.Terms.Any(tr =>
|
||||
tr.Field == fieldName
|
||||
@@ -291,7 +292,7 @@ namespace Orchard.Taxonomies.Services {
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
|
||||
public long GetContentItemsCount(TermPart term, string fieldName = null) {
|
||||
return GetContentItemsQuery(term, fieldName).Count();
|
||||
}
|
||||
@@ -315,14 +316,14 @@ namespace Orchard.Taxonomies.Services {
|
||||
.List();
|
||||
|
||||
if (includeParent) {
|
||||
result = result.Concat(new [] {term});
|
||||
result = result.Concat(new[] { term });
|
||||
}
|
||||
|
||||
return TermPart.Sort(result);
|
||||
}
|
||||
|
||||
public IEnumerable<TermPart> GetParents(TermPart term) {
|
||||
return term.Path.Split(new [] {'/'}, StringSplitOptions.RemoveEmptyEntries).Select(id => GetTerm(int.Parse(id)));
|
||||
return term.Path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Select(id => GetTerm(int.Parse(id)));
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetSlugs() {
|
||||
@@ -357,12 +358,12 @@ namespace Orchard.Taxonomies.Services {
|
||||
|
||||
public void ProcessPath(TermPart term) {
|
||||
var parentTerm = term.Container.As<TermPart>();
|
||||
term.Path = parentTerm != null ? parentTerm.FullPath + "/": "/";
|
||||
term.Path = parentTerm != null ? parentTerm.FullPath + "/" : "/";
|
||||
}
|
||||
|
||||
public void CreateHierarchy(IEnumerable<TermPart> terms, Action<TermPartNode, TermPartNode> append) {
|
||||
var root = new TermPartNode();
|
||||
var stack = new Stack<TermPartNode>(new [] { root } );
|
||||
var stack = new Stack<TermPartNode>(new[] { root });
|
||||
|
||||
foreach (var term in terms) {
|
||||
var current = CreateNode(term);
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Orchard.Taxonomies.Services {
|
||||
_contentManager = contentManager;
|
||||
_taxonomyService = taxonomyService;
|
||||
}
|
||||
|
||||
|
||||
public void Process(params int[] termPartRecordIds) {
|
||||
|
||||
foreach (var id in termPartRecordIds) {
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace Orchard.Taxonomies {
|
||||
|
||||
foreach (var parent in GetHierarchyAlternates(termPart).Reverse()) {
|
||||
var formatted = FormatAlternate(parent);
|
||||
|
||||
|
||||
metadata.Alternates.Add(String.Concat("Content__", contentItem.ContentType, "__", field, "__", formatted));
|
||||
metadata.Alternates.Add(String.Concat("Content_", metadata.DisplayType, "__", contentItem.ContentType, "__", field, "__", formatted));
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Orchard.Taxonomies.StandardQueries {
|
||||
var containerId = (int)termParthId.ConvertTo(typeof(int));
|
||||
var container = _contentManager.Get<TermPart>(containerId);
|
||||
|
||||
if(container == null){
|
||||
if (container == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
Layout.Title = T("Import Terms for {0}", Model.Taxonomy.Name).Text;
|
||||
}
|
||||
|
||||
@using(Html.BeginFormAntiForgeryPost()) {
|
||||
@using (Html.BeginFormAntiForgeryPost()) {
|
||||
@Html.ValidationSummary()
|
||||
<fieldset>
|
||||
<input type="hidden" value="@Model.Taxonomy.Id" name="id"/>
|
||||
<input type="hidden" value="@Model.Taxonomy.Id" name="id" />
|
||||
<textarea rows="25" cols="80" onkeydown="return interceptTabs(event, this);" name="terms">@Model.Terms</textarea>
|
||||
<span class="hint">@T("One term per line, followed by a semi-colon and the slug")</span>
|
||||
<span class="hint">@T("Hierarchies are defined using tabs (handled in this editor zone)")</span>
|
||||
@@ -21,47 +21,47 @@
|
||||
<input class="button" type="submit" value="@T("Import")" />
|
||||
}
|
||||
|
||||
@using(Script.Foot()){
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
function insertAtCursor(myField, myValue) {
|
||||
//IE support
|
||||
if (document.selection) {
|
||||
myField.focus();
|
||||
sel = document.selection.createRange();
|
||||
sel.text = myValue;
|
||||
@using (Script.Foot()) {
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
function insertAtCursor(myField, myValue) {
|
||||
//IE support
|
||||
if (document.selection) {
|
||||
myField.focus();
|
||||
sel = document.selection.createRange();
|
||||
sel.text = myValue;
|
||||
}
|
||||
|
||||
//MOZILLA/NETSCAPE support
|
||||
else if (myField.selectionStart || myField.selectionStart == '0') {
|
||||
var startPos = myField.selectionStart;
|
||||
var endPos = myField.selectionEnd;
|
||||
var restoreTop = myField.scrollTop;
|
||||
|
||||
myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length);
|
||||
|
||||
myField.selectionStart = startPos + myValue.length;
|
||||
myField.selectionEnd = startPos + myValue.length;
|
||||
|
||||
if (restoreTop>0) {
|
||||
myField.scrollTop = restoreTop;
|
||||
}
|
||||
}
|
||||
else {
|
||||
myField.value += myValue;
|
||||
}
|
||||
}
|
||||
|
||||
function interceptTabs(evt, control) {
|
||||
var key = evt.keyCode ? evt.keyCode : evt.which ? evt.which : evt.charCode;
|
||||
if (key==9) {
|
||||
insertAtCursor(control, '\t');
|
||||
return false;
|
||||
//MOZILLA/NETSCAPE support
|
||||
else if (myField.selectionStart || myField.selectionStart == '0') {
|
||||
var startPos = myField.selectionStart;
|
||||
var endPos = myField.selectionEnd;
|
||||
var restoreTop = myField.scrollTop;
|
||||
|
||||
myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length);
|
||||
|
||||
myField.selectionStart = startPos + myValue.length;
|
||||
myField.selectionEnd = startPos + myValue.length;
|
||||
|
||||
if (restoreTop > 0) {
|
||||
myField.scrollTop = restoreTop;
|
||||
}
|
||||
}
|
||||
else {
|
||||
myField.value += myValue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return key;
|
||||
|
||||
function interceptTabs(evt, control) {
|
||||
var key = evt.keyCode ? evt.keyCode : evt.which ? evt.which : evt.charCode;
|
||||
if (key == 9) {
|
||||
insertAtCursor(control, '\t');
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
//]]>
|
||||
</script>
|
||||
}
|
||||
@@ -7,59 +7,59 @@
|
||||
}
|
||||
|
||||
@using (Html.BeginFormAntiForgeryPost()) {
|
||||
@Html.ValidationSummary()
|
||||
<fieldset class="bulk-actions">
|
||||
<label for="publishActions">@T("Actions:")</label>
|
||||
<select id="publishActions" name="@Html.NameOf(m => m.BulkAction)">
|
||||
@Html.SelectOption(Model.BulkAction, TaxonomiesAdminIndexBulkAction.None, T("Choose action...").ToString())
|
||||
@Html.SelectOption(Model.BulkAction, TaxonomiesAdminIndexBulkAction.Delete, T("Remove").ToString())
|
||||
</select>
|
||||
<input class="button" type="submit" name="submit.BulkEdit" value="@T("Apply")" />
|
||||
</fieldset>
|
||||
<div class="manage">@Html.ActionLink(T("Add a taxonomy").Text, "Create", new { Area = "Contents", Id = "Taxonomy", ReturnUrl = Request.RawUrl }, new { @class = "button primaryAction" })</div>
|
||||
<fieldset>
|
||||
<table class="items" summary="@T("This is a table of the taxonomies in your application")">
|
||||
<colgroup>
|
||||
<col id="Col1" />
|
||||
<col id="Col2" />
|
||||
<col id="Col3" />
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col"><input type="checkbox" class="check-all"/></th>
|
||||
<th scope="col">@T("Name")</th>
|
||||
<th scope="col"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@foreach (var taxonomyEntry in Model.Taxonomies) {
|
||||
ti = taxonomyIndex;
|
||||
<tr class="@(taxonomyEntry.IsInternal ? "internal" : null)">
|
||||
<td>
|
||||
<input type="hidden" value="@Model.Taxonomies[taxonomyIndex].Id" name="@Html.NameOf(m => m.Taxonomies[ti].Id)"/>
|
||||
@if (!taxonomyEntry.IsInternal || Authorizer.Authorize(Orchard.Security.StandardPermissions.SiteOwner)) {
|
||||
<input type="checkbox" value="true" name="@Html.NameOf(m => m.Taxonomies[ti].IsChecked)"/>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
@if (!taxonomyEntry.IsInternal || Authorizer.Authorize(Orchard.Security.StandardPermissions.SiteOwner)) {
|
||||
@Html.ActionLink(taxonomyEntry.Name, "Index", "TermAdmin", new { taxonomyId = taxonomyEntry.Id }, new object { })
|
||||
}
|
||||
else {
|
||||
@Html.ItemDisplayText(taxonomyEntry.ContentItem)
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
@if (!taxonomyEntry.IsInternal || Authorizer.Authorize(Orchard.Security.StandardPermissions.SiteOwner)) {
|
||||
@Html.ItemEditLink(T("Edit").Text, taxonomyEntry.ContentItem) <text>|</text>
|
||||
@Html.ActionLink(T("Terms").Text, "Index", "TermAdmin", new { taxonomyId = taxonomyEntry.Id }, new object { }) <text>|</text>
|
||||
@Html.ActionLink(T("Delete").Text, "Delete", new { id = taxonomyEntry.Id }, new object { }) <text>|</text>
|
||||
@Html.ActionLink(T("Import").Text, "Import", new { id = taxonomyEntry.Id }, new object { })
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
taxonomyIndex++;
|
||||
}
|
||||
</table>
|
||||
@Html.ValidationSummary()
|
||||
<fieldset class="bulk-actions">
|
||||
<label for="publishActions">@T("Actions:")</label>
|
||||
<select id="publishActions" name="@Html.NameOf(m => m.BulkAction)">
|
||||
@Html.SelectOption(Model.BulkAction, TaxonomiesAdminIndexBulkAction.None, T("Choose action...").ToString())
|
||||
@Html.SelectOption(Model.BulkAction, TaxonomiesAdminIndexBulkAction.Delete, T("Remove").ToString())
|
||||
</select>
|
||||
<input class="button" type="submit" name="submit.BulkEdit" value="@T("Apply")" />
|
||||
</fieldset>
|
||||
<div class="manage">@Html.ActionLink(T("Add a taxonomy").Text, "Create", new { Area = "Contents", Id = "Taxonomy", ReturnUrl = Request.RawUrl }, new { @class = "button primaryAction" })</div>
|
||||
<fieldset>
|
||||
<table class="items" summary="@T("This is a table of the taxonomies in your application")">
|
||||
<colgroup>
|
||||
<col id="Col1" />
|
||||
<col id="Col2" />
|
||||
<col id="Col3" />
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col"><input type="checkbox" class="check-all" /></th>
|
||||
<th scope="col">@T("Name")</th>
|
||||
<th scope="col"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@foreach (var taxonomyEntry in Model.Taxonomies) {
|
||||
ti = taxonomyIndex;
|
||||
<tr class="@(taxonomyEntry.IsInternal ? "internal" : null)">
|
||||
<td>
|
||||
<input type="hidden" value="@Model.Taxonomies[taxonomyIndex].Id" name="@Html.NameOf(m => m.Taxonomies[ti].Id)" />
|
||||
@if (!taxonomyEntry.IsInternal || Authorizer.Authorize(Orchard.Security.StandardPermissions.SiteOwner)) {
|
||||
<input type="checkbox" value="true" name="@Html.NameOf(m => m.Taxonomies[ti].IsChecked)" />
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
@if (!taxonomyEntry.IsInternal || Authorizer.Authorize(Orchard.Security.StandardPermissions.SiteOwner)) {
|
||||
@Html.ActionLink(taxonomyEntry.Name, "Index", "TermAdmin", new { taxonomyId = taxonomyEntry.Id }, new object { })
|
||||
}
|
||||
else {
|
||||
@Html.ItemDisplayText(taxonomyEntry.ContentItem)
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
@if (!taxonomyEntry.IsInternal || Authorizer.Authorize(Orchard.Security.StandardPermissions.SiteOwner)) {
|
||||
@Html.ItemEditLink(T("Edit").Text, taxonomyEntry.ContentItem) <text>|</text>
|
||||
@Html.ActionLink(T("Terms").Text, "Index", "TermAdmin", new { taxonomyId = taxonomyEntry.Id }, new object { }) <text>|</text>
|
||||
@Html.ActionLink(T("Delete").Text, "Delete", new { id = taxonomyEntry.Id }, new object { }) <text>|</text>
|
||||
@Html.ActionLink(T("Import").Text, "Import", new { id = taxonomyEntry.Id }, new object { })
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
taxonomyIndex++;
|
||||
}
|
||||
</table>
|
||||
@Display(Model.Pager)
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
}
|
||||
@@ -3,10 +3,10 @@
|
||||
Script.Include("admin-taxonomy-field-settings.js").AtFoot();
|
||||
}
|
||||
<fieldset>
|
||||
<label>@T("Select a taxonomy")</label>
|
||||
<label>@T("Select a taxonomy")</label>
|
||||
<select id="@Html.FieldIdFor(m => m.Taxonomy)" name="@Html.FieldNameFor(m => m.Taxonomy)">
|
||||
@Html.SelectOption(-1, false, T("Choose a taxonomy ...").ToString())
|
||||
@foreach ( var taxonomy in Model.Taxonomies.OrderBy(t => t.Name) ) {
|
||||
@foreach (var taxonomy in Model.Taxonomies.OrderBy(t => t.Name)) {
|
||||
@Html.SelectOption(taxonomy.Name, Model.Taxonomy == taxonomy.Name, taxonomy.Name)
|
||||
}
|
||||
</select>
|
||||
@@ -14,10 +14,10 @@
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<label>@T("Restrictions")</label>
|
||||
<label>@T("Restrictions")</label>
|
||||
<div class="help">
|
||||
<div class="content">
|
||||
@Html.CheckBoxFor(m => m.LeavesOnly) <label class="forcheckbox" for="@Html.FieldIdFor(m => m.LeavesOnly)">@T("Restrict selectable elements to leaves (parent / child terms) only")</label>
|
||||
@Html.CheckBoxFor(m => m.LeavesOnly) <label class="forcheckbox" for="@Html.FieldIdFor(m => m.LeavesOnly)">@T("Restrict selectable elements to leaves (parent / child terms) only")</label>
|
||||
</div>
|
||||
<a class="help" title="@T("A leaf is the last descendant in a parent/child hierarchy")"></a>
|
||||
</div>
|
||||
@@ -32,7 +32,7 @@
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="autocomplete-settings">
|
||||
<label>@T("Autocomplete")</label>
|
||||
<label>@T("Autocomplete")</label>
|
||||
@Html.CheckBoxFor(m => m.Autocomplete) <label class="forcheckbox" for="@Html.FieldIdFor(m => m.Autocomplete)">@T("Enable Autocomplete")</label>
|
||||
<div class="allow-custom-terms-wrapper">
|
||||
@Html.CheckBoxFor(m => m.AllowCustomTerms) <label class="forcheckbox" for="@Html.FieldIdFor(m => m.AllowCustomTerms)">@T("Allow new terms to be created")</label>
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
<fieldset>
|
||||
<label for="@Html.FieldIdFor(m => m.Hint)">@T("Help text")</label>
|
||||
@Html.TextAreaFor(m => m.Hint, new { @class = "text medium", rows = "5" } )
|
||||
@Html.TextAreaFor(m => m.Hint, new { @class = "text medium", rows = "5" })
|
||||
<span class="hint">@T("The help text is written under the field when authors are editing the content item.")</span>
|
||||
@Html.ValidationMessageFor(m => m.Hint)
|
||||
</fieldset>
|
||||
@@ -26,52 +26,52 @@
|
||||
}
|
||||
}
|
||||
@{
|
||||
var allTerms = Newtonsoft.Json.JsonConvert.SerializeObject(Model.Terms.Select(x => new { label = x.Name, value = x.Id, levels = x.GetLevels(), disabled = IsTermDisabled(x)}));
|
||||
var allTerms = Newtonsoft.Json.JsonConvert.SerializeObject(Model.Terms.Select(x => new { label = x.Name, value = x.Id, levels = x.GetLevels(), disabled = IsTermDisabled(x) }));
|
||||
var selectedTerms = Newtonsoft.Json.JsonConvert.SerializeObject(Model.Terms.Where(x => x.IsChecked).Select(x => new { label = x.Name, value = x.Id, levels = 0, disabled = true }));
|
||||
}
|
||||
<fieldset class="taxonomy-wrapper" data-name-prefix="@Html.FieldNameFor(m => m)" data-id-prefix="@Html.FieldIdFor(m => m)">
|
||||
<legend @if(Model.Settings.Required) { <text>class="required"</text> }>@Model.DisplayName.CamelFriendly()</legend>
|
||||
<legend @if (Model.Settings.Required) { <text> class="required" </text> }>@Model.DisplayName.CamelFriendly()</legend>
|
||||
@if (Model.Settings.Autocomplete) {
|
||||
<div class="terms-editor" data-all-terms="@allTerms" data-selected-terms="@selectedTerms" data-allow-new-terms="@Model.Settings.AllowCustomTerms.ToString().ToLower()" data-singlechoice="@Model.Settings.SingleChoice.ToString().ToLower()">
|
||||
<ul></ul>
|
||||
@if (Model.Settings.SingleChoice) {
|
||||
<div class="hint">@T("Enter a single term. Hit <i>tab</i> or <i>enter</i> to apply the term.") @if (!Model.Settings.AllowCustomTerms) { <text>@T("This taxonomy does not allow you to create new terms.") </text> }</div>
|
||||
}
|
||||
else {
|
||||
<div class="hint">@T("Enter multiple terms. Hit <i>tab</i>, <i>enter</i> or <i>,</i> to add multiple terms.") @if (!Model.Settings.AllowCustomTerms) { <text>@T("This taxonomy does not allow you to create new terms.") </text> }</div>
|
||||
}
|
||||
</div>
|
||||
<div class="terms-editor" data-all-terms="@allTerms" data-selected-terms="@selectedTerms" data-allow-new-terms="@Model.Settings.AllowCustomTerms.ToString().ToLower()" data-singlechoice="@Model.Settings.SingleChoice.ToString().ToLower()">
|
||||
<ul></ul>
|
||||
@if (Model.Settings.SingleChoice) {
|
||||
<div class="hint">@T("Enter a single term. Hit <i>tab</i> or <i>enter</i> to apply the term.") @if (!Model.Settings.AllowCustomTerms) { <text>@T("This taxonomy does not allow you to create new terms.") </text> }</div>
|
||||
}
|
||||
else {
|
||||
<div class="hint">@T("Enter multiple terms. Hit <i>tab</i>, <i>enter</i> or <i>,</i> to add multiple terms.") @if (!Model.Settings.AllowCustomTerms) { <text>@T("This taxonomy does not allow you to create new terms.") </text> }</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
@if (!String.IsNullOrWhiteSpace(Model.Settings.Hint)) {
|
||||
<span class="hint">@Model.Settings.Hint</span>
|
||||
<span class="hint">@Model.Settings.Hint</span>
|
||||
}
|
||||
<div class="hidden-taxonomy-state">
|
||||
<ul class="terms">
|
||||
@foreach (var entry in Model.Terms) {
|
||||
var ti = termIndex;
|
||||
<li>
|
||||
@{
|
||||
var disabled = IsTermDisabled(entry);
|
||||
if (Model.Settings.SingleChoice) {
|
||||
<input @if (disabled){ <text>disabled="disabled"</text> } type="radio" value="@Model.Terms[ti].Id" @if (entry.Id == Model.SingleTermId){ <text>checked="checked"</text> } name="@Html.FieldNameFor(m => m.SingleTermId)" id="@Html.FieldIdFor(m => m.Terms[ti].IsChecked)" data-term="@entry.Name" data-term-identity="@entry.Name.ToLower()" />
|
||||
@foreach (var entry in Model.Terms) {
|
||||
var ti = termIndex;
|
||||
<li>
|
||||
@{
|
||||
var disabled = IsTermDisabled(entry);
|
||||
if (Model.Settings.SingleChoice) {
|
||||
<input @if (disabled) { <text> disabled="disabled" </text> } type="radio" value="@Model.Terms[ti].Id" @if (entry.Id == Model.SingleTermId) { <text> checked="checked" </text> } name="@Html.FieldNameFor(m => m.SingleTermId)" id="@Html.FieldIdFor(m => m.Terms[ti].IsChecked)" data-term="@entry.Name" data-term-identity="@entry.Name.ToLower()" />
|
||||
}
|
||||
else {
|
||||
<input @if (disabled) { <text> disabled="disabled" </text> } type="checkbox" value="true" @if (entry.IsChecked) { <text> checked="checked" </text> } name="@Html.FieldNameFor(m => m.Terms[ti].IsChecked)" id="@Html.FieldIdFor(m => m.Terms[ti].IsChecked)" data-term="@entry.Name" data-term-identity="@entry.Name.ToLower()" />
|
||||
}
|
||||
}
|
||||
else {
|
||||
<input @if (disabled){ <text>disabled="disabled"</text> } type="checkbox" value="true" @if (entry.IsChecked) { <text>checked="checked"</text> } name="@Html.FieldNameFor(m => m.Terms[ti].IsChecked)" id="@Html.FieldIdFor(m => m.Terms[ti].IsChecked)" data-term="@entry.Name" data-term-identity="@entry.Name.ToLower()" />
|
||||
}
|
||||
}
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.Terms[ti].IsChecked)">@entry.Name</label>
|
||||
@Html.HiddenFor(m => m.Terms[ti].Id)
|
||||
</li>
|
||||
termIndex++;
|
||||
}
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.Terms[ti].IsChecked)">@entry.Name</label>
|
||||
@Html.HiddenFor(m => m.Terms[ti].Id)
|
||||
</li>
|
||||
termIndex++;
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
@if (!Model.Terms.Any()) {
|
||||
<div class="no-terms">
|
||||
@T("There are no terms defined for {0} yet.", Model.DisplayName.CamelFriendly())
|
||||
<a href="@Url.Action("Index", "TermAdmin", new { taxonomyId = Model.TaxonomyId, area = "Orchard.Taxonomies" })">@T("Create some terms")</a>
|
||||
</div>
|
||||
<div class="no-terms">
|
||||
@T("There are no terms defined for {0} yet.", Model.DisplayName.CamelFriendly())
|
||||
<a href="@Url.Action("Index", "TermAdmin", new { taxonomyId = Model.TaxonomyId, area = "Orchard.Taxonomies" })">@T("Create some terms")</a>
|
||||
</div>
|
||||
}
|
||||
@Html.HiddenFor(m => m.TaxonomyId)
|
||||
</fieldset>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
@{
|
||||
Style.Include("admin-taxonomy.css");
|
||||
Script.Require("jQuery");
|
||||
Script.Require("jQuery");
|
||||
Script.Include("~/Themes/TheAdmin/scripts/admin.js").AtFoot();
|
||||
Script.Include("admin-taxonomy-expando.js").AtFoot();
|
||||
|
||||
@@ -14,40 +14,39 @@
|
||||
}
|
||||
|
||||
<fieldset class="taxonomy-wrapper" data-name-prefix="@Html.FieldNameFor(m => m)" data-id-prefix="@Html.FieldIdFor(m => m)">
|
||||
<legend @if(settings.Required) { <text>class="required"</text> }>@Model.DisplayName.CamelFriendly()</legend>
|
||||
|
||||
<legend @if (settings.Required) { <text> class="required" </text> }>@Model.DisplayName.CamelFriendly()</legend>
|
||||
|
||||
<div class="expando">
|
||||
@if (!String.IsNullOrWhiteSpace(Model.Settings.Hint))
|
||||
{
|
||||
@if (!String.IsNullOrWhiteSpace(Model.Settings.Hint)) {
|
||||
<span class="hint">@Model.Settings.Hint</span>
|
||||
}
|
||||
|
||||
|
||||
<ul class="terms">
|
||||
@foreach (var entry in Model.Terms) {
|
||||
var ti = termIndex;
|
||||
<li>
|
||||
@* Tabs for levels *@ @for (var i = 1; i <= entry.GetLevels(); i++){ <span class="gap"> </span> }
|
||||
@* Tabs for levels *@ @for (var i = 1; i <= entry.GetLevels(); i++) { <span class="gap"> </span> }
|
||||
@{
|
||||
var disabled = !entry.Selectable || (Model.Settings.LeavesOnly && Model.Terms.Any(t => t.Path.Contains(entry.Path + entry.Id)));
|
||||
if (Model.Settings.SingleChoice) {
|
||||
<input @if (disabled){ <text>disabled="disabled"</text> } type="radio" value="@Model.Terms[ti].Id" @if (entry.Id == Model.SingleTermId) { <text>checked="checked"</text> } name="@Html.FieldNameFor(m => m.SingleTermId)" id="@Html.FieldIdFor(m => m.Terms[ti].IsChecked)" data-term="@entry.Name.ToLower()"/>
|
||||
}
|
||||
else {
|
||||
<input @if (disabled) { <text>disabled="disabled"</text> } type="checkbox" value="true" @if (entry.IsChecked){ <text>checked="checked"</text> } name="@Html.FieldNameFor(m => m.Terms[ti].IsChecked)" id="@Html.FieldIdFor(m => m.Terms[ti].IsChecked)" data-term="@entry.Name.ToLower()"/>
|
||||
}
|
||||
var disabled = !entry.Selectable || (Model.Settings.LeavesOnly && Model.Terms.Any(t => t.Path.Contains(entry.Path + entry.Id)));
|
||||
if (Model.Settings.SingleChoice) {
|
||||
<input @if (disabled) { <text> disabled="disabled" </text> } type="radio" value="@Model.Terms[ti].Id" @if (entry.Id == Model.SingleTermId) { <text> checked="checked" </text> } name="@Html.FieldNameFor(m => m.SingleTermId)" id="@Html.FieldIdFor(m => m.Terms[ti].IsChecked)" data-term="@entry.Name.ToLower()" />
|
||||
}
|
||||
else {
|
||||
<input @if (disabled) { <text> disabled="disabled" </text> } type="checkbox" value="true" @if (entry.IsChecked) { <text> checked="checked" </text> } name="@Html.FieldNameFor(m => m.Terms[ti].IsChecked)" id="@Html.FieldIdFor(m => m.Terms[ti].IsChecked)" data-term="@entry.Name.ToLower()" />
|
||||
}
|
||||
}
|
||||
@Html.HiddenFor(m => m.Terms[ti].Id)
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.Terms[ti].IsChecked)">@entry.Name</label>
|
||||
</li>
|
||||
termIndex++;
|
||||
termIndex++;
|
||||
}
|
||||
</ul>
|
||||
|
||||
|
||||
@if (!Model.Terms.Any()) {
|
||||
<div class="no-terms">
|
||||
@T("There are no terms defined for {0} yet.", Model.DisplayName.CamelFriendly())
|
||||
<a href="@Url.Action("Index", "TermAdmin", new { taxonomyId = Model.TaxonomyId, area = "Orchard.Taxonomies" })">@T("Create some terms")</a>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@Html.HiddenFor(m => m.TaxonomyId)
|
||||
|
||||
@@ -2,66 +2,66 @@
|
||||
@using Orchard.Taxonomies.ViewModels;
|
||||
|
||||
@{
|
||||
Script.Require("jQuery");
|
||||
Script.Require("jQuery");
|
||||
}
|
||||
|
||||
<fieldset>
|
||||
@Html.LabelFor(m => m.SelectedTaxonomyId, T("Taxonomy"))
|
||||
@Html.DropDownListFor(m => m.SelectedTaxonomyId, Model.AvailableTaxonomies)
|
||||
@Html.LabelFor(m => m.SelectedTaxonomyId, T("Taxonomy"))
|
||||
@Html.DropDownListFor(m => m.SelectedTaxonomyId, Model.AvailableTaxonomies)
|
||||
<span class="hint">@T("Select the taxonomy whose terms will be rendered in the menu.")</span>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
@Html.LabelFor(m => m.SelectedTermId, T("Root Term"))
|
||||
<select id="@Html.FieldIdFor(m => m.SelectedTermId)" name="@Html.FieldNameFor(m => m.SelectedTermId)">
|
||||
@Html.SelectOption(-1, false, T("- Parent Taxonomy -").ToString())
|
||||
@{Html.RenderAction("RenderTermSelect", "TermAdmin", new { area = "Orchard.Taxonomies", taxonomyId = Model.SelectedTaxonomyId, selectedTermId = Model.SelectedTermId });}
|
||||
@Html.LabelFor(m => m.SelectedTermId, T("Root Term"))
|
||||
<select id="@Html.FieldIdFor(m => m.SelectedTermId)" name="@Html.FieldNameFor(m => m.SelectedTermId)">
|
||||
@Html.SelectOption(-1, false, T("- Parent Taxonomy -").ToString())
|
||||
@{Html.RenderAction("RenderTermSelect", "TermAdmin", new { area = "Orchard.Taxonomies", taxonomyId = Model.SelectedTaxonomyId, selectedTermId = Model.SelectedTermId });}
|
||||
</select>
|
||||
<span class="hint">@T("Select the root term to display")</span>
|
||||
<span class="hint">@T("Select the root term to display")</span>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
@Html.CheckBoxFor(m => m.DisplayTopMenuItem)
|
||||
<label for="@Html.FieldIdFor(m => m.DisplayTopMenuItem)" class="forcheckbox">@T("Display top level menu item")</label>
|
||||
<span class="hint">@T("When checked, the selected term to display will be rendered as a root element in the menu.")</span>
|
||||
@Html.CheckBoxFor(m => m.DisplayTopMenuItem)
|
||||
<label for="@Html.FieldIdFor(m => m.DisplayTopMenuItem)" class="forcheckbox">@T("Display top level menu item")</label>
|
||||
<span class="hint">@T("When checked, the selected term to display will be rendered as a root element in the menu.")</span>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<label for="@Html.FieldIdFor( m => m.LevelsToDisplay)">@T("Levels to display")</label>
|
||||
@Html.TextBoxFor(m => m.LevelsToDisplay, new { @class = "text small" } )
|
||||
@Html.TextBoxFor(m => m.LevelsToDisplay, new { @class = "text small" })
|
||||
@Html.ValidationMessage("LevelsToDisplay", "*")
|
||||
<span class="hint">@T("The number of levels to display in the hierarchy. 0 to display all levels.")</span>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
@Html.CheckBoxFor(m => m.HideEmptyTerms)
|
||||
<label for="@Html.FieldIdFor(m => m.HideEmptyTerms)" class="forcheckbox">@T("Hide empty entries")</label>
|
||||
<span class="hint">@T("When checked, any term which has no content item associated to it won't be rendered.")</span>
|
||||
@Html.CheckBoxFor(m => m.HideEmptyTerms)
|
||||
<label for="@Html.FieldIdFor(m => m.HideEmptyTerms)" class="forcheckbox">@T("Hide empty entries")</label>
|
||||
<span class="hint">@T("When checked, any term which has no content item associated to it won't be rendered.")</span>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
@Html.CheckBoxFor(m => m.DisplayContentCount)
|
||||
<label for="@Html.FieldIdFor(m => m.DisplayContentCount)" class="forcheckbox">@T("Display content count")</label>
|
||||
<span class="hint">@T("When checked, the number of content items is rendered following the term name.")</span>
|
||||
@Html.CheckBoxFor(m => m.DisplayContentCount)
|
||||
<label for="@Html.FieldIdFor(m => m.DisplayContentCount)" class="forcheckbox">@T("Display content count")</label>
|
||||
<span class="hint">@T("When checked, the number of content items is rendered following the term name.")</span>
|
||||
</fieldset>
|
||||
|
||||
@using (Script.Foot()) {
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
$(function () {
|
||||
$('#@Html.FieldIdFor(m => m.SelectedTaxonomyId)').change(function () {
|
||||
var self = $(this);
|
||||
var id = self.find("option:selected").attr("value");
|
||||
// do nothing if no term
|
||||
if (!id) return;
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
$(function () {
|
||||
$('#@Html.FieldIdFor(m => m.SelectedTaxonomyId)').change(function () {
|
||||
var self = $(this);
|
||||
var id = self.find("option:selected").attr("value");
|
||||
// do nothing if no term
|
||||
if (!id) return;
|
||||
|
||||
$.get(
|
||||
"@Url.Action("RenderTermSelect", "TermAdmin", new { area = "Orchard.Taxonomies" })", { taxonomyId: id }, function (data) {
|
||||
$('#@Html.FieldIdFor(m => m.SelectedTermId) option[value != -1]').remove();
|
||||
$('#@Html.FieldIdFor(m => m.SelectedTermId)').append(data);
|
||||
});
|
||||
});
|
||||
})
|
||||
//]]>
|
||||
</script>
|
||||
$.get(
|
||||
"@Url.Action("RenderTermSelect", "TermAdmin", new { area = "Orchard.Taxonomies" })", { taxonomyId: id }, function (data) {
|
||||
$('#@Html.FieldIdFor(m => m.SelectedTermId) option[value != -1]').remove();
|
||||
$('#@Html.FieldIdFor(m => m.SelectedTermId)').append(data);
|
||||
});
|
||||
});
|
||||
})
|
||||
//]]>
|
||||
</script>
|
||||
}
|
||||
@@ -4,8 +4,8 @@
|
||||
string name = @Model.ContentField.DisplayName;
|
||||
}
|
||||
@if (Model.Terms.Count > 0) {
|
||||
<p class="taxonomy-field">
|
||||
<span class="name">@name.CamelFriendly():</span>
|
||||
@(new HtmlString( string.Join(", ", terms.Select(t => Html.ItemDisplayLink(t.Name, t.ContentItem ).ToString()).ToArray()) ))
|
||||
</p>
|
||||
<p class="taxonomy-field">
|
||||
<span class="name">@name.CamelFriendly():</span>
|
||||
@(new HtmlString(string.Join(", ", terms.Select(t => Html.ItemDisplayLink(t.Name, t.ContentItem).ToString()).ToArray())))
|
||||
</p>
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
if (items.Any()) {
|
||||
items[0].Classes.Add("first");
|
||||
items[items.Count - 1].Classes.Add("last");
|
||||
}
|
||||
}
|
||||
}
|
||||
<div>
|
||||
@tag.StartElement
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@*
|
||||
@*
|
||||
This shape is displayed for a TermPart when in a Taxonomy details page
|
||||
Its children are the element shapes in the list.
|
||||
Alternates:
|
||||
@@ -16,21 +16,21 @@
|
||||
var tag = Tag(Model, "li");
|
||||
@tag.StartElement
|
||||
|
||||
@*
|
||||
- morphing the shape to keep Model untouched and
|
||||
- provide a simple way to customize the shape
|
||||
*@
|
||||
|
||||
Model.Metadata.Alternates.Clear();
|
||||
Model.Metadata.Type = "TaxonomyItemLink";
|
||||
@Display(Model)
|
||||
@*
|
||||
- morphing the shape to keep Model untouched and
|
||||
- provide a simple way to customize the shape
|
||||
*@
|
||||
|
||||
@* render child elements *@
|
||||
|
||||
if (items.Any()) {
|
||||
<ul>
|
||||
@DisplayChildren(Model)
|
||||
</ul>
|
||||
}
|
||||
Model.Metadata.Alternates.Clear();
|
||||
Model.Metadata.Type = "TaxonomyItemLink";
|
||||
@Display(Model)
|
||||
|
||||
@* render child elements *@
|
||||
|
||||
if (items.Any()) {
|
||||
<ul>
|
||||
@DisplayChildren(Model)
|
||||
</ul>
|
||||
}
|
||||
@tag.EndElement
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
<label for="@Html.FieldIdFor(m => m.SelectedTermId)">@T("Parent term")</label>
|
||||
<select name="@Html.FieldNameFor(m => m.SelectedTermId)" id="@Html.FieldIdFor(m => m.SelectedTermId)">
|
||||
@foreach(var term in Model.Terms) {
|
||||
@foreach (var term in Model.Terms) {
|
||||
<option value="@term.Id">@T(term.Name)</option>
|
||||
}
|
||||
</select>
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
<select id="@Html.FieldIdFor(m => m.SelectedTermId)" name="@Html.FieldNameFor(m => m.SelectedTermId)">
|
||||
@Html.SelectOption(-1, false, T("- None -").ToString())
|
||||
@foreach (var term in Model.Terms) {
|
||||
<option @if (term.Id == Model.SelectedTermId) { <text>selected="selected"</text> } value="@term.Id">@for (var i = 1; i <= term.GetLevels(); i++) { <span class="gap"> </span> }@term.Name</option>
|
||||
<option @if (term.Id == Model.SelectedTermId) { <text> selected="selected" </text> } value="@term.Id">@for (var i = 1; i <= term.GetLevels(); i++) { <span class="gap"> </span> }@term.Name</option>
|
||||
}
|
||||
</select>
|
||||
</select>
|
||||
<span class="hint">@T("By selecting a parent term you can create hierarchies")</span>
|
||||
|
||||
</fieldset>
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
@using Orchard.Taxonomies.Helpers;
|
||||
|
||||
@foreach (var term in Model.Terms) {
|
||||
<option @if (term.Id == Model.SelectedTermId) { <text>selected="selected"</text> } value="@term.Id">@for (var i = 1; i <= term.GetLevels(); i++) { <span class="gap"> </span> }@term.Name</option>
|
||||
<option @if (term.Id == Model.SelectedTermId) { <text> selected="selected" </text> } value="@term.Id">@for (var i = 1; i <= term.GetLevels(); i++) { <span class="gap"> </span> }@term.Name</option>
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
<select id="@Html.FieldIdFor(m => m.SelectedTermId)" name="@Html.FieldNameFor(m => m.SelectedTermId)">
|
||||
@Html.SelectOption(-1, false, T("- None -").ToString())
|
||||
@foreach (var term in Model.Terms) {
|
||||
<option @if (term.Id == Model.SelectedTermId) { <text>selected="selected"</text> } value="@term.Id">@for (var i = 1; i <= term.GetLevels(); i++) { <span class="gap"> </span> }@term.Name</option>
|
||||
<option @if (term.Id == Model.SelectedTermId) { <text> selected="selected" </text> } value="@term.Id">@for (var i = 1; i <= term.GetLevels(); i++) { <span class="gap"> </span> }@term.Name</option>
|
||||
}
|
||||
</select>
|
||||
</select>
|
||||
<span class="hint">@T("By selecting a parent term you can create hierarchies")</span>
|
||||
|
||||
</fieldset>
|
||||
|
||||
Reference in New Issue
Block a user