Merge with 4.11.4
This commit is contained in:
@@ -13,6 +13,13 @@ namespace Umbraco.Tests.IO
|
|||||||
public class IOHelperTest
|
public class IOHelperTest
|
||||||
{
|
{
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IOHelper_ResolveUrl()
|
||||||
|
{
|
||||||
|
var result = IOHelper.ResolveUrl("~/Scripts");
|
||||||
|
Assert.AreEqual("/Scripts", result);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///A test for MapPath verifying that HttpContext method (which includes vdirs) matches non-HttpContext method
|
///A test for MapPath verifying that HttpContext method (which includes vdirs) matches non-HttpContext method
|
||||||
///</summary>
|
///</summary>
|
||||||
|
|||||||
@@ -10,6 +10,16 @@ namespace Umbraco.Tests
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class StringExtensionsTests
|
public class StringExtensionsTests
|
||||||
{
|
{
|
||||||
|
|
||||||
|
[TestCase("This is a string to encrypt")]
|
||||||
|
public void Encrypt_And_Decrypt(string input)
|
||||||
|
{
|
||||||
|
var encrypted = input.EncryptWithMachineKey();
|
||||||
|
var decrypted = encrypted.DecryptWithMachineKey();
|
||||||
|
Assert.AreNotEqual(input, encrypted);
|
||||||
|
Assert.AreEqual(input, decrypted);
|
||||||
|
}
|
||||||
|
|
||||||
[TestCase("Hello this is my string", " string", "Hello this is my")]
|
[TestCase("Hello this is my string", " string", "Hello this is my")]
|
||||||
[TestCase("Hello this is my string strung", " string", "Hello this is my string strung")]
|
[TestCase("Hello this is my string strung", " string", "Hello this is my string strung")]
|
||||||
[TestCase("Hello this is my string string", " string", "Hello this is my")]
|
[TestCase("Hello this is my string string", " string", "Hello this is my")]
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using System;
|
|||||||
using System.Data;
|
using System.Data;
|
||||||
|
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
using System.Linq;
|
||||||
using umbraco.DataLayer;
|
using umbraco.DataLayer;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using umbraco.interfaces;
|
using umbraco.interfaces;
|
||||||
@@ -9,16 +10,16 @@ using umbraco.cms.businesslogic.propertytype;
|
|||||||
|
|
||||||
namespace umbraco.cms.businesslogic.datatype
|
namespace umbraco.cms.businesslogic.datatype
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Datatypedefinitions is the basic buildingblocks of umbraco's documents/medias/members generic datastructure
|
/// Datatypedefinitions is the basic buildingblocks of umbraco's documents/medias/members generic datastructure
|
||||||
///
|
///
|
||||||
/// A datatypedefinition encapsulates an object which implements the interface IDataType, and are used when defining
|
/// A datatypedefinition encapsulates an object which implements the interface IDataType, and are used when defining
|
||||||
/// the properties of a document in the documenttype. This extra layer between IDataType and a documenttypes propertytype
|
/// the properties of a document in the documenttype. This extra layer between IDataType and a documenttypes propertytype
|
||||||
/// are used amongst other for enabling shared prevalues.
|
/// are used amongst other for enabling shared prevalues.
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class DataTypeDefinition : CMSNode
|
public class DataTypeDefinition : CMSNode
|
||||||
{
|
{
|
||||||
#region Private fields
|
#region Private fields
|
||||||
private Guid _controlId;
|
private Guid _controlId;
|
||||||
|
|
||||||
@@ -39,8 +40,8 @@ namespace umbraco.cms.businesslogic.datatype
|
|||||||
/// Initialization of the datatypedefinition
|
/// Initialization of the datatypedefinition
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">Datattypedefininition id</param>
|
/// <param name="id">Datattypedefininition id</param>
|
||||||
public DataTypeDefinition(Guid id) : base(id) { }
|
public DataTypeDefinition(Guid id) : base(id) { }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Public Properties
|
#region Public Properties
|
||||||
@@ -66,10 +67,10 @@ namespace umbraco.cms.businesslogic.datatype
|
|||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (SqlHelper == null)
|
if (SqlHelper == null)
|
||||||
throw new InvalidOperationException("Cannot execute a SQL command when the SqlHelper is null");
|
throw new InvalidOperationException("Cannot execute a SQL command when the SqlHelper is null");
|
||||||
if (value == null)
|
if (value == null)
|
||||||
throw new InvalidOperationException("The value passed in is null. The DataType property cannot be set to a null value");
|
throw new InvalidOperationException("The value passed in is null. The DataType property cannot be set to a null value");
|
||||||
|
|
||||||
SqlHelper.ExecuteNonQuery("update cmsDataType set controlId = @id where nodeID = " + this.Id.ToString(),
|
SqlHelper.ExecuteNonQuery("update cmsDataType set controlId = @id where nodeID = " + this.Id.ToString(),
|
||||||
SqlHelper.CreateParameter("@id", value.Id));
|
SqlHelper.CreateParameter("@id", value.Id));
|
||||||
@@ -79,7 +80,7 @@ namespace umbraco.cms.businesslogic.datatype
|
|||||||
internal string DbType
|
internal string DbType
|
||||||
{
|
{
|
||||||
get { return _dbType; }
|
get { return _dbType; }
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Public methods
|
#region Public methods
|
||||||
@@ -87,7 +88,7 @@ namespace umbraco.cms.businesslogic.datatype
|
|||||||
{
|
{
|
||||||
//first clear the prevalues
|
//first clear the prevalues
|
||||||
PreValues.DeleteByDataTypeDefinition(this.Id);
|
PreValues.DeleteByDataTypeDefinition(this.Id);
|
||||||
|
|
||||||
//next clear out the property types
|
//next clear out the property types
|
||||||
var propTypes = PropertyType.GetByDataTypeDefinition(this.Id);
|
var propTypes = PropertyType.GetByDataTypeDefinition(this.Id);
|
||||||
foreach (var p in propTypes)
|
foreach (var p in propTypes)
|
||||||
@@ -153,7 +154,7 @@ namespace umbraco.cms.businesslogic.datatype
|
|||||||
dt.AppendChild(prevalues);
|
dt.AppendChild(prevalues);
|
||||||
|
|
||||||
return dt;
|
return dt;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Static methods
|
#region Static methods
|
||||||
@@ -178,11 +179,11 @@ namespace umbraco.cms.businesslogic.datatype
|
|||||||
|
|
||||||
|
|
||||||
DataTypeDefinition dtd = MakeNew(u, _name, new Guid(_def));
|
DataTypeDefinition dtd = MakeNew(u, _name, new Guid(_def));
|
||||||
var dataType = f.DataType(new Guid(_id));
|
var dataType = f.DataType(new Guid(_id));
|
||||||
if (dataType == null)
|
if (dataType == null)
|
||||||
throw new NullReferenceException("Could not resolve a data type with id " + _id);
|
throw new NullReferenceException("Could not resolve a data type with id " + _id);
|
||||||
|
|
||||||
dtd.DataType = dataType;
|
dtd.DataType = dataType;
|
||||||
dtd.Save();
|
dtd.Save();
|
||||||
|
|
||||||
//add prevalues
|
//add prevalues
|
||||||
@@ -254,11 +255,11 @@ namespace umbraco.cms.businesslogic.datatype
|
|||||||
|
|
||||||
int newId = CMSNode.MakeNew(-1, _objectType, u.Id, 1, Text, UniqueId).Id;
|
int newId = CMSNode.MakeNew(-1, _objectType, u.Id, 1, Text, UniqueId).Id;
|
||||||
cms.businesslogic.datatype.controls.Factory f = new cms.businesslogic.datatype.controls.Factory();
|
cms.businesslogic.datatype.controls.Factory f = new cms.businesslogic.datatype.controls.Factory();
|
||||||
|
|
||||||
// initial control id changed to empty to ensure that it'll always work no matter if 3rd party configurators fail
|
// initial control id changed to empty to ensure that it'll always work no matter if 3rd party configurators fail
|
||||||
// ref: http://umbraco.codeplex.com/workitem/29788
|
// ref: http://umbraco.codeplex.com/workitem/29788
|
||||||
Guid FirstcontrolId = Guid.Empty;
|
Guid FirstcontrolId = Guid.Empty;
|
||||||
|
|
||||||
SqlHelper.ExecuteNonQuery("Insert into cmsDataType (nodeId, controlId, dbType) values (" + newId.ToString() + ",@controlId,'Ntext')",
|
SqlHelper.ExecuteNonQuery("Insert into cmsDataType (nodeId, controlId, dbType) values (" + newId.ToString() + ",@controlId,'Ntext')",
|
||||||
SqlHelper.CreateParameter("@controlId", FirstcontrolId));
|
SqlHelper.CreateParameter("@controlId", FirstcontrolId));
|
||||||
|
|
||||||
@@ -276,7 +277,8 @@ namespace umbraco.cms.businesslogic.datatype
|
|||||||
public static DataTypeDefinition GetByDataTypeId(Guid DataTypeId)
|
public static DataTypeDefinition GetByDataTypeId(Guid DataTypeId)
|
||||||
{
|
{
|
||||||
int dfId = 0;
|
int dfId = 0;
|
||||||
foreach (DataTypeDefinition df in DataTypeDefinition.GetAll())
|
// When creating a datatype and not saving it, it will be null, so we need this check
|
||||||
|
foreach (DataTypeDefinition df in DataTypeDefinition.GetAll().Where(x => x.DataType != null))
|
||||||
if (df.DataType.Id == DataTypeId)
|
if (df.DataType.Id == DataTypeId)
|
||||||
{
|
{
|
||||||
dfId = df.Id;
|
dfId = df.Id;
|
||||||
@@ -323,7 +325,7 @@ namespace umbraco.cms.businesslogic.datatype
|
|||||||
System.Web.HttpRuntime.Cache.Insert(string.Format("UmbracoDataTypeDefinition{0}", id.ToString()), dt);
|
System.Web.HttpRuntime.Cache.Insert(string.Format("UmbracoDataTypeDefinition{0}", id.ToString()), dt);
|
||||||
}
|
}
|
||||||
return (DataTypeDefinition)System.Web.HttpRuntime.Cache[string.Format("UmbracoDataTypeDefinition{0}", id.ToString())];
|
return (DataTypeDefinition)System.Web.HttpRuntime.Cache[string.Format("UmbracoDataTypeDefinition{0}", id.ToString())];
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Protected methods
|
#region Protected methods
|
||||||
@@ -341,8 +343,8 @@ namespace umbraco.cms.businesslogic.datatype
|
|||||||
else
|
else
|
||||||
throw new ArgumentException("No dataType with id = " + this.Id.ToString() + " found");
|
throw new ArgumentException("No dataType with id = " + this.Id.ToString() + " found");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Events
|
#region Events
|
||||||
@@ -373,7 +375,7 @@ namespace umbraco.cms.businesslogic.datatype
|
|||||||
{
|
{
|
||||||
if (Deleting != null)
|
if (Deleting != null)
|
||||||
Deleting(this, e);
|
Deleting(this, e);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user