This commit is contained in:
Sebastiaan Janssen
2012-11-29 15:40:15 -01:00
13 changed files with 694 additions and 440 deletions
+37 -40
View File
@@ -10,7 +10,7 @@
IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT
Database version: 4.8.0.2
Database version: 6.0.0.0
Please increment this version number if ANY change is made to this script,
so compatibility with scripts for other database systems can be verified easily.
@@ -147,12 +147,17 @@ CREATE TABLE [cmsContentType]
[nodeId] [int] NOT NULL,
[alias] [nvarchar] (255) NULL,
[icon] [nvarchar] (255) NULL,
[thumbnail] nvarchar(255) NOT NULL CONSTRAINT [DF_cmsContentType_thumbnail] DEFAULT ('folder.png')
[isContainer] bit NOT NULL CONSTRAINT [DF_cmsContentType_isContainer] DEFAULT (0),
[allowAtRoot] bit NOT NULL CONSTRAINT [DF_cmsContentType_allowAtRoot] DEFAULT (0)
)
;
ALTER TABLE [cmsContentType] ADD CONSTRAINT [PK_cmsContentType] PRIMARY KEY ([pk])
;
CREATE TABLE [cmsContentType2ContentType] ([parentContentTypeId] int NOT NULL,[childContentTypeId] int NOT NULL)
;
ALTER TABLE [cmsContentType2ContentType] ADD CONSTRAINT [cmsContentType2ContentType_PK] PRIMARY KEY ([parentContentTypeId],[childContentTypeId])
;
CREATE TABLE [cmsMacroPropertyType]
(
[id] [int] NOT NULL IDENTITY(1, 1),
@@ -184,16 +189,19 @@ ALTER TABLE [umbracoStylesheetProperty] ADD CONSTRAINT [PK_stylesheetProperty] P
*/
CREATE TABLE [cmsTab]
CREATE TABLE [cmsPropertyTypeGroup]
(
[id] [int] NOT NULL IDENTITY(1, 1),
[contenttypeNodeId] [int] NOT NULL,
[text] [nvarchar] (255) NOT NULL,
[sortorder] [int] NOT NULL
[sortorder] [int] NOT NULL,
[parentGroupId] int NULL CONSTRAINT [DF_cmsPropertyTypeGroup_parentGroupId] DEFAULT NULL
)
;
ALTER TABLE [cmsTab] ADD CONSTRAINT [PK_cmsTab] PRIMARY KEY ([id])
ALTER TABLE [cmsPropertyTypeGroup] ADD CONSTRAINT [PK_cmsPropertyTypeGroup] PRIMARY KEY ([id])
;
ALTER TABLE [cmsPropertyTypeGroup] ADD CONSTRAINT [FK_cmsPropertyTypeGroup_cmsPropertyTypeGroup] FOREIGN KEY([parentGroupId]) REFERENCES [cmsPropertyTypeGroup] ([id])
;
CREATE TABLE [cmsTemplate]
(
@@ -301,7 +309,7 @@ CREATE TABLE [cmsPropertyType]
[id] [int] NOT NULL IDENTITY(1, 1),
[dataTypeId] [int] NOT NULL,
[contentTypeId] [int] NOT NULL,
[tabId] [int] NULL,
[propertyTypeGroupId] int,
[Alias] [nvarchar] (255) NOT NULL,
[Name] [nvarchar] (255) NULL,
[helpText] [nvarchar] (1000) NULL,
@@ -378,7 +386,8 @@ ALTER TABLE [umbracoAppTree] ADD CONSTRAINT [PK_umbracoAppTree] PRIMARY KEY ([a
CREATE TABLE [cmsContentTypeAllowedContentType]
(
[Id] [int] NOT NULL,
[AllowedId] [int] NOT NULL
[AllowedId] [int] NOT NULL,
[sortOrder] int NOT NULL CONSTRAINT [DF_cmsContentTypeAllowedContentType_sortOrder] DEFAULT (1)
)
;
@@ -578,9 +587,6 @@ CONSTRAINT [FK_cmsTemplate_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbra
ALTER TABLE [cmsContentType] ADD
CONSTRAINT [FK_cmsContentType_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id])
;
ALTER TABLE [cmsPropertyType] ADD
CONSTRAINT [FK_cmsPropertyType_cmsTab] FOREIGN KEY ([tabId]) REFERENCES [cmsTab] ([id])
;
ALTER TABLE [cmsContent] ADD
CONSTRAINT [FK_cmsContent_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id])
;
@@ -594,8 +600,6 @@ CONSTRAINT [FK_umbracoUser2app_umbracoApp] FOREIGN KEY ([app]) REFERENCES [umbra
ALTER TABLE [cmsTemplate] DROP CONSTRAINT [FK_cmsTemplate_umbracoNode]
;
ALTER TABLE [cmsPropertyType] DROP CONSTRAINT [FK_cmsPropertyType_cmsTab]
;
ALTER TABLE [cmsContent] DROP CONSTRAINT [FK_cmsContent_umbracoNode]
;
ALTER TABLE [cmsMacroProperty] DROP CONSTRAINT [FK_umbracoMacroProperty_umbracoMacroPropertyType]
@@ -658,9 +662,9 @@ ALTER TABLE [umbracoNode] DROP CONSTRAINT [FK_umbracoNode_umbracoNode]
|SET IDENTITY_INSERT [umbracoNode] OFF
;
!!!SET IDENTITY_INSERT [cmsContentType] ON
|INSERT INTO [cmsContentType] ([pk], [nodeId], [alias], [icon], [thumbnail]) VALUES (532, 1031, N'Folder', N'folder.gif', N'folder.png')
|INSERT INTO [cmsContentType] ([pk], [nodeId], [alias], [icon], [thumbnail]) VALUES (533, 1032, N'Image', N'mediaPhoto.gif', N'mediaPhoto.png')
|INSERT INTO [cmsContentType] ([pk], [nodeId], [alias], [icon], [thumbnail]) VALUES (534, 1033, N'File', N'mediaFile.gif', N'mediaFile.png')
|INSERT INTO [cmsContentType] ([pk], [nodeId], [alias], [icon]) VALUES (532, 1031, N'Folder', N'folder.gif')
|INSERT INTO [cmsContentType] ([pk], [nodeId], [alias], [icon]) VALUES (533, 1032, N'Image', N'mediaPhoto.gif')
|INSERT INTO [cmsContentType] ([pk], [nodeId], [alias], [icon]) VALUES (534, 1033, N'File', N'mediaFile.gif')
|SET IDENTITY_INSERT [cmsContentType] OFF
;
!!!SET IDENTITY_INSERT [umbracoUser] ON
@@ -727,22 +731,22 @@ ALTER TABLE [umbracoNode] DROP CONSTRAINT [FK_umbracoNode_umbracoNode]
|INSERT INTO [cmsMacroPropertyType] ([id], [macroPropertyTypeAlias], [macroPropertyTypeRenderAssembly], [macroPropertyTypeRenderType], [macroPropertyTypeBaseType]) VALUES (25, N'textMultiLine', N'umbraco.macroRenderings', N'textMultiple', N'String')
|SET IDENTITY_INSERT [cmsMacroPropertyType] OFF
;
!!!SET IDENTITY_INSERT [cmsTab] ON
|INSERT INTO [cmsTab] ([id], [contenttypeNodeId], [text], [sortorder]) VALUES (3, 1032, N'Image', 1)
|INSERT INTO [cmsTab] ([id], [contenttypeNodeId], [text], [sortorder]) VALUES (4, 1033, N'File', 1)
|INSERT INTO [cmsTab] ([id], [contenttypeNodeId], [text], [sortorder]) VALUES (5, 1031, N'Contents', 1)
|SET IDENTITY_INSERT [cmsTab] OFF
!!!SET IDENTITY_INSERT [cmsPropertyTypeGroup] ON
|INSERT INTO [cmsPropertyTypeGroup] ([id], [contenttypeNodeId], [text], [sortorder]) VALUES (3, 1032, N'Image', 1)
|INSERT INTO [cmsPropertyTypeGroup] ([id], [contenttypeNodeId], [text], [sortorder]) VALUES (4, 1033, N'File', 1)
|INSERT INTO [cmsPropertyTypeGroup] ([id], [contenttypeNodeId], [text], [sortorder]) VALUES (5, 1031, N'Contents', 1)
|SET IDENTITY_INSERT [cmsPropertyTypeGroup] OFF
;
!!!SET IDENTITY_INSERT [cmsPropertyType] ON
|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (6, -90, 1032, 3, N'umbracoFile', N'Upload image', NULL, 0, 0, NULL, NULL)
|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (7, -92, 1032, 3, N'umbracoWidth', N'Width', NULL, 0, 0, NULL, NULL)
|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (8, -92, 1032, 3, N'umbracoHeight', N'Height', NULL, 0, 0, NULL, NULL)
|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (9, -92, 1032, 3, N'umbracoBytes', N'Size', NULL, 0, 0, NULL, NULL)
|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (10, -92, 1032, 3, N'umbracoExtension', N'Type', NULL, 0, 0, NULL, NULL)
|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (24, -90, 1033, 4, N'umbracoFile', N'Upload file', NULL, 0, 0, NULL, NULL)
|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (25, -92, 1033, 4, N'umbracoExtension', N'Type', NULL, 0, 0, NULL, NULL)
|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (26, -92, 1033, 4, N'umbracoBytes', N'Size', NULL, 0, 0, NULL, NULL)
|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (27, -38, 1031, 5, N'contents', N'Contents:', NULL, 0, 0, NULL, NULL)
|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (6, -90, 1032, 3, N'umbracoFile', N'Upload image', NULL, 0, 0, NULL, NULL)
|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (7, -92, 1032, 3, N'umbracoWidth', N'Width', NULL, 0, 0, NULL, NULL)
|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (8, -92, 1032, 3, N'umbracoHeight', N'Height', NULL, 0, 0, NULL, NULL)
|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (9, -92, 1032, 3, N'umbracoBytes', N'Size', NULL, 0, 0, NULL, NULL)
|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (10, -92, 1032, 3, N'umbracoExtension', N'Type', NULL, 0, 0, NULL, NULL)
|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (24, -90, 1033, 4, N'umbracoFile', N'Upload file', NULL, 0, 0, NULL, NULL)
|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (25, -92, 1033, 4, N'umbracoExtension', N'Type', NULL, 0, 0, NULL, NULL)
|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (26, -92, 1033, 4, N'umbracoBytes', N'Size', NULL, 0, 0, NULL, NULL)
|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (27, -38, 1031, 5, N'contents', N'Contents:', NULL, 0, 0, NULL, NULL)
|SET IDENTITY_INSERT [cmsPropertyType] OFF
;
!!!SET IDENTITY_INSERT [umbracoLanguage] ON
@@ -792,8 +796,6 @@ INSERT INTO [cmsContentTypeAllowedContentType] ([Id], [AllowedId]) VALUES (1031,
;
ALTER TABLE [cmsTemplate] ADD CONSTRAINT [FK_cmsTemplate_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id])
;
ALTER TABLE [cmsPropertyType] ADD CONSTRAINT [FK_cmsPropertyType_cmsTab] FOREIGN KEY ([tabId]) REFERENCES [cmsTab] ([id])
;
ALTER TABLE [cmsContent] ADD CONSTRAINT [FK_cmsContent_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id])
;
ALTER TABLE [cmsMacroProperty] ADD CONSTRAINT [FK_umbracoMacroProperty_umbracoMacroPropertyType] FOREIGN KEY ([macroPropertyType]) REFERENCES [cmsMacroPropertyType] ([id])
@@ -864,10 +866,10 @@ INSERT INTO [umbracoAppTree]([treeSilent], [treeInitialize], [treeSortOrder], [a
INSERT INTO [umbracoAppTree]([treeSilent], [treeInitialize], [treeSortOrder], [appAlias], [treeAlias], [treeTitle], [treeIconClosed], [treeIconOpen], [treeHandlerAssembly], [treeHandlerType]) VALUES(0, 1, 2, 'settings', 'scripts', 'Scripts', 'folder.gif', 'folder_o.gif', 'umbraco', 'loadScripts')
;
*/
/*alter TABLE [cmsContentType]
alter TABLE [cmsContentType]
add [thumbnail] nvarchar(255) NOT NULL CONSTRAINT
[DF_cmsContentType_thumbnail] DEFAULT ('folder.png')
;*/
;
alter TABLE [cmsContentType]
add [description] nvarchar(1500) NULL
;
@@ -926,10 +928,6 @@ INSERT INTO umbracoAppTree (treeSilent, treeInitialize, treeSortOrder, appAlias,
VALUES (0, 1, 2, 'translation','yourTasks', 'Tasks created by you', '.sprTreeFolder', '.sprTreeFolder_o', 'umbraco', 'loadYourTasks');
;
*/
alter TABLE [cmsContentType]
add [masterContentType] int NULL CONSTRAINT
[DF_cmsContentType_masterContentType] DEFAULT (0)
;
CREATE TABLE [cmsTagRelationship](
[nodeId] [int] NOT NULL,
[tagId] [int] NOT NULL)
@@ -963,11 +961,10 @@ CREATE TABLE [cmsPreviewXml](
[versionId] [uniqueidentifier] NOT NULL,
[timestamp] [datetime] NOT NULL,
[xml] [ntext] NOT NULL)
;
/***********************************************************************************************************************
ADD NEW PRIMARY KEYS, FOREIGN KEYS AND INDEXES FOR VERSION 4.1
@@ -992,7 +989,7 @@ ALTER TABLE [umbracoUserType] ALTER COLUMN id IDENTITY(5,1)
;
ALTER TABLE [cmsMacroPropertyType] ALTER COLUMN id IDENTITY(26,1)
;
ALTER TABLE [cmsTab] ALTER COLUMN id IDENTITY(6,1)
ALTER TABLE [cmsPropertyTypeGroup] ALTER COLUMN id IDENTITY(6,1)
;
ALTER TABLE [cmsPropertyType] ALTER COLUMN id IDENTITY(28,1)
;
@@ -241,21 +241,16 @@ function openContent(id) {
}
protected void SetSourcesAttributes(ref XmlTreeNode treeElement, Document dd)
{
treeElement.HasChildren = dd.HasChildren;
if (!IsDialog)
treeElement.Source = GetTreeServiceUrl(dd.Id);
else
treeElement.Source = GetTreeDialogUrl(dd.Id);
treeElement.HasChildren = dd.ContentType.IsContainerContentType == false && dd.HasChildren;
treeElement.Source = IsDialog == false ? GetTreeServiceUrl(dd.Id) : GetTreeDialogUrl(dd.Id);
}
protected void SetMenuAttribute(ref XmlTreeNode treeElement, List<IAction> allowedUserActions)
{
//clear menu if we're to hide it
if (!this.ShowContextMenu)
treeElement.Menu = null;
else
treeElement.Menu = RemoveDuplicateMenuDividers(GetUserAllowedActions(AllowedActions, allowedUserActions));
treeElement.Menu = this.ShowContextMenu == false ? null : RemoveDuplicateMenuDividers(GetUserAllowedActions(AllowedActions, allowedUserActions));
}
#endregion
/// <summary>
@@ -75,10 +75,10 @@ function openNodeType(id) {
public override void Render(ref XmlTree tree)
{
List<DocumentType> docTypes;
if (base.m_id == -1)
docTypes = DocumentType.GetAllAsList().FindAll(delegate(DocumentType dt) { return dt.MasterContentType == 0; });
else
docTypes = DocumentType.GetAllAsList().FindAll(delegate(DocumentType dt) { return dt.MasterContentType == base.m_id; });
docTypes = base.m_id == -1
? DocumentType.GetAllAsList().FindAll(dt => dt.MasterContentType == 0)
: DocumentType.GetAllAsList().FindAll(dt => dt.MasterContentTypes.Contains(base.m_id));
foreach (DocumentType dt in docTypes)
{
@@ -459,6 +459,13 @@ namespace umbraco.presentation.developer.packages
DocumentType s = new DocumentType(nId);
if (s != null)
{
// check for master doctypes
if (s.IsMaster())
{
foreach(var ct in s.GetChildTypes())
ct.RemoveParentContentType(s.Id);
}
s.delete();
pack.Data.Documenttypes.Remove(nId.ToString());
+240 -208
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using System.Runtime.CompilerServices;
using System.Linq;
@@ -75,14 +76,16 @@ namespace umbraco.cms.businesslogic
/// all of the properties that are initialized normally from the database.
/// This is used for performance reasons.
/// </remarks>
internal ContentType(int id, string alias, string icon, string thumbnail, int? masterContentType)
internal ContentType(int id, string alias, string icon, string thumbnail, int? masterContentType, bool? isContainer)
: base(id, true)
{
_alias = alias;
_iconurl = icon;
_thumbnail = thumbnail;
if (masterContentType.HasValue)
m_masterContentType = masterContentType.Value;
MasterContentType = masterContentType.Value;
if (isContainer.HasValue)
_isContainerContentType = isContainer.Value;
}
#endregion
@@ -91,7 +94,7 @@ namespace umbraco.cms.businesslogic
protected internal const string m_SQLOptimizedGetAll = @"
SELECT id, createDate, trashed, parentId, nodeObjectType, nodeUser, level, path, sortOrder, uniqueID, text,
masterContentType,Alias,icon,thumbnail,description
allowAtRoot, isContainer, Alias,icon,thumbnail,description
FROM umbracoNode INNER JOIN cmsContentType ON umbracoNode.id = cmsContentType.nodeId
WHERE nodeObjectType = @nodeObjectType";
@@ -101,36 +104,36 @@ namespace umbraco.cms.businesslogic
#region Static Methods
/// <summary>
/// Used for cache so we don't have to lookup column names all the time, this is actually only used for the ChildrenAsTable methods
/// </summary>
private static readonly ConcurrentDictionary<string, IDictionary<string, string>> AliasToNames = new ConcurrentDictionary<string, IDictionary<string, string>>();
/// <summary>
/// Used for cache so we don't have to lookup column names all the time, this is actually only used for the ChildrenAsTable methods
/// </summary>
private static readonly ConcurrentDictionary<string, IDictionary<string, string>> AliasToNames = new ConcurrentDictionary<string, IDictionary<string, string>>();
private static Dictionary<Tuple<string, string>, Guid> _propertyTypeCache = new Dictionary<Tuple<string, string>, Guid>();
/// <summary>
/// Returns a content type's columns alias -> name mapping
/// </summary>
/// <param name="contentTypeAlias"></param>
/// <returns></returns>
/// <remarks>
/// This is currently only used for ChildrenAsTable methods, caching is moved here instead of in the app logic so we can clear the cache
/// </remarks>
internal static IDictionary<string, string> GetAliasesAndNames(string contentTypeAlias)
{
IDictionary<string, string> cached;
if (AliasToNames.TryGetValue(contentTypeAlias, out cached))
{
return cached;
}
var ct = ContentType.GetByAlias(contentTypeAlias);
var userFields = ct.PropertyTypes.ToDictionary(x => x.Alias, x => x.Name);
AliasToNames.TryAdd(contentTypeAlias, userFields);
return userFields;
}
public static void RemoveFromDataTypeCache(string contentTypeAlias)
/// <summary>
/// Returns a content type's columns alias -> name mapping
/// </summary>
/// <param name="contentTypeAlias"></param>
/// <returns></returns>
/// <remarks>
/// This is currently only used for ChildrenAsTable methods, caching is moved here instead of in the app logic so we can clear the cache
/// </remarks>
internal static IDictionary<string, string> GetAliasesAndNames(string contentTypeAlias)
{
IDictionary<string, string> cached;
if (AliasToNames.TryGetValue(contentTypeAlias, out cached))
{
return cached;
}
var ct = ContentType.GetByAlias(contentTypeAlias);
var userFields = ct.PropertyTypes.ToDictionary(x => x.Alias, x => x.Name);
AliasToNames.TryAdd(contentTypeAlias, userFields);
return userFields;
}
public static void RemoveFromDataTypeCache(string contentTypeAlias)
{
lock (_propertyTypeCache)
{
@@ -145,10 +148,10 @@ namespace umbraco.cms.businesslogic
foreach (Tuple<string, string> key in toDelete)
{
_propertyTypeCache.Remove(key);
}
}
}
//don't put lock around this as it is ConcurrentDictionary.
AliasToNames.Clear();
//don't put lock around this as it is ConcurrentDictionary.
AliasToNames.Clear();
}
public static Guid GetDataType(string contentTypeAlias, string propertyTypeAlias)
{
@@ -164,68 +167,16 @@ namespace umbraco.cms.businesslogic
return _propertyTypeCache[key];
}
//Instead of going via API, run this query to find the control type
//by-passes a lot of queries just to determine if this is a true/false data type
//This SQL returns a larger recordset than intended
//causing controlId to sometimes be null instead of correct
//because all properties for the type are returned
//side effect of changing inner join to left join when adding masterContentType
//string sql = "select " +
// "cmsDataType.controlId, masterContentType.alias as masterAlias " +
// "from " +
// "cmsContentType " +
// "inner join cmsPropertyType on (cmsContentType.nodeId = cmsPropertyType.contentTypeId) " +
// "left join cmsDataType on (cmsPropertyType.dataTypeId = cmsDataType.nodeId) and cmsPropertyType.Alias = @propertyAlias " +
// "left join cmsContentType masterContentType on masterContentType.nodeid = cmsContentType.masterContentType " +
// "where cmsContentType.alias = @contentTypeAlias";
//this SQL correctly returns a single row when the property exists, but still returns masterAlias if it doesn't
string sql = "select cmsDataType.controlId, masterContentType.alias as masterAlias " +
"from " +
"cmsContentType " +
"left join cmsPropertyType on (cmsContentType.nodeId = cmsPropertyType.contentTypeId and cmsPropertyType.Alias = @propertyAlias) " +
"left join cmsDataType on (cmsPropertyType.dataTypeId = cmsDataType.nodeId) " +
"left join cmsContentType masterContentType on masterContentType.nodeid = cmsContentType.masterContentType " +
"where " +
"cmsContentType.alias = @contentTypeAlias";
//Ensure that getdatatype doesn't throw an exception
//http://our.umbraco.org/forum/developers/razor/18085-Access-custom-node-properties-with-Razor
//grab the controlid or test for parent
// With 4.10 we can't do this via direct SQL as we have content type mixins
Guid controlId = Guid.Empty;
IRecordsReader reader = null;
try
ContentType ct = GetByAlias(contentTypeAlias);
PropertyType pt = ct.getPropertyType(propertyTypeAlias);
if (pt != null)
{
reader = Application.SqlHelper.ExecuteReader(sql,
Application.SqlHelper.CreateParameter("@contentTypeAlias", contentTypeAlias),
Application.SqlHelper.CreateParameter("@propertyAlias", propertyTypeAlias)
);
if (reader.Read())
{
if (!reader.IsNull("controlId"))
controlId = reader.GetGuid("controlId");
else if (!reader.IsNull("masterAlias") && !String.IsNullOrEmpty(reader.GetString("masterAlias")))
{
controlId = GetDataType(reader.GetString("masterAlias"), propertyTypeAlias);
}
}
}
catch (UmbracoException)
{
_propertyTypeCache.Add(key, controlId);
}
finally
{
if (reader != null)
{
reader.Close();
}
controlId = pt.DataTypeDefinition.DataType.Id;
}
//add to cache
//add to cache (even if empty!)
if (!_propertyTypeCache.ContainsKey(key))
{
_propertyTypeCache.Add(key, controlId);
@@ -325,11 +276,12 @@ namespace umbraco.cms.businesslogic
#region Private Members
//private bool _optimizedMode = false;
private bool _allowAtRoot;
private string _alias;
private string _iconurl;
private string _description;
private string _thumbnail;
private int m_masterContentType = 0;
List<int> m_masterContentTypes;
private bool _isContainerContentType = false;
private List<int> m_AllowedChildContentTypeIDs = null;
@@ -352,12 +304,24 @@ namespace umbraco.cms.businesslogic
{
_isContainerContentType = value;
SqlHelper.ExecuteNonQuery(
"update cmsContentType set isContainerContentType = @isContainerContentType where nodeId = @id",
SqlHelper.CreateParameter("@isContainerContentType", value),
"update cmsContentType set isContainer = @isContainer where nodeId = @id",
SqlHelper.CreateParameter("@isContainer", value),
SqlHelper.CreateParameter("@id", Id));
}
}
public bool AllowAtRoot
{
get { return _allowAtRoot; }
set
{
_allowAtRoot = value;
SqlHelper.ExecuteNonQuery(
"update cmsContentType set allowAtRoot = @allowAtRoot where nodeId = @id",
SqlHelper.CreateParameter("@allowAtRoot", value),
SqlHelper.CreateParameter("@id", Id));
}
}
/// <summary>
/// Gets or sets the description.
/// </summary>
@@ -502,11 +466,15 @@ namespace umbraco.cms.businesslogic
}
// Get Property Types from the master content type
if (MasterContentType != 0)
if (MasterContentTypes.Count > 0)
{
foreach (PropertyType pt in ContentType.GetContentType(MasterContentType).PropertyTypes)
foreach (var mct in MasterContentTypes)
{
result.Add(pt);
List<PropertyType> pts = ContentType.GetContentType(mct).PropertyTypes;
foreach (PropertyType pt in pts)
{
result.Add(pt);
}
}
}
return result;
@@ -551,13 +519,34 @@ namespace umbraco.cms.businesslogic
set
{
_iconurl = value;
SqlHelper.ExecuteNonQuery(
"update cmsContentType set icon='" + value + "' where nodeid = " + Id);
SqlHelper.ExecuteNonQuery("update cmsContentType set icon='" + value + "' where nodeid = " + Id);
// Remove from cache
FlushFromCache(Id);
}
}
public List<int> MasterContentTypes
{
get
{
if (m_masterContentTypes == null)
{
m_masterContentTypes = new List<int>();
using (var dr = SqlHelper.ExecuteReader(@"SELECT parentContentTypeId FROM cmsContentType2ContentType WHERE childContentTypeId = @id", SqlHelper.CreateParameter("@id", Id)))
{
while (dr.Read())
{
m_masterContentTypes.Add(dr.GetInt("parentContentTypeId"));
}
}
}
return m_masterContentTypes;
}
}
/// <summary>
/// Gets or sets the Master Content Type for inheritance of tabs and properties.
/// </summary>
@@ -566,24 +555,118 @@ namespace umbraco.cms.businesslogic
{
get
{
return m_masterContentType;
if (MasterContentTypes.Count > 0)
return MasterContentTypes[0];
return 0;
}
set
{
m_masterContentType = value;
SqlHelper.ExecuteNonQuery("update cmsContentType set masterContentType = @masterContentType where nodeId = @nodeId",
SqlHelper.CreateParameter("@masterContentType", value),
SqlHelper.CreateParameter("@nodeId", Id));
// Remove from cache
FlushFromCache(Id);
if (value != MasterContentType)
{
//TODO: Add support for multiple masters
foreach (var mct in MasterContentTypes)
{
RemoveParentContentType(mct);
}
AddParentContentType(value);
}
}
}
public void AddParentContentType(int parentContentTypeId)
{
if (MasterContentTypes.Contains(parentContentTypeId))
{
// Should we throw an exception if you try to add something that already exist?
}
else
{
SqlHelper.ExecuteNonQuery(
"INSERT INTO [cmsContentType2ContentType] (parentContentTypeId, childContentTypeId) VALUES (@parentContentTypeId, @childContentTypeId)",
SqlHelper.CreateParameter("@parentContentTypeId", parentContentTypeId),
SqlHelper.CreateParameter("@childContentTypeId", Id));
MasterContentTypes.Add(parentContentTypeId);
}
}
public bool IsMaster()
{
return SqlHelper.ExecuteScalar<int>("select count(*) from cmsContentType2ContentType where parentContentTypeId = @parentContentTypeId",
SqlHelper.CreateParameter("@parentContentTypeId", this.Id)) > 0;
}
public IEnumerable<ContentType> GetChildTypes()
{
var cts = new List<ContentType>();
using (var dr = SqlHelper.ExecuteReader(@"SELECT childContentTypeId FROM cmsContentType2ContentType WHERE parentContentTypeId = @parentContentTypeId",
SqlHelper.CreateParameter("@parentContentTypeId", Id)))
{
while (dr.Read())
{
cts.Add(GetContentType(dr.GetInt("childContentTypeId")));
}
}
return cts;
}
public void RemoveParentContentType(int parentContentTypeId)
{
if (MasterContentTypes.Contains(parentContentTypeId) == false)
{
// Should we throw an exception if you're trying to remove something that doesn't exist?
}
else
{
// Clean up property data (when we remove a reference we also need to remove all data relating to the doc type!
// So that would be all propertyData that uses a propertyType from the content type with 'parentContentTypeId' and
// has a nodetype of this id
var contentTypeToRemove = new ContentType(parentContentTypeId);
RemoveMasterPropertyTypeData(contentTypeToRemove, this);
SqlHelper.ExecuteNonQuery(
"DELETE FROM [cmsContentType2ContentType] WHERE parentContentTypeId = @parentContentTypeId AND childContentTypeId = @childContentTypeId",
SqlHelper.CreateParameter("@parentContentTypeId", parentContentTypeId),
SqlHelper.CreateParameter("@childContentTypeId", Id));
MasterContentTypes.Remove(parentContentTypeId);
}
}
private void RemoveMasterPropertyTypeData(ContentType contentTypeToRemove, ContentType currentContentType)
{
foreach (var pt in contentTypeToRemove.PropertyTypes)
{
if (pt.ContentTypeId == contentTypeToRemove.Id)
{
// before we can remove a parent content type we need to remove all data that
// relates to property types
SqlHelper.ExecuteNonQuery(
@"delete cmsPropertyData from cmsPropertyData
inner join cmsContent on cmsContent.nodeId = cmsPropertyData.contentNodeId
where cmsPropertyData.propertyTypeId = @propertyType
and contentType = @contentType",
SqlHelper.CreateParameter("@contentType", currentContentType.Id),
SqlHelper.CreateParameter("@propertyType", pt.Id));
}
}
// remove sub data too
foreach (var ct in currentContentType.GetChildTypes())
RemoveMasterPropertyTypeData(contentTypeToRemove, ct);
}
public IEnumerable<PropertyTypeGroup> PropertyTypeGroups
{
get { return PropertyTypeGroup.GetPropertyTypeGroupsFromContentType(Id); }
}
/// <summary>
/// Retrieve a list of all Tabs on the current ContentType
/// </summary>
[Obsolete("Use PropertyTypeGroup methods instead", false)]
public TabI[] getVirtualTabs
{
get
@@ -597,6 +680,7 @@ namespace umbraco.cms.businesslogic
/// <summary>
/// Clears the locally loaded tabs which forces them to be reloaded next time they requested
/// </summary>
[Obsolete("Use PropertyTypeGroup methods instead", false)]
public void ClearVirtualTabs()
{
// zb-00040 #29889 : clear the right cache! t.contentType is the ctype which _defines_ the tab, not the current one.
@@ -731,6 +815,7 @@ namespace umbraco.cms.businesslogic
/// </summary>
/// <param name="pt">The PropertyType</param>
/// <param name="TabId">The Id of the Tab</param>
[Obsolete("Use PropertyTypeGroup methods instead", false)]
public void SetTabOnPropertyType(PropertyType pt, int TabId)
{
// This is essentially just a wrapper for the property
@@ -743,6 +828,7 @@ namespace umbraco.cms.businesslogic
/// Removing a PropertyType from the associated Tab
/// </summary>
/// <param name="pt">The PropertyType which should be freed from its tab</param>
[Obsolete("Use PropertyTypeGroup methods instead", false)]
public void removePropertyTypeFromTab(PropertyType pt)
{
pt.TabId = 0; //this will set to null in the database.
@@ -756,45 +842,28 @@ namespace umbraco.cms.businesslogic
/// <param name="Caption">Returns the Id of the new Tab</param>
/// <returns></returns>
[MethodImpl(MethodImplOptions.Synchronized)]
[Obsolete("Use PropertyTypeGroup methods instead", false)]
public int AddVirtualTab(string Caption)
{
// Get tab count
int tabCount = SqlHelper.ExecuteScalar<int>("SELECT COUNT(*) FROM cmsPropertyTypeGroup WHERE contenttypeNodeId = @nodeId",
SqlHelper.CreateParameter("@nodeId", Id));
// The method is synchronized
SqlHelper.ExecuteNonQuery("INSERT INTO cmsPropertyTypeGroup (contenttypeNodeId,text,sortorder) VALUES (@nodeId,@text,@sortorder)",
SqlHelper.CreateParameter("@nodeId", Id),
SqlHelper.CreateParameter("@text", Caption),
SqlHelper.CreateParameter("@sortorder", tabCount + 1));
PropertyTypeGroup ptg = new PropertyTypeGroup(0, Id, Caption);
ptg.Save();
// Remove from cache
FlushFromCache(Id);
return SqlHelper.ExecuteScalar<int>("SELECT MAX(id) FROM cmsPropertyTypeGroup");
return ptg.Id;
}
/// <summary>
/// Releases all PropertyTypes on tab (this does not delete the PropertyTypes) and then Deletes the Tab
/// </summary>
/// <param name="id">The Id of the Tab to be deleted.</param>
[Obsolete("Use PropertyTypeGroup methods instead", false)]
public void DeleteVirtualTab(int id)
{
//set each property on the tab to have a tab id of zero
// zb-00036 #29889 : fix property types getter
this.getVirtualTabs.ToList()
.Where(x => x.Id == id)
.Single()
.GetAllPropertyTypes()
.ForEach(x =>
{
x.TabId = 0;
});
PropertyTypeGroup.GetPropertyTypeGroup(id).Delete();
SqlHelper.ExecuteNonQuery("delete from cmsPropertyTypeGroup where id =" + id);
InitializeVirtualTabs();
// Remove from cache
FlushFromCache(Id);
}
@@ -804,11 +873,12 @@ namespace umbraco.cms.businesslogic
/// </summary>
/// <param name="tabId">The Id of the Tab to be updated</param>
/// <param name="Caption">The new Caption</param>
[Obsolete("Use PropertyTypeGroup methods instead", false)]
public void SetTabName(int tabId, string Caption)
{
SqlHelper.ExecuteNonQuery("Update cmsPropertyTypeGroup set text = @text where id = @id",
SqlHelper.CreateParameter("@text", Caption),
SqlHelper.CreateParameter("@id", tabId));
var ptg = PropertyTypeGroup.GetPropertyTypeGroup(tabId);
ptg.Name = Caption;
ptg.Save();
// Remove from cache
FlushFromCache(Id);
@@ -819,10 +889,12 @@ namespace umbraco.cms.businesslogic
/// </summary>
/// <param name="tabId">The Id of the Tab to be updated</param>
/// <param name="Caption">The new order number</param>
[Obsolete("Use PropertyTypeGroup methods instead", false)]
public void SetTabSortOrder(int tabId, int sortOrder)
{
SqlHelper.ExecuteNonQuery(
"Update cmsPropertyTypeGroup set sortOrder = " + sortOrder + " where id = " + tabId);
var ptg = PropertyTypeGroup.GetPropertyTypeGroup(tabId);
ptg.SortOrder = sortOrder;
ptg.Save();
// Remove from cache
FlushFromCache(Id);
@@ -877,11 +949,11 @@ namespace umbraco.cms.businesslogic
}
// delete all tabs
foreach (Tab t in getVirtualTabs.ToList())
foreach (PropertyTypeGroup ptg in PropertyTypeGroups)
{
if (t.ContentType == this.Id)
if (ptg.ContentTypeId == this.Id)
{
t.Delete();
ptg.Delete();
}
}
@@ -905,8 +977,8 @@ namespace umbraco.cms.businesslogic
{
_alias = dr.GetString("Alias");
_iconurl = dr.GetString("icon");
if (!dr.IsNull("masterContentType"))
m_masterContentType = dr.GetInt("masterContentType");
_isContainerContentType = dr.GetBoolean("isContainer");
_allowAtRoot = dr.GetBoolean("allowAtRoot");
if (!dr.IsNull("thumbnail"))
_thumbnail = dr.GetString("thumbnail");
@@ -921,8 +993,9 @@ namespace umbraco.cms.businesslogic
{
base.setupNode();
// TODO: Load master content types
using (IRecordsReader dr =
SqlHelper.ExecuteReader("Select masterContentType,Alias,icon,thumbnail,description from cmsContentType where nodeid=" + Id)
SqlHelper.ExecuteReader("Select allowAtRoot, isContainer, Alias,icon,thumbnail,description from cmsContentType where nodeid=" + Id)
)
{
if (dr.Read())
@@ -960,6 +1033,7 @@ namespace umbraco.cms.businesslogic
RemoveFromDataTypeCache(ct.Alias);
// clear anything that uses this as master content type
//TODO: Update to load all content types
if (ct.nodeObjectType == DocumentType._objectType)
{
List<DocumentType> cacheToFlush = DocumentType.GetAllAsList().FindAll(dt => dt.MasterContentType == id);
@@ -998,6 +1072,7 @@ namespace umbraco.cms.businesslogic
/// <summary>
/// Checks if we've loaded the virtual tabs into memory and if not gets them from the databse.
/// </summary>
[Obsolete("Use PropertyTypeGroup methods instead", false)]
private void EnsureVirtualTabs()
{
// This class can be cached and potentially shared between multiple threads.
@@ -1022,27 +1097,22 @@ namespace umbraco.cms.businesslogic
/// <summary>
/// Loads the tabs into memory from the database and stores them in a local list for retreival
/// </summary>
[Obsolete("Use PropertyTypeGroup methods instead", false)]
private void InitializeVirtualTabs()
{
// While we are initialising, we should not use the class-scoped list, as it may be used by other threads
var temporaryList = new List<TabI>();
using (IRecordsReader dr = SqlHelper.ExecuteReader(
string.Format(
"Select Id,text,sortOrder from cmsPropertyTypeGroup where contenttypeNodeId = {0} order by sortOrder",
Id)))
{
while (dr.Read())
{
temporaryList.Add(new Tab(dr.GetInt("id"), dr.GetString("text"), dr.GetInt("sortOrder"), this));
}
}
foreach (PropertyTypeGroup ptg in PropertyTypeGroups.Where(x => x.ParentId == 0 && x.ContentTypeId == this.Id))
temporaryList.Add(new Tab(ptg.Id, ptg.Name, ptg.SortOrder, this));
// Master Content Type
if (MasterContentType != 0)
if (MasterContentTypes.Count > 0)
{
temporaryList.AddRange(GetContentType(MasterContentType).getVirtualTabs.ToList());
foreach (var mct in MasterContentTypes)
temporaryList.AddRange(GetContentType(mct).getVirtualTabs.ToList());
}
// sort all tabs
temporaryList.Sort((a, b) => a.SortOrder.CompareTo(b.SortOrder));
@@ -1054,7 +1124,8 @@ namespace umbraco.cms.businesslogic
{
foreach (web.DocumentType docType in web.DocumentType.GetAllAsList())
{
if (docType.MasterContentType == docTypeId)
//TODO: Check for multiple references (mixins) not causing endless loops!
if (docType.MasterContentTypes.Contains(docTypeId))
{
populatePropertyData(pt, docType.Id);
populateMasterContentTypes(pt, docType.Id);
@@ -1148,6 +1219,7 @@ namespace umbraco.cms.businesslogic
/// A tab is merely a way to organize data on a ContentType to make it more
/// human friendly
/// </summary>
[Obsolete("Please use PropertyTypes instead", false)]
public class Tab : TabI
{
private ContentType _contenttype;
@@ -1172,16 +1244,11 @@ namespace umbraco.cms.businesslogic
public static Tab GetTab(int id)
{
Tab tab = null;
using (IRecordsReader dr = SqlHelper.ExecuteReader(
string.Format(
"Select Id, text, contenttypeNodeId, sortOrder from cmsPropertyTypeGroup where Id = {0} order by sortOrder",
id)))
// Tabs have been replaced with PropertyTypeGroups, so we use the new api to provide legacy support
PropertyTypeGroup ptg = PropertyTypeGroup.GetPropertyTypeGroup(id);
if (ptg != null)
{
if (dr.Read())
{
tab = new Tab(id, dr.GetString("text"), dr.GetInt("sortOrder"), new ContentType(dr.GetInt("contenttypeNodeId")));
}
dr.Close();
tab = new Tab(id, ptg.Name, ptg.SortOrder, new ContentType(ptg.ContentTypeId));
}
return tab;
@@ -1199,53 +1266,17 @@ namespace umbraco.cms.businesslogic
// Also this is public now because we removed the PropertyTypes property (not making sense).
public PropertyType[] GetPropertyTypes(int contentTypeId, bool includeInheritedProperties)
{
// zb-00040 #29889 : fix cache key issues!
// now maintaining a cache of local properties per contentTypeId, then merging when required
// another way would be to maintain a cache of *all* properties, then filter when required
// however it makes it more difficult to figure out what to clear (ie needs to find all children...)
var tmp = new List<PropertyType>();
var ctypes = new List<int>();
// NH, temp fix for 4.9 to use the new PropertyTypeGroup API
var pts = PropertyTypeGroup.GetPropertyTypeGroup(this.Id).GetPropertyTypes();
if (includeInheritedProperties)
{
// start from contentTypeId and list all ctypes, going up
int c = contentTypeId;
while (c != 0)
{
ctypes.Add(c);
c = umbraco.cms.businesslogic.ContentType.GetContentType(c).MasterContentType;
}
ctypes.Reverse(); // order from the top
}
else
{
// just that one
ctypes.Add(contentTypeId);
// we need to
var contentType = businesslogic.ContentType.GetContentType(contentTypeId);
return pts.Where(x => contentType.MasterContentTypes.Contains(x.ContentTypeId) || x.ContentTypeId == contentTypeId).ToArray();
}
foreach (var ctype in ctypes)
{
var ptypes = Cache.GetCacheItem<List<PropertyType>>(
generateCacheKey(Id, ctype), propertyTypesCacheSyncLock, TimeSpan.FromMinutes(10),
delegate
{
var tmp1 = new List<PropertyType>();
using (IRecordsReader dr = SqlHelper.ExecuteReader(string.Format(
@"select id from cmsPropertyType where propertyTypeGroupId = {0} and contentTypeId = {1}
order by sortOrder", _id, ctype)))
{
while (dr.Read())
tmp1.Add(PropertyType.GetPropertyType(dr.GetInt("id")));
}
return tmp1;
});
tmp.AddRange(ptypes);
}
return tmp.ToArray();
return pts.Where(x => x.ContentTypeId == contentTypeId).ToArray();
}
// zb-00036 #29889 : yet we may want to be able to get *all* property types
@@ -1253,8 +1284,7 @@ namespace umbraco.cms.businesslogic
{
var tmp = new List<PropertyType>();
using (IRecordsReader dr = SqlHelper.ExecuteReader(string.Format(
@"select id from cmsPropertyType where propertyTypeGroupId = {0}", _id)))
using (IRecordsReader dr = SqlHelper.ExecuteReader(string.Format(@"select id from cmsPropertyType where propertyTypeGroupId = {0}", _id)))
{
while (dr.Read())
tmp.Add(PropertyType.GetPropertyType(dr.GetInt("id")));
@@ -1357,6 +1387,7 @@ namespace umbraco.cms.businesslogic
/// <summary>
/// Moves the Tab up
/// </summary>
[Obsolete("Please use GetPropertyTypes() instead", false)]
public void MoveUp()
{
FixTabOrder();
@@ -1379,6 +1410,7 @@ namespace umbraco.cms.businesslogic
/// <summary>
/// Moves the Tab down
/// </summary>
[Obsolete("Please use GetPropertyTypes() instead", false)]
public void MoveDown()
{
FixTabOrder();
+12 -19
View File
@@ -22,15 +22,15 @@ namespace umbraco.cms.businesslogic.media
#region Constants and static members
private const string m_SQLOptimizedMany = @"
select
count(children.id) as children, umbracoNode.id, umbracoNode.uniqueId, umbracoNode.level, umbracoNode.parentId, umbracoNode.path, umbracoNode.sortOrder, umbracoNode.createDate, umbracoNode.nodeUser, umbracoNode.text,
cmsContentType.icon, cmsContentType.alias, cmsContentType.thumbnail, cmsContentType.description, cmsContentType.masterContentType, cmsContentType.nodeId as contentTypeId
count(children.id) as children, cmsContentType.isContainer, umbracoNode.id, umbracoNode.uniqueId, umbracoNode.level, umbracoNode.parentId, umbracoNode.path, umbracoNode.sortOrder, umbracoNode.createDate, umbracoNode.nodeUser, umbracoNode.text,
cmsContentType.icon, cmsContentType.alias, cmsContentType.thumbnail, cmsContentType.description, cmsContentType.nodeId as contentTypeId
from umbracoNode
left join umbracoNode children on children.parentId = umbracoNode.id
inner join cmsContent on cmsContent.nodeId = umbracoNode.id
inner join cmsContentType on cmsContentType.nodeId = cmsContent.contentType
where umbracoNode.nodeObjectType = @nodeObjectType AND {0}
group by umbracoNode.id, umbracoNode.uniqueId, umbracoNode.level, umbracoNode.parentId, umbracoNode.path, umbracoNode.sortOrder, umbracoNode.createDate, umbracoNode.nodeUser, umbracoNode.text,
cmsContentType.icon, cmsContentType.alias, cmsContentType.thumbnail, cmsContentType.description, cmsContentType.masterContentType, cmsContentType.nodeId
group by cmsContentType.isContainer, umbracoNode.id, umbracoNode.uniqueId, umbracoNode.level, umbracoNode.parentId, umbracoNode.path, umbracoNode.sortOrder, umbracoNode.createDate, umbracoNode.nodeUser, umbracoNode.text,
cmsContentType.icon, cmsContentType.alias, cmsContentType.thumbnail, cmsContentType.description, cmsContentType.nodeId
order by {1}";
#endregion
@@ -188,10 +188,6 @@ namespace umbraco.cms.businesslogic.media
return Media.GetChildrenForTree(this.Id).ToArray();
}
}
#endregion
#region Public methods
@@ -271,12 +267,8 @@ namespace umbraco.cms.businesslogic.media
#region Protected methods
protected void PopulateMediaFromReader(IRecordsReader dr)
{
bool _hc = false;
if (dr.GetInt("children") > 0)
_hc = true;
int? masterContentType = null;
if (!dr.IsNull("masterContentType"))
masterContentType = dr.GetInt("masterContentType");
var hc = dr.GetInt("children") > 0;
SetupMediaForTree(dr.GetGuid("uniqueId")
, dr.GetShort("level")
, dr.GetInt("parentId")
@@ -285,22 +277,23 @@ namespace umbraco.cms.businesslogic.media
, dr.GetString("text")
, dr.GetDateTime("createDate")
, dr.GetString("icon")
, _hc
, hc
, dr.GetString("alias")
, dr.GetString("thumbnail")
, dr.GetString("description")
, masterContentType
, dr.GetInt("contentTypeId"));
, null
, dr.GetInt("contentTypeId")
, dr.GetBoolean("isContainer"));
}
#endregion
#region Private methods
private void SetupMediaForTree(Guid uniqueId, int level, int parentId, int user, string path,
string text, DateTime createDate, string icon, bool hasChildren, string contentTypeAlias, string contentTypeThumb,
string contentTypeDesc, int? masterContentType, int contentTypeId)
string contentTypeDesc, int? masterContentType, int contentTypeId, bool isContainer)
{
SetupNodeForTree(uniqueId, _objectType, level, parentId, user, path, text, createDate, hasChildren);
ContentType = new ContentType(contentTypeId, contentTypeAlias, icon, contentTypeThumb, masterContentType);
ContentType = new ContentType(contentTypeId, contentTypeAlias, icon, contentTypeThumb, masterContentType, isContainer);
ContentTypeIcon = icon;
}
@@ -0,0 +1,176 @@
using System;
using System.Collections.Generic;
using System.Linq;
using umbraco.BusinessLogic;
using umbraco.DataLayer;
namespace umbraco.cms.businesslogic.propertytype
{
public class PropertyTypeGroup
{
public int Id { get; set; }
public int ParentId { get; set; }
public int ContentTypeId { get; set; }
public string Name { get; set; }
public int SortOrder { get; set; }
public PropertyTypeGroup()
{
}
public PropertyTypeGroup(int parentId, int contentTypeId, string name, int sortOrder)
{
ParentId = parentId;
ContentTypeId = contentTypeId;
Name = name;
SortOrder = sortOrder;
}
public PropertyTypeGroup(int parentId, int contentTypeId, string name)
{
ParentId = parentId;
ContentTypeId = contentTypeId;
Name = name;
SortOrder = -1; // we set this to -1 so in the save method we can get the current highest sortorder in case it's not sat after init (ie. if you want to force a sortOrder)
}
public IEnumerable<PropertyType> GetPropertyTypes(List<int> contentTypeIds)
{
return PropertyType.GetPropertyTypesByGroup(Id, contentTypeIds);
}
public IEnumerable<PropertyType> GetPropertyTypes()
{
return PropertyType.GetPropertyTypesByGroup(Id);
}
//TODO: Verify support for master doctypes / mixins!
public IEnumerable<PropertyTypeGroup> GetPropertyTypeGroups()
{
var ptgs = new List<PropertyTypeGroup>();
using (var dr = SqlHelper.ExecuteReader(@"SELECT id FROM cmsPropertyTypeGroup WHERE parentGroupId = @id", SqlHelper.CreateParameter("@id", Id)))
{
while (dr.Read())
{
ptgs.Add(GetPropertyTypeGroup(dr.GetInt("id")));
}
}
return ptgs;
}
public void Save()
{
if (Id != 0)
{
SqlHelper.ExecuteNonQuery(
@"UPDATE
cmsPropertyTypeGroup
SET
parentGroupId = @parentGroupId,
contenttypeNodeId = @contentTypeId,
sortOrder = @sortOrder,
text = @name
WHERE
id = @id
",
SqlHelper.CreateParameter("@id", Id),
SqlHelper.CreateParameter("@parentGroupId", ConvertParentId(ParentId)),
SqlHelper.CreateParameter("@contentTypeId", ContentTypeId),
SqlHelper.CreateParameter("@sortOrder", SortOrder),
SqlHelper.CreateParameter("@name", Name)
);
}
else
{
if (SortOrder == -1)
SortOrder = SqlHelper.ExecuteScalar<int>("select count(*) from cmsPropertyTypeGroup where COALESCE(parentGroupId, 0) = 0 and contenttypeNodeId = @nodeId",
SqlHelper.CreateParameter("@nodeId", ContentTypeId)) + 1;
SqlHelper.ExecuteNonQuery(
@"
INSERT INTO
cmsPropertyTypeGroup
(parentGroupId, contenttypeNodeId, sortOrder, text)
VALUES
(@parentGroupId, @contentTypeId, @sortOrder, @name)
",
SqlHelper.CreateParameter("@parentGroupId", ConvertParentId(ParentId)),
SqlHelper.CreateParameter("@contentTypeId", ContentTypeId),
SqlHelper.CreateParameter("@sortOrder", SortOrder),
SqlHelper.CreateParameter("@name", Name)
);
Id = SqlHelper.ExecuteScalar<int>("SELECT MAX(id) FROM [cmsPropertyTypeGroup]");
}
}
public void Delete()
{
// update all PropertyTypes using this group
foreach (var pt in GetPropertyTypes())
{
pt.PropertyTypeGroup = 0;
pt.Save();
}
foreach (var ptg in GetPropertyTypeGroups())
ptg.Delete();
SqlHelper.ExecuteNonQuery("DELETE FROM cmsPropertyTypeGroup WHERE id = @id", SqlHelper.CreateParameter("@id", Id));
}
internal void Load()
{
using (var dr = SqlHelper.ExecuteReader(@" SELECT parentGroupId, contenttypeNodeId, sortOrder, text FROM cmsPropertyTypeGroup WHERE id = @id", SqlHelper.CreateParameter("@id", Id)))
{
if (dr.Read())
{
// if no parent, the value should just be null. The GetInt helper method returns -1 if value is null so we need to check
ParentId = dr.GetInt("parentGroupId") != -1 ? dr.GetInt("parentGroupId") : 0;
SortOrder = dr.GetInt("sortOrder");
ContentTypeId = dr.GetInt("contenttypeNodeId");
Name = dr.GetString("text");
}
}
}
public static PropertyTypeGroup GetPropertyTypeGroup(int id)
{
var ptg = new PropertyTypeGroup { Id = id };
ptg.Load();
return ptg;
}
public static IEnumerable<PropertyTypeGroup> GetPropertyTypeGroupsFromContentType(int contentTypeId)
{
var ptgs = new List<PropertyTypeGroup>();
using (var dr = SqlHelper.ExecuteReader(@" SELECT id FROM cmsPropertyTypeGroup WHERE contenttypeNodeId = @contentTypeId", SqlHelper.CreateParameter("@contentTypeId", contentTypeId)))
{
while (dr.Read())
{
ptgs.Add(GetPropertyTypeGroup(dr.GetInt("id")));
}
}
return ptgs;
}
private object ConvertParentId(int parentId)
{
if (parentId == 0)
return DBNull.Value;
return parentId;
}
/// <summary>
/// Gets the SQL helper.
/// </summary>
/// <value>The SQL helper.</value>
protected static ISqlHelper SqlHelper
{
get { return Application.SqlHelper; }
}
}
}
@@ -35,6 +35,7 @@ namespace umbraco.cms.businesslogic.propertytype
private string _name;
private int _sortOrder;
private int _tabId;
private int _propertyTypeGroup;
private string _validationRegExp = "";
#endregion
@@ -57,7 +58,11 @@ namespace umbraco.cms.businesslogic.propertytype
_mandatory = dr.GetBoolean("mandatory");
_id = id;
if (!dr.IsNull("propertyTypeGroupId"))
_tabId = dr.GetInt("propertyTypeGroupId");
{
_propertyTypeGroup = dr.GetInt("propertyTypeGroupId");
//TODO: Remove after refactoring!
_tabId = _propertyTypeGroup;
}
_sortOrder = dr.GetInt("sortOrder");
_alias = dr.GetString("alias");
_name = dr.GetString("Name");
@@ -96,22 +101,31 @@ namespace umbraco.cms.businesslogic.propertytype
/// <remarks>
/// Setting the tab id to a negative value will actually set the value to NULL in the database
/// </remarks>
[Obsolete("Use the new PropertyTypeGroup parameter", false)]
public int TabId
{
get { return _tabId; }
set
{
_tabId = value;
PropertyTypeGroup = value;
InvalidateCache();
object tabId = value;
}
}
public int PropertyTypeGroup
{
get { return _propertyTypeGroup; }
set
{
_propertyTypeGroup = value;
object dbPropertyTypeGroup = value;
if (value < 1)
{
tabId = DBNull.Value;
dbPropertyTypeGroup = DBNull.Value;
}
SqlHelper.ExecuteNonQuery("Update cmsPropertyType set propertyTypeGroupId = @tabId where id = @id",
SqlHelper.CreateParameter("@tabId", tabId),
SqlHelper.CreateParameter("@id", Id));
SqlHelper.ExecuteNonQuery("Update cmsPropertyType set propertyTypeGroupId = @propertyTypeGroupId where id = @id",
SqlHelper.CreateParameter("@propertyTypeGroupId", dbPropertyTypeGroup),
SqlHelper.CreateParameter("@id", Id));
}
}
@@ -294,10 +308,15 @@ namespace umbraco.cms.businesslogic.propertytype
}
public static PropertyType[] GetAll()
{
var result = GetPropertyTypes();
return result.ToArray();
}
public static IEnumerable<PropertyType> GetPropertyTypes()
{
var result = new List<PropertyType>();
using (IRecordsReader dr =
SqlHelper.ExecuteReader("select id, Name from cmsPropertyType order by Name"))
SqlHelper.ExecuteReader("select id from cmsPropertyType order by Name"))
{
while (dr.Read())
{
@@ -306,7 +325,29 @@ namespace umbraco.cms.businesslogic.propertytype
result.Add(pt);
}
}
return result.ToArray();
return result;
}
public static IEnumerable<PropertyType> GetPropertyTypesByGroup(int groupId, List<int> contentTypeIds)
{
return GetPropertyTypesByGroup(groupId).Where(x => contentTypeIds.Contains(x.ContentTypeId));
}
public static IEnumerable<PropertyType> GetPropertyTypesByGroup(int groupId)
{
var result = new List<PropertyType>();
using (IRecordsReader dr =
SqlHelper.ExecuteReader("SELECT id FROM cmsPropertyType WHERE propertyTypeGroupId = @groupId order by SortOrder",
SqlHelper.CreateParameter("@groupId", groupId)))
{
while (dr.Read())
{
PropertyType pt = GetPropertyType(dr.GetInt("id"));
if (pt != null)
result.Add(pt);
}
}
return result;
}
/// <summary>
@@ -338,13 +379,11 @@ namespace umbraco.cms.businesslogic.propertytype
FlushCache();
// clean all properties on inherited document types (if this propertytype is removed from a master)
//cleanPropertiesOnDeletion(_contenttypeid);
CleanPropertiesOnDeletion(_contenttypeid);
// DocumentType.GetAllAsList().FindAll(dt => dt.MasterContentType == _contenttypeid).ForEach(dt => cleanPropertiesOnDeletion(dt.Id));
// Delete all properties of propertytype
cleanPropertiesOnDeletion(_contenttypeid, DocumentType.GetAllAsList());
ContentType.FlushFromCache(_contenttypeid);
CleanPropertiesOnDeletion(_contenttypeid);
// Delete PropertyType ..
SqlHelper.ExecuteNonQuery("Delete from cmsPropertyType where id = " + Id);
@@ -367,11 +406,12 @@ namespace umbraco.cms.businesslogic.propertytype
}
}
private void cleanPropertiesOnDeletion(int contentTypeId, List<DocumentType> documentTypes )
private void CleanPropertiesOnDeletion(int contentTypeId)
{
// first delete from all master document types
documentTypes.FindAll(dt => dt.MasterContentType == contentTypeId).ForEach(
dt => cleanPropertiesOnDeletion(dt.Id, documentTypes));
//TODO: Verify no endless loops with mixins
DocumentType.GetAllAsList().FindAll(dt => dt.MasterContentTypes.Contains(contentTypeId)).ForEach(
dt => CleanPropertiesOnDeletion(dt.Id));
// then remove from the current doc type
Content[] objs = Content.getContentOfContentType(new ContentType(contentTypeId));
@@ -382,10 +422,10 @@ namespace umbraco.cms.businesslogic.propertytype
{
prop.delete();
}
}
}
// invalidate content type cache
//ContentType.FlushFromCache(contentTypeId);
ContentType.FlushFromCache(contentTypeId);
}
public IDataType GetEditControl(object value, bool isPostBack)
@@ -424,8 +464,8 @@ namespace umbraco.cms.businesslogic.propertytype
// clear cache in tab
// zb-00040 #29889 : clear the right cache! t.ContentType is the ctype which _defines_ the tab, not the current one.
foreach (ContentType.TabI t in new ContentType(ContentTypeId).getVirtualTabs)
ContentType.FlushTabCache(t.Id, ContentTypeId);
// foreach (ContentType.TabI t in new ContentType(ContentTypeId).getVirtualTabs)
// ContentType.FlushTabCache(t.Id, ContentTypeId);
}
public static PropertyType GetPropertyType(int id)
+37 -44
View File
@@ -94,9 +94,6 @@ namespace umbraco.cms.businesslogic.web
bool _hc = false;
if (dr.GetInt("children") > 0)
_hc = true;
int? masterContentType = null;
if (!dr.IsNull("masterContentType"))
masterContentType = dr.GetInt("masterContentType");
SetupDocumentForTree(dr.GetGuid("uniqueId")
, dr.GetShort("level")
, dr.GetInt("parentId")
@@ -113,9 +110,10 @@ namespace umbraco.cms.businesslogic.web
, dr.GetString("alias")
, dr.GetString("thumbnail")
, dr.GetString("description")
, masterContentType
, null
, dr.GetInt("contentTypeId")
, dr.GetInt("templateId")
, dr.GetBoolean("isContainer")
);
// initialize content object
@@ -153,10 +151,11 @@ namespace umbraco.cms.businesslogic.web
Select
CASE WHEN (childrenTable.total>0) THEN childrenTable.total ELSE 0 END as Children,
CASE WHEN (publishedTable.publishedTotal>0) THEN publishedTable.publishedTotal ELSE 0 END as Published,
cmsContentVersion.VersionId,
cmsContentType.isContainer,
cmsContentVersion.VersionId,
cmsContentVersion.versionDate,
contentTypeNode.uniqueId as ContentTypeGuid,
cmsContent.ContentType, cmsContentType.icon, cmsContentType.alias, cmsContentType.thumbnail, cmsContentType.description, cmsContentType.masterContentType, cmsContentType.nodeId as contentTypeId,
cmsContent.ContentType, cmsContentType.icon, cmsContentType.alias, cmsContentType.thumbnail, cmsContentType.description, cmsContentType.nodeId as contentTypeId,
published, documentUser, coalesce(templateId, cmsDocumentType.templateNodeId) as templateId, cmsDocument.text as DocumentText, releaseDate, expireDate, updateDate,
umbracoNode.createDate, umbracoNode.trashed, umbracoNode.parentId, umbracoNode.nodeObjectType, umbracoNode.nodeUser, umbracoNode.level, umbracoNode.path, umbracoNode.sortOrder, umbracoNode.uniqueId, umbracoNode.text
from
@@ -182,11 +181,11 @@ namespace umbraco.cms.businesslogic.web
// inner join (select contentId, max(versionDate) as versionDate from cmsContentVersion group by contentId) temp
// on cmsContentVersion.contentId = temp.contentId and cmsContentVersion.versionDate = temp.versionDate
private const string m_SQLOptimizedMany = @"
select count(children.id) as children, umbracoNode.id, umbracoNode.uniqueId, umbracoNode.level, umbracoNode.parentId,
select count(children.id) as children, cmsContentType.isContainer, umbracoNode.id, umbracoNode.uniqueId, umbracoNode.level, umbracoNode.parentId,
cmsDocument.documentUser, coalesce(cmsDocument.templateId, cmsDocumentType.templateNodeId) as templateId,
umbracoNode.path, umbracoNode.sortOrder, coalesce(publishCheck.published,0) as isPublished, umbracoNode.createDate,
cmsDocument.text, cmsDocument.updateDate, cmsContentVersion.versionDate, cmsDocument.releaseDate, cmsDocument.expireDate, cmsContentType.icon, cmsContentType.alias,
cmsContentType.thumbnail, cmsContentType.description, cmsContentType.masterContentType, cmsContentType.nodeId as contentTypeId,
cmsContentType.thumbnail, cmsContentType.description, cmsContentType.nodeId as contentTypeId,
umbracoNode.nodeUser
from umbracoNode
left join umbracoNode children on children.parentId = umbracoNode.id
@@ -198,11 +197,11 @@ namespace umbraco.cms.businesslogic.web
left join cmsDocumentType on cmsDocumentType.contentTypeNodeId = cmsContent.contentType and cmsDocumentType.IsDefault = 1
where umbracoNode.nodeObjectType = @nodeObjectType AND cmsDocument.newest = 1 AND {0}
group by
umbracoNode.id, umbracoNode.uniqueId, umbracoNode.level, umbracoNode.parentId, cmsDocument.documentUser,
cmsContentType.isContainer, umbracoNode.id, umbracoNode.uniqueId, umbracoNode.level, umbracoNode.parentId, cmsDocument.documentUser,
cmsDocument.templateId, cmsDocumentType.templateNodeId, umbracoNode.path, umbracoNode.sortOrder,
coalesce(publishCheck.published,0), umbracoNode.createDate, cmsDocument.text,
cmsContentType.icon, cmsContentType.alias, cmsContentType.thumbnail, cmsContentType.description,
cmsContentType.masterContentType, cmsContentType.nodeId, cmsDocument.updateDate, cmsContentVersion.versionDate, cmsDocument.releaseDate, cmsDocument.expireDate, umbracoNode.nodeUser
cmsContentType.nodeId, cmsDocument.updateDate, cmsContentVersion.versionDate, cmsDocument.releaseDate, cmsDocument.expireDate, umbracoNode.nodeUser
order by {1}
";
@@ -402,8 +401,9 @@ namespace umbraco.cms.businesslogic.web
tmp.CreateContent(dct);
//now create the document data
SqlHelper.ExecuteNonQuery("insert into cmsDocument (newest, nodeId, published, documentUser, versionId, updateDate, Text) "
+ "values (1, " + tmp.Id + ", 0, " + u.Id + ", @versionId, @updateDate, @text)",
SqlHelper.ExecuteNonQuery("insert into cmsDocument (newest, nodeId, published, documentUser, versionId, updateDate, Text) values (1, " +
tmp.Id + ", 0, " +
u.Id + ", @versionId, @updateDate, @text)",
SqlHelper.CreateParameter("@versionId", tmp.Version),
SqlHelper.CreateParameter("@updateDate", DateTime.Now),
SqlHelper.CreateParameter("@text", tmp.Text));
@@ -1013,8 +1013,8 @@ where '" + Path + ",' like " + SqlHelper.Concat("node.path", "'%'"));
}
_published = true;
string tempVersion = Version.ToString();
DateTime versionDate = DateTime.Now;
string tempVersion = Version.ToString();
Guid newVersion = createNewVersion(versionDate);
Log.Add(LogTypes.Publish, u, Id, "");
@@ -1022,15 +1022,13 @@ where '" + Path + ",' like " + SqlHelper.Concat("node.path", "'%'"));
//PPH make sure that there is only 1 newest node, this is important in regard to schedueled publishing...
SqlHelper.ExecuteNonQuery("update cmsDocument set newest = 0 where nodeId = " + Id);
SqlHelper.ExecuteNonQuery("insert into cmsDocument (newest, nodeId, published, documentUser, versionId, updateDate, Text, TemplateId) "
+ "values (1, @id, 0, @userId, @versionId, @updateDate, @text, @template)",
SqlHelper.ExecuteNonQuery("insert into cmsDocument (newest, nodeId, published, documentUser, versionId, updateDate, Text, TemplateId) values (1,@id, 0, @userId, @versionId, @updateDate, @text, @template)",
SqlHelper.CreateParameter("@id", Id),
SqlHelper.CreateParameter("@template", _template > 0 ? (object)_template : (object)DBNull.Value), //pass null in if the template doesn't have a valid id
SqlHelper.CreateParameter("@userId", u.Id),
SqlHelper.CreateParameter("@versionId", newVersion),
SqlHelper.CreateParameter("@updateDate", versionDate),
SqlHelper.CreateParameter("@text", Text),
SqlHelper.CreateParameter("@template", _template > 0 ? (object)_template : (object)DBNull.Value) //pass null in if the template doesn't have a valid id
);
SqlHelper.CreateParameter("@text", Text));
SqlHelper.ExecuteNonQuery("update cmsDocument set published = 0 where nodeId = " + Id);
SqlHelper.ExecuteNonQuery("update cmsDocument set published = 1, newest = 0 where versionId = @versionId",
@@ -1091,24 +1089,22 @@ where '" + Path + ",' like " + SqlHelper.Concat("node.path", "'%'"));
if (_template != 0)
{
SqlHelper.ExecuteNonQuery("insert into cmsDocument (nodeId, published, documentUser, versionId, updateDate, Text, TemplateId) "
+ "values (@nodeId, 0, @userId, @versionId, @updateDate, @text, @templateId)",
SqlHelper.CreateParameter("@nodeId", Id),
SqlHelper.CreateParameter("@userId", u.Id),
SqlHelper.CreateParameter("@versionId", newVersion),
SqlHelper.CreateParameter("@updateDate", versionDate),
SqlHelper.CreateParameter("@text", Text),
SqlHelper.CreateParameter("@templateId", _template));
SqlHelper.ExecuteNonQuery("insert into cmsDocument (nodeId, published, documentUser, versionId, updateDate, Text, TemplateId) values (" +
Id +
", 0, " + u.Id + ", @versionId, @text, " +
_template + ")",
SqlHelper.CreateParameter("@versionId", newVersion),
SqlHelper.CreateParameter("@updateDate", versionDate),
SqlHelper.CreateParameter("@text", Text));
}
else
{
SqlHelper.ExecuteNonQuery("insert into cmsDocument (nodeId, published, documentUser, versionId, updateDate, Text) "
+ "values (@nodeId, 0, @userId, @versionId, @updateDate, @text)",
SqlHelper.CreateParameter("@nodeId", Id),
SqlHelper.CreateParameter("@userId", u.Id),
SqlHelper.CreateParameter("@versionId", newVersion),
SqlHelper.CreateParameter("@updateDate", versionDate),
SqlHelper.CreateParameter("@text", Text));
SqlHelper.ExecuteNonQuery("insert into cmsDocument (nodeId, published, documentUser, versionId, updateDate, Text) values (" +
Id +
", 0, " + u.Id + ", @versionId, @text )",
SqlHelper.CreateParameter("@versionId", newVersion),
SqlHelper.CreateParameter("@updateDate", versionDate),
SqlHelper.CreateParameter("@text", Text));
}
// Get new version
@@ -1155,8 +1151,9 @@ where '" + Path + ",' like " + SqlHelper.Concat("node.path", "'%'"));
DateTime versionDate = DateTime.Now;
Guid newVersion = createNewVersion(versionDate);
SqlHelper.ExecuteNonQuery("insert into cmsDocument (nodeId, published, documentUser, versionId, updateDate, Text) "
+ "values (" + Id + ", 0, " + u.Id + ", @versionId, @text)",
SqlHelper.ExecuteNonQuery("insert into cmsDocument (nodeId, published, documentUser, versionId, updateDate, Text) values (" +
Id + ", 0, " + u.Id +
", @versionId, @text)",
SqlHelper.CreateParameter("@versionId", newVersion),
SqlHelper.CreateParameter("@updateDate", versionDate),
SqlHelper.CreateParameter("@text", Text));
@@ -1724,11 +1721,6 @@ where '" + Path + ",' like " + SqlHelper.Concat("node.path", "'%'"));
if (dr.GetInt("children") > 0)
_hc = true;
int? masterContentType = null;
if (!dr.IsNull("masterContentType"))
masterContentType = dr.GetInt("masterContentType");
SetupDocumentForTree(dr.GetGuid("uniqueId")
, dr.GetShort("level")
, dr.GetInt("parentId")
@@ -1745,9 +1737,10 @@ where '" + Path + ",' like " + SqlHelper.Concat("node.path", "'%'"));
, dr.GetString("alias")
, dr.GetString("thumbnail")
, dr.GetString("description")
, masterContentType
, null
, dr.GetInt("contentTypeId")
, dr.GetInt("templateId"));
, dr.GetInt("templateId")
, dr.GetBoolean("isContainer"));
if (!dr.IsNull("releaseDate"))
_release = dr.GetDateTime("releaseDate");
@@ -1766,7 +1759,7 @@ where '" + Path + ",' like " + SqlHelper.Concat("node.path", "'%'"));
private void SetupDocumentForTree(Guid uniqueId, int level, int parentId, int creator, int writer, bool publish, string path,
string text, DateTime createDate, DateTime updateDate,
DateTime versionDate, string icon, bool hasChildren, string contentTypeAlias, string contentTypeThumb,
string contentTypeDesc, int? masterContentType, int contentTypeId, int templateId)
string contentTypeDesc, int? masterContentType, int contentTypeId, int templateId, bool isContainer)
{
SetupNodeForTree(uniqueId, _objectType, level, parentId, creator, path, text, createDate, hasChildren);
@@ -1774,7 +1767,7 @@ where '" + Path + ",' like " + SqlHelper.Concat("node.path", "'%'"));
_published = publish;
_updated = updateDate;
_template = templateId;
ContentType = new ContentType(contentTypeId, contentTypeAlias, icon, contentTypeThumb, masterContentType);
ContentType = new ContentType(contentTypeId, contentTypeAlias, icon, contentTypeThumb, null, isContainer);
ContentTypeIcon = icon;
VersionDate = versionDate;
}
@@ -1,6 +1,5 @@
using System;
using System.Collections;
using System.Data;
using System.Text;
using System.Xml;
using System.Linq;
@@ -8,8 +7,7 @@ using umbraco.BusinessLogic;
using umbraco.cms.businesslogic.propertytype;
using umbraco.DataLayer;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Umbraco.Core;
namespace umbraco.cms.businesslogic.web
{
@@ -34,7 +32,7 @@ namespace umbraco.cms.businesslogic.web
new internal const string m_SQLOptimizedGetAll = @"
SELECT id, createDate, trashed, parentId, nodeObjectType, nodeUser, level, path, sortOrder, uniqueID, text,
masterContentType,Alias,icon,thumbnail,description,
allowAtRoot, isContainer, Alias,icon,thumbnail,description,
templateNodeId, IsDefault
FROM umbracoNode
INNER JOIN cmsContentType ON umbracoNode.id = cmsContentType.nodeId
@@ -201,7 +199,7 @@ namespace umbraco.cms.businesslogic.web
{
if (!_hasChildrenInitialized)
{
HasChildren = SqlHelper.ExecuteScalar<int>("select count(NodeId) as tmp from cmsContentType where masterContentType = " + Id) > 0;
HasChildren = SqlHelper.ExecuteScalar<int>("select count(childContentTypeId) as tmp from cmsContentType2ContentType where parentContentTypeId = @id", SqlHelper.CreateParameter("@id", Id)) > 0;
}
return _hasChildren;
}
@@ -321,16 +319,12 @@ namespace umbraco.cms.businesslogic.web
DeleteEventArgs e = new DeleteEventArgs();
FireBeforeDelete(e);
if (!e.Cancel)
if (e.Cancel == false)
{
// check that no document types uses me as a master
foreach (DocumentType dt in DocumentType.GetAllAsList())
if (GetAllAsList().Any(dt => dt.MasterContentTypes.Contains(this.Id)))
{
if (dt.MasterContentType == this.Id)
{
//this should be InvalidOperationException (or something other than ArgumentException)!
throw new ArgumentException("Can't delete a Document Type used as a Master Content Type. Please remove all references first!");
}
throw new ArgumentException("Can't delete a Document Type used as a Master Content Type. Please remove all references first!");
}
// delete all documents of this type
@@ -358,38 +352,39 @@ namespace umbraco.cms.businesslogic.web
// info section
XmlElement info = xd.CreateElement("Info");
doc.AppendChild(info);
info.AppendChild(xmlHelper.addTextNode(xd, "Name", Text));
info.AppendChild(xmlHelper.addTextNode(xd, "Alias", Alias));
info.AppendChild(xmlHelper.addTextNode(xd, "Icon", IconUrl));
info.AppendChild(xmlHelper.addTextNode(xd, "Thumbnail", Thumbnail));
info.AppendChild(xmlHelper.addTextNode(xd, "Description", Description));
info.AppendChild(XmlHelper.AddTextNode(xd, "Name", Text));
info.AppendChild(XmlHelper.AddTextNode(xd, "Alias", Alias));
info.AppendChild(XmlHelper.AddTextNode(xd, "Icon", IconUrl));
info.AppendChild(XmlHelper.AddTextNode(xd, "Thumbnail", Thumbnail));
info.AppendChild(XmlHelper.AddTextNode(xd, "Description", Description));
//TODO: Add support for mixins!
if (this.MasterContentType > 0)
{
DocumentType dt = new DocumentType(this.MasterContentType);
if (dt != null)
info.AppendChild(xmlHelper.addTextNode(xd, "Master", dt.Alias));
info.AppendChild(XmlHelper.AddTextNode(xd, "Master", dt.Alias));
}
// templates
XmlElement allowed = xd.CreateElement("AllowedTemplates");
foreach (template.Template t in allowedTemplates)
allowed.AppendChild(xmlHelper.addTextNode(xd, "Template", t.Alias));
allowed.AppendChild(XmlHelper.AddTextNode(xd, "Template", t.Alias));
info.AppendChild(allowed);
if (DefaultTemplate != 0)
info.AppendChild(
xmlHelper.addTextNode(xd, "DefaultTemplate", new template.Template(DefaultTemplate).Alias));
XmlHelper.AddTextNode(xd, "DefaultTemplate", new template.Template(DefaultTemplate).Alias));
else
info.AppendChild(xmlHelper.addTextNode(xd, "DefaultTemplate", ""));
info.AppendChild(XmlHelper.AddTextNode(xd, "DefaultTemplate", ""));
// structure
XmlElement structure = xd.CreateElement("Structure");
doc.AppendChild(structure);
foreach (int cc in AllowedChildContentTypeIDs.ToList())
structure.AppendChild(xmlHelper.addTextNode(xd, "DocumentType", new DocumentType(cc).Alias));
structure.AppendChild(XmlHelper.AddTextNode(xd, "DocumentType", new DocumentType(cc).Alias));
// generic properties
XmlElement pts = xd.CreateElement("GenericProperties");
@@ -399,35 +394,37 @@ namespace umbraco.cms.businesslogic.web
if (pt.ContentTypeId == this.Id)
{
XmlElement ptx = xd.CreateElement("GenericProperty");
ptx.AppendChild(xmlHelper.addTextNode(xd, "Name", pt.Name));
ptx.AppendChild(xmlHelper.addTextNode(xd, "Alias", pt.Alias));
ptx.AppendChild(xmlHelper.addTextNode(xd, "Type", pt.DataTypeDefinition.DataType.Id.ToString()));
ptx.AppendChild(XmlHelper.AddTextNode(xd, "Name", pt.Name));
ptx.AppendChild(XmlHelper.AddTextNode(xd, "Alias", pt.Alias));
ptx.AppendChild(XmlHelper.AddTextNode(xd, "Type", pt.DataTypeDefinition.DataType.Id.ToString()));
//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, "Mandatory", pt.Mandatory.ToString()));
ptx.AppendChild(xmlHelper.addTextNode(xd, "Validation", pt.ValidationRegExp));
ptx.AppendChild(xmlHelper.addCDataNode(xd, "Description", pt.Description));
ptx.AppendChild(XmlHelper.AddTextNode(xd, "Tab", Tab.GetCaptionById(pt.TabId)));
ptx.AppendChild(XmlHelper.AddTextNode(xd, "Mandatory", pt.Mandatory.ToString()));
ptx.AppendChild(XmlHelper.AddTextNode(xd, "Validation", pt.ValidationRegExp));
ptx.AppendChild(XmlHelper.AddCDataNode(xd, "Description", pt.Description));
pts.AppendChild(ptx);
}
}
doc.AppendChild(pts);
// tabs
XmlElement tabs = xd.CreateElement("Tabs");
foreach (TabI t in getVirtualTabs.ToList())
var tabs = xd.CreateElement("Tabs");
foreach (var propertyTypeGroup in PropertyTypeGroups)
{
//only add tabs that aren't from a master doctype
if (t.ContentType == this.Id)
if (propertyTypeGroup.ContentTypeId == this.Id)
{
XmlElement tabx = xd.CreateElement("Tab");
tabx.AppendChild(xmlHelper.addTextNode(xd, "Id", t.Id.ToString()));
tabx.AppendChild(xmlHelper.addTextNode(xd, "Caption", t.Caption));
var tabx = xd.CreateElement("Tab");
tabx.AppendChild(XmlHelper.AddTextNode(xd, "Id", propertyTypeGroup.Id.ToString()));
tabx.AppendChild(XmlHelper.AddTextNode(xd, "Caption", propertyTypeGroup.Name));
tabs.AppendChild(tabx);
}
}
doc.AppendChild(tabs);
return doc;
}
@@ -435,8 +432,7 @@ namespace umbraco.cms.businesslogic.web
public void RemoveDefaultTemplate()
{
_defaultTemplate = 0;
SqlHelper.ExecuteNonQuery("update cmsDocumentType set IsDefault = 0 where contentTypeNodeId = " +
Id.ToString());
SqlHelper.ExecuteNonQuery("update cmsDocumentType set IsDefault = 0 where contentTypeNodeId = " + Id.ToString());
}
public bool HasTemplate()
+1
View File
@@ -239,6 +239,7 @@
<DesignTime>True</DesignTime>
<DependentUpon>PackageFiles.resx</DependentUpon>
</Compile>
<Compile Include="businesslogic\propertytype\PropertyTypeGroup.cs" />
<Compile Include="businesslogic\Property\Properties.cs" />
<Compile Include="businesslogic\skinning\controls\ColorPicker.cs" />
<Compile Include="businesslogic\skinning\controls\ImageUploader.cs" />
@@ -10,7 +10,7 @@
IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT
Database version: 4.8.0.6
Database version: 6.0.0.0
Please increment this version number if ANY change is made to this script,
so compatibility with scripts for other database systems can be verified easily.
@@ -137,10 +137,22 @@ pk int NOT NULL PRIMARY KEY AUTO_INCREMENT,
nodeId int NOT NULL,
alias nvarchar (255) NULL,
icon nvarchar (255) NULL,
thumbnail nvarchar(255) NOT NULL DEFAULT 'folder.png'
isContainer bit NOT NULL DEFAULT 0,
allowAtRoot bit NOT NULL DEFAULT 0
)
;
CREATE TABLE cmsContentType2ContentType
(
parentContentTypeId int NOT NULL,
childContentTypeId int NOT NULL
)
;
ALTER TABLE cmsContentType2ContentType ADD CONSTRAINT PK_cmsContentType2ContentType PRIMARY KEY CLUSTERED (parentContentTypeId, childContentTypeId)
;
CREATE TABLE cmsMacroPropertyType
(
id smallint NOT NULL PRIMARY KEY AUTO_INCREMENT,
@@ -166,9 +178,10 @@ stylesheetPropertyValue nvarchar (400) NULL
*/
CREATE TABLE cmsTab
CREATE TABLE cmsPropertyTypeGroup
(
id int NOT NULL PRIMARY KEY AUTO_INCREMENT,
parentGroupId int NULL DEFAULT NULL,
contenttypeNodeId int NOT NULL,
text nvarchar (255) NOT NULL,
sortorder int NOT NULL
@@ -275,7 +288,7 @@ CREATE TABLE cmsPropertyType
id int NOT NULL PRIMARY KEY AUTO_INCREMENT,
dataTypeId int NOT NULL,
contentTypeId int NOT NULL,
tabId int NULL,
propertyTypeGroupId int NULL,
Alias nvarchar (255) NOT NULL,
Name nvarchar (255) NULL,
helpText nvarchar (1000) NULL,
@@ -344,7 +357,8 @@ ALTER TABLE umbracoAppTree ADD CONSTRAINT PK_umbracoAppTree PRIMARY KEY CLUSTERE
CREATE TABLE cmsContentTypeAllowedContentType
(
Id int NOT NULL,
AllowedId int NOT NULL
AllowedId int NOT NULL,
SortOrder int NOT NULL DEFAULT 1
)
;
@@ -497,7 +511,7 @@ INSERT INTO umbracoNode (id, trashed, parentID, nodeUser, level, path, sortOrder
(-51, 0, -1, 0, 11, '-1,-51', 4, '2e6d3631-066e-44b8-aec4-96f09099b2b5', 'Numeric', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '2004/09/30 14:01:49.920'),
(-49, 0, -1, 0, 11, '-1,-49', 2, '92897bc6-a5f3-4ffe-ae27-f2e7e33dda49', 'True/false', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '2004/09/30 14:01:49.920'),
(-43, 0, -1, 0, 1, '-1,-43', 2, 'fbaf13a8-4036-41f2-93a3-974f678c312a', 'Checkbox list', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '2004/10/15 14:11:04.367'),
(-42, 0, -1, 0, 1, '-1,-42', 2, '0b6a45e7-44ba-430d-9da5-4e46060b9e03', 'Dropdown', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '2004/10/15 14:10:59.000'),
(-42, 0, -1, 0, 1, '-1,-42', 2, '0b6a45e7-44ba-430d-9da5-4e46060b9e03', 'Dropdow', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '2004/10/15 14:10:59.000'),
(-41, 0, -1, 0, 1, '-1,-41', 2, '5046194e-4237-453c-a547-15db3a07c4e1', 'Date Picker', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '2004/10/15 14:10:54.303'),
(-40, 0, -1, 0, 1, '-1,-40', 2, 'bb5f57c9-ce2b-4bb9-b697-4caca783a805', 'Radiobox', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '2004/10/15 14:10:49.253'),
(-39, 0, -1, 0, 1, '-1,-39', 2, 'f38f0ac7-1d27-439c-9f3f-089cd8825a53', 'Dropdown multiple', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '2004/10/15 14:10:44.480'),
@@ -520,10 +534,10 @@ INSERT INTO umbracoNode (id, trashed, parentID, nodeUser, level, path, sortOrder
(1043, 0, -1, 0, 1, '-1,1042', 2, '1df9f033-e6d4-451f-b8d2-e0cbc50a836f', 'Image Cropper', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '2006/01/03 13:07:55.250')
;
INSERT INTO cmsContentType (pk, nodeId, alias, icon, thumbnail) VALUES
(532, 1031, 'Folder', 'folder.gif', 'folder.png'),
(533, 1032, 'Image', 'mediaPhoto.gif', 'mediaPhoto.png'),
(534, 1033, 'File', 'mediaFile.gif', 'mediaFile.png')
INSERT INTO cmsContentType (pk, nodeId, alias, icon, isContainer, allowAtRoot) VALUES
(532, 1031, 'Folder', 'folder.gif', 1, 1),
(533, 1032, 'Image', 'mediaPhoto.gif', 0, 0),
(534, 1033, 'File', 'mediaFile.gif', 0, 0)
;
INSERT INTO umbracoUserType (id, userTypeAlias, userTypeName, userTypeDefaultPermissions) VALUES
(1, 'admin', 'Administrators', 'CADMOSKTPIURZ5:'),
@@ -601,12 +615,12 @@ INSERT INTO cmsMacroPropertyType (id, macroPropertyTypeAlias, macroPropertyTypeR
(24, 'propertyTypePickerMultiple', 'umbraco.macroRenderings', 'propertyTypePickerMultiple', 'String'),
(25, 'textMultiLine', 'umbraco.macroRenderings', 'textMultiple', 'String')
;
INSERT INTO cmsTab (id, contenttypeNodeId, text, sortorder) VALUES
INSERT INTO cmsPropertyTypeGroup (id, contenttypeNodeId, text, sortorder) VALUES
(3, 1032, 'Image', 1),
(4, 1033, 'File', 1),
(5, 1031, 'Contents', 1)
;
INSERT INTO cmsPropertyType (id, dataTypeId, contentTypeId, tabId, Alias, Name, helpText, sortOrder, mandatory, validationRegExp, Description) VALUES
INSERT INTO cmsPropertyType (id, dataTypeId, contentTypeId, propertyTypeGroupId, Alias, Name, helpText, sortOrder, mandatory, validationRegExp, Description) VALUES
(6, -90, 1032, 3, 'umbracoFile', 'Upload image', NULL, 0, 0, NULL, NULL),
(7, -92, 1032, 3, 'umbracoWidth', 'Width', NULL, 0, 0, NULL, NULL),
(8, -92, 1032, 3, 'umbracoHeight', 'Height', NULL, 0, 0, NULL, NULL),
@@ -685,7 +699,7 @@ ALTER TABLE cmsContentType ADD FOREIGN KEY (nodeId) REFERENCES umbracoNode (id)
;
ALTER TABLE umbracoNode ADD FOREIGN KEY (parentID) REFERENCES umbracoNode (id)
;
ALTER TABLE cmsPropertyType ADD FOREIGN KEY (tabId) REFERENCES cmsTab (id)
ALTER TABLE cmsPropertyType ADD FOREIGN KEY (propertyTypeGroupId) REFERENCES cmsPropertyTypeGroup (id)
;
ALTER TABLE cmsContent ADD FOREIGN KEY (nodeId) REFERENCES umbracoNode (id)
;
@@ -731,12 +745,9 @@ INSERT INTO umbracoAppTree(treeSilent, treeInitialize, treeSortOrder, appAlias,
INSERT INTO umbracoAppTree(treeSilent, treeInitialize, treeSortOrder, appAlias, treeAlias, treeTitle, treeIconClosed, treeIconOpen, treeHandlerAssembly, treeHandlerType) VALUES(0, 1, 2, 'settings', 'scripts', 'Scripts', 'folder.gif', 'folder_o.gif', 'umbraco', 'loadScripts')
;
*/
/*alter TABLE cmsContentType add thumbnail nvarchar(255) NOT NULL DEFAULT 'folder.png'
;*/
alter TABLE cmsContentType add description nvarchar(1500) NULL
alter TABLE cmsContentType add thumbnail nvarchar(255) NOT NULL DEFAULT 'folder.png'
;
alter TABLE cmsContentType add masterContentType int NULL
alter TABLE cmsContentType add description nvarchar(1500) NULL
;
insert into cmsDataTypePreValues (id, dataTypeNodeId, value, sortorder, alias) values
(3,-87,',code,undo,redo,cut,copy,mcepasteword,stylepicker,bold,italic,bullist,numlist,outdent,indent,mcelink,unlink,mceinsertanchor,mceimage,umbracomacro,mceinserttable,umbracoembed,mcecharmap,|1|1,2,3,|0|500,400|1049,|true|', 0, ''),
@@ -845,5 +856,8 @@ CREATE INDEX IX_Icon ON cmsContentType(nodeId, icon)
/* Create Custom Index to speed up tree loading */
CREATE INDEX IX_contentid_versiondate ON cmscontentversion(CONTENTID, VERSIONDATE)
;
ALTER TABLE cmsPropertyTypeGroup ADD FOREIGN KEY (parentGroupId) REFERENCES cmsPropertyTypeGroup (id)
;
/* CHANGE:End */
@@ -10,7 +10,7 @@
IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT
Database version: 4.8.0.3
Database version: 6.0.0.0
Please increment this version number if ANY change is made to this script,
so compatibility with scripts for other database systems can be verified easily.
@@ -152,13 +152,23 @@ CREATE TABLE [cmsContentType]
[pk] [int] NOT NULL IDENTITY(1, 1),
[nodeId] [int] NOT NULL,
[alias] [nvarchar] (255) NULL,
[icon] [nvarchar] (255) NULL,
[thumbnail] nvarchar(255) NOT NULL CONSTRAINT [DF_cmsContentType_thumbnail] DEFAULT ('folder.png')
[icon] [nvarchar] (255) NULL,
[isContainer] [bit] NOT NULL CONSTRAINT [df_cmsContentType_isContainer] DEFAULT 0,
[allowAtRoot] [bit] NOT NULL CONSTRAINT [df_cmsContentType_allowAtRoot] DEFAULT 0
)
;
ALTER TABLE [cmsContentType] ADD CONSTRAINT [PK_cmsContentType] PRIMARY KEY CLUSTERED ([pk])
;
CREATE TABLE [cmsContentType2ContentType](
[parentContentTypeId] [int] NOT NULL,
[childContentTypeId] [int] NOT NULL,
CONSTRAINT [PK_cmsContentType2ContentType] PRIMARY KEY CLUSTERED
(
[parentContentTypeId] ASC,
[childContentTypeId] ASC
))
;
CREATE TABLE [cmsMacroPropertyType]
(
[id] [smallint] NOT NULL IDENTITY(1, 1),
@@ -190,16 +200,17 @@ ALTER TABLE [umbracoStylesheetProperty] ADD CONSTRAINT [PK_stylesheetProperty] P
*/
CREATE TABLE [cmsTab]
CREATE TABLE [cmsPropertyTypeGroup]
(
[id] [int] NOT NULL IDENTITY(1, 1),
[parentGroupId] [int] NULL CONSTRAINT [df_cmsPropertyTypeGroup_parentGroupId] DEFAULT NULL,
[contenttypeNodeId] [int] NOT NULL,
[text] [nvarchar] (255) NOT NULL,
[sortorder] [int] NOT NULL
)
;
ALTER TABLE [cmsTab] ADD CONSTRAINT [PK_cmsTab] PRIMARY KEY CLUSTERED ([id])
ALTER TABLE [cmsPropertyTypeGroup] ADD CONSTRAINT [PK_cmsPropertyTypeGroup] PRIMARY KEY CLUSTERED ([id])
;
CREATE TABLE [cmsTemplate]
(
@@ -310,7 +321,7 @@ CREATE TABLE [cmsPropertyType]
[id] [int] NOT NULL IDENTITY(1, 1),
[dataTypeId] [int] NOT NULL,
[contentTypeId] [int] NOT NULL,
[tabId] [int] NULL,
[propertyTypeGroupId] [int] NULL,
[Alias] [nvarchar] (255) NOT NULL,
[Name] [nvarchar] (255) NULL,
[helpText] [nvarchar] (1000) NULL,
@@ -387,7 +398,8 @@ ALTER TABLE [umbracoAppTree] ADD CONSTRAINT [PK_umbracoAppTree] PRIMARY KEY CLUS
CREATE TABLE [cmsContentTypeAllowedContentType]
(
[Id] [int] NOT NULL,
[AllowedId] [int] NOT NULL
[AllowedId] [int] NOT NULL,
[SortOrder] [int] NOT NULL CONSTRAINT [df_cmsContentTypeAllowedContentType_sortOrder] DEFAULT 1
)
;
@@ -584,7 +596,7 @@ ALTER TABLE [cmsContentType] ADD
CONSTRAINT [FK_cmsContentType_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id])
;
ALTER TABLE [cmsPropertyType] ADD
CONSTRAINT [FK_cmsPropertyType_cmsTab] FOREIGN KEY ([tabId]) REFERENCES [cmsTab] ([id])
CONSTRAINT [FK_cmsPropertyType_cmsPropertyTypeGroup] FOREIGN KEY ([propertyTypeGroupId]) REFERENCES [cmsPropertyTypeGroup] ([id])
;
ALTER TABLE [cmsContent] ADD
CONSTRAINT [FK_cmsContent_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id])
@@ -595,7 +607,7 @@ CONSTRAINT [FK_umbracoUser2app_umbracoUser] FOREIGN KEY ([user]) REFERENCES [umb
ALTER TABLE [cmsTemplate] DROP CONSTRAINT [FK_cmsTemplate_umbracoNode]
;
ALTER TABLE [cmsPropertyType] DROP CONSTRAINT [FK_cmsPropertyType_cmsTab]
ALTER TABLE [cmsPropertyType] DROP CONSTRAINT [FK_cmsPropertyType_cmsPropertyTypeGroup]
;
ALTER TABLE [cmsContent] DROP CONSTRAINT [FK_cmsContent_umbracoNode]
;
@@ -656,9 +668,9 @@ INSERT INTO [umbracoNode] ([id], [trashed], [parentID], [nodeUser], [level], [pa
SET IDENTITY_INSERT [umbracoNode] OFF
;
SET IDENTITY_INSERT [cmsContentType] ON
INSERT INTO [cmsContentType] ([pk], [nodeId], [alias], [icon], [thumbnail]) VALUES (532, 1031, N'Folder', N'folder.gif', N'folder.png')
INSERT INTO [cmsContentType] ([pk], [nodeId], [alias], [icon], [thumbnail]) VALUES (533, 1032, N'Image', N'mediaPhoto.gif', N'mediaPhoto.png')
INSERT INTO [cmsContentType] ([pk], [nodeId], [alias], [icon], [thumbnail]) VALUES (534, 1033, N'File', N'mediaFile.gif', N'mediaFile.png')
INSERT INTO [cmsContentType] ([pk], [nodeId], [alias], [icon], [isContainer], [allowAtRoot]) VALUES (532, 1031, N'Folder', N'folder.gif', 1, 1)
INSERT INTO [cmsContentType] ([pk], [nodeId], [alias], [icon]) VALUES (533, 1032, N'Image', N'mediaPhoto.gif')
INSERT INTO [cmsContentType] ([pk], [nodeId], [alias], [icon]) VALUES (534, 1033, N'File', N'mediaFile.gif')
SET IDENTITY_INSERT [cmsContentType] OFF
;
SET IDENTITY_INSERT [umbracoUser] ON
@@ -697,22 +709,22 @@ INSERT INTO [cmsMacroPropertyType] ([id], [macroPropertyTypeAlias], [macroProper
INSERT INTO [cmsMacroPropertyType] ([id], [macroPropertyTypeAlias], [macroPropertyTypeRenderAssembly], [macroPropertyTypeRenderType], [macroPropertyTypeBaseType]) VALUES (25, N'textMultiLine', N'umbraco.macroRenderings', N'textMultiple', N'String')
SET IDENTITY_INSERT [cmsMacroPropertyType] OFF
;
SET IDENTITY_INSERT [cmsTab] ON
INSERT INTO [cmsTab] ([id], [contenttypeNodeId], [text], [sortorder]) VALUES (3, 1032, N'Image', 1)
INSERT INTO [cmsTab] ([id], [contenttypeNodeId], [text], [sortorder]) VALUES (4, 1033, N'File', 1)
INSERT INTO [cmsTab] ([id], [contenttypeNodeId], [text], [sortorder]) VALUES (5, 1031, N'Contents', 1)
SET IDENTITY_INSERT [cmsTab] OFF
SET IDENTITY_INSERT [cmsPropertyTypeGroup] ON
INSERT INTO [cmsPropertyTypeGroup] ([id], [contenttypeNodeId], [text], [sortorder]) VALUES (3, 1032, N'Image', 1)
INSERT INTO [cmsPropertyTypeGroup] ([id], [contenttypeNodeId], [text], [sortorder]) VALUES (4, 1033, N'File', 1)
INSERT INTO [cmsPropertyTypeGroup] ([id], [contenttypeNodeId], [text], [sortorder]) VALUES (5, 1031, N'Contents', 1)
SET IDENTITY_INSERT [cmsPropertyTypeGroup] OFF
;
SET IDENTITY_INSERT [cmsPropertyType] ON
INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (6, -90, 1032, 3, N'umbracoFile', N'Upload image', NULL, 0, 0, NULL, NULL)
INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (7, -92, 1032, 3, N'umbracoWidth', N'Width', NULL, 0, 0, NULL, NULL)
INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (8, -92, 1032, 3, N'umbracoHeight', N'Height', NULL, 0, 0, NULL, NULL)
INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (9, -92, 1032, 3, N'umbracoBytes', N'Size', NULL, 0, 0, NULL, NULL)
INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (10, -92, 1032, 3, N'umbracoExtension', N'Type', NULL, 0, 0, NULL, NULL)
INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (24, -90, 1033, 4, N'umbracoFile', N'Upload file', NULL, 0, 0, NULL, NULL)
INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (25, -92, 1033, 4, N'umbracoExtension', N'Type', NULL, 0, 0, NULL, NULL)
INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (26, -92, 1033, 4, N'umbracoBytes', N'Size', NULL, 0, 0, NULL, NULL)
INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (27, -38, 1031, 5, N'contents', N'Contents:', NULL, 0, 0, NULL, NULL)
INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (6, -90, 1032, 3, N'umbracoFile', N'Upload image', NULL, 0, 0, NULL, NULL)
INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (7, -92, 1032, 3, N'umbracoWidth', N'Width', NULL, 0, 0, NULL, NULL)
INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (8, -92, 1032, 3, N'umbracoHeight', N'Height', NULL, 0, 0, NULL, NULL)
INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (9, -92, 1032, 3, N'umbracoBytes', N'Size', NULL, 0, 0, NULL, NULL)
INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (10, -92, 1032, 3, N'umbracoExtension', N'Type', NULL, 0, 0, NULL, NULL)
INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (24, -90, 1033, 4, N'umbracoFile', N'Upload file', NULL, 0, 0, NULL, NULL)
INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (25, -92, 1033, 4, N'umbracoExtension', N'Type', NULL, 0, 0, NULL, NULL)
INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (26, -92, 1033, 4, N'umbracoBytes', N'Size', NULL, 0, 0, NULL, NULL)
INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (27, -38, 1031, 5, N'contents', N'Contents:', NULL, 0, 0, NULL, NULL)
SET IDENTITY_INSERT [cmsPropertyType] OFF
;
SET IDENTITY_INSERT [umbracoLanguage] ON
@@ -761,7 +773,7 @@ INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (40, 10
SET IDENTITY_INSERT [cmsDataType] OFF
;
ALTER TABLE [cmsTemplate] ADD CONSTRAINT [FK_cmsTemplate_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id])
ALTER TABLE [cmsPropertyType] ADD CONSTRAINT [FK_cmsPropertyType_cmsTab] FOREIGN KEY ([tabId]) REFERENCES [cmsTab] ([id])
ALTER TABLE [cmsPropertyType] ADD CONSTRAINT [FK_cmsPropertyType_cmsPropertyTypeGroup] FOREIGN KEY ([propertyTypeGroupId]) REFERENCES [cmsPropertyTypeGroup] ([id])
ALTER TABLE [cmsContent] ADD CONSTRAINT [FK_cmsContent_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id])
ALTER TABLE [cmsMacroProperty] ADD CONSTRAINT [FK_umbracoMacroProperty_umbracoMacroPropertyType] FOREIGN KEY ([macroPropertyType]) REFERENCES [cmsMacroPropertyType] ([id])
ALTER TABLE [umbracoUser2app] ADD CONSTRAINT [FK_umbracoUser2app_umbracoUser] FOREIGN KEY ([user]) REFERENCES [umbracoUser] ([id])
@@ -819,10 +831,10 @@ insert into umbracoRelationType (dual, parentObjectType, childObjectType, name,
;
ALTER TABLE cmsMacro ADD macroPython nvarchar(255)
;
--alter TABLE [cmsContentType]
--add [thumbnail] nvarchar(255) NOT NULL CONSTRAINT
--[DF_cmsContentType_thumbnail] DEFAULT ('folder.png')
--;
alter TABLE [cmsContentType]
add [thumbnail] nvarchar(255) NOT NULL CONSTRAINT
[DF_cmsContentType_thumbnail] DEFAULT ('folder.png')
;
alter TABLE [cmsContentType]
add [description] nvarchar(1500) NULL
;
@@ -858,11 +870,6 @@ SELECT DISTINCT userID, nodeId, 'H' FROM umbracoUser2NodePermission WHERE userId
(SELECT umbracoUser.id FROM umbracoUserType INNER JOIN umbracoUser ON umbracoUserType.id = umbracoUser.userType WHERE (umbracoUserType.userTypeAlias = 'writer'))
;
alter TABLE [cmsContentType]
add [masterContentType] int NULL CONSTRAINT
[DF_cmsContentType_masterContentType] DEFAULT (0)
;
CREATE TABLE [cmsTagRelationship](
[nodeId] [int] NOT NULL,
[tagId] [int] NOT NULL,
@@ -1305,8 +1312,8 @@ ALTER TABLE cmsPropertyType ADD CONSTRAINT
ON DELETE NO ACTION
;
ALTER TABLE cmsTab ADD CONSTRAINT
FK_cmsTab_cmsContentType FOREIGN KEY
ALTER TABLE cmsPropertyTypeGroup ADD CONSTRAINT
FK_cmsPropertyTypeGroup_cmsContentType FOREIGN KEY
(
contenttypeNodeId
) REFERENCES cmsContentType
@@ -1589,7 +1596,10 @@ ALTER TABLE cmsMember2MemberGroup ADD CONSTRAINT
) ON UPDATE NO ACTION
ON DELETE NO ACTION
;
ALTER TABLE [cmsPropertyTypeGroup]
WITH CHECK ADD CONSTRAINT [FK_cmsPropertyTypeGroup_cmsPropertyTypeGroup] FOREIGN KEY([parentGroupId])
REFERENCES [cmsPropertyTypeGroup] ([id])
;
/***********************************************************************************************************************