Merge remote-tracking branch 'origin/6.2.0' into 7.1.0

Conflicts:
	build/Build.bat
	src/Umbraco.Web.UI/umbraco/create/simple.ascx
	src/Umbraco.Web/Umbraco.Web.csproj
	src/Umbraco.Web/umbraco.presentation/umbraco/create/simple.ascx
	src/Umbraco.Web/umbraco.presentation/umbraco/create/simple.ascx.cs
	src/Umbraco.Web/umbraco.presentation/umbraco/create/simple.ascx.designer.cs
	src/Umbraco.Web/umbraco.presentation/umbraco/developer/Macros/assemblyBrowser.aspx.cs
	src/umbraco.cms/businesslogic/datatype/DataTypeDefinition.cs
This commit is contained in:
Shannon
2014-03-10 15:27:09 +11:00
9 changed files with 154 additions and 131 deletions

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Globalization;
using System.Linq;
using Umbraco.Core.Models;
@@ -8,6 +9,7 @@ using Umbraco.Core.Models.Rdbms;
using Umbraco.Core.Persistence.Caching;
using Umbraco.Core.Persistence.Factories;
using Umbraco.Core.Persistence.Querying;
using Umbraco.Core.Persistence.SqlSyntax;
using Umbraco.Core.Persistence.UnitOfWork;
namespace Umbraco.Core.Persistence.Repositories
@@ -119,6 +121,15 @@ namespace Umbraco.Core.Persistence.Repositories
{
((DataTypeDefinition)entity).AddingEntity();
//Cannot add a duplicate data type
var exists = Database.ExecuteScalar<int>(@"SELECT COUNT(*) FROM cmsDataType
INNER JOIN umbracoNode ON cmsDataType.nodeId = umbracoNode.id
WHERE umbracoNode." + SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName("text") + "= @name", new {name = entity.Name});
if (exists > 0)
{
throw new DuplicateNameException("A data type with the name " + entity.Name + " already exists");
}
var factory = new DataTypeDefinitionFactory(NodeObjectTypeId);
var dto = factory.BuildDto(entity);

View File

@@ -1,4 +1,5 @@
using System;
using System.Data;
using System.Linq;
using NUnit.Framework;
using Umbraco.Core;
@@ -28,6 +29,57 @@ namespace Umbraco.Tests.Persistence.Repositories
return dataTypeDefinitionRepository;
}
[Test]
public void Can_Create()
{
var provider = new PetaPocoUnitOfWorkProvider();
var unitOfWork = provider.GetUnitOfWork();
int id;
using (var repository = CreateRepository(unitOfWork))
{
var dataTypeDefinition = new DataTypeDefinition(-1, new Guid(Constants.PropertyEditors.RadioButtonList)) {Name = "test"};
repository.AddOrUpdate(dataTypeDefinition);
unitOfWork.Commit();
id = dataTypeDefinition.Id;
Assert.That(id, Is.GreaterThan(0));
}
using (var repository = CreateRepository(unitOfWork))
{
// Act
var dataTypeDefinition = repository.Get(id);
// Assert
Assert.That(dataTypeDefinition, Is.Not.Null);
Assert.That(dataTypeDefinition.HasIdentity, Is.True);
}
}
[Test]
public void Cannot_Create_Duplicate_Name()
{
var provider = new PetaPocoUnitOfWorkProvider();
var unitOfWork = provider.GetUnitOfWork();
int id;
using (var repository = CreateRepository(unitOfWork))
{
var dataTypeDefinition = new DataTypeDefinition(-1, new Guid(Constants.PropertyEditors.RadioButtonList)) { Name = "test" };
repository.AddOrUpdate(dataTypeDefinition);
unitOfWork.Commit();
id = dataTypeDefinition.Id;
Assert.That(id, Is.GreaterThan(0));
}
using (var repository = CreateRepository(unitOfWork))
{
var dataTypeDefinition = new DataTypeDefinition(-1, new Guid(Constants.PropertyEditors.RadioButtonList)) { Name = "test" };
repository.AddOrUpdate(dataTypeDefinition);
Assert.Throws<DuplicateNameException>(unitOfWork.Commit);
}
}
[Test]
public void Can_Instantiate_Repository_From_Resolver()
{

View File

@@ -1,4 +1,4 @@
<%@ Control Language="c#" AutoEventWireup="True" Codebehind="simple.ascx.cs" Inherits="umbraco.cms.presentation.create.controls.simple" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<%@ Control Language="c#" AutoEventWireup="True" Inherits="umbraco.cms.presentation.create.controls.simple" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %>
@@ -13,9 +13,10 @@
<asp:Button id="sbmt" Runat="server" CssClass="btn btn-primary" onclick="sbmt_Click"></asp:Button>
</cc1:Pane>
<!-- added to support missing postback on enter in IE -->
<asp:TextBox runat="server" style="visibility:hidden;display:none;" ID="Textbox1"/>
<asp:CustomValidator runat="server" ID="CustomValidation" style="color:#8a1f11;display:block;"></asp:CustomValidator>
<input type="hidden" name="nodeType">

View File

@@ -683,6 +683,9 @@
<Compile Include="umbraco.presentation\umbraco\controls\Tree\TreeControl.ascx.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="umbraco.presentation\umbraco\create\simple.ascx.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="umbraco.presentation\umbraco\developer\Packages\directoryBrowser.aspx.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
@@ -1274,13 +1277,6 @@
<Compile Include="umbraco.presentation\umbraco\create\script.ascx.designer.cs">
<DependentUpon>script.ascx</DependentUpon>
</Compile>
<Compile Include="umbraco.presentation\umbraco\create\simple.ascx.cs">
<DependentUpon>simple.ascx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="umbraco.presentation\umbraco\create\simple.ascx.designer.cs">
<DependentUpon>simple.ascx</DependentUpon>
</Compile>
<Compile Include="umbraco.presentation\umbraco\create\languageTasks.cs">
<SubType>Code</SubType>
</Compile>
@@ -1958,9 +1954,7 @@
<SubType>ASPXCodeBehind</SubType>
</Content>
<Content Include="umbraco.presentation\umbraco\create\nodeType.ascx" />
<Content Include="umbraco.presentation\umbraco\create\simple.ascx">
<SubType>ASPXCodeBehind</SubType>
</Content>
<Content Include="umbraco.presentation\umbraco\dashboard\LatestEdits.ascx">
<SubType>ASPXCodeBehind</SubType>
</Content>

View File

@@ -1,18 +0,0 @@
<%@ Control Language="c#" AutoEventWireup="True" Codebehind="simple.ascx.cs" Inherits="umbraco.cms.presentation.create.controls.simple" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %>
<cc1:Pane runat="server">
<cc1:PropertyPanel runat="server" Text="Name">
<asp:TextBox id="rename" CssClass="bigInput input-block-level" Runat="server"></asp:TextBox><asp:RequiredFieldValidator id="RequiredFieldValidator1" ErrorMessage="*" ControlToValidate="rename" runat="server">*</asp:RequiredFieldValidator>
</cc1:PropertyPanel>
</cc1:Pane>
<div class="btn-toolbar umb-btn-toolbar">
<a href="#" class="btn btn-link" onclick="UmbClientMgr.closeModalWindow()"><%=umbraco.ui.Text("cancel")%></a>
<asp:Button id="sbmt" Runat="server" CssClass="btn btn-primary" onclick="sbmt_Click"></asp:Button>
</div>
<!-- added to support missing postback on enter in IE -->
<asp:TextBox runat="server" style="visibility:hidden;display:none;" ID="Textbox1"/>
<input type="hidden" name="nodeType">

View File

@@ -1,72 +1,100 @@
using System.Web;
using System.Web;
using System.Web.UI;
using Umbraco.Core.Logging;
using Umbraco.Web.UI;
using Umbraco.Web;
using System;
using Umbraco.Web.UI.Controls;
using System.Web.UI.WebControls;
using umbraco.BasePages;
using umbraco.BusinessLogic;
using Umbraco.Web;
using UmbracoUserControl = Umbraco.Web.UI.Controls.UmbracoUserControl;
namespace umbraco.cms.presentation.create.controls
{
/// <summary>
/// Summary description for simple.
/// </summary>
/// Summary description for simple.
/// </summary>
public partial class simple : UmbracoUserControl
{
{
protected void Page_Load(object sender, System.EventArgs e)
{
sbmt.Text = ui.Text("create");
protected void Page_Load(object sender, EventArgs e)
{
sbmt.Text = ui.Text("create");
rename.Attributes["placeholder"] = ui.Text("name");
// Put user code to initialize the page here
}
// Put user code to initialize the page here
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
}
#endregion
protected void sbmt_Click(object sender, System.EventArgs e)
{
if (Page.IsValid)
{
int nodeId;
if (int.TryParse(Request.QueryString["nodeId"], out nodeId) == false)
nodeId = -1;
protected void sbmt_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
int nodeId;
if (int.TryParse(Request.QueryString["nodeId"], out nodeId) == false)
nodeId = -1;
try
{
var returnUrl = LegacyDialogHandler.Create(
new HttpContextWrapper(Context),
new User(Security.CurrentUser),
Request.GetItemAsString("nodeType"),
nodeId,
rename.Text.Trim());
nodeId,
rename.Text.Trim());
BasePage.Current.ClientTools
.ChangeContentFrameUrl(returnUrl)
BasePage.Current.ClientTools
.ChangeContentFrameUrl(returnUrl)
.ReloadActionNode(false, true)
.CloseModalWindow();
.CloseModalWindow();
}
catch (Exception ex)
{
CustomValidation.ErrorMessage = ex.Message;
CustomValidation.IsValid = false;
}
}
}
}
}
protected CustomValidator CustomValidation;
/// <summary>
/// RequiredFieldValidator1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
/// <summary>
/// rename control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.TextBox rename;
/// <summary>
/// Textbox1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.TextBox Textbox1;
/// <summary>
/// sbmt control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Button sbmt;
}
}

View File

@@ -1,51 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace umbraco.cms.presentation.create.controls {
public partial class simple {
/// <summary>
/// rename control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.TextBox rename;
/// <summary>
/// RequiredFieldValidator1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
/// <summary>
/// sbmt control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Button sbmt;
/// <summary>
/// Textbox1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.TextBox Textbox1;
}
}

View File

@@ -44,11 +44,7 @@ namespace umbraco.developer
if (Request.QueryString["type"] == null)
{
isUserControl = true;
var fileName = Request.QueryString["fileName"];
//yes this is crap but the ClearnForXss cleans / - so this is a shortcut
fileName = fileName.Replace('/', '@').CleanForXss().Replace('@', '/');
var fileName = Request.GetItemAsString("fileName");
if (!fileName.StartsWith("~"))
{
if (fileName.StartsWith("/"))
@@ -116,7 +112,7 @@ namespace umbraco.developer
}
catch (Exception err)
{
AssemblyName.Text = "Error reading " + Request["fileName"];
AssemblyName.Text = "Error reading " + Request.CleanForXss("fileName");
Button1.Visible = false;
ChooseProperties.Controls.Add(new LiteralControl("<p class=\"guiDialogNormal\" style=\"color: red;\">" + err.ToString() + "</p><p/><p class=\"guiDialogNormal\">"));
}

View File

@@ -1,9 +1,11 @@
using System;
using System.Collections;
using System.Globalization;
using System.Data;
using System.Linq;
using Umbraco.Core.Cache;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.SqlSyntax;
using Umbraco.Core.PropertyEditors;
using umbraco.DataLayer;
using System.Xml;
@@ -265,6 +267,14 @@ namespace umbraco.cms.businesslogic.datatype
/// <returns></returns>
public static DataTypeDefinition MakeNew(BusinessLogic.User u, string Text, Guid UniqueId)
{
//Cannot add a duplicate data type
var exists = Database.ExecuteScalar<int>(@"SELECT COUNT(*) FROM cmsDataType
INNER JOIN umbracoNode ON cmsDataType.nodeId = umbracoNode.id
WHERE umbracoNode." + SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName("text") + "= @name", new { name = Text });
if (exists > 0)
{
throw new DuplicateNameException("A data type with the name " + Text + " already exists");
}
var newId = MakeNew(-1, ObjectType, u.Id, 1, Text, UniqueId).Id;