Fixes #7493 TextFieldDriver doesn't export its tag if content is empty (#7510)

* TextFieldDriver doesn't export its tag if content is empty
* Null check implemented , string.Empty returned
* TextFieldDriver doesn't export its tag if content is empty #7493
* TextFieldDriver doesn't export its tag if content is empty #7493
This commit is contained in:
Hannan Azam Khan
2017-02-09 18:00:18 +05:00
committed by Daniel Stolt
parent 8dde994bde
commit ac978b665b
8 changed files with 11 additions and 23 deletions

View File

@@ -84,8 +84,7 @@ namespace Orchard.Core.Common.Drivers {
} }
protected override void Exporting(ContentPart part, TextField field, ExportContentContext context) { protected override void Exporting(ContentPart part, TextField field, ExportContentContext context) {
if (!String.IsNullOrEmpty(field.Value)) context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Text", field.Value);
context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Text", field.Value);
} }
protected override void Describe(DescribeMembersContext context) { protected override void Describe(DescribeMembersContext context) {

View File

@@ -62,8 +62,7 @@ namespace Orchard.Fields.Drivers {
} }
protected override void Exporting(ContentPart part, BooleanField field, ExportContentContext context) { protected override void Exporting(ContentPart part, BooleanField field, ExportContentContext context) {
if (field.Value.HasValue) context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Value", field.Value);
context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Value", field.Value);
} }
protected override void Describe(DescribeMembersContext context) { protected override void Describe(DescribeMembersContext context) {

View File

@@ -165,9 +165,7 @@ namespace Orchard.Fields.Drivers {
} }
protected override void Exporting(ContentPart part, DateTimeField field, ExportContentContext context) { protected override void Exporting(ContentPart part, DateTimeField field, ExportContentContext context) {
var value = field.Storage.Get<DateTime>(null); context.Element(GetPrefix(field, part)).SetAttributeValue("Value", XmlConvert.ToString(field.Storage.Get<DateTime>(null), XmlDateTimeSerializationMode.Utc));
if (value != DateTime.MinValue)
context.Element(GetPrefix(field, part)).SetAttributeValue("Value", XmlConvert.ToString(value, XmlDateTimeSerializationMode.Utc));
} }
protected override void Describe(DescribeMembersContext context) { protected override void Describe(DescribeMembersContext context) {

View File

@@ -63,8 +63,7 @@ namespace Orchard.Fields.Drivers {
} }
protected override void Exporting(ContentPart part, EnumerationField field, ExportContentContext context) { protected override void Exporting(ContentPart part, EnumerationField field, ExportContentContext context) {
if (!String.IsNullOrEmpty(field.Value)) context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Value", field.Value);
context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Value", field.Value);
} }
protected override void Describe(DescribeMembersContext context) { protected override void Describe(DescribeMembersContext context) {

View File

@@ -61,8 +61,7 @@ namespace Orchard.Fields.Drivers {
} }
protected override void Exporting(ContentPart part, InputField field, ExportContentContext context) { protected override void Exporting(ContentPart part, InputField field, ExportContentContext context) {
if (!String.IsNullOrEmpty(field.Value)) context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Value", field.Value);
context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Value", field.Value);
} }
protected override void Describe(DescribeMembersContext context) { protected override void Describe(DescribeMembersContext context) {

View File

@@ -75,11 +75,9 @@ namespace Orchard.Fields.Drivers {
} }
protected override void Exporting(ContentPart part, LinkField field, ExportContentContext context) { protected override void Exporting(ContentPart part, LinkField field, ExportContentContext context) {
if (!String.IsNullOrEmpty(field.Text) || !String.IsNullOrEmpty(field.Value) || !String.IsNullOrEmpty(field.Target)) { context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Text", field.Text);
context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Text", field.Text); context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Url", field.Value);
context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Url", field.Value); context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Target", field.Target);
context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Target", field.Target);
}
} }
protected override void Describe(DescribeMembersContext context) { protected override void Describe(DescribeMembersContext context) {

View File

@@ -106,8 +106,7 @@ namespace Orchard.Fields.Drivers {
} }
protected override void Exporting(ContentPart part, NumericField field, ExportContentContext context) { protected override void Exporting(ContentPart part, NumericField field, ExportContentContext context) {
if (field.Value.HasValue) context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Value", !field.Value.HasValue ? String.Empty : field.Value.Value.ToString(CultureInfo.InvariantCulture));
context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Value", field.Value.Value.ToString(CultureInfo.InvariantCulture));
} }
protected override void Describe(DescribeMembersContext context) { protected override void Describe(DescribeMembersContext context) {

View File

@@ -117,13 +117,10 @@ namespace Orchard.Taxonomies.Drivers {
} }
protected override void Exporting(ContentPart part, TaxonomyField field, ExportContentContext context) { protected override void Exporting(ContentPart part, TaxonomyField field, ExportContentContext context) {
var appliedTerms = _taxonomyService.GetTermsForContentItem(part.ContentItem.Id, field.Name); var appliedTerms = _taxonomyService.GetTermsForContentItem(part.ContentItem.Id, field.Name);
// stores all content items associated to this field // stores all content items associated to this field
var termIdentities = appliedTerms.Select(x => Services.ContentManager.GetItemMetadata(x).Identity.ToString()).ToArray(); var termIdentities = appliedTerms.Select(x => Services.ContentManager.GetItemMetadata(x).Identity.ToString()).ToArray();
context.Element(XmlConvert.EncodeLocalName(field.FieldDefinition.Name + "." + field.Name)).SetAttributeValue("Terms", String.Join(",", termIdentities));
if (termIdentities.Any())
context.Element(XmlConvert.EncodeLocalName(field.FieldDefinition.Name + "." + field.Name)).SetAttributeValue("Terms", String.Join(",", termIdentities));
} }
protected override void Importing(ContentPart part, TaxonomyField field, ImportContentContext context) { protected override void Importing(ContentPart part, TaxonomyField field, ImportContentContext context) {