Fixes issue with the Member editor throwing a YSOD because new API was used in the ContentControl.
The new API is now only used if available, which is the case for Content and Media, but currently not for Members.
This commit is contained in:
@@ -9,15 +9,18 @@ using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Models;
|
||||
using umbraco.BasePages;
|
||||
using umbraco.cms.businesslogic;
|
||||
using umbraco.cms.businesslogic.media;
|
||||
using umbraco.cms.businesslogic.property;
|
||||
using umbraco.cms.businesslogic.propertytype;
|
||||
using umbraco.cms.businesslogic.web;
|
||||
using umbraco.interfaces;
|
||||
using umbraco.uicontrols;
|
||||
using Content = umbraco.cms.businesslogic.Content;
|
||||
using ContentType = umbraco.cms.businesslogic.ContentType;
|
||||
using Media = umbraco.cms.businesslogic.media.Media;
|
||||
using Property = umbraco.cms.businesslogic.property.Property;
|
||||
using StylesheetProperty = umbraco.cms.businesslogic.web.StylesheetProperty;
|
||||
|
||||
namespace umbraco.controls
|
||||
{
|
||||
@@ -111,7 +114,7 @@ namespace umbraco.controls
|
||||
Save += new EventHandler(standardSaveAndPublishHandler);
|
||||
_prntpage = (UmbracoEnsuredPage)Page;
|
||||
int i = 0;
|
||||
var inTab = new Hashtable();
|
||||
Hashtable inTab = new Hashtable();
|
||||
|
||||
// zb-00036 #29889 : load it only once
|
||||
if (_virtualTabs == null)
|
||||
@@ -130,27 +133,14 @@ namespace umbraco.controls
|
||||
|
||||
tabPage.Style.Add("text-align", "center");
|
||||
|
||||
var tabId = tab.Id;
|
||||
var propertyGroups = _contentType.ContentTypeItem.CompositionPropertyGroups.Where(x => x.Id == tabId || x.ParentId == tabId);
|
||||
var propertyTypeAliases = propertyGroups.SelectMany(x => x.PropertyTypes.OrderBy(y => y.SortOrder).Select(y => new System.Tuple<int, string, int>(y.Id, y.Alias, y.SortOrder)));
|
||||
foreach (var items in propertyTypeAliases)
|
||||
//Legacy vs New API loading of PropertyTypes
|
||||
if (_contentType.ContentTypeItem != null)
|
||||
{
|
||||
var property = _content.getProperty(items.Item2);
|
||||
if (property != null)
|
||||
{
|
||||
AddControlNew(property, tabPage, tab.Caption);
|
||||
|
||||
if (!inTab.ContainsKey(items.Item1.ToString(CultureInfo.InvariantCulture)))
|
||||
inTab.Add(items.Item1.ToString(CultureInfo.InvariantCulture), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentNullException(
|
||||
string.Format(
|
||||
"Property {0} ({1}) on Content Type {2} could not be retrieved for Document {3} on Tab Page {4}. To fix this problem, delete the property and recreate it.",
|
||||
items.Item2, items.Item1, _content.ContentType.Alias, _content.Id,
|
||||
tab.Caption));
|
||||
}
|
||||
LoadPropertyTypes(_contentType.ContentTypeItem, tabPage, inTab, tab.Id, tab.Caption);
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadPropertyTypes(tab, tabPage, inTab);
|
||||
}
|
||||
|
||||
i++;
|
||||
@@ -173,6 +163,72 @@ namespace umbraco.controls
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loades PropertyTypes by Tab/PropertyGroup using the new API.
|
||||
/// </summary>
|
||||
/// <param name="contentType"></param>
|
||||
/// <param name="tabPage"></param>
|
||||
/// <param name="inTab"></param>
|
||||
/// <param name="tabId"></param>
|
||||
/// <param name="tabCaption"></param>
|
||||
private void LoadPropertyTypes(IContentTypeComposition contentType, TabPage tabPage, Hashtable inTab, int tabId, string tabCaption)
|
||||
{
|
||||
var propertyGroups = contentType.CompositionPropertyGroups.Where(x => x.Id == tabId || x.ParentId == tabId);
|
||||
var propertyTypeAliases = propertyGroups.SelectMany(x => x.PropertyTypes.OrderBy(y => y.SortOrder).Select(y => new Tuple<int, string, int>(y.Id, y.Alias, y.SortOrder)));
|
||||
foreach (var items in propertyTypeAliases)
|
||||
{
|
||||
var property = _content.getProperty(items.Item2);
|
||||
if (property != null)
|
||||
{
|
||||
AddControlNew(property, tabPage, tabCaption);
|
||||
|
||||
if (!inTab.ContainsKey(items.Item1.ToString(CultureInfo.InvariantCulture)))
|
||||
inTab.Add(items.Item1.ToString(CultureInfo.InvariantCulture), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentNullException(
|
||||
string.Format(
|
||||
"Property {0} ({1}) on Content Type {2} could not be retrieved for Document {3} on Tab Page {4}. To fix this problem, delete the property and recreate it.",
|
||||
items.Item2, items.Item1, _content.ContentType.Alias, _content.Id,
|
||||
tabCaption));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loades PropertyTypes by Tab using the Legacy API.
|
||||
/// </summary>
|
||||
/// <param name="tab"></param>
|
||||
/// <param name="tabPage"></param>
|
||||
/// <param name="inTab"></param>
|
||||
private void LoadPropertyTypes(ContentType.TabI tab, TabPage tabPage, Hashtable inTab)
|
||||
{
|
||||
// Iterate through the property types and add them to the tab
|
||||
// zb-00036 #29889 : fix property types getter to get the right set of properties
|
||||
// ge : had a bit of a corrupt db and got weird NRE errors so rewrote this to catch the error and rethrow with detail
|
||||
var propertyTypes = tab.GetPropertyTypes(_content.ContentType.Id);
|
||||
foreach (var propertyType in propertyTypes)
|
||||
{
|
||||
var property = _content.getProperty(propertyType);
|
||||
if (property != null && tabPage != null)
|
||||
{
|
||||
AddControlNew(property, tabPage, tab.Caption);
|
||||
|
||||
// adding this check, as we occasionally get an already in dictionary error, though not sure why
|
||||
if (!inTab.ContainsKey(propertyType.Id.ToString(CultureInfo.InvariantCulture)))
|
||||
inTab.Add(propertyType.Id.ToString(CultureInfo.InvariantCulture), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentNullException(
|
||||
string.Format(
|
||||
"Property {0} ({1}) on Content Type {2} could not be retrieved for Document {3} on Tab Page {4}. To fix this problem, delete the property and recreate it.",
|
||||
propertyType.Alias, propertyType.Id, _content.ContentType.Alias, _content.Id, tab.Caption));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the control and ensures child controls are setup
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user