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