Merge with 6.0.1

This commit is contained in:
Shannon Deminick
2013-02-27 23:20:34 +06:00
16 changed files with 156 additions and 99 deletions

View File

@@ -33,26 +33,44 @@ namespace Umbraco.Core.Configuration
private static volatile string _reservedUrlsCache;
private static string _reservedPathsCache;
private static StartsWithContainer _reservedList = new StartsWithContainer();
private static string _reservedPaths;
private static string _reservedUrls;
//ensure the built on (non-changeable) reserved paths are there at all times
private const string StaticReservedPaths = "~/app_plugins/,~/install/,";
private const string StaticReservedUrls = "~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/VSEnterpriseHelper.axd,";
#endregion
/// <summary>
/// used for unit tests
/// </summary>
internal static void ResetCache()
{
_reservedUrlsCache = null;
_reservedPaths = null;
_reservedUrls = null;
}
/// <summary>
/// Gets the reserved urls from web.config.
/// </summary>
/// <value>The reserved urls.</value>
public static string ReservedUrls
{
get
{
//ensure the built on (non-changeable) reserved paths are there at all times
const string staticReservedUrls = "~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/VSEnterpriseHelper.axd,";
{
if (_reservedUrls == null)
{
var urls = ConfigurationManager.AppSettings.ContainsKey("umbracoReservedUrls")
? ConfigurationManager.AppSettings["umbracoReservedUrls"]
: string.Empty;
var urls = ConfigurationManager.AppSettings.ContainsKey("umbracoReservedUrls")
? ConfigurationManager.AppSettings["umbracoReservedUrls"]
: string.Empty;
return staticReservedUrls + urls;
//ensure the built on (non-changeable) reserved paths are there at all times
_reservedUrls = StaticReservedUrls + urls;
}
return _reservedUrls;
}
internal set { _reservedUrls = value; }
}
/// <summary>
@@ -63,21 +81,25 @@ namespace Umbraco.Core.Configuration
{
get
{
//ensure the built on (non-changeable) reserved paths are there at all times
var staticReservedPaths = "~/app_plugins/,~/install/,";
//always add the umbraco path to the list
if (ConfigurationManager.AppSettings.ContainsKey("umbracoPath"))
if (_reservedPaths == null)
{
staticReservedPaths += ConfigurationManager.AppSettings["umbracoPath"].EnsureEndsWith(',');
var reservedPaths = StaticReservedPaths;
//always add the umbraco path to the list
if (ConfigurationManager.AppSettings.ContainsKey("umbracoPath")
&& !ConfigurationManager.AppSettings["umbracoPath"].IsNullOrWhiteSpace())
{
reservedPaths += ConfigurationManager.AppSettings["umbracoPath"].EnsureEndsWith(',');
}
var allPaths = ConfigurationManager.AppSettings.ContainsKey("umbracoReservedPaths")
? ConfigurationManager.AppSettings["umbracoReservedPaths"]
: string.Empty;
_reservedPaths = reservedPaths + allPaths;
}
var paths = ConfigurationManager.AppSettings.ContainsKey("umbracoReservedPaths")
? ConfigurationManager.AppSettings["umbracoReservedPaths"]
: string.Empty;
return staticReservedPaths + paths;
return _reservedPaths;
}
internal set { _reservedPaths = value; }
}
/// <summary>

View File

@@ -329,6 +329,14 @@ namespace Umbraco.Core.Models
/// <returns>Returns <c>True</c> if a PropertyType with the passed in alias exists, otherwise <c>False</c></returns>
public abstract bool PropertyTypeExists(string propertyTypeAlias);
/// <summary>
/// Adds a PropertyGroup.
/// This method will also check if a group already exists with the same name and link it to the parent.
/// </summary>
/// <param name="groupName">Name of the PropertyGroup to add</param>
/// <returns>Returns <c>True</c> if a PropertyGroup with the passed in name was added, otherwise <c>False</c></returns>
public abstract bool AddPropertyGroup(string groupName);
/// <summary>
/// Adds a PropertyType to a specific PropertyGroup
/// </summary>

View File

@@ -125,6 +125,35 @@ namespace Umbraco.Core.Models
return CompositionPropertyTypes.Any(x => x.Alias == propertyTypeAlias);
}
/// <summary>
/// Adds a PropertyGroup.
/// This method will also check if a group already exists with the same name and link it to the parent.
/// </summary>
/// <param name="groupName">Name of the PropertyGroup to add</param>
/// <returns>Returns <c>True</c> if a PropertyGroup with the passed in name was added, otherwise <c>False</c></returns>
public override bool AddPropertyGroup(string groupName)
{
if (PropertyGroups.Any(x => x.Name == groupName))
return false;
var propertyGroup = new PropertyGroup {Name = groupName, SortOrder = 0};
if (CompositionPropertyGroups.Any(x => x.Name == groupName))
{
var first = CompositionPropertyGroups.First(x => x.Name == groupName && x.ParentId.HasValue == false);
propertyGroup.ParentId = first.Id;
}
if (PropertyGroups.Any())
{
var last = PropertyGroups.Last();
propertyGroup.SortOrder = last.SortOrder + 1;
}
PropertyGroups.Add(propertyGroup);
return true;
}
/// <summary>
/// Adds a PropertyType to a specific PropertyGroup
/// </summary>

View File

@@ -91,5 +91,13 @@ namespace Umbraco.Core.Models
/// <param name="propertyType"><see cref="PropertyType"/> to add</param>
/// <returns>Returns <c>True</c> if PropertyType was added, otherwise <c>False</c></returns>
bool AddPropertyType(PropertyType propertyType);
/// <summary>
/// Adds a PropertyGroup.
/// This method will also check if a group already exists with the same name and link it to the parent.
/// </summary>
/// <param name="groupName">Name of the PropertyGroup to add</param>
/// <returns>Returns <c>True</c> if a PropertyGroup with the passed in name was added, otherwise <c>False</c></returns>
bool AddPropertyGroup(string groupName);
}
}

View File

@@ -55,6 +55,7 @@ namespace Umbraco.Core.Persistence.Factories
HelpText = typeDto.HelpText,
Mandatory = typeDto.Mandatory,
SortOrder = typeDto.SortOrder,
ValidationRegExp = typeDto.ValidationRegExp,
PropertyGroupId = groupDto.Id
};
@@ -106,7 +107,8 @@ namespace Umbraco.Core.Persistence.Factories
HelpText = propertyType.HelpText,
Mandatory = propertyType.Mandatory,
Name = propertyType.Name,
SortOrder = propertyType.SortOrder
SortOrder = propertyType.SortOrder,
ValidationRegExp = propertyType.ValidationRegExp
};
if (tabId != default(int))

View File

@@ -259,14 +259,6 @@ namespace Umbraco.Core.Persistence.Repositories
: Convert.ToInt32(Database.Insert(tabDto));
if (propertyGroup.HasIdentity == false)
propertyGroup.Id = groupPrimaryKey; //Set Id on new PropertyGroup
//Ensure that the PropertyGroup's Id is set on the PropertyTypes within a group
//unless the PropertyGroupId has already been changed.
foreach (var propertyType in propertyGroup.PropertyTypes)
{
if ((propertyType.IsPropertyDirty("PropertyGroupId") && propertyType.PropertyGroupId == 0) == false)
propertyType.PropertyGroupId = propertyGroup.Id;
}
}
//Run through all PropertyTypes to insert or update entries
@@ -337,7 +329,8 @@ namespace Umbraco.Core.Persistence.Repositories
Name = dto.Name,
HelpText = dto.HelpText,
Mandatory = dto.Mandatory,
SortOrder = dto.SortOrder
SortOrder = dto.SortOrder,
ValidationRegExp = dto.ValidationRegExp
}).ToList();
//Reset dirty properties

View File

@@ -802,9 +802,18 @@ namespace Umbraco.Core.Services
return;
content.WriterId = userId;
var parent = GetById(parentId);
content.Path = string.Concat(parent.Path, ",", content.Id);
content.Level = parent.Level + 1;
if (parentId == -1)
{
content.Path = string.Concat("-1,", content.Id);
content.Level = 1;
}
else
{
var parent = GetById(parentId);
content.Path = string.Concat(parent.Path, ",", content.Id);
content.Level = parent.Level + 1;
}
//If Content is being moved away from Recycle Bin, its state should be un-trashed
if (content.Trashed && parentId != -20)

View File

@@ -16,18 +16,16 @@ namespace Umbraco.Tests
}
public override void Initialize()
{
{
base.Initialize();
ConfigurationManager.AppSettings.Set("umbracoReservedPaths", "~/umbraco,~/install/");
ConfigurationManager.AppSettings.Set("umbracoReservedUrls", "~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/VSEnterpriseHelper.axd");
SettingsForTests.UmbracoPath = "~/umbraco";
}
public override void TearDown()
{
//reset the app config
base.TearDown();
//reset the app config
ConfigurationManager.AppSettings.Set("umbracoReservedPaths", "");
ConfigurationManager.AppSettings.Set("umbracoReservedUrls", "");
}
[Ignore]
@@ -78,8 +76,8 @@ namespace Umbraco.Tests
public void Is_Reserved_By_Route(string url, bool shouldMatch)
{
//reset the app config, we only want to test routes not the hard coded paths
ConfigurationManager.AppSettings.Set("umbracoReservedPaths", "");
ConfigurationManager.AppSettings.Set("umbracoReservedUrls", "");
Umbraco.Core.Configuration.GlobalSettings.ReservedPaths = "";
Umbraco.Core.Configuration.GlobalSettings.ReservedUrls = "";
var routes = new RouteCollection();

View File

@@ -32,8 +32,8 @@ namespace Umbraco.Tests.Routing
_module = new UmbracoModule();
SettingsForTests.ConfigurationStatus = UmbracoVersion.Current.ToString(3);
SettingsForTests.ReservedPaths = "~/umbraco,~/install/";
SettingsForTests.ReservedUrls = "~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/VSEnterpriseHelper.axd";
//SettingsForTests.ReservedPaths = "~/umbraco,~/install/";
//SettingsForTests.ReservedUrls = "~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/VSEnterpriseHelper.axd";
//create the not found handlers config
using (var sw = File.CreateText(Umbraco.Core.IO.IOHelper.MapPath(Umbraco.Core.IO.SystemFiles.NotFoundhandlersConfig, false)))

View File

@@ -75,13 +75,13 @@ namespace Umbraco.Tests.TestHelpers
public static string ReservedPaths
{
get { return GlobalSettings.ReservedPaths; }
set { ConfigurationManager.AppSettings.Set("umbracoReservedPaths", value); }
set { GlobalSettings.ReservedPaths = value; }
}
public static string ReservedUrls
{
get { return GlobalSettings.ReservedUrls; }
set { ConfigurationManager.AppSettings.Set("umbracoReservedUrls", value); }
set { GlobalSettings.ReservedUrls = value; }
}
public static string ConfigurationStatus
@@ -100,7 +100,7 @@ namespace Umbraco.Tests.TestHelpers
public static void Reset()
{
UmbracoSettings.ResetSetters();
GlobalSettings.ResetCache();
foreach (var kvp in SavedAppSettings)
ConfigurationManager.AppSettings.Set(kvp.Key, kvp.Value);

View File

@@ -254,17 +254,4 @@
trySkipIisCustomErrors="false">
</web.routing>
<!--
web.routing
@trySkipIisCustomErrors
Tries to skip IIS custom errors.
Starting with IIS 7.5, this must be set to true for Umbraco 404 pages to show. Else, IIS will take
over and render its build-in error page. See MS doc for HttpResponseBase.TrySkipIisCustomErrors.
The default value is false, for backward compatibility reasons, which means that IIS _will_ take
over, and _prevent_ Umbraco 404 pages to show.
-->
<web.routing
trySkipIisCustomErrors="false">
</web.routing>
</settings>

View File

@@ -306,6 +306,7 @@ namespace umbraco.controls
if (defaultData != null)
{
defaultData.PropertyTypeAlias = property.Key;
defaultData.NodeId = _content.Id;
}
property.Value.DataEditor.Save();
}

View File

@@ -13,6 +13,7 @@ using System.Web.UI.WebControls;
using ClientDependency.Core;
using Umbraco.Core;
using Umbraco.Core.Models;
using umbraco.cms.businesslogic.propertytype;
using umbraco.cms.businesslogic.web;
using umbraco.cms.helpers;
using umbraco.controls.GenericProperties;
@@ -20,6 +21,7 @@ using umbraco.IO;
using umbraco.presentation;
using umbraco.BasePages;
using ContentType = umbraco.cms.businesslogic.ContentType;
using PropertyType = Umbraco.Core.Models.PropertyType;
namespace umbraco.controls
{
@@ -416,7 +418,6 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
gp = new GenericPropertyWrapper();
gp.ID = "GenericPropertyNew";
gp.Tabs = tabs;
gp.PropertyGroups = propertyTypeGroups;
gp.DataTypeDefinitions = dtds;
PropertyTypeNew.Controls.Add(gp);
PropertyTypeNew.Controls.Add(new LiteralControl("</ul>"));
@@ -426,7 +427,6 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
gp = (GenericPropertyWrapper)PropertyTypeNew.Controls[1];
gp.ID = "GenericPropertyNew";
gp.Tabs = tabs;
gp.PropertyGroups = propertyTypeGroups;
gp.DataTypeDefinitions = dtds;
gp.UpdateEditControl();
gp.GenricPropertyControl.UpdateInterface();
@@ -443,7 +443,7 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
string tabCaption = tab.ContentType == _contentType.Id ? tab.GetRawCaption() : tab.GetRawCaption() + " (inherited from " + new ContentType(tab.ContentType).Text + ")";
PropertyTypes.Controls.Add(new LiteralControl("<div class='genericPropertyListBox'><h2 class=\"propertypaneTitel\">Tab: " + tabCaption + "</h2>"));
var propertyGroup = propertyTypeGroups.SingleOrDefault(x => x.Id == tab.Id || x.ParentId == tab.Id);
var propertyGroup = propertyTypeGroups.SingleOrDefault(x => x.ParentId == tab.Id);
var propertyTypes = propertyGroup == null
? tab.GetPropertyTypes(_contentType.Id, false)
: propertyGroup.GetPropertyTypes();
@@ -452,7 +452,7 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
if (propertyGroup != null && propertyGroup.ParentId > 0)
propertyGroupId = propertyGroup.Id;
if (propertyTypes.Any())
if (propertyTypes.Any(x => x.ContentTypeId == _contentType.Id))
{
var propSort = new HtmlInputHidden();
propSort.ID = "propSort_" + propertyGroupId.ToString() + "_Content";
@@ -470,7 +470,6 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
gpw.ID = "gpw_" + pt.Id;
gpw.PropertyType = pt;
gpw.Tabs = tabs;
gp.PropertyGroups = propertyTypeGroups;
gpw.TabId = propertyGroupId;
gpw.DataTypeDefinitions = dtds;
gpw.Delete += new EventHandler(gpw_Delete);
@@ -546,7 +545,6 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
gpw.PropertyType = pt;
gpw.Tabs = tabs;
gpw.PropertyGroups = propertyTypeGroups;
gpw.DataTypeDefinitions = dtds;
gpw.Delete += new EventHandler(gpw_Delete);
gpw.FullId = "t_general_Contents_" + pt.Id;
@@ -661,11 +659,43 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
propertyType.Description = gpw.GenricPropertyControl.Description;
propertyType.ValidationRegExp = gpw.GenricPropertyControl.Validation;
propertyType.Mandatory = gpw.GenricPropertyControl.Mandatory;
propertyType.PropertyGroupId = gpw.GenricPropertyControl.Tab;
propertyType.DataTypeDatabaseType = dataTypeDefinition.DatabaseType;
propertyType.DataTypeDefinitionId = dataTypeDefinition.Id;
propertyType.DataTypeId = dataTypeDefinition.ControlId;
if (propertyType.PropertyGroupId != gpw.GenricPropertyControl.Tab)
{
if (gpw.GenricPropertyControl.Tab == 0)
{
propertyType.PropertyGroupId = 0;
}
else if (contentTypeItem.PropertyGroups.Any(x => x.Id == gpw.GenricPropertyControl.Tab))
{
propertyType.PropertyGroupId = gpw.GenricPropertyControl.Tab;
}
else if (contentTypeItem.PropertyGroups.Any(x => x.ParentId == gpw.GenricPropertyControl.Tab))
{
var propertyGroup = contentTypeItem.PropertyGroups.First(x => x.ParentId == gpw.GenricPropertyControl.Tab);
propertyType.PropertyGroupId = propertyGroup.Id;
}
else
{
if (
contentTypeItem.CompositionPropertyGroups.Any(
x => x.ParentId == gpw.GenricPropertyControl.Tab))
{
var propertyGroups = contentTypeItem.CompositionPropertyGroups.Where(x => x.ParentId == gpw.GenricPropertyControl.Tab);
var propertyGroup = propertyGroups.First();
propertyType.PropertyGroupId = propertyGroup.Id;
}
else
{
var propertyGroup = contentTypeItem.CompositionPropertyGroups.First(x => x.Id == gpw.GenricPropertyControl.Tab);
contentTypeItem.AddPropertyGroup(propertyGroup.Name);
}
}
}
//Is only called to flush cache since gpw.PropertyType.Save() isn't called
// clear local cache
cms.businesslogic.cache.Cache.ClearCacheItem("UmbracoPropertyTypeCache" + gpw.PropertyType.Id);
@@ -972,13 +1002,7 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
{
if (_contentType.ContentTypeItem is IContentType || _contentType.ContentTypeItem is IMediaType)
{
var propertyGroup = new PropertyGroup { Name = txtNewTab.Text };
if (_contentType.ContentTypeItem.PropertyGroups.Any())
{
var last = _contentType.ContentTypeItem.PropertyGroups.OrderBy(x => x.SortOrder).Last();
propertyGroup.SortOrder = last.SortOrder + 1;
}
_contentType.ContentTypeItem.PropertyGroups.Add(propertyGroup);
_contentType.ContentTypeItem.AddPropertyGroup(txtNewTab.Text);
_contentType.Save();
}
else

View File

@@ -108,7 +108,6 @@ namespace umbraco.controls.GenericProperties
}
private int _id;
private List<PropertyTypeGroup> _propertyGroups;
public int Id {
set {
@@ -123,12 +122,6 @@ namespace umbraco.controls.GenericProperties
get {return int.Parse(ddlTypes.SelectedValue);}
}
public List<PropertyTypeGroup> PropertyGroups
{
get { return _propertyGroups; }
set { _propertyGroups = value; }
}
public void Clear()
{
tbName.Text = "";
@@ -195,18 +188,7 @@ namespace umbraco.controls.GenericProperties
}
// tabs
if (_propertyGroups != null)
{
ddlTab.Items.Clear();
foreach (var propertyGroup in _propertyGroups.OrderBy(x => x.SortOrder))
{
var li = new ListItem(propertyGroup.Name, propertyGroup.Id.ToString(CultureInfo.InvariantCulture));
if (propertyGroup.Id == _tabId)
li.Selected = true;
ddlTab.Items.Add(li);
}
}
else if (_tabs != null)
if (_tabs != null)
{
ddlTab.Items.Clear();
for (int i=0;i<_tabs.Length;i++)

View File

@@ -17,7 +17,6 @@ namespace umbraco.controls.GenericProperties
private cms.businesslogic.datatype.DataTypeDefinition[] _dtds;
private int _tabId;
private string _fullId = "";
private List<PropertyTypeGroup> _propertyGroups;
public event System.EventHandler Delete;
@@ -62,11 +61,6 @@ namespace umbraco.controls.GenericProperties
}
}
public List<PropertyTypeGroup> PropertyGroups
{
set { _propertyGroups = value; }
}
public GenericPropertyWrapper()
{
//
@@ -84,7 +78,6 @@ namespace umbraco.controls.GenericProperties
_gp.PropertyType = _pt;
_gp.DataTypeDefinitions = _dtds;
_gp.Tabs = _tabs;
_gp.PropertyGroups = _propertyGroups;
_gp.TabId = _tabId;
_gp.FullId = _fullId;
}

View File

@@ -210,6 +210,7 @@ namespace umbraco.cms.businesslogic.datatype
}
return _nodeId.Value;
}
internal set { _nodeId = value; }
}
#endregion