Merge remote-tracking branch 'origin/6.1.4' into 7.0.0

Conflicts:
	.gitignore
	src/Umbraco.Core/Models/PropertyExtensions.cs
	src/Umbraco.Core/Models/PropertyTypeExtensions.cs
	src/Umbraco.Core/Security/AuthenticationExtensions.cs
	src/Umbraco.Core/Security/UmbracoBackOfficeIdentity.cs
	src/Umbraco.Core/Security/UserData.cs
	src/Umbraco.Core/Umbraco.Core.csproj
	src/Umbraco.Tests/TestHelpers/BaseDatabaseFactoryTest.cs
	src/Umbraco.Tests/TestHelpers/BaseUmbracoApplicationTest.cs
	src/Umbraco.Tests/Umbraco.Tests.csproj
	src/Umbraco.Web/Security/WebSecurity.cs
	src/Umbraco.Web/UmbracoModule.cs
	src/umbraco.businesslogic/BasePages/BasePage.cs
	src/umbraco.cms/businesslogic/datatype/DefaultData.cs
	src/umbraco.sln
This commit is contained in:
Shannon
2013-08-07 10:29:34 +10:00
27 changed files with 540 additions and 200 deletions

View File

@@ -303,6 +303,8 @@ namespace Umbraco.Core
connString = ConfigurationManager.ConnectionStrings[GlobalSettings.UmbracoConnectionName].ConnectionString; connString = ConfigurationManager.ConnectionStrings[GlobalSettings.UmbracoConnectionName].ConnectionString;
} }
Initialize(providerName, connString); Initialize(providerName, connString);
DetermineSqlServerVersion();
} }
else if (ConfigurationManager.AppSettings.ContainsKey(GlobalSettings.UmbracoConnectionName) && string.IsNullOrEmpty(ConfigurationManager.AppSettings[GlobalSettings.UmbracoConnectionName]) == false) else if (ConfigurationManager.AppSettings.ContainsKey(GlobalSettings.UmbracoConnectionName) && string.IsNullOrEmpty(ConfigurationManager.AppSettings[GlobalSettings.UmbracoConnectionName]) == false)
{ {
@@ -339,6 +341,8 @@ namespace Umbraco.Core
//Remove the legacy connection string, so we don't end up in a loop if something goes wrong. //Remove the legacy connection string, so we don't end up in a loop if something goes wrong.
GlobalSettings.RemoveSetting(GlobalSettings.UmbracoConnectionName); GlobalSettings.RemoveSetting(GlobalSettings.UmbracoConnectionName);
DetermineSqlServerVersion();
} }
else else
{ {
@@ -372,6 +376,49 @@ namespace Umbraco.Core
Initialize(providerName); Initialize(providerName);
} }
/// <summary>
/// Set the lazy resolution of determining the SQL server version if that is the db type we're using
/// </summary>
private void DetermineSqlServerVersion()
{
var sqlServerSyntax = SqlSyntaxContext.SqlSyntaxProvider as SqlServerSyntaxProvider;
if (sqlServerSyntax != null)
{
//this will not execute now, it is lazy so will only execute when we need to actually know
// the sql server version.
sqlServerSyntax.VersionName = new Lazy<SqlServerVersionName>(() =>
{
try
{
var database = this._factory.CreateDatabase();
var version = database.ExecuteScalar<string>("SELECT SERVERPROPERTY('productversion')");
var firstPart = version.Split('.')[0];
switch (firstPart)
{
case "11":
return SqlServerVersionName.V2012;
case "10":
return SqlServerVersionName.V2008;
case "9":
return SqlServerVersionName.V2005;
case "8":
return SqlServerVersionName.V2000;
case "7":
return SqlServerVersionName.V7;
default:
return SqlServerVersionName.Other;
}
}
catch (Exception)
{
return SqlServerVersionName.Invalid;
}
});
}
}
internal DatabaseSchemaResult ValidateDatabaseSchema() internal DatabaseSchemaResult ValidateDatabaseSchema()
{ {
if (_configured == false || (string.IsNullOrEmpty(_connectionString) || string.IsNullOrEmpty(ProviderName))) if (_configured == false || (string.IsNullOrEmpty(_connectionString) || string.IsNullOrEmpty(ProviderName)))
@@ -463,6 +510,8 @@ namespace Umbraco.Core
message = message + "<p>Upgrade completed!</p>"; message = message + "<p>Upgrade completed!</p>";
} }
//now that everything is done, we need to determine the version of SQL server that is executing
LogHelper.Info<DatabaseContext>("Database configuration status: " + message); LogHelper.Info<DatabaseContext>("Database configuration status: " + message);
return new Result { Message = message, Success = true, Percentage = "100" }; return new Result { Message = message, Success = true, Percentage = "100" };

View File

@@ -15,7 +15,12 @@ namespace Umbraco.Core.Models
/// <returns>Xml of the property and its value</returns> /// <returns>Xml of the property and its value</returns>
public static XElement ToXml(this Property property) public static XElement ToXml(this Property property)
{ {
string nodeName = UmbracoSettings.UseLegacyXmlSchema ? "data" : property.Alias.ToSafeAlias(); return property.ToXml(ApplicationContext.Current.Services.DataTypeService);
}
internal static XElement ToXml(this Property property, IDataTypeService dataTypeService)
{
var nodeName = UmbracoSettings.UseLegacyXmlSchema ? "data" : property.Alias.ToSafeAlias();
var xd = new XmlDocument(); var xd = new XmlDocument();
var xmlNode = xd.CreateNode(XmlNodeType.Element, nodeName, ""); var xmlNode = xd.CreateNode(XmlNodeType.Element, nodeName, "");
@@ -37,6 +42,16 @@ namespace Umbraco.Core.Models
//var dataType = ApplicationContext.Current.Services.DataTypeService.GetDataTypeDefinitionById(property.PropertyType.DataTypeDefinitionId); //var dataType = ApplicationContext.Current.Services.DataTypeService.GetDataTypeDefinitionById(property.PropertyType.DataTypeDefinitionId);
//if (dataType == null) throw new InvalidOperationException("No data type definition found with id " + property.PropertyType.DataTypeDefinitionId); //if (dataType == null) throw new InvalidOperationException("No data type definition found with id " + property.PropertyType.DataTypeDefinitionId);
//We've already got the value for the property so we're going to give it to the
// data type's data property so it doesn't go re-look up the value from the db again.
var defaultData = dt.Data as IDataValueSetter;
if (defaultData != null)
{
defaultData.SetValue(property.Value, property.PropertyType.DataTypeDatabaseType.ToString());
}
xmlNode.AppendChild(dt.Data.ToXMl(xd));
var propertyEditor = PropertyEditorResolver.Current.GetById(property.PropertyType.DataTypeId); var propertyEditor = PropertyEditorResolver.Current.GetById(property.PropertyType.DataTypeId);
if (propertyEditor != null) if (propertyEditor != null)
{ {

View File

@@ -1,4 +1,5 @@
using System; using System;
using Umbraco.Core.Services;
using umbraco.interfaces; using umbraco.interfaces;
namespace Umbraco.Core.Models namespace Umbraco.Core.Models
@@ -10,6 +11,7 @@ namespace Umbraco.Core.Models
/// </summary> /// </summary>
/// <param name="propertyType">PropertyType that references a DataType</param> /// <param name="propertyType">PropertyType that references a DataType</param>
/// <param name="propertyId">Id of the Property which references this DataType through its PropertyType</param> /// <param name="propertyId">Id of the Property which references this DataType through its PropertyType</param>
/// <param name="dataTypeService"></param>
/// <returns><see cref="IDataType"/></returns> /// <returns><see cref="IDataType"/></returns>
/// <remarks> /// <remarks>
/// This extension method is left internal because we don't want to take /// This extension method is left internal because we don't want to take
@@ -17,10 +19,10 @@ namespace Umbraco.Core.Models
/// be replaced by PropertyEditors. It is however needed to generate xml /// be replaced by PropertyEditors. It is however needed to generate xml
/// for a property/propertytype when publishing. /// for a property/propertytype when publishing.
/// </remarks> /// </remarks>
internal static IDataType DataType(this PropertyType propertyType, int propertyId) internal static IDataType DataType(this PropertyType propertyType, int propertyId, IDataTypeService dataTypeService)
{ {
Mandate.ParameterNotNull(propertyType, "propertyType"); Mandate.ParameterNotNull(propertyType, "propertyType");
var dataType = ApplicationContext.Current.Services.DataTypeService.GetDataTypeById(propertyType.DataTypeId); var dataType = dataTypeService.GetDataTypeById(propertyType.DataTypeId);
if (dataType == null) if (dataType == null)
throw new InvalidOperationException("No IDataType found for control ID " + propertyType.DataTypeId); throw new InvalidOperationException("No IDataType found for control ID " + propertyType.DataTypeId);

View File

@@ -51,7 +51,10 @@ namespace Umbraco.Core.Persistence
try try
{ {
if (SqlSyntaxContext.SqlSyntaxProvider is SqlCeSyntaxProvider) //if it is sql ce or it is a sql server version less than 2008, we need to do individual inserts.
var sqlServerSyntax = SqlSyntaxContext.SqlSyntaxProvider as SqlServerSyntaxProvider;
if ((sqlServerSyntax != null && (int)sqlServerSyntax.VersionName.Value < (int)SqlServerVersionName.V2008)
|| SqlSyntaxContext.SqlSyntaxProvider is SqlCeSyntaxProvider)
{ {
//SqlCe doesn't support bulk insert statements! //SqlCe doesn't support bulk insert statements!

View File

@@ -339,19 +339,22 @@ namespace Umbraco.Core.Persistence.Repositories
} }
} }
//Look up (newest) entries by id in cmsDocument table to set newest = false
//NOTE: This should only be done for all other versions then the current one, so we don't cause the same entry to be updated multiple times.
var documentDtos =
Database.Query<DocumentDto>(
"WHERE nodeId = @Id AND newest = @IsNewest AND NOT(versionId = @VersionId)",
new {Id = entity.Id, IsNewest = true, VersionId = dto.ContentVersionDto.VersionId});
foreach (var documentDto in documentDtos)
{
var docDto = documentDto;
docDto.Newest = false;
Database.Update(docDto);
}
var contentVersionDto = dto.ContentVersionDto; var contentVersionDto = dto.ContentVersionDto;
if (shouldCreateNewVersion) if (shouldCreateNewVersion)
{ {
//Look up (newest) entries by id in cmsDocument table to set newest = false
//NOTE: This is only relevant when a new version is created, which is why its done inside this if-statement.
var documentDtos = Database.Fetch<DocumentDto>("WHERE nodeId = @Id AND newest = @IsNewest", new { Id = entity.Id, IsNewest = true });
foreach (var documentDto in documentDtos)
{
var docDto = documentDto;
docDto.Newest = false;
Database.Update(docDto);
}
//Create a new version - cmsContentVersion //Create a new version - cmsContentVersion
//Assumes a new Version guid and Version date (modified date) has been set //Assumes a new Version guid and Version date (modified date) has been set
Database.Insert(contentVersionDto); Database.Insert(contentVersionDto);

View File

@@ -13,6 +13,20 @@ namespace Umbraco.Core.Persistence.SqlSyntax
public static ISqlSyntaxProvider Provider { get { return new SqlServerSyntaxProvider(); } } public static ISqlSyntaxProvider Provider { get { return new SqlServerSyntaxProvider(); } }
} }
/// <summary>
/// Represents the version name of SQL server (i.e. the year 2008, 2005, etc...)
/// </summary>
internal enum SqlServerVersionName
{
Invalid = -1,
V7 = 0,
V2000 = 1,
V2005 = 2,
V2008 = 3,
V2012 = 4,
Other = 5
}
/// <summary> /// <summary>
/// Represents an SqlSyntaxProvider for Sql Server /// Represents an SqlSyntaxProvider for Sql Server
/// </summary> /// </summary>
@@ -36,6 +50,11 @@ namespace Umbraco.Core.Persistence.SqlSyntax
InitColumnTypeMap(); InitColumnTypeMap();
} }
/// <summary>
/// Gets/sets the version of the current SQL server instance
/// </summary>
internal Lazy<SqlServerVersionName> VersionName { get; set; }
public override string GetQuotedTableName(string tableName) public override string GetQuotedTableName(string tableName)
{ {
return string.Format("[{0}]", tableName); return string.Format("[{0}]", tableName);

View File

@@ -8,15 +8,14 @@ namespace Umbraco.Core.Publishing
/// </summary> /// </summary>
internal class PublishStatus internal class PublishStatus
{ {
public IContent ContentItem { get; private set; } public PublishStatus()
public PublishStatusType StatusType { get; internal set; } {
//initialize
/// <summary> InvalidProperties = new List<Property>();
/// Gets sets the invalid properties if the status failed due to validation. }
/// </summary>
public IEnumerable<Property> InvalidProperties { get; set; }
public PublishStatus(IContent content, PublishStatusType statusType) public PublishStatus(IContent content, PublishStatusType statusType)
: this()
{ {
ContentItem = content; ContentItem = content;
StatusType = statusType; StatusType = statusType;
@@ -29,6 +28,13 @@ namespace Umbraco.Core.Publishing
: this(content, PublishStatusType.Success) : this(content, PublishStatusType.Success)
{ {
} }
public IContent ContentItem { get; private set; }
public PublishStatusType StatusType { get; internal set; }
/// <summary>
/// Gets sets the invalid properties if the status failed due to validation.
/// </summary>
public IEnumerable<Property> InvalidProperties { get; set; }
} }
} }

View File

@@ -1,4 +1,6 @@
using System.Web.Security; using System;
using System.Web;
using System.Web.Security;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace Umbraco.Core.Security namespace Umbraco.Core.Security
@@ -15,6 +17,7 @@ namespace Umbraco.Core.Security
: base(ticket) : base(ticket)
{ {
UserData = ticket.UserData; UserData = ticket.UserData;
EnsureDeserialized();
} }
protected readonly string UserData; protected readonly string UserData;
@@ -24,54 +27,33 @@ namespace Umbraco.Core.Security
{ {
get get
{ {
EnsureDeserialized();
return DeserializedData.StartContentNode; return DeserializedData.StartContentNode;
} }
} }
public int StartMediaNode public int StartMediaNode
{ {
get get { return DeserializedData.StartMediaNode; }
{
EnsureDeserialized();
return DeserializedData.StartMediaNode;
}
} }
public string[] AllowedApplications public string[] AllowedApplications
{ {
get get { return DeserializedData.AllowedApplications; }
{
EnsureDeserialized();
return DeserializedData.AllowedApplications;
}
} }
public object Id public object Id
{ {
get get { return DeserializedData.Id; }
{
EnsureDeserialized();
return DeserializedData.Id;
}
} }
public string RealName public string RealName
{ {
get get { return DeserializedData.RealName; }
{
EnsureDeserialized();
return DeserializedData.RealName;
}
} }
public string Culture public string Culture
{ {
get get { return DeserializedData.Culture; }
{
EnsureDeserialized();
return DeserializedData.Culture;
}
} }
//public int SessionTimeout //public int SessionTimeout
@@ -85,24 +67,42 @@ namespace Umbraco.Core.Security
public string[] Roles public string[] Roles
{ {
get get { return DeserializedData.Roles; }
{
EnsureDeserialized();
return DeserializedData.Roles;
}
} }
/// <summary>
/// This will ensure we only deserialize once
/// </summary>
/// <remarks>
/// For performance reasons, we'll also check if there's an http context available,
/// if so, we'll chuck our instance in there so that we only deserialize once per request.
/// </remarks>
protected void EnsureDeserialized() protected void EnsureDeserialized()
{ {
if (DeserializedData != null) if (DeserializedData != null)
return; return;
if (HttpContext.Current != null)
{
//check if we've already done this in this request
var data = HttpContext.Current.Items[typeof(UmbracoBackOfficeIdentity)] as UserData;
if (data != null)
{
DeserializedData = data;
return;
}
}
if (string.IsNullOrEmpty(UserData)) if (string.IsNullOrEmpty(UserData))
{ {
DeserializedData = new UserData(); throw new NullReferenceException("The " + typeof(UserData) + " found in the ticket cannot be empty");
return; }
DeserializedData = JsonConvert.DeserializeObject<UserData>(UserData);
if (HttpContext.Current != null)
{
HttpContext.Current.Items[typeof (UmbracoBackOfficeIdentity)] = DeserializedData;
} }
DeserializedData = JsonConvert.DeserializeObject<UserData>(UserData);
} }
} }
} }

View File

@@ -1479,7 +1479,12 @@ namespace Umbraco.Core.Services
LogHelper.Info<ContentService>( LogHelper.Info<ContentService>(
string.Format("Content '{0}' with Id '{1}' could not be published because of invalid properties.", string.Format("Content '{0}' with Id '{1}' could not be published because of invalid properties.",
content.Name, content.Id)); content.Name, content.Id));
result.Add(new Attempt<PublishStatus>(false, new PublishStatus(content, PublishStatusType.FailedContentInvalid))); result.Add(
new Attempt<PublishStatus>(false,
new PublishStatus(content, PublishStatusType.FailedContentInvalid)
{
InvalidProperties = ((ContentBase) content).LastInvalidProperties
}));
return result; return result;
} }

View File

@@ -13,6 +13,7 @@ namespace Umbraco.Core
/// </summary> /// </summary>
public static class UriExtensions public static class UriExtensions
{ {
/// <summary> /// <summary>
/// Checks if the current uri is a back office request /// Checks if the current uri is a back office request
/// </summary> /// </summary>
@@ -20,11 +21,14 @@ namespace Umbraco.Core
/// <returns></returns> /// <returns></returns>
internal static bool IsBackOfficeRequest(this Uri url) internal static bool IsBackOfficeRequest(this Uri url)
{ {
var authority = url.GetLeftPart(UriPartial.Authority); var authority = url.GetLeftPart(UriPartial.Authority);
var afterAuthority = url.GetLeftPart(UriPartial.Query) var afterAuthority = url.GetLeftPart(UriPartial.Query)
.TrimStart(authority) .TrimStart(authority)
.TrimStart("/"); .TrimStart("/");
//check if this is in the umbraco back office //check if this is in the umbraco back office
return afterAuthority.InvariantStartsWith(GlobalSettings.Path.TrimStart("/")); return afterAuthority.InvariantStartsWith(GlobalSettings.Path.TrimStart("/"));
} }

View File

@@ -0,0 +1,102 @@
using System;
using System.Diagnostics;
using System.Xml;
using NUnit.Framework;
using Rhino.Mocks;
using Rhino.Mocks.Interfaces;
using Umbraco.Core.Models;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
using Umbraco.Tests.TestHelpers;
using umbraco.cms.businesslogic.datatype;
using umbraco.interfaces;
namespace Umbraco.Tests.Models
{
[TestFixture]
public class DataValueSetterTests : BaseUmbracoApplicationTest
{
protected override void FreezeResolution()
{
ShortStringHelperResolver.Current = new ShortStringHelperResolver(new DefaultShortStringHelper());
base.FreezeResolution();
}
[Test]
public void LoadValueFromDatabase_Is_Not_Called_When_SetValue_Is_Used()
{
// Arrange
var baseDataType = MockRepository.GenerateStub<BaseDataType>();
var dataTypeData = MockRepository.GenerateMock<DefaultData>(baseDataType);
dataTypeData.Stub(x => x.Value).CallOriginalMethod(OriginalCallOptions.NoExpectation);
// Act
((IDataValueSetter)dataTypeData).SetValue("Hello world", DataTypeDatabaseType.Nvarchar.ToString());
var val = dataTypeData.Value;
// Assert
dataTypeData.AssertWasNotCalled(data => data.LoadValueFromDatabase());
}
[Test]
public void LoadValueFromDatabase_Is_Called_When_SetValue_Is_Not_Used()
{
// Arrange
var baseDataType = MockRepository.GenerateStub<BaseDataType>();
var dataTypeData = MockRepository.GenerateMock<DefaultData>(baseDataType);
dataTypeData
.Stub(data => data.LoadValueFromDatabase()).WhenCalled(invocation => Debug.WriteLine("asdf"));
dataTypeData.Stub(x => x.Value).CallOriginalMethod(OriginalCallOptions.NoExpectation);
// Act
var val = dataTypeData.Value;
// Assert
dataTypeData.AssertWasCalled(data => data.LoadValueFromDatabase());
}
[Test]
public void SetValue_Is_Called_When_Executing_ToXml_On_A_Property_With_DataType_That_Implements_IDataValueSetter()
{
// Arrange
var dataTypeId = Guid.NewGuid();
var dataTypeData = MockRepository.GenerateMock<IData, IDataValueSetter>();
dataTypeData
.Stub(data => data.ToXMl(Arg<XmlDocument>.Is.Anything))
.Return(null) // you have to call Return() even though we're about to override it
.WhenCalled(invocation =>
{
var xmlDoc = (XmlDocument) invocation.Arguments[0];
invocation.ReturnValue = xmlDoc.CreateElement("test");
});
var dataType = MockRepository.GenerateStub<IDataType>();
dataType.Stub(type => type.Data).Return(dataTypeData);
var dataTypeSvc = MockRepository.GenerateStub<IDataTypeService>();
dataTypeSvc.Stub(service => service.GetDataTypeById(dataTypeId)).Return(dataType);
var property = new Property(
1234,
Guid.NewGuid(),
new PropertyType(dataTypeId, DataTypeDatabaseType.Nvarchar)
{
Alias = "test"
}, "Hello world");
// Act
var xml = property.ToXml(dataTypeSvc);
// Assert
((IDataValueSetter)dataTypeData).AssertWasCalled(setter => setter.SetValue("Hello world", DataTypeDatabaseType.Nvarchar.ToString()));
}
}
}

View File

@@ -0,0 +1,41 @@
using System;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Tests.TestHelpers.Entities;
namespace Umbraco.Tests.Services
{
//[TestFixture]
//public class PackagingServiceTests : BaseServiceTest
//{
// [Test]
// public void Export_Content()
// {
// var yesNo = DataTypesResolver.Current.GetById(new Guid(Constants.PropertyEditors.TrueFalse));
// var txtField = DataTypesResolver.Current.GetById(new Guid(Constants.PropertyEditors.Textbox));
// var contentWithDataType = MockedContentTypes.CreateSimpleContentType(
// "test",
// "Test",
// new PropertyTypeCollection(
// new PropertyType[]
// {
// new PropertyType(new DataTypeDefinition(-1, txtField.Id)
// {
// Name = "Testing Textfield", DatabaseType = DataTypeDatabaseType.Ntext
// }),
// new PropertyType(new DataTypeDefinition(-1, yesNo.Id)
// {
// Name = "Testing intfield", DatabaseType = DataTypeDatabaseType.Integer
// })
// }));
// var content = MockedContent.CreateSimpleContent(contentWithDataType);
// content.Name = "Test";
// var exported = ServiceContext.PackagingService.Export(content);
// }
//}
}

View File

@@ -42,28 +42,39 @@ namespace Umbraco.Tests.TestHelpers
private static volatile bool _firstRunInTestSession = true; private static volatile bool _firstRunInTestSession = true;
private static readonly object Locker = new object(); private static readonly object Locker = new object();
private bool _firstTestInFixture = true; private bool _firstTestInFixture = true;
private DefaultDatabaseFactory _dbFactory;
//Used to flag if its the first test in the current session //Used to flag if its the first test in the current session
private bool _isFirstRunInTestSession = false; private bool _isFirstRunInTestSession = false;
//Used to flag if its the first test in the current fixture //Used to flag if its the first test in the current fixture
private bool _isFirstTestInFixture = false; private bool _isFirstTestInFixture = false;
private ApplicationContext _appContext;
[SetUp] [SetUp]
public override void Initialize() public override void Initialize()
{ {
InitializeFirstRunFlags(); InitializeFirstRunFlags();
_dbFactory = new DefaultDatabaseFactory(
GetDbConnectionString(),
GetDbProviderName());
base.Initialize();
var path = TestHelper.CurrentAssemblyDirectory; var path = TestHelper.CurrentAssemblyDirectory;
AppDomain.CurrentDomain.SetData("DataDirectory", path); AppDomain.CurrentDomain.SetData("DataDirectory", path);
DatabaseContext.Initialize(_dbFactory.ProviderName, _dbFactory.ConnectionString); var dbFactory = new DefaultDatabaseFactory(
GetDbConnectionString(),
GetDbProviderName());
_appContext = new ApplicationContext(
//assign the db context
new DatabaseContext(dbFactory),
//assign the service context
new ServiceContext(new PetaPocoUnitOfWorkProvider(dbFactory), new FileUnitOfWorkProvider(), new PublishingStrategy()),
//disable cache
false)
{
IsReady = true
};
base.Initialize();
DatabaseContext.Initialize(dbFactory.ProviderName, dbFactory.ConnectionString);
CreateSqlCeDatabase(); CreateSqlCeDatabase();
@@ -75,18 +86,7 @@ namespace Umbraco.Tests.TestHelpers
protected override void SetupApplicationContext() protected override void SetupApplicationContext()
{ {
//disable cache ApplicationContext.Current = _appContext;
var cacheHelper = new CacheHelper(new NullCacheProvider(), false);
ApplicationContext.Current = new ApplicationContext(
//assign the db context
new DatabaseContext(_dbFactory),
//assign the service context
new ServiceContext(new PetaPocoUnitOfWorkProvider(), new FileUnitOfWorkProvider(), new PublishingStrategy(), cacheHelper),
cacheHelper)
{
IsReady = true
};
} }
/// <summary> /// <summary>

View File

@@ -33,6 +33,7 @@ namespace Umbraco.Tests.TestHelpers
SetupPluginManager(); SetupPluginManager();
SetupApplicationContext(); SetupApplicationContext();
InitializeMappers(); InitializeMappers();
FreezeResolution(); FreezeResolution();
} }
@@ -48,7 +49,7 @@ namespace Umbraco.Tests.TestHelpers
ApplicationContext.Current = null; ApplicationContext.Current = null;
ResetPluginManager(); ResetPluginManager();
} }
private void InitializeMappers() private void InitializeMappers()
{ {
Mapper.Initialize(configuration => Mapper.Initialize(configuration =>

View File

@@ -198,10 +198,12 @@
<Compile Include="Controllers\WebApiEditors\ContentControllerTests.cs" /> <Compile Include="Controllers\WebApiEditors\ContentControllerTests.cs" />
<Compile Include="CoreXml\FrameworkXmlTests.cs" /> <Compile Include="CoreXml\FrameworkXmlTests.cs" />
<Compile Include="Integration\CreateContent.cs" /> <Compile Include="Integration\CreateContent.cs" />
<Compile Include="Models\DataValueSetterTests.cs" />
<Compile Include="Persistence\PetaPocoExtensionsTest.cs" /> <Compile Include="Persistence\PetaPocoExtensionsTest.cs" />
<Compile Include="Persistence\Repositories\UserRepositoryTest.cs" /> <Compile Include="Persistence\Repositories\UserRepositoryTest.cs" />
<Compile Include="Persistence\Repositories\UserTypeRepositoryTest.cs" /> <Compile Include="Persistence\Repositories\UserTypeRepositoryTest.cs" />
<Compile Include="Models\Mapping\ContentWebModelMappingTests.cs" /> <Compile Include="Models\Mapping\ContentWebModelMappingTests.cs" />
<Compile Include="Services\PackagingServiceTests.cs" />
<Compile Include="Services\PerformanceTests.cs" /> <Compile Include="Services\PerformanceTests.cs" />
<Compile Include="Services\UserServiceTests.cs" /> <Compile Include="Services\UserServiceTests.cs" />
<Compile Include="Manifest\ManifestParserTests.cs" /> <Compile Include="Manifest\ManifestParserTests.cs" />

View File

@@ -937,6 +937,7 @@
<Content Include="Umbraco_Client\Tinymce3\Langs\no.js" /> <Content Include="Umbraco_Client\Tinymce3\Langs\no.js" />
<Content Include="Umbraco_Client\Tinymce3\Langs\pl.js" /> <Content Include="Umbraco_Client\Tinymce3\Langs\pl.js" />
<Content Include="Umbraco_Client\Tinymce3\Langs\pt.js" /> <Content Include="Umbraco_Client\Tinymce3\Langs\pt.js" />
<Content Include="Umbraco_Client\Tinymce3\Langs\ru.js" />
<Content Include="Umbraco_Client\Tinymce3\Langs\sv.js" /> <Content Include="Umbraco_Client\Tinymce3\Langs\sv.js" />
<Content Include="Umbraco_Client\Tinymce3\Langs\zh.js" /> <Content Include="Umbraco_Client\Tinymce3\Langs\zh.js" />
<Content Include="Umbraco_Client\Tinymce3\license.txt" /> <Content Include="Umbraco_Client\Tinymce3\license.txt" />
@@ -957,6 +958,7 @@
<Content Include="Umbraco_Client\Tinymce3\Plugins\Advhr\Langs\no_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Advhr\Langs\no_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Advhr\Langs\pl_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Advhr\Langs\pl_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Advhr\Langs\pt_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Advhr\Langs\pt_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Advhr\Langs\ru_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Advhr\Langs\sv_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Advhr\Langs\sv_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Advhr\Langs\zh_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Advhr\Langs\zh_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Advhr\rule.htm" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Advhr\rule.htm" />
@@ -979,6 +981,7 @@
<Content Include="Umbraco_Client\Tinymce3\Plugins\Advimage\Langs\no_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Advimage\Langs\no_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Advimage\Langs\pl_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Advimage\Langs\pl_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Advimage\Langs\pt_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Advimage\Langs\pt_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Advimage\Langs\ru_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Advimage\Langs\sv_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Advimage\Langs\sv_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Advimage\Langs\zh_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Advimage\Langs\zh_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Advlink\Css\advlink.css" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Advlink\Css\advlink.css" />
@@ -998,6 +1001,7 @@
<Content Include="Umbraco_Client\Tinymce3\Plugins\Advlink\Langs\no_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Advlink\Langs\no_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Advlink\Langs\pl_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Advlink\Langs\pl_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Advlink\Langs\pt_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Advlink\Langs\pt_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Advlink\Langs\ru_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Advlink\Langs\sv_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Advlink\Langs\sv_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Advlink\Langs\zh_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Advlink\Langs\zh_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Advlink\link.htm" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Advlink\link.htm" />
@@ -1050,6 +1054,7 @@
<Content Include="Umbraco_Client\Tinymce3\Plugins\Emotions\Langs\no_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Emotions\Langs\no_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Emotions\Langs\pl_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Emotions\Langs\pl_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Emotions\Langs\pt_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Emotions\Langs\pt_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Emotions\Langs\ru_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Emotions\Langs\sv_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Emotions\Langs\sv_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Emotions\Langs\zh_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Emotions\Langs\zh_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Example\dialog.htm" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Example\dialog.htm" />
@@ -1079,6 +1084,7 @@
<Content Include="Umbraco_Client\Tinymce3\Plugins\Fullpage\Langs\no_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Fullpage\Langs\no_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Fullpage\Langs\pl_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Fullpage\Langs\pl_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Fullpage\Langs\pt_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Fullpage\Langs\pt_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Fullpage\Langs\ru_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Fullpage\Langs\sv_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Fullpage\Langs\sv_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Fullpage\Langs\zh_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Fullpage\Langs\zh_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Fullscreen\editor_plugin.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Fullscreen\editor_plugin.js" />
@@ -1112,6 +1118,7 @@
<Content Include="Umbraco_Client\Tinymce3\Plugins\Layer\editor_plugin_src.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Layer\editor_plugin_src.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Legacyoutput\editor_plugin.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Legacyoutput\editor_plugin.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Legacyoutput\editor_plugin_src.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Legacyoutput\editor_plugin_src.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Media\Langs\ru_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Lists\editor_plugin.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Lists\editor_plugin.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Lists\editor_plugin_src.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Lists\editor_plugin_src.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Media\Css\media.css" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Media\Css\media.css" />
@@ -1161,6 +1168,7 @@
<Content Include="Umbraco_Client\Tinymce3\Plugins\Paste\Langs\no_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Paste\Langs\no_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Paste\Langs\pl_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Paste\Langs\pl_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Paste\Langs\pt_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Paste\Langs\pt_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Paste\Langs\ru_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Paste\Langs\sv_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Paste\Langs\sv_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Paste\Langs\zh_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Paste\Langs\zh_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Paste\pastetext.htm" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Paste\pastetext.htm" />
@@ -1191,6 +1199,7 @@
<Content Include="Umbraco_Client\Tinymce3\Plugins\Searchreplace\Langs\no_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Searchreplace\Langs\no_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Searchreplace\Langs\pl_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Searchreplace\Langs\pl_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Searchreplace\Langs\pt_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Searchreplace\Langs\pt_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Searchreplace\Langs\ru_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Searchreplace\Langs\sv_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Searchreplace\Langs\sv_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Searchreplace\Langs\zh_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Searchreplace\Langs\zh_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Searchreplace\searchreplace.htm" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Searchreplace\searchreplace.htm" />
@@ -1215,6 +1224,7 @@
<Content Include="Umbraco_Client\Tinymce3\Plugins\Style\Langs\no_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Style\Langs\no_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Style\Langs\pl_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Style\Langs\pl_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Style\Langs\pt_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Style\Langs\pt_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Style\Langs\ru_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Style\Langs\sv_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Style\Langs\sv_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Style\Langs\zh_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Style\Langs\zh_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Style\props.htm" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Style\props.htm" />
@@ -1244,6 +1254,7 @@
<Content Include="Umbraco_Client\Tinymce3\Plugins\Table\Langs\no_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Table\Langs\no_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Table\Langs\pl_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Table\Langs\pl_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Table\Langs\pt_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Table\Langs\pt_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Table\Langs\ru_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Table\Langs\sv_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Table\Langs\sv_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Table\Langs\zh_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Table\Langs\zh_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Table\merge_cells.htm" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Table\merge_cells.htm" />
@@ -1267,6 +1278,7 @@
<Content Include="Umbraco_Client\Tinymce3\Plugins\Template\Langs\no_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Template\Langs\no_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Template\Langs\pl_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Template\Langs\pl_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Template\Langs\pt_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Template\Langs\pt_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Template\Langs\ru_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Template\Langs\sv_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Template\Langs\sv_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Template\Langs\zh_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Template\Langs\zh_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Template\template.htm" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Template\template.htm" />
@@ -1281,8 +1293,12 @@
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracocss\Langs\en_us_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracocss\Langs\en_us_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracocss\Langs\it.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracocss\Langs\it.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracocss\Langs\it_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracocss\Langs\it_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracocss\Langs\ja.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracocss\Langs\ja_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracocss\Langs\ru.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracocss\Langs\ru.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracocss\Langs\ru_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracocss\Langs\ru_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracocss\Langs\sv.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracocss\Langs\sv_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracocss\Langs\zh.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracocss\Langs\zh.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracocss\Langs\zh_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracocss\Langs\zh_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\dialog.htm" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\dialog.htm" />
@@ -1291,6 +1307,8 @@
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Img\ajax-loader.gif" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Img\ajax-loader.gif" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Img\embed.gif" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Img\embed.gif" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Js\dialog.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Js\dialog.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Langs\da.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Langs\da_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Langs\de.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Langs\de.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Langs\de_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Langs\de_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Langs\en.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Langs\en.js" />
@@ -1299,8 +1317,12 @@
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Langs\en_us_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Langs\en_us_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Langs\it.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Langs\it.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Langs\it_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Langs\it_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Langs\ja.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Langs\ja_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Langs\ru.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Langs\ru.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Langs\ru_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Langs\ru_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Langs\sv.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Langs\sv_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Langs\zh.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Langs\zh.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Langs\zh_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoembed\Langs\zh_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoimg\editor_plugin_src.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoimg\editor_plugin_src.js" />
@@ -1308,8 +1330,10 @@
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoimg\Langs\en_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoimg\Langs\en_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoimg\Langs\en_us_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoimg\Langs\en_us_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoimg\Langs\he_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoimg\Langs\he_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoimg\Langs\it_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoimg\Langs\ja_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoimg\Langs\ja_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoimg\Langs\ru_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoimg\Langs\ru_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoimg\Langs\sv_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoimg\Langs\zh_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracoimg\Langs\zh_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracolink\editor_plugin_src.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracolink\editor_plugin_src.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracolink\Js\umbracolink.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracolink\Js\umbracolink.js" />
@@ -1318,6 +1342,7 @@
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracolink\Langs\he_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracolink\Langs\he_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracolink\Langs\ja_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracolink\Langs\ja_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracolink\Langs\ru_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracolink\Langs\ru_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracolink\Langs\sv_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracolink\Langs\zh_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracolink\Langs\zh_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracomacro\dialog.htm" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracomacro\dialog.htm" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracomacro\editor_plugin_src.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracomacro\editor_plugin_src.js" />
@@ -1333,6 +1358,8 @@
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracomacro\Langs\ja_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracomacro\Langs\ja_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracomacro\Langs\ru.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracomacro\Langs\ru.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracomacro\Langs\ru_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracomacro\Langs\ru_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracomacro\Langs\sv.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracomacro\Langs\sv_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracomacro\Langs\zh.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracomacro\Langs\zh.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracomacro\Langs\zh_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracomacro\Langs\zh_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracopaste\editor_plugin_src.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Umbracopaste\editor_plugin_src.js" />
@@ -1374,6 +1401,7 @@
<Content Include="Umbraco_Client\Tinymce3\Plugins\Xhtmlxtras\Langs\no_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Xhtmlxtras\Langs\no_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Xhtmlxtras\Langs\pl_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Xhtmlxtras\Langs\pl_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Xhtmlxtras\Langs\pt_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Xhtmlxtras\Langs\pt_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Xhtmlxtras\Langs\ru_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Xhtmlxtras\Langs\sv_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Xhtmlxtras\Langs\sv_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Plugins\Xhtmlxtras\Langs\zh_dlg.js" /> <Content Include="Umbraco_Client\Tinymce3\Plugins\Xhtmlxtras\Langs\zh_dlg.js" />
<Content Include="Umbraco_Client\Tinymce3\Themes\Advanced\about.htm" /> <Content Include="Umbraco_Client\Tinymce3\Themes\Advanced\about.htm" />

View File

@@ -5,7 +5,7 @@
<user>0</user> <user>0</user>
<startNode>1080</startNode> <startNode>1080</startNode>
<fullTree>False</fullTree> <fullTree>False</fullTree>
<documentTypeAlias>Home</documentTypeAlias> <documentTypeAlias>Base</documentTypeAlias>
<fields> <fields>
<categories> <categories>
</categories> </categories>
@@ -14,6 +14,6 @@
<excerpt> <excerpt>
</excerpt> </excerpt>
</fields> </fields>
<mediaObjectSupport enabled="True" folderId="-1" mediaTypeAlias="image" mediaTypeFileProperty="umbracoFile" /> <mediaObjectSupport enabled="True" folderId="-1" mediaTypeAlias="Image" mediaTypeFileProperty="umbracoFile" />
</channel> </channel>
</metablogapi> </metablogapi>

View File

@@ -1,16 +1,34 @@
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="passwordChanger.ascx.cs" Inherits="umbraco.controls.passwordChanger" %> <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="passwordChanger.ascx.cs" Inherits="umbraco.controls.passwordChanger" %>
<a href="#" onclick="if (document.getElementById('umbPasswordChanger').style.display == '' || document.getElementById('umbPasswordChanger').style.display == 'none') {document.getElementById('umbPasswordChanger').style.display = 'block'; this.style.display = 'none';}">Change password</a><br /> <script type="text/javascript">
(function ($) {
Umbraco.Sys.registerNamespace("Umbraco.Controls");
Umbraco.Controls.PasswordChanger = {
toggle: function (e) {
if (!$("#umbPasswordChanger").is(":visible")) {
ValidatorEnable(document.getElementById('<%=CompareValidator1.ClientID %>'), true);
$(e).closest(".propertyItem").replaceWith($("#umbPasswordChanger"));
$("#umbPasswordChanger").show();
$(e).hide();
}
}
};
})(jQuery);
</script>
<div id="umbPasswordChanger" style="display: none;"> <a href="#" onclick="Umbraco.Controls.PasswordChanger.toggle(this);">Change password</a><br />
<table>
<tr><th style="width: 270px;"><%=umbraco.ui.GetText("user", "newPassword")%>:</th><td style="width: 359px"> <div class="propertyItem" id="umbPasswordChanger" style="display: none;">
<asp:TextBox ID="umbPasswordChanger_passwordNew" autocomplete="off" AutoCompleteType="None" TextMode="password" runat="server"></asp:TextBox>
</td></tr> <div class="propertyItemheader"><%=umbraco.ui.GetText("user", "newPassword")%></div>
<tr><th><%=umbraco.ui.GetText("user", "confirmNewPassword")%>:</th><td style="width: 359px"> <div class="propertyItemContent">
<asp:TextBox ID="umbPasswordChanger_passwordNewConfirm" autocomplete="off" AutoCompleteType="None" TextMode="password" runat="server"></asp:TextBox> <asp:TextBox ID="umbPasswordChanger_passwordNew" autocomplete="off" AutoCompleteType="None" TextMode="password" runat="server"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="Passwords must match" ControlToValidate="umbPasswordChanger_passwordNew" </div>
ControlToCompare="umbPasswordChanger_passwordNewConfirm" Operator="Equal"></asp:CompareValidator>
</td></tr> <div class="propertyItemheader"><%=umbraco.ui.GetText("user", "confirmNewPassword")%></div>
</table> <div class="propertyItemContent">
</div> <asp:TextBox ID="umbPasswordChanger_passwordNewConfirm" autocomplete="off" AutoCompleteType="None" TextMode="password" runat="server"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator1" runat="server" Enabled="False" ErrorMessage="Passwords must match" ControlToValidate="umbPasswordChanger_passwordNew"
ControlToCompare="umbPasswordChanger_passwordNewConfirm" Operator="Equal"></asp:CompareValidator>
</div>
</div>

View File

@@ -51,14 +51,6 @@ namespace Umbraco.Web.UI.Pages
Response.Redirect(SystemDirectories.Umbraco + "/logout.aspx?redir=" + Server.UrlEncode(Request.RawUrl), true); Response.Redirect(SystemDirectories.Umbraco + "/logout.aspx?redir=" + Server.UrlEncode(Request.RawUrl), true);
} }
} }
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(ui.Culture(Security.CurrentUser));
System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentCulture;
}
/// <summary> /// <summary>
/// Gets/sets the app that this page is assigned to /// Gets/sets the app that this page is assigned to

View File

@@ -249,7 +249,7 @@ namespace umbraco.cms.presentation
//update UI and set document properties //update UI and set document properties
PerformSaveLogic(); PerformSaveLogic();
//persist the document //persist the document
_document.Save(); _document.Save();
@@ -257,7 +257,7 @@ namespace umbraco.cms.presentation
BusinessLogic.Actions.Action.RunActionHandlers(_document, ActionUpdate.Instance); BusinessLogic.Actions.Action.RunActionHandlers(_document, ActionUpdate.Instance);
ClientTools.ShowSpeechBubble( ClientTools.ShowSpeechBubble(
speechBubbleIcon.save, ui.Text("speechBubbles", "editContentSavedHeader", null), speechBubbleIcon.save, ui.Text("speechBubbles", "editContentSavedHeader", null),
ui.Text("speechBubbles", "editContentSavedText", null)); ui.Text("speechBubbles", "editContentSavedText", null));
ClientTools.SyncTree(_document.Path, true); ClientTools.SyncTree(_document.Path, true);
@@ -291,7 +291,7 @@ namespace umbraco.cms.presentation
{ {
//update UI and set document properties //update UI and set document properties
PerformSaveLogic(); PerformSaveLogic();
//the business logic here will check to see if the doc can actually be published and will return the //the business logic here will check to see if the doc can actually be published and will return the
// appropriate result so we can display the correct error messages (or success). // appropriate result so we can display the correct error messages (or success).
var savePublishResult = _document.SaveAndPublishWithResult(UmbracoUser); var savePublishResult = _document.SaveAndPublishWithResult(UmbracoUser);
@@ -309,7 +309,7 @@ namespace umbraco.cms.presentation
_documentHasPublishedVersion = _document.Content.HasPublishedVersion(); _documentHasPublishedVersion = _document.Content.HasPublishedVersion();
} }
ClientTools.SyncTree(_document.Path, true); ClientTools.SyncTree(_document.Path, true);
} }
@@ -320,8 +320,8 @@ namespace umbraco.cms.presentation
case PublishStatusType.Success: case PublishStatusType.Success:
case PublishStatusType.SuccessAlreadyPublished: case PublishStatusType.SuccessAlreadyPublished:
ClientTools.ShowSpeechBubble( ClientTools.ShowSpeechBubble(
speechBubbleIcon.save, speechBubbleIcon.save,
ui.Text("speechBubbles", "editContentPublishedHeader", UmbracoUser), ui.Text("speechBubbles", "editContentPublishedHeader", UmbracoUser),
ui.Text("speechBubbles", "editContentPublishedText", UmbracoUser)); ui.Text("speechBubbles", "editContentPublishedText", UmbracoUser));
break; break;
case PublishStatusType.FailedPathNotPublished: case PublishStatusType.FailedPathNotPublished:
@@ -550,23 +550,40 @@ namespace umbraco.cms.presentation
} }
menuItem.ImageURL = SystemDirectories.Umbraco + "/images/editor/vis.gif"; menuItem.ImageURL = SystemDirectories.Umbraco + "/images/editor/vis.gif";
// Fix for U4-682, if there's no template, disable the preview button
if (_document.Template != -1) if (EnablePreviewButton())
{ {
menuItem.AltText = ui.Text("buttons", "showPage", UmbracoUser); menuItem.AltText = ui.Text("buttons", "showPage", UmbracoUser);
menuItem.OnClickCommand = "window.open('dialogs/preview.aspx?id=" + id + "','umbPreview')"; menuItem.OnClickCommand = "window.open('dialogs/preview.aspx?id=" + id + "','umbPreview')";
} }
else else
{ {
string showPageDisabledText = ui.Text("buttons", "showPageDisabled", UmbracoUser); var showPageDisabledText = ui.Text("buttons", "showPageDisabled", UmbracoUser);
if (showPageDisabledText.StartsWith("[")) if (showPageDisabledText.StartsWith("["))
showPageDisabledText = ui.GetText("buttons", "showPageDisabled", null, "en"); ; showPageDisabledText = ui.GetText("buttons", "showPageDisabled", null, "en");
menuItem.AltText = showPageDisabledText; menuItem.AltText = showPageDisabledText;
((Image)menuItem).Attributes.Add("style", "opacity: 0.5"); ((Image) menuItem).Attributes.Add("style", "opacity: 0.5");
} }
} }
private bool EnablePreviewButton()
{
// Fix for U4-862, if there's no template, disable the preview button
// Fixed again for U4-2587, apparently at some point "no template" changed from -1 to 0? -SJ
// Now also catches when template doesn't exist any more or is not allowed any more
// Don't think there's a better way to check if the template exists besides trying to instantiate it..
try
{
var template = new businesslogic.template.Template(_document.Template);
// If template is found check if it's in the list of allowed templates for this document
return _document.Content.ContentType.AllowedTemplates.ToList().Any(t => t.Id == template.Id);
}
catch (Exception) { }
return false;
}
/// <summary> /// <summary>
/// JsInclude1 control. /// JsInclude1 control.
/// </summary> /// </summary>

View File

@@ -348,16 +348,12 @@ namespace umbraco.cms.presentation.user
} }
} }
} }
#region Web Form Designer generated code
protected override void OnInit(EventArgs e) protected override void OnInit(EventArgs e)
{ {
// //lapps.SelectionMode = ListSelectionMode.Multiple;
// CODEGEN: This call is required by the ASP.NET Web Form Designer. lapps.RepeatLayout = RepeatLayout.Flow;
// lapps.RepeatDirection = RepeatDirection.Vertical;
InitializeComponent();
base.OnInit(e);
} }
protected override void OnPreRender(EventArgs e) protected override void OnPreRender(EventArgs e)
@@ -366,23 +362,9 @@ namespace umbraco.cms.presentation.user
ScriptManager.GetCurrent(Page).Services.Add(new ServiceReference("../webservices/CMSNode.asmx")); ScriptManager.GetCurrent(Page).Services.Add(new ServiceReference("../webservices/CMSNode.asmx"));
// ScriptManager.GetCurrent(Page).Services.Add(new ServiceReference("../webservices/legacyAjaxCalls.asmx")); // ScriptManager.GetCurrent(Page).Services.Add(new ServiceReference("../webservices/legacyAjaxCalls.asmx"));
} }
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
//lapps.SelectionMode = ListSelectionMode.Multiple;
lapps.RepeatLayout = RepeatLayout.Flow;
lapps.RepeatDirection = RepeatDirection.Vertical;
}
#endregion
/// <summary> /// <summary>
/// Handles the Click event of the saveUser control. /// Handles the Click event of the saveUser control.
/// </summary> /// </summary>

View File

@@ -115,9 +115,6 @@ namespace umbraco.BasePages
else else
Response.Redirect(SystemDirectories.Umbraco + "/logout.aspx?redir=" + Server.UrlEncode(Request.RawUrl), true); Response.Redirect(SystemDirectories.Umbraco + "/logout.aspx?redir=" + Server.UrlEncode(Request.RawUrl), true);
} }
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(ui.Culture(this.getUser()));
System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentCulture;
} }
} }
} }

View File

@@ -70,7 +70,7 @@ namespace umbraco.cms.businesslogic
_alias = alias; _alias = alias;
_iconurl = icon; _iconurl = icon;
_thumbnail = thumbnail; _thumbnail = thumbnail;
if (masterContentType.HasValue) if (masterContentType.HasValue)
MasterContentType = masterContentType.Value; MasterContentType = masterContentType.Value;
@@ -92,7 +92,7 @@ namespace umbraco.cms.businesslogic
allowAtRoot, isContainer, Alias,icon,thumbnail,description allowAtRoot, isContainer, Alias,icon,thumbnail,description
FROM umbracoNode INNER JOIN cmsContentType ON umbracoNode.id = cmsContentType.nodeId FROM umbracoNode INNER JOIN cmsContentType ON umbracoNode.id = cmsContentType.nodeId
WHERE nodeObjectType = @nodeObjectType"; WHERE nodeObjectType = @nodeObjectType";
#endregion #endregion
#region Static Methods #region Static Methods
@@ -113,12 +113,12 @@ namespace umbraco.cms.businesslogic
/// </remarks> /// </remarks>
internal static IDictionary<string, string> GetAliasesAndNames(string contentTypeAlias) internal static IDictionary<string, string> GetAliasesAndNames(string contentTypeAlias)
{ {
return AliasToNames.GetOrAdd(contentTypeAlias, s => return AliasToNames.GetOrAdd(contentTypeAlias, s =>
{ {
var ct = GetByAlias(contentTypeAlias); var ct = GetByAlias(contentTypeAlias);
var userFields = ct.PropertyTypes.ToDictionary(x => x.Alias, x => x.Name); var userFields = ct.PropertyTypes.ToDictionary(x => x.Alias, x => x.Name);
return userFields; return userFields;
}); });
} }
/// <summary> /// <summary>
@@ -150,21 +150,21 @@ namespace umbraco.cms.businesslogic
//propertyTypeAlias needs to be invariant, so we will store uppercase //propertyTypeAlias needs to be invariant, so we will store uppercase
var key = new System.Tuple<string, string>(contentTypeAlias, propertyTypeAlias.ToUpper()); var key = new System.Tuple<string, string>(contentTypeAlias, propertyTypeAlias.ToUpper());
return PropertyTypeCache.GetOrAdd( return PropertyTypeCache.GetOrAdd(
key, key,
tuple => tuple =>
{ {
// With 4.10 we can't do this via direct SQL as we have content type mixins // With 4.10 we can't do this via direct SQL as we have content type mixins
var controlId = Guid.Empty; var controlId = Guid.Empty;
var ct = GetByAlias(contentTypeAlias); var ct = GetByAlias(contentTypeAlias);
var pt = ct.getPropertyType(propertyTypeAlias); var pt = ct.getPropertyType(propertyTypeAlias);
if (pt != null) if (pt != null)
{ {
controlId = pt.DataTypeDefinition.DataType.Id; controlId = pt.DataTypeDefinition.DataType.Id;
} }
return controlId; return controlId;
}); });
} }
/// <summary> /// <summary>
@@ -244,7 +244,7 @@ namespace umbraco.cms.businesslogic
private bool _isContainerContentType; private bool _isContainerContentType;
private List<int> _allowedChildContentTypeIDs; private List<int> _allowedChildContentTypeIDs;
private List<TabI> _virtualTabs; private List<TabI> _virtualTabs;
protected internal IContentTypeComposition ContentTypeItem; protected internal IContentTypeComposition ContentTypeItem;
#endregion #endregion
@@ -264,7 +264,7 @@ namespace umbraco.cms.businesslogic
foreach (var i in GetContentIdsForContentType()) foreach (var i in GetContentIdsForContentType())
{ {
RebuildXmlStructureForContentItem(i); RebuildXmlStructureForContentItem(i);
} }
} }
/// <summary> /// <summary>
@@ -292,7 +292,7 @@ namespace umbraco.cms.businesslogic
dr.Close(); dr.Close();
} }
return ids; return ids;
} }
/// <summary> /// <summary>
/// Rebuilds the xml structure for the content item by id /// Rebuilds the xml structure for the content item by id
@@ -325,7 +325,7 @@ namespace umbraco.cms.businesslogic
INNER JOIN cmsContentType ON cmsContent.contentType = cmsContentType.nodeId INNER JOIN cmsContentType ON cmsContent.contentType = cmsContentType.nodeId
WHERE cmsContentType.nodeId = @nodeId)", WHERE cmsContentType.nodeId = @nodeId)",
SqlHelper.CreateParameter("@nodeId", this.Id)); SqlHelper.CreateParameter("@nodeId", this.Id));
} }
#endregion #endregion
@@ -443,7 +443,7 @@ namespace umbraco.cms.businesslogic
} }
} }
} }
/// <summary> /// <summary>
/// Gets or sets the description. /// Gets or sets the description.
/// </summary> /// </summary>
@@ -580,41 +580,41 @@ namespace umbraco.cms.businesslogic
cacheKey, cacheKey,
TimeSpan.FromMinutes(15), TimeSpan.FromMinutes(15),
() => () =>
{
//MCH NOTE: For the timing being I have changed this to a dictionary to ensure that property types
//aren't added multiple times through the MasterContentType structure, because each level loads
//its own + inherited property types, which is wrong. Once we are able to fully switch to the new api
//this should no longer be a problem as the composition always contains a correct list of property types.
var result = new Dictionary<int, PropertyType>();
using (IRecordsReader dr =
SqlHelper.ExecuteReader(
"select id from cmsPropertyType where contentTypeId = @ctId order by sortOrder",
SqlHelper.CreateParameter("@ctId", Id)))
{ {
//MCH NOTE: For the timing being I have changed this to a dictionary to ensure that property types while (dr.Read())
//aren't added multiple times through the MasterContentType structure, because each level loads
//its own + inherited property types, which is wrong. Once we are able to fully switch to the new api
//this should no longer be a problem as the composition always contains a correct list of property types.
var result = new Dictionary<int, PropertyType>();
using (IRecordsReader dr =
SqlHelper.ExecuteReader(
"select id from cmsPropertyType where contentTypeId = @ctId order by sortOrder",
SqlHelper.CreateParameter("@ctId", Id)))
{ {
while (dr.Read()) int id = dr.GetInt("id");
PropertyType pt = PropertyType.GetPropertyType(id);
if (pt != null)
result.Add(pt.Id, pt);
}
}
// Get Property Types from the master content type
if (MasterContentTypes.Count > 0)
{
foreach (var mct in MasterContentTypes)
{
var pts = GetContentType(mct).PropertyTypes;
foreach (var pt in pts)
{ {
int id = dr.GetInt("id"); if (result.ContainsKey(pt.Id) == false)
PropertyType pt = PropertyType.GetPropertyType(id);
if (pt != null)
result.Add(pt.Id, pt); result.Add(pt.Id, pt);
} }
} }
}
// Get Property Types from the master content type return result.Select(x => x.Value).ToList();
if (MasterContentTypes.Count > 0) });
{
foreach (var mct in MasterContentTypes)
{
var pts = GetContentType(mct).PropertyTypes;
foreach (var pt in pts)
{
if (result.ContainsKey(pt.Id) == false)
result.Add(pt.Id, pt);
}
}
}
return result.Select(x => x.Value).ToList();
});
} }
} }
@@ -850,7 +850,7 @@ namespace umbraco.cms.businesslogic
foreach (var i in value) foreach (var i in value)
{ {
int id = i; int id = i;
list.Add(new ContentTypeSort{Id = new Lazy<int>(() => id), SortOrder = sort}); list.Add(new ContentTypeSort { Id = new Lazy<int>(() => id), SortOrder = sort });
sort++; sort++;
} }
@@ -963,7 +963,7 @@ namespace umbraco.cms.businesslogic
{ {
ContentTypeItem.RemovePropertyType(pt.Alias); ContentTypeItem.RemovePropertyType(pt.Alias);
} }
// Remove from cache // Remove from cache
FlushFromCache(Id); FlushFromCache(Id);
} }
@@ -1163,7 +1163,7 @@ namespace umbraco.cms.businesslogic
/// </summary> /// </summary>
/// <param name="id">The id.</param> /// <param name="id">The id.</param>
public static void FlushFromCache(int id) public static void FlushFromCache(int id)
{ {
//Ensure that MediaTypes are reloaded from db by clearing cache //Ensure that MediaTypes are reloaded from db by clearing cache
InMemoryCacheProvider.Current.Clear(); InMemoryCacheProvider.Current.Clear();
@@ -1428,12 +1428,12 @@ namespace umbraco.cms.businesslogic
public List<PropertyType> GetAllPropertyTypes() public List<PropertyType> GetAllPropertyTypes()
{ {
var db = ApplicationContext.Current.DatabaseContext.Database; var db = ApplicationContext.Current.DatabaseContext.Database;
var propertyTypeDtos = db.Fetch<PropertyTypeDto>("WHERE propertyTypeGroupId = @Id", new {Id = _id}); var propertyTypeDtos = db.Fetch<PropertyTypeDto>("WHERE propertyTypeGroupId = @Id", new { Id = _id });
var tmp = propertyTypeDtos var tmp = propertyTypeDtos
.Select(propertyTypeDto => PropertyType.GetPropertyType(propertyTypeDto.Id)) .Select(propertyTypeDto => PropertyType.GetPropertyType(propertyTypeDto.Id))
.ToList(); .ToList();
var propertyTypeGroupDtos = db.Fetch<PropertyTypeGroupDto>("WHERE parentGroupId = @Id", new {Id = _id}); var propertyTypeGroupDtos = db.Fetch<PropertyTypeGroupDto>("WHERE parentGroupId = @Id", new { Id = _id });
foreach (var propertyTypeGroupDto in propertyTypeGroupDtos) foreach (var propertyTypeGroupDto in propertyTypeGroupDtos)
{ {
var inheritedPropertyTypeDtos = db.Fetch<PropertyTypeDto>("WHERE propertyTypeGroupId = @Id", new { Id = propertyTypeGroupDto.Id }); var inheritedPropertyTypeDtos = db.Fetch<PropertyTypeDto>("WHERE propertyTypeGroupId = @Id", new { Id = propertyTypeGroupDto.Id });
@@ -1504,6 +1504,24 @@ namespace umbraco.cms.businesslogic
} }
} }
/// <summary>
/// Gets the tab caption by id.
/// </summary>
/// <param name="id">The id.</param>
/// <returns></returns>
internal static string GetRawCaptionById(int id)
{
try
{
var tempCaption = SqlHelper.ExecuteScalar<string>("Select text from cmsPropertyTypeGroup where id = " + id);
return tempCaption;
}
catch
{
return null;
}
}
private readonly int _id; private readonly int _id;
private int? _sortOrder; private int? _sortOrder;
@@ -1629,7 +1647,7 @@ namespace umbraco.cms.businesslogic
{ {
if (!_caption.StartsWith("#")) if (!_caption.StartsWith("#"))
return _caption; return _caption;
var lang = Language.GetByCultureCode(Thread.CurrentThread.CurrentCulture.Name); var lang = Language.GetByCultureCode(Thread.CurrentThread.CurrentCulture.Name);
if (lang != null) if (lang != null)
{ {
@@ -1645,6 +1663,5 @@ namespace umbraco.cms.businesslogic
} }
} }
#endregion #endregion
} }
} }

View File

@@ -15,7 +15,7 @@ namespace umbraco.cms.businesslogic.datatype
/// Default implementation of the <c>IData</c> interface that stores data inside the Umbraco database. /// Default implementation of the <c>IData</c> interface that stores data inside the Umbraco database.
/// </summary> /// </summary>
[Obsolete("This class is no longer used and will be removed from the codebase in the future.")] [Obsolete("This class is no longer used and will be removed from the codebase in the future.")]
public class DefaultData : IData, IDataWithPreview public class DefaultData : IData, IDataWithPreview, IDataValueSetter
{ {
private int _propertyId; private int _propertyId;
private object _value; private object _value;
@@ -58,10 +58,29 @@ namespace umbraco.cms.businesslogic.datatype
_value = InitValue; _value = InitValue;
} }
/// <summary>
/// This is here for performance reasons since in some cases we will have already resolved the value from the db
/// and want to just give this object the value so it doesn't go re-look it up from the database.
/// </summary>
/// <param name="val"></param>
/// <param name="strDbType"></param>
void IDataValueSetter.SetValue(object val, string strDbType)
{
_value = val;
//now that we've set our value, we can update our BaseDataType object with the correct values from the db
//instead of making it query for itself. This is a peformance optimization enhancement.
var dbType = BaseDataType.GetDBType(strDbType);
var fieldName = BaseDataType.GetDataFieldName(dbType);
_dataType.SetDataTypeProperties(fieldName, dbType);
//ensures that it doesn't go back to the db
_valueLoaded = true;
}
/// <summary> /// <summary>
/// Loads the data value from the database. /// Loads the data value from the database.
/// </summary> /// </summary>
protected virtual void LoadValueFromDatabase() protected internal virtual void LoadValueFromDatabase()
{ {
var sql = new Sql(); var sql = new Sql();
sql.Select("*") sql.Select("*")
@@ -244,5 +263,7 @@ namespace umbraco.cms.businesslogic.datatype
} }
#endregion #endregion
} }
} }

View File

@@ -527,7 +527,7 @@ namespace umbraco.cms.businesslogic.web
//Datatype definition guid was added in v4 to enable datatype imports //Datatype definition guid was added in v4 to enable datatype imports
ptx.AppendChild(XmlHelper.AddTextNode(xd, "Definition", pt.DataTypeDefinition.UniqueId.ToString())); ptx.AppendChild(XmlHelper.AddTextNode(xd, "Definition", pt.DataTypeDefinition.UniqueId.ToString()));
ptx.AppendChild(XmlHelper.AddTextNode(xd, "Tab", Tab.GetCaptionById(pt.TabId))); ptx.AppendChild(XmlHelper.AddTextNode(xd, "Tab", Tab.GetRawCaptionById(pt.TabId)));
ptx.AppendChild(XmlHelper.AddTextNode(xd, "Mandatory", pt.Mandatory.ToString())); ptx.AppendChild(XmlHelper.AddTextNode(xd, "Mandatory", pt.Mandatory.ToString()));
ptx.AppendChild(XmlHelper.AddTextNode(xd, "Validation", pt.ValidationRegExp)); ptx.AppendChild(XmlHelper.AddTextNode(xd, "Validation", pt.ValidationRegExp));
ptx.AppendChild(XmlHelper.AddCDataNode(xd, "Description", pt.GetRawDescription())); ptx.AppendChild(XmlHelper.AddCDataNode(xd, "Description", pt.GetRawDescription()));

View File

@@ -3,6 +3,15 @@ using System.Xml;
namespace umbraco.interfaces namespace umbraco.interfaces
{ {
/// <summary>
/// Internal interface used to decorate any IData that can be optimized when exporting
/// XML like in the packaging service. Instead of relying on the IData to go get the value
/// from the db, any IData that implements this can have it's value set from the packaging service.
/// </summary>
internal interface IDataValueSetter
{
void SetValue(object val, string strDbType);
}
/// <summary> /// <summary>
/// The IData is part of the IDataType interface for creating new data types in the umbraco backoffice. /// The IData is part of the IDataType interface for creating new data types in the umbraco backoffice.

View File

@@ -9,4 +9,11 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyTitle("umbraco.interfaces")] [assembly: AssemblyTitle("umbraco.interfaces")]
[assembly: AssemblyDescription("Core assembly containing legacy interfaces")] [assembly: AssemblyDescription("Core assembly containing legacy interfaces")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyProduct("Umbraco CMS")] [assembly: AssemblyProduct("Umbraco CMS")]
[assembly: InternalsVisibleTo("cms")]
[assembly: InternalsVisibleTo("Umbraco.Core")]
[assembly: InternalsVisibleTo("Umbraco.Tests")]
//allow this to be mocked in our unit tests
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]