#19910: Including the field name as part of a field shape alternate.

Work Item: 19910

--HG--
branch : 1.x
This commit is contained in:
Sipke Schoorstra
2013-07-30 22:40:50 -07:00
parent 5a43c494d1
commit 661b581186

View File

@@ -148,39 +148,39 @@ namespace Orchard.ContentManagement.Drivers {
var shapeType = metadata.Type;
var fieldName = differentiator ?? String.Empty;
string partName = ctx.ContentPart.PartDefinition.Name;
var partName = ctx.ContentPart.PartDefinition.Name;
string contentType = shape.ContentItem.ContentType;
// whether the content type has been created dynamically or not
var dynamicType = string.Equals(partName, contentType, StringComparison.Ordinal);
var dynamicType = String.Equals(partName, contentType, StringComparison.Ordinal);
// [ShapeType__FieldName] e.g. Fields/Common.Text-Teaser
if ( !string.IsNullOrEmpty(fieldName) )
if ( !String.IsNullOrEmpty(fieldName) )
metadata.Alternates.Add(shapeType + "__" + EncodeAlternateElement(fieldName));
// [ShapeType__PartName] e.g. Fields/Common.Text-TeaserPart
if ( !string.IsNullOrEmpty(partName) ) {
if ( !String.IsNullOrEmpty(partName) ) {
metadata.Alternates.Add(shapeType + "__" + EncodeAlternateElement(partName));
}
// [ShapeType]__[ContentType]__[PartName] e.g. Fields/Common.Text-Blog-TeaserPart
if ( !string.IsNullOrEmpty(partName) && !string.IsNullOrEmpty(contentType) && !dynamicType ) {
if ( !String.IsNullOrEmpty(partName) && !String.IsNullOrEmpty(contentType) && !dynamicType ) {
metadata.Alternates.Add(EncodeAlternateElement(shapeType + "__" + contentType + "__" + partName));
}
// [ShapeType]__[PartName]__[FieldName] e.g. Fields/Common.Text-TeaserPart-Teaser
if ( !string.IsNullOrEmpty(partName) && !string.IsNullOrEmpty(fieldName) ) {
if ( !String.IsNullOrEmpty(partName) && !String.IsNullOrEmpty(fieldName) ) {
metadata.Alternates.Add(EncodeAlternateElement(shapeType + "__" + partName + "__" + fieldName));
}
// [ShapeType]__[ContentType]__[FieldName] e.g. Fields/Common.Text-Blog-Teaser
if ( !string.IsNullOrEmpty(contentType) && !string.IsNullOrEmpty(fieldName) ) {
if ( !String.IsNullOrEmpty(contentType) && !String.IsNullOrEmpty(fieldName) ) {
metadata.Alternates.Add(EncodeAlternateElement(shapeType + "__" + contentType + "__" + fieldName));
}
// [ShapeType]__[ContentType]__[PartName]__[FieldName] e.g. Fields/Common.Text-Blog-TeaserPart-Teaser
if ( !string.IsNullOrEmpty(contentType) && !string.IsNullOrEmpty(partName) && !string.IsNullOrEmpty(fieldName) && !dynamicType ) {
metadata.Alternates.Add(EncodeAlternateElement(shapeType + "__" + contentType + "__" + partName));
if ( !String.IsNullOrEmpty(contentType) && !String.IsNullOrEmpty(partName) && !String.IsNullOrEmpty(fieldName) && !dynamicType ) {
metadata.Alternates.Add(EncodeAlternateElement(shapeType + "__" + contentType + "__" + partName + "__" + fieldName));
}
return shape;