mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Shifting Taxonomies
Light shift as records are necessary. Upgrade code could be done too.
This commit is contained in:
@@ -92,16 +92,16 @@ namespace Orchard.Taxonomies.Drivers {
|
||||
}
|
||||
|
||||
protected override void Exporting(TermPart part, ExportContentContext context) {
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("Count", part.Record.Count);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("Selectable", part.Record.Selectable);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("Weight", part.Record.Weight);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("Count", part.Count);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("Selectable", part.Selectable);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("Weight", part.Weight);
|
||||
|
||||
var taxonomy = _contentManager.Get(part.Record.TaxonomyId);
|
||||
var taxonomy = _contentManager.Get(part.TaxonomyId);
|
||||
var identity = _contentManager.GetItemMetadata(taxonomy).Identity.ToString();
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("TaxonomyId", identity);
|
||||
|
||||
var identityPaths = new List<string>();
|
||||
foreach(var pathPart in part.Record.Path.Split('/')) {
|
||||
foreach(var pathPart in part.Path.Split('/')) {
|
||||
if(String.IsNullOrEmpty(pathPart)) {
|
||||
continue;
|
||||
}
|
||||
@@ -114,9 +114,9 @@ namespace Orchard.Taxonomies.Drivers {
|
||||
}
|
||||
|
||||
protected override void Importing(TermPart part, ImportContentContext context) {
|
||||
part.Record.Count = Int32.Parse(context.Attribute(part.PartDefinition.Name, "Count"));
|
||||
part.Record.Selectable = Boolean.Parse(context.Attribute(part.PartDefinition.Name, "Selectable"));
|
||||
part.Record.Weight = Int32.Parse(context.Attribute(part.PartDefinition.Name, "Weight"));
|
||||
part.Count = Int32.Parse(context.Attribute(part.PartDefinition.Name, "Count"));
|
||||
part.Selectable = Boolean.Parse(context.Attribute(part.PartDefinition.Name, "Selectable"));
|
||||
part.Weight = Int32.Parse(context.Attribute(part.PartDefinition.Name, "Weight"));
|
||||
|
||||
var identity = context.Attribute(part.PartDefinition.Name, "TaxonomyId");
|
||||
var contentItem = context.GetItemFromSession(identity);
|
||||
@@ -125,12 +125,12 @@ namespace Orchard.Taxonomies.Drivers {
|
||||
throw new OrchardException(T("Unknown taxonomy: {0}", identity));
|
||||
}
|
||||
|
||||
part.Record.TaxonomyId = contentItem.Id;
|
||||
part.Record.Path = "/";
|
||||
part.TaxonomyId = contentItem.Id;
|
||||
part.Path = "/";
|
||||
|
||||
foreach(var identityPath in context.Attribute(part.PartDefinition.Name, "Path").Split(new [] {','}, StringSplitOptions.RemoveEmptyEntries)) {
|
||||
var pathContentItem = context.GetItemFromSession(identityPath);
|
||||
part.Record.Path += pathContentItem.Id + "/";
|
||||
part.Path += pathContentItem.Id + "/";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -20,13 +20,13 @@ namespace Orchard.Taxonomies.Models {
|
||||
}
|
||||
|
||||
public string TermTypeName {
|
||||
get { return Record.TermTypeName; }
|
||||
set { Record.TermTypeName = value; }
|
||||
get { return Retrieve(x => x.TermTypeName); }
|
||||
set { Store(x => x.TermTypeName, value); }
|
||||
}
|
||||
|
||||
public bool IsInternal {
|
||||
get { return Record.IsInternal; }
|
||||
set { Record.IsInternal = value; }
|
||||
get { return Retrieve(x => x.IsInternal); }
|
||||
set { Store(x => x.IsInternal, value); }
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -24,31 +24,31 @@ namespace Orchard.Taxonomies.Models {
|
||||
}
|
||||
|
||||
public int TaxonomyId {
|
||||
get { return Record.TaxonomyId; }
|
||||
set { Record.TaxonomyId = value; }
|
||||
get { return Retrieve(x => x.TaxonomyId); }
|
||||
set { Store(x => x.TaxonomyId, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// e.g., /; /1/; /1/2/
|
||||
/// </summary>
|
||||
public string Path {
|
||||
get { return Record.Path; }
|
||||
set { Record.Path = value; }
|
||||
get { return Retrieve(x => x.Path); }
|
||||
set { Store(x => x.Path, value); }
|
||||
}
|
||||
|
||||
public int Count {
|
||||
get { return Record.Count; }
|
||||
set { Record.Count = value; }
|
||||
get { return Retrieve(x => x.Count); }
|
||||
set { Store(x => x.Count, value); }
|
||||
}
|
||||
|
||||
public bool Selectable {
|
||||
get { return Record.Selectable; }
|
||||
set { Record.Selectable = value; }
|
||||
get { return Retrieve(x => x.Selectable); }
|
||||
set { Store(x => x.Selectable, value); }
|
||||
}
|
||||
|
||||
public int Weight {
|
||||
get { return Record.Weight; }
|
||||
set { Record.Weight = value; }
|
||||
get { return Retrieve(x => x.Weight); }
|
||||
set { Store(x => x.Weight, value); }
|
||||
}
|
||||
|
||||
public string FullPath { get { return String.Concat(Path, Id); } }
|
||||
|
@@ -5,7 +5,6 @@ namespace Orchard.Taxonomies.Models {
|
||||
/// </summary>
|
||||
public class TermPartRecord : ContentPartRecord {
|
||||
public virtual int TaxonomyId { get; set; }
|
||||
|
||||
public virtual string Path { get; set; }
|
||||
public virtual int Count { get; set; }
|
||||
public virtual bool Selectable { get; set; }
|
||||
|
Reference in New Issue
Block a user