U4-3027 - fix content & property types alias casing

This commit is contained in:
Stephan
2014-04-24 00:10:50 +02:00
parent 6d50b46bd8
commit f46811ff67
6 changed files with 22 additions and 9 deletions

View File

@@ -17,6 +17,7 @@ using ClientDependency.Core;
using Umbraco.Core;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Strings;
using Umbraco.Web.UI.Controls;
using umbraco.BusinessLogic;
using umbraco.cms.businesslogic;
@@ -294,7 +295,7 @@ namespace umbraco.controls
global::Umbraco.Web.UmbracoContext.Current = asyncState.UmbracoContext;
_contentType.ContentTypeItem.Name = txtName.Text;
_contentType.ContentTypeItem.Alias = txtAlias.Text;
_contentType.ContentTypeItem.Alias = txtAlias.Text; // raw, contentType.Alias takes care of it
_contentType.ContentTypeItem.Icon = ddlIcons.SelectedValue;
_contentType.ContentTypeItem.Description = description.Text;
_contentType.ContentTypeItem.Thumbnail = ddlThumbnails.SelectedValue;
@@ -834,7 +835,9 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
GenericProperty gpData = gp.GenricPropertyControl;
if (string.IsNullOrEmpty(gpData.Name.Trim()) == false && string.IsNullOrEmpty(gpData.Alias.Trim()) == false)
{
var propertyTypeAlias = gpData.Alias.ToSafeAlias();
// when creating a property don't do anything special, propertyType.Alias will take care of it
// don't enforce camel here because the user might have changed what the CoreStringsController returned
var propertyTypeAlias = gpData.Alias;
if (contentTypeItem.PropertyTypeExists(propertyTypeAlias) == false)
{
//Find the DataTypeDefinition that the PropertyType should be based on
@@ -891,7 +894,8 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
var propertyType = contentTypeItem.PropertyTypes.First(x => x.Alias == gpw.PropertyType.Alias);
if (propertyType == null) continue;
var dataTypeDefinition = ApplicationContext.Current.Services.DataTypeService.GetDataTypeDefinitionById(gpw.GenricPropertyControl.Type);
propertyType.Alias = gpw.GenricPropertyControl.Alias.ToSafeAlias();
// when saving, respect user's casing, so do nothing here as propertyType takes care of it
propertyType.Alias = gpw.GenricPropertyControl.Alias;
propertyType.Name = gpw.GenricPropertyControl.Name;
propertyType.Description = gpw.GenricPropertyControl.Description;
propertyType.ValidationRegExp = gpw.GenricPropertyControl.Validation;

View File

@@ -5,6 +5,7 @@ using System.Web.Security;
using Umbraco.Core;
using Umbraco.Core.Models;
using umbraco.BusinessLogic;
using Umbraco.Core.Strings;
using umbraco.DataLayer;
using umbraco.BasePages;
using Umbraco.Core.IO;
@@ -52,7 +53,9 @@ namespace umbraco
? new ContentType(-1)
: new ContentType(ApplicationContext.Current.Services.ContentTypeService.GetContentType(parentId));
contentType.CreatorId = _userID;
contentType.Alias = Alias.Replace("'", "''");
// when creating a content type, enforce PascalCase
// preserve separator because contentType.Alias will re-alias it
contentType.Alias = Alias.ToCleanString(CleanStringType.Alias | CleanStringType.PascalCase, ' ');
contentType.Name = Alias.Replace("'", "''");
contentType.Icon = UmbracoSettings.IconPickerBehaviour == IconPickerBehaviour.HideFileDuplicates
? ".sprTreeFolder"