merge with 6.1.0
This commit is contained in:
@@ -1256,6 +1256,41 @@ namespace Umbraco.Core.Configuration
|
||||
}
|
||||
}
|
||||
|
||||
private static IconPickerBehaviour? _iconPickerBehaviour;
|
||||
|
||||
/// <summary>
|
||||
/// This configuration setting defines how to show icons in the document type editor.
|
||||
/// - ShowDuplicates - Show duplicates in files and sprites. (default and current Umbraco 'normal' behaviour)
|
||||
/// - HideSpriteDuplicates - Show files on disk and hide duplicates from the sprite
|
||||
/// - HideFileDuplicates - Show files in the sprite and hide duplicates on disk
|
||||
/// </summary>
|
||||
/// <value>MacroErrorBehaviour enum defining how to show icons in the document type editor.</value>
|
||||
public static IconPickerBehaviour IconPickerBehaviour
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_iconPickerBehaviour == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var behaviour = IconPickerBehaviour.ShowDuplicates;
|
||||
var value = GetKey("/settings/content/DocumentTypeIconList");
|
||||
if (value != null)
|
||||
{
|
||||
Enum<IconPickerBehaviour>.TryParse(value, true, out behaviour);
|
||||
}
|
||||
_iconPickerBehaviour = behaviour;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error<UmbracoSettings>("Could not load /settings/content/DocumentTypeIconList from umbracosettings.config", ex);
|
||||
_iconPickerBehaviour = IconPickerBehaviour.ShowDuplicates;
|
||||
}
|
||||
}
|
||||
return _iconPickerBehaviour.Value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configuration regarding webservices
|
||||
/// </summary>
|
||||
|
||||
24
src/Umbraco.Core/IconPickerBehaviour.cs
Normal file
24
src/Umbraco.Core/IconPickerBehaviour.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
namespace Umbraco.Core
|
||||
{
|
||||
public enum IconPickerBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// Default umbraco behavior - show duplicates in files and sprites
|
||||
/// </summary>
|
||||
ShowDuplicates,
|
||||
|
||||
/// <summary>
|
||||
/// If a file exists on disk with the same name as one in the sprite
|
||||
/// then the file on disk overrules the one in the sprite, the
|
||||
/// sprite icon will not be shown
|
||||
/// </summary>
|
||||
HideSpriteDuplicates,
|
||||
|
||||
/// <summary>
|
||||
/// If a file exists on disk with the same name as one in the sprite
|
||||
/// then the file in the sprite overrules the one on disk, the file
|
||||
/// on disk will be shown
|
||||
/// </summary>
|
||||
HideFileDuplicates
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,8 @@ namespace Umbraco.Core.Models
|
||||
private bool _isPublished;
|
||||
private bool _isDraft;
|
||||
private bool _hasPendingChanges;
|
||||
private string _contentTypeAlias;
|
||||
private string _umbracoFile;
|
||||
private Guid _nodeObjectTypeId;
|
||||
|
||||
private static readonly PropertyInfo CreatorIdSelector = ExpressionHelper.GetPropertyInfo<UmbracoEntity, int>(x => x.CreatorId);
|
||||
@@ -33,7 +35,13 @@ namespace Umbraco.Core.Models
|
||||
private static readonly PropertyInfo IsPublishedSelector = ExpressionHelper.GetPropertyInfo<UmbracoEntity, bool>(x => x.IsPublished);
|
||||
private static readonly PropertyInfo IsDraftSelector = ExpressionHelper.GetPropertyInfo<UmbracoEntity, bool>(x => x.IsDraft);
|
||||
private static readonly PropertyInfo HasPendingChangesSelector = ExpressionHelper.GetPropertyInfo<UmbracoEntity, bool>(x => x.HasPendingChanges);
|
||||
private static readonly PropertyInfo ContentTypeAliasSelector = ExpressionHelper.GetPropertyInfo<UmbracoEntity, string>(x => x.ContentTypeAlias);
|
||||
private static readonly PropertyInfo ContentTypeIconSelector = ExpressionHelper.GetPropertyInfo<UmbracoEntity, string>(x => x.ContentTypeIcon);
|
||||
private static readonly PropertyInfo ContentTypeThumbnailSelector = ExpressionHelper.GetPropertyInfo<UmbracoEntity, string>(x => x.ContentTypeThumbnail);
|
||||
private static readonly PropertyInfo UmbracoFileSelector = ExpressionHelper.GetPropertyInfo<UmbracoEntity, string>(x => x.UmbracoFile);
|
||||
private static readonly PropertyInfo NodeObjectTypeIdSelector = ExpressionHelper.GetPropertyInfo<UmbracoEntity, Guid>(x => x.NodeObjectTypeId);
|
||||
private string _contentTypeIcon;
|
||||
private string _contentTypeThumbnail;
|
||||
|
||||
public UmbracoEntity()
|
||||
{
|
||||
@@ -187,6 +195,58 @@ namespace Umbraco.Core.Models
|
||||
}
|
||||
}
|
||||
|
||||
public string ContentTypeAlias
|
||||
{
|
||||
get { return _contentTypeAlias; }
|
||||
set
|
||||
{
|
||||
SetPropertyValueAndDetectChanges(o =>
|
||||
{
|
||||
_contentTypeAlias = value;
|
||||
return _contentTypeAlias;
|
||||
}, _contentTypeAlias, ContentTypeAliasSelector);
|
||||
}
|
||||
}
|
||||
|
||||
public string ContentTypeIcon
|
||||
{
|
||||
get { return _contentTypeIcon; }
|
||||
set
|
||||
{
|
||||
SetPropertyValueAndDetectChanges(o =>
|
||||
{
|
||||
_contentTypeIcon = value;
|
||||
return _contentTypeIcon;
|
||||
}, _contentTypeIcon, ContentTypeIconSelector);
|
||||
}
|
||||
}
|
||||
|
||||
public string ContentTypeThumbnail
|
||||
{
|
||||
get { return _contentTypeThumbnail; }
|
||||
set
|
||||
{
|
||||
SetPropertyValueAndDetectChanges(o =>
|
||||
{
|
||||
_contentTypeThumbnail = value;
|
||||
return _contentTypeThumbnail;
|
||||
}, _contentTypeThumbnail, ContentTypeThumbnailSelector);
|
||||
}
|
||||
}
|
||||
|
||||
public string UmbracoFile
|
||||
{
|
||||
get { return _umbracoFile; }
|
||||
set
|
||||
{
|
||||
SetPropertyValueAndDetectChanges(o =>
|
||||
{
|
||||
_umbracoFile = value;
|
||||
return _umbracoFile;
|
||||
}, _umbracoFile, UmbracoFileSelector);
|
||||
}
|
||||
}
|
||||
|
||||
public Guid NodeObjectTypeId
|
||||
{
|
||||
get { return _nodeObjectTypeId; }
|
||||
|
||||
@@ -21,7 +21,11 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
ParentId = dto.ParentId,
|
||||
Path = dto.Path,
|
||||
SortOrder = dto.SortOrder,
|
||||
HasChildren = dto.Children > 0
|
||||
HasChildren = dto.Children > 0,
|
||||
ContentTypeAlias = dto.Alias ?? string.Empty,
|
||||
ContentTypeIcon = dto.Icon ?? string.Empty,
|
||||
ContentTypeThumbnail = dto.Thumbnail ?? string.Empty,
|
||||
UmbracoFile = dto.UmbracoFile ?? string.Empty
|
||||
};
|
||||
|
||||
entity.IsPublished = dto.PublishedVersion != default(Guid) ||
|
||||
|
||||
@@ -58,8 +58,8 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
|
||||
public virtual IUmbracoEntity Get(int id, Guid objectTypeId)
|
||||
{
|
||||
bool isContent = objectTypeId == new Guid(Constants.ObjectTypes.Document);
|
||||
var sql = GetBaseWhere(GetBase, isContent, objectTypeId, id).Append(GetGroupBy(isContent));
|
||||
bool isContentOrMedia = objectTypeId == new Guid(Constants.ObjectTypes.Document) || objectTypeId == new Guid(Constants.ObjectTypes.Media);
|
||||
var sql = GetBaseWhere(GetBase, isContentOrMedia, objectTypeId, id).Append(GetGroupBy(isContentOrMedia));
|
||||
var nodeDto = _work.Database.FirstOrDefault<UmbracoEntityDto>(sql);
|
||||
if (nodeDto == null)
|
||||
return null;
|
||||
@@ -81,8 +81,8 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isContent = objectTypeId == new Guid(Constants.ObjectTypes.Document);
|
||||
var sql = GetBaseWhere(GetBase, isContent, objectTypeId).Append(GetGroupBy(isContent));
|
||||
bool isContentOrMedia = objectTypeId == new Guid(Constants.ObjectTypes.Document) || objectTypeId == new Guid(Constants.ObjectTypes.Media);
|
||||
var sql = GetBaseWhere(GetBase, isContentOrMedia, objectTypeId).Append(GetGroupBy(isContentOrMedia));
|
||||
var dtos = _work.Database.Fetch<UmbracoEntityDto>(sql);
|
||||
|
||||
var factory = new UmbracoEntityFactory();
|
||||
@@ -111,10 +111,10 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
|
||||
public virtual IEnumerable<IUmbracoEntity> GetByQuery(IQuery<IUmbracoEntity> query, Guid objectTypeId)
|
||||
{
|
||||
bool isContent = objectTypeId == new Guid(Constants.ObjectTypes.Document);
|
||||
var sqlClause = GetBaseWhere(GetBase, isContent, objectTypeId);
|
||||
bool isContentOrMedia = objectTypeId == new Guid(Constants.ObjectTypes.Document) || objectTypeId == new Guid(Constants.ObjectTypes.Media);
|
||||
var sqlClause = GetBaseWhere(GetBase, isContentOrMedia, objectTypeId);
|
||||
var translator = new SqlTranslator<IUmbracoEntity>(sqlClause, query);
|
||||
var sql = translator.Translate().Append(GetGroupBy(isContent));
|
||||
var sql = translator.Translate().Append(GetGroupBy(isContentOrMedia));
|
||||
|
||||
var dtos = _work.Database.Fetch<UmbracoEntityDto>(sql);
|
||||
|
||||
@@ -128,94 +128,112 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
|
||||
#region Sql Statements
|
||||
|
||||
protected virtual Sql GetBase(bool isContent)
|
||||
protected virtual Sql GetBase(bool isContentOrMedia)
|
||||
{
|
||||
var columns = new List<object>
|
||||
{
|
||||
"main.id",
|
||||
"main.trashed",
|
||||
"main.parentID",
|
||||
"main.nodeUser",
|
||||
"main.level",
|
||||
"main.path",
|
||||
"main.sortOrder",
|
||||
"main.uniqueID",
|
||||
"main.text",
|
||||
"main.nodeObjectType",
|
||||
"main.createDate",
|
||||
"umbracoNode.id",
|
||||
"umbracoNode.trashed",
|
||||
"umbracoNode.parentID",
|
||||
"umbracoNode.nodeUser",
|
||||
"umbracoNode.level",
|
||||
"umbracoNode.path",
|
||||
"umbracoNode.sortOrder",
|
||||
"umbracoNode.uniqueID",
|
||||
"umbracoNode.text",
|
||||
"umbracoNode.nodeObjectType",
|
||||
"umbracoNode.createDate",
|
||||
"COUNT(parent.parentID) as children"
|
||||
};
|
||||
|
||||
if (isContent)
|
||||
if (isContentOrMedia)
|
||||
{
|
||||
columns.Add("published.versionId as publishedVerison");
|
||||
columns.Add("latest.versionId as newestVersion");
|
||||
columns.Add("contenttype.alias");
|
||||
columns.Add("contenttype.icon");
|
||||
columns.Add("contenttype.thumbnail");
|
||||
columns.Add("property.dataNvarchar as umbracoFile");
|
||||
}
|
||||
|
||||
var sql = new Sql()
|
||||
.Select(columns.ToArray())
|
||||
.From("umbracoNode main")
|
||||
.LeftJoin("umbracoNode parent").On("parent.parentID = main.id");
|
||||
.From("umbracoNode umbracoNode")
|
||||
.LeftJoin("umbracoNode parent").On("parent.parentID = umbracoNode.id");
|
||||
|
||||
|
||||
if (isContent)
|
||||
if (isContentOrMedia)
|
||||
{
|
||||
sql.LeftJoin("(SELECT nodeId, versionId FROM cmsDocument WHERE published = 1 GROUP BY nodeId, versionId) as published").On("main.id = published.nodeId");
|
||||
sql.LeftJoin("(SELECT nodeId, versionId FROM cmsDocument WHERE newest = 1 GROUP BY nodeId, versionId) as latest").On("main.id = latest.nodeId");
|
||||
sql.InnerJoin("cmsContent content").On("content.nodeId = umbracoNode.id")
|
||||
.LeftJoin("cmsContentType contenttype").On("contenttype.nodeId = content.contentType")
|
||||
.LeftJoin(
|
||||
"(SELECT nodeId, versionId FROM cmsDocument WHERE published = 1 GROUP BY nodeId, versionId) as published")
|
||||
.On("umbracoNode.id = published.nodeId")
|
||||
.LeftJoin(
|
||||
"(SELECT nodeId, versionId FROM cmsDocument WHERE newest = 1 GROUP BY nodeId, versionId) as latest")
|
||||
.On("umbracoNode.id = latest.nodeId")
|
||||
.LeftJoin(
|
||||
"(SELECT contentNodeId, dataNvarchar FROM cmsPropertyData INNER JOIN cmsPropertyType ON cmsPropertyType.id = cmsPropertyData.propertytypeid"+
|
||||
" INNER JOIN cmsDataType ON cmsPropertyType.dataTypeId = cmsDataType.nodeId WHERE cmsDataType.controlId = '"+ Constants.PropertyEditors.UploadField +"') as property")
|
||||
.On("umbracoNode.id = property.contentNodeId");
|
||||
}
|
||||
|
||||
return sql;
|
||||
}
|
||||
|
||||
protected virtual Sql GetBaseWhere(Func<bool, Sql> baseQuery, bool isContent, Guid id)
|
||||
protected virtual Sql GetBaseWhere(Func<bool, Sql> baseQuery, bool isContentOrMedia, Guid id)
|
||||
{
|
||||
var sql = baseQuery(isContent)
|
||||
.Where("main.nodeObjectType = @NodeObjectType", new {NodeObjectType = id});
|
||||
var sql = baseQuery(isContentOrMedia)
|
||||
.Where("umbracoNode.nodeObjectType = @NodeObjectType", new { NodeObjectType = id });
|
||||
return sql;
|
||||
}
|
||||
|
||||
protected virtual Sql GetBaseWhere(Func<bool, Sql> baseQuery, bool isContent, int id)
|
||||
protected virtual Sql GetBaseWhere(Func<bool, Sql> baseQuery, bool isContentOrMedia, int id)
|
||||
{
|
||||
var sql = baseQuery(isContent)
|
||||
.Where("main.id = @Id", new {Id = id})
|
||||
.Append(GetGroupBy(isContent));
|
||||
var sql = baseQuery(isContentOrMedia)
|
||||
.Where("umbracoNode.id = @Id", new { Id = id })
|
||||
.Append(GetGroupBy(isContentOrMedia));
|
||||
return sql;
|
||||
}
|
||||
|
||||
protected virtual Sql GetBaseWhere(Func<bool, Sql> baseQuery, bool isContent, Guid objectId, int id)
|
||||
protected virtual Sql GetBaseWhere(Func<bool, Sql> baseQuery, bool isContentOrMedia, Guid objectId, int id)
|
||||
{
|
||||
var sql = baseQuery(isContent)
|
||||
.Where("main.id = @Id AND main.nodeObjectType = @NodeObjectType",
|
||||
var sql = baseQuery(isContentOrMedia)
|
||||
.Where("umbracoNode.id = @Id AND umbracoNode.nodeObjectType = @NodeObjectType",
|
||||
new {Id = id, NodeObjectType = objectId});
|
||||
return sql;
|
||||
}
|
||||
|
||||
protected virtual Sql GetGroupBy(bool isContent)
|
||||
protected virtual Sql GetGroupBy(bool isContentOrMedia)
|
||||
{
|
||||
var columns = new List<object>
|
||||
{
|
||||
"main.id",
|
||||
"main.trashed",
|
||||
"main.parentID",
|
||||
"main.nodeUser",
|
||||
"main.level",
|
||||
"main.path",
|
||||
"main.sortOrder",
|
||||
"main.uniqueID",
|
||||
"main.text",
|
||||
"main.nodeObjectType",
|
||||
"main.createDate"
|
||||
"umbracoNode.id",
|
||||
"umbracoNode.trashed",
|
||||
"umbracoNode.parentID",
|
||||
"umbracoNode.nodeUser",
|
||||
"umbracoNode.level",
|
||||
"umbracoNode.path",
|
||||
"umbracoNode.sortOrder",
|
||||
"umbracoNode.uniqueID",
|
||||
"umbracoNode.text",
|
||||
"umbracoNode.nodeObjectType",
|
||||
"umbracoNode.createDate"
|
||||
};
|
||||
|
||||
if (isContent)
|
||||
if (isContentOrMedia)
|
||||
{
|
||||
columns.Add("published.versionId");
|
||||
columns.Add("latest.versionId");
|
||||
columns.Add("contenttype.alias");
|
||||
columns.Add("contenttype.icon");
|
||||
columns.Add("contenttype.thumbnail");
|
||||
columns.Add("property.dataNvarchar");
|
||||
}
|
||||
|
||||
var sql = new Sql()
|
||||
.GroupBy(columns.ToArray())
|
||||
.OrderBy("main.sortOrder");
|
||||
.OrderBy("umbracoNode.sortOrder");
|
||||
return sql;
|
||||
}
|
||||
|
||||
@@ -246,6 +264,18 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
|
||||
[Column("newestVerison")]
|
||||
public Guid NewestVersion { get; set; }
|
||||
|
||||
[Column("alias")]
|
||||
public string Alias { get; set; }
|
||||
|
||||
[Column("icon")]
|
||||
public string Icon { get; set; }
|
||||
|
||||
[Column("thumbnail")]
|
||||
public string Thumbnail { get; set; }
|
||||
|
||||
[Column("umbracoFile")]
|
||||
public string UmbracoFile { get; set; }
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -164,13 +164,13 @@ namespace Umbraco.Core.Services
|
||||
/// <summary>
|
||||
/// Gets a collection of children by the parents Id
|
||||
/// </summary>
|
||||
/// <param name="id">Id of the parent to retrieve children for</param>
|
||||
/// <param name="parentId">Id of the parent to retrieve children for</param>
|
||||
/// <returns>An enumerable list of <see cref="IUmbracoEntity"/> objects</returns>
|
||||
public virtual IEnumerable<IUmbracoEntity> GetChildren(int id)
|
||||
public virtual IEnumerable<IUmbracoEntity> GetChildren(int parentId)
|
||||
{
|
||||
using (var repository = _repositoryFactory.CreateEntityRepository(_uowProvider.GetUnitOfWork()))
|
||||
{
|
||||
var query = Query<IUmbracoEntity>.Builder.Where(x => x.ParentId == id);
|
||||
var query = Query<IUmbracoEntity>.Builder.Where(x => x.ParentId == parentId);
|
||||
var contents = repository.GetByQuery(query);
|
||||
|
||||
return contents;
|
||||
@@ -180,15 +180,15 @@ namespace Umbraco.Core.Services
|
||||
/// <summary>
|
||||
/// Gets a collection of children by the parents Id and UmbracoObjectType
|
||||
/// </summary>
|
||||
/// <param name="id">Id of the parent to retrieve children for</param>
|
||||
/// <param name="parentId">Id of the parent to retrieve children for</param>
|
||||
/// <param name="umbracoObjectType">UmbracoObjectType of the children to retrieve</param>
|
||||
/// <returns>An enumerable list of <see cref="IUmbracoEntity"/> objects</returns>
|
||||
public virtual IEnumerable<IUmbracoEntity> GetChildren(int id, UmbracoObjectTypes umbracoObjectType)
|
||||
public virtual IEnumerable<IUmbracoEntity> GetChildren(int parentId, UmbracoObjectTypes umbracoObjectType)
|
||||
{
|
||||
var objectTypeId = umbracoObjectType.GetGuid();
|
||||
using (var repository = _repositoryFactory.CreateEntityRepository(_uowProvider.GetUnitOfWork()))
|
||||
{
|
||||
var query = Query<IUmbracoEntity>.Builder.Where(x => x.ParentId == id);
|
||||
var query = Query<IUmbracoEntity>.Builder.Where(x => x.ParentId == parentId);
|
||||
var contents = repository.GetByQuery(query, objectTypeId);
|
||||
|
||||
return contents;
|
||||
|
||||
@@ -209,7 +209,7 @@ namespace Umbraco.Core.Services
|
||||
_importedContentTypes = new Dictionary<string, IContentType>();
|
||||
var documentTypes = name.Equals("DocumentTypes")
|
||||
? (from doc in element.Elements("DocumentType") select doc).ToList()
|
||||
: new List<XElement> {element.Element("DocumentType")};
|
||||
: new List<XElement> {element};
|
||||
//NOTE it might be an idea to sort the doctype XElements based on dependencies
|
||||
//before creating the doc types - should also allow for a better structure/inheritance support.
|
||||
foreach (var documentType in documentTypes)
|
||||
@@ -580,8 +580,19 @@ namespace Umbraco.Core.Services
|
||||
foreach (XElement tempElement in templateElements)
|
||||
{
|
||||
var dependencies = new List<string>();
|
||||
if(tempElement.Element("Master") != null && string.IsNullOrEmpty(tempElement.Element("Master").Value) == false)
|
||||
if (tempElement.Element("Master") != null &&
|
||||
string.IsNullOrEmpty(tempElement.Element("Master").Value) == false &&
|
||||
templateElements.Any(x => x.Element("Alias").Value == tempElement.Element("Master").Value))
|
||||
{
|
||||
dependencies.Add(tempElement.Element("Master").Value);
|
||||
}
|
||||
else if (tempElement.Element("Master") != null &&
|
||||
string.IsNullOrEmpty(tempElement.Element("Master").Value) == false &&
|
||||
templateElements.Any(x => x.Element("Alias").Value == tempElement.Element("Master").Value) ==
|
||||
false)
|
||||
{
|
||||
LogHelper.Info<PackagingService>(string.Format("Template '{0}' has an invalid Master '{1}', so the reference has been ignored.", tempElement.Element("Alias").Value, tempElement.Element("Master").Value));
|
||||
}
|
||||
|
||||
var field = new TopologicalSorter.DependencyField<XElement>
|
||||
{
|
||||
|
||||
@@ -139,9 +139,15 @@ namespace Umbraco.Core
|
||||
{
|
||||
if (fields[i].DependsOn != null)
|
||||
{
|
||||
foreach (string t in fields[i].DependsOn.Where(t => indexes.ContainsKey(t.ToLowerInvariant())))
|
||||
for (int j = 0; j < fields[i].DependsOn.Length; j++)
|
||||
{
|
||||
g.AddEdge(i,indexes[t.ToLowerInvariant()]);
|
||||
if (indexes.ContainsKey(fields[i].DependsOn[j].ToLowerInvariant()) == false)
|
||||
throw new IndexOutOfRangeException(
|
||||
string.Format(
|
||||
"The alias '{0}' has an invalid dependency. The dependency '{1}' does not exist in the list of aliases",
|
||||
fields[i], fields[i].DependsOn[j]));
|
||||
|
||||
g.AddEdge(i, indexes[fields[i].DependsOn[j].ToLowerInvariant()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,6 +164,7 @@
|
||||
<Compile Include="Enum.cs" />
|
||||
<Compile Include="Events\MacroErrorEventArgs.cs" />
|
||||
<Compile Include="HashCodeCombiner.cs" />
|
||||
<Compile Include="IconPickerBehaviour.cs" />
|
||||
<Compile Include="IO\FileSystemWrapper.cs" />
|
||||
<Compile Include="MacroErrorBehaviour.cs" />
|
||||
<Compile Include="Media\IImageUrlProvider.cs" />
|
||||
|
||||
@@ -81,10 +81,10 @@ namespace Umbraco.Tests.CoreStrings
|
||||
}
|
||||
|
||||
#region Cases
|
||||
[TestCase("Home Page", "Home-Page")]
|
||||
[TestCase("Shannon's Home Page!", "Shannons-Home-Page!")]
|
||||
[TestCase("#Someones's Twitter $h1z%n", "Someoness-Twitter-$h1zn")]
|
||||
[TestCase("Räksmörgås", "Raeksmoergaas")]
|
||||
[TestCase("Home Page", "home-page")]
|
||||
[TestCase("Shannon's Home Page!", "shannons-home-page!")]
|
||||
[TestCase("#Someones's Twitter $h1z%n", "someoness-twitter-$h1zn")]
|
||||
[TestCase("Räksmörgås", "raeksmoergaas")]
|
||||
[TestCase("'em guys-over there, are#goin' a \"little\"bit crazy eh!! :)", "em-guys-over-there,-aregoin-a-littlebit-crazy-eh!!-)")]
|
||||
[TestCase("汉#字*/漢?字", "汉字star漢字")]
|
||||
[TestCase("Réalösk fix bran#lo'sk", "realosk-fix-bran-lo-sk", IgnoreReason = "cannot handle it")]
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.TestHelpers.Entities;
|
||||
using umbraco.editorControls.tinyMCE3;
|
||||
using umbraco.interfaces;
|
||||
|
||||
namespace Umbraco.Tests.Services
|
||||
{
|
||||
@@ -26,7 +23,7 @@ namespace Umbraco.Tests.Services
|
||||
base.TearDown();
|
||||
}
|
||||
|
||||
public void CreateTestData()
|
||||
public virtual void CreateTestData()
|
||||
{
|
||||
//NOTE Maybe not the best way to create/save test data as we are using the services, which are being tested.
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Tests.TestHelpers.Entities;
|
||||
|
||||
namespace Umbraco.Tests.Services
|
||||
{
|
||||
@@ -61,6 +62,18 @@ namespace Umbraco.Tests.Services
|
||||
Assert.That(entities.Any(x => x.Trashed), Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EntityService_Can_Get_Child_Content_By_ParentId_And_UmbracoObjectType()
|
||||
{
|
||||
var service = ServiceContext.EntityService;
|
||||
|
||||
var entities = service.GetChildren(-1, UmbracoObjectTypes.Document);
|
||||
|
||||
Assert.That(entities.Any(), Is.True);
|
||||
Assert.That(entities.Count(), Is.EqualTo(1));
|
||||
Assert.That(entities.Any(x => x.Trashed), Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EntityService_Throws_When_Getting_All_With_Invalid_Type()
|
||||
{
|
||||
@@ -105,5 +118,37 @@ namespace Umbraco.Tests.Services
|
||||
Assert.That(entities.Any(), Is.True);
|
||||
Assert.That(entities.Count(), Is.EqualTo(1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EntityService_Can_Find_All_Media_By_UmbracoObjectTypes()
|
||||
{
|
||||
var service = ServiceContext.EntityService;
|
||||
|
||||
var entities = service.GetAll(UmbracoObjectTypes.Media);
|
||||
|
||||
Assert.That(entities.Any(), Is.True);
|
||||
Assert.That(entities.Count(), Is.EqualTo(3));
|
||||
Assert.That(entities.Any(x => ((UmbracoEntity)x).UmbracoFile != string.Empty), Is.True);
|
||||
}
|
||||
|
||||
public override void CreateTestData()
|
||||
{
|
||||
base.CreateTestData();
|
||||
|
||||
//Create and Save folder-Media -> 1050
|
||||
var folderMediaType = ServiceContext.ContentTypeService.GetMediaType(1031);
|
||||
var folder = MockedMedia.CreateMediaFolder(folderMediaType, -1);
|
||||
ServiceContext.MediaService.Save(folder, 0);
|
||||
|
||||
//Create and Save image-Media -> 1051
|
||||
var imageMediaType = ServiceContext.ContentTypeService.GetMediaType(1032);
|
||||
var image = MockedMedia.CreateMediaImage(imageMediaType, folder.Id);
|
||||
ServiceContext.MediaService.Save(image, 0);
|
||||
|
||||
//Create and Save file-Media -> 1052
|
||||
var fileMediaType = ServiceContext.ContentTypeService.GetMediaType(1033);
|
||||
var file = MockedMedia.CreateMediaFile(fileMediaType, folder.Id);
|
||||
ServiceContext.MediaService.Save(file, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -136,5 +136,32 @@ namespace Umbraco.Tests.Services.Importing {
|
||||
return ResourceManager.GetString("uBlogsy_Package", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to <?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
///<umbPackage>
|
||||
/// <files>
|
||||
/// <file>
|
||||
/// <guid>XSLTsearch.xslt</guid>
|
||||
/// <orgPath>/xslt</orgPath>
|
||||
/// <orgName>XSLTsearch.xslt</orgName>
|
||||
/// </file>
|
||||
/// <file>
|
||||
/// <guid>XSLTsearch.cs</guid>
|
||||
/// <orgPath>/App_Code</orgPath>
|
||||
/// <orgName>XSLTsearch.cs</orgName>
|
||||
/// </file>
|
||||
/// </files>
|
||||
/// <info>
|
||||
/// <package>
|
||||
/// <name>XSLTsearch</name>
|
||||
/// <version>3.0.4</version>
|
||||
/// <license url="http://www.opensource.org/licenses/mit-li [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string XsltSearch_Package {
|
||||
get {
|
||||
return ResourceManager.GetString("XsltSearch_Package", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,4 +127,7 @@
|
||||
<data name="uBlogsy_Package" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>ublogsy-package.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
|
||||
</data>
|
||||
<data name="XsltSearch_Package" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>xsltsearch-package.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -188,5 +188,23 @@ namespace Umbraco.Tests.Services.Importing
|
||||
Assert.That(contents.Any(), Is.True);
|
||||
Assert.That(contents.Count(), Is.EqualTo(numberOfDocs));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PackagingService_Can_Import_Templates_Package_Xml_With_Invalid_Master()
|
||||
{
|
||||
// Arrange
|
||||
string strXml = ImportResources.XsltSearch_Package;
|
||||
var xml = XElement.Parse(strXml);
|
||||
var templateElement = xml.Descendants("Templates").First();
|
||||
var packagingService = ServiceContext.PackagingService;
|
||||
|
||||
// Act
|
||||
var templates = packagingService.ImportTemplates(templateElement);
|
||||
var numberOfTemplates = (from doc in templateElement.Elements("Template") select doc).Count();
|
||||
|
||||
// Assert
|
||||
Assert.That(templates.Any(), Is.True);
|
||||
Assert.That(templates.Count(), Is.EqualTo(numberOfTemplates));
|
||||
}
|
||||
}
|
||||
}
|
||||
254
src/Umbraco.Tests/Services/Importing/XsltSearch-Package.xml
Normal file
254
src/Umbraco.Tests/Services/Importing/XsltSearch-Package.xml
Normal file
@@ -0,0 +1,254 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<umbPackage>
|
||||
<files>
|
||||
<file>
|
||||
<guid>XSLTsearch.xslt</guid>
|
||||
<orgPath>/xslt</orgPath>
|
||||
<orgName>XSLTsearch.xslt</orgName>
|
||||
</file>
|
||||
<file>
|
||||
<guid>XSLTsearch.cs</guid>
|
||||
<orgPath>/App_Code</orgPath>
|
||||
<orgName>XSLTsearch.cs</orgName>
|
||||
</file>
|
||||
</files>
|
||||
<info>
|
||||
<package>
|
||||
<name>XSLTsearch</name>
|
||||
<version>3.0.4</version>
|
||||
<license url="http://www.opensource.org/licenses/mit-license.php">MIT license</license>
|
||||
<url>http://www.percipientstudios.com</url>
|
||||
<requirements>
|
||||
<major>3</major>
|
||||
<minor>0</minor>
|
||||
<patch>0</patch>
|
||||
</requirements>
|
||||
</package>
|
||||
<author>
|
||||
<name>Percipient Studios</name>
|
||||
<website>http://www.percipientstudios.com</website>
|
||||
</author>
|
||||
<readme>
|
||||
<![CDATA[XSLTsearch is the easy search solution for Umbraco web sites with up to a few thousand pages. It is fast, completely self-contained, and extremely configurable.
|
||||
|
||||
With XSLTsearch you can search for all words and phrases in all document properties and attributes, including your custom properties. Search results are automatically sorted by relevance with search terms highlighted in the results.
|
||||
|
||||
XSLTsearch installs in all Umbraco sites.
|
||||
|
||||
New in 3.0:
|
||||
- Multi-lingual support with dictionary items
|
||||
- Medium trust support (helper functions now in /app_code/xsltsearch.cs)
|
||||
- Many bug fixes
|
||||
|
||||
Version 3.0.1
|
||||
- For umbraco 4.5+ and new XML schema
|
||||
- Fixed xslt error when a previewed field had fewer than six characters
|
||||
- Changed default behavior to only search within current site if source node id is not specified (better for multiple sites in one installation)
|
||||
- Multi-site searching made easier. Now searches only within the current site if the source= parameter is not specified (better for multiple sites in one installation)
|
||||
|
||||
Version 3.0.2
|
||||
- Fixed issue of PreviewMode="CONTEXT" in which the search term would not be highlighted if it were the last word in the content being searched
|
||||
|
||||
Version 3.0.3
|
||||
- Removed extraneous whitespace and empty quotes from search term
|
||||
|
||||
Version 3.0.4
|
||||
- Additional fix for PreviewMode="CONTEXT" in which the search term would not be displayed if it were the last word in the content being search and the search term were more than $maxChars from the beginning of the search field
|
||||
- Removed errant 'xmp' debug statement that appeared in v3.0.3
|
||||
]]>
|
||||
</readme>
|
||||
</info>
|
||||
<Documents>
|
||||
<DocumentSet importMode="root">
|
||||
<XSLTsearch id="1090" parentID="-1" level="1" writerID="0" creatorID="0" nodeType="1087" template="1086" sortOrder="39" createDate="2010-11-09T13:45:22" updateDate="2010-11-09T14:18:04" nodeName="Search" urlName="search" writerName="Administrator" creatorName="Administrator" path="-1,1090" isDoc="">
|
||||
<umbracoNaviHide>0</umbracoNaviHide>
|
||||
</XSLTsearch>
|
||||
</DocumentSet>
|
||||
</Documents>
|
||||
<DocumentTypes>
|
||||
<DocumentType>
|
||||
<Info>
|
||||
<Name>XSLTsearch</Name>
|
||||
<Alias>XSLTsearch</Alias>
|
||||
<Icon>.sprTreeDoc2</Icon>
|
||||
<Thumbnail>doc.png</Thumbnail>
|
||||
<Description>
|
||||
XSLTsearch page.
|
||||
(adjust settings via the macro in the XSLTsearch template)
|
||||
</Description>
|
||||
<AllowedTemplates>
|
||||
<Template>XSLTsearch</Template>
|
||||
</AllowedTemplates>
|
||||
<DefaultTemplate>XSLTsearch</DefaultTemplate>
|
||||
</Info>
|
||||
<Structure />
|
||||
<GenericProperties>
|
||||
<GenericProperty>
|
||||
<Name>Hide in navigation</Name>
|
||||
<Alias>umbracoNaviHide</Alias>
|
||||
<Type>38b352c1-e9f8-4fd8-9324-9a2eab06d97a</Type>
|
||||
<Definition>92897bc6-a5f3-4ffe-ae27-f2e7e33dda49</Definition>
|
||||
<Tab>
|
||||
</Tab>
|
||||
<Mandatory>False</Mandatory>
|
||||
<Validation>
|
||||
</Validation>
|
||||
<Description><![CDATA[]]></Description>
|
||||
</GenericProperty>
|
||||
</GenericProperties>
|
||||
<Tabs />
|
||||
</DocumentType>
|
||||
</DocumentTypes>
|
||||
<Templates>
|
||||
<Template>
|
||||
<Name>XSLTsearch</Name>
|
||||
<Alias>XSLTsearch</Alias>
|
||||
<Master>RunwayMaster</Master>
|
||||
<Design>
|
||||
<![CDATA[<%@ Master Language="C#" MasterPageFile="~/masterpages/RunwayMaster.master" AutoEventWireup="true" %>
|
||||
|
||||
|
||||
<asp:Content ContentPlaceHolderId="RunwayMasterContentPlaceHolder" runat="server">
|
||||
<div id="content">
|
||||
<div id="contentHeader">
|
||||
<h2><umbraco:Item runat="server" field="pageName"/></h2>
|
||||
</div>
|
||||
|
||||
<umbraco:Macro runat="server" Alias="XSLTsearch"
|
||||
macroAlias="XSLTsearch"
|
||||
source="-1"
|
||||
searchFields="@nodeName,metaKeywords,metaDescription,bodyText"
|
||||
previewFields="bodyText,metaDescription"
|
||||
previewType="beginning"
|
||||
searchBoxLocation="bottom"
|
||||
resultsPerPage="5"
|
||||
previewChars="255"
|
||||
showPageRange="0"
|
||||
showOrdinals="0"
|
||||
showScores="0"
|
||||
showStats="1">
|
||||
</umbraco:Macro>
|
||||
|
||||
</div>
|
||||
</asp:Content>]]>
|
||||
</Design>
|
||||
</Template>
|
||||
</Templates>
|
||||
<Stylesheets>
|
||||
<Stylesheet>
|
||||
<Name>XSLTsearch</Name>
|
||||
<FileName>
|
||||
</FileName>
|
||||
<Content>
|
||||
<![CDATA[#xsltsearch {margin: 0; padding-bottom: 20px;}
|
||||
#xsltsearch_navigation {text-align: center;}
|
||||
#xsltsearch_navigation .disabled {color: #AAA;}
|
||||
#xsltsearch_stats {font-size: 75%; color: #999;}
|
||||
#xsltsearch_results {padding-bottom: 20px;}
|
||||
#xsltsearch h2 {font-size: 150%;}
|
||||
.xsltsearch_result p {margin: 0; padding: 0;}
|
||||
.xsltsearch_result:hover {background: #fafafa;}
|
||||
.xsltsearch_ordinal {font-weight: bold; font-size: 75%;}
|
||||
.xsltsearch_title {font-weight: bold;}
|
||||
.xsltsearch_score {font-size: 75%;}
|
||||
p.xsltsearch_result_description {padding-bottom: 10px;}
|
||||
.xsltsearch_description strong {background: #FFD;} /* highlighting */
|
||||
]]>
|
||||
</Content>
|
||||
</Stylesheet>
|
||||
</Stylesheets>
|
||||
<Macros>
|
||||
<macro>
|
||||
<name>XSLTsearch</name>
|
||||
<alias>XSLTsearch</alias>
|
||||
<scriptType>
|
||||
</scriptType>
|
||||
<scriptAssembly>
|
||||
</scriptAssembly>
|
||||
<xslt>XSLTsearch.xslt</xslt>
|
||||
<useInEditor>False</useInEditor>
|
||||
<refreshRate>0</refreshRate>
|
||||
<scriptingFile>
|
||||
</scriptingFile>
|
||||
<properties>
|
||||
<property name="Source" alias="source" show="True" propertyType="contentTree" />
|
||||
<property name="Umbraco fields to search" alias="searchFields" show="True" propertyType="text" />
|
||||
<property name="Umbraco fields shown in results preview" alias="previewFields" show="True" propertyType="text" />
|
||||
<property name="Display search box at TOP, BOTTOM, BOTH, or NONE" alias="searchBoxLocation" show="True" propertyType="text" />
|
||||
<property name="Display BEGINNING or CONTEXT of each result" alias="previewType" show="True" propertyType="text" />
|
||||
<property name="Number of search results to display per page" alias="resultsPerPage" show="True" propertyType="number" />
|
||||
<property name="Number of characters of preview text to display" alias="previewChars" show="True" propertyType="number" />
|
||||
<property name="Display 'Showing result X to Y'?" alias="showPageRange" show="True" propertyType="bool" />
|
||||
<property name="Display numbers before each result?" alias="showOrdinals" show="True" propertyType="bool" />
|
||||
<property name="Display search score for each result?" alias="showScores" show="True" propertyType="bool" />
|
||||
<property name="Display 'Searched X documents in Y seconds'?" alias="showStats" show="True" propertyType="bool" />
|
||||
</properties>
|
||||
</macro>
|
||||
</Macros>
|
||||
<DictionaryItems>
|
||||
<DictionaryItem Key="XSLTsearch">
|
||||
<Value LanguageId="1" LanguageCultureAlias="en-US"><![CDATA[]]></Value>
|
||||
<DictionaryItem Key="[XSLTsearch]Button-Search">
|
||||
<Value LanguageId="1" LanguageCultureAlias="en-US"><![CDATA[Search]]></Value>
|
||||
</DictionaryItem>
|
||||
<DictionaryItem Key="[XSLTsearch]Description-Context">
|
||||
<Value LanguageId="1" LanguageCultureAlias="en-US"><![CDATA[Context]]></Value>
|
||||
</DictionaryItem>
|
||||
<DictionaryItem Key="[XSLTsearch]Description-ContextUnavailable">
|
||||
<Value LanguageId="1" LanguageCultureAlias="en-US"><![CDATA[unavailable]]></Value>
|
||||
</DictionaryItem>
|
||||
<DictionaryItem Key="[XSLTsearch]Heading-SearchResults">
|
||||
<Value LanguageId="1" LanguageCultureAlias="en-US"><![CDATA[Search Results]]></Value>
|
||||
</DictionaryItem>
|
||||
<DictionaryItem Key="[XSLTsearch]Navigation-Next">
|
||||
<Value LanguageId="1" LanguageCultureAlias="en-US"><![CDATA[Next]]></Value>
|
||||
</DictionaryItem>
|
||||
<DictionaryItem Key="[XSLTsearch]Navigation-Previous">
|
||||
<Value LanguageId="1" LanguageCultureAlias="en-US"><![CDATA[Previous]]></Value>
|
||||
</DictionaryItem>
|
||||
<DictionaryItem Key="[XSLTsearch]PageRange-ShowingResults">
|
||||
<Value LanguageId="1" LanguageCultureAlias="en-US"><![CDATA[Showing results]]></Value>
|
||||
</DictionaryItem>
|
||||
<DictionaryItem Key="[XSLTsearch]PageRange-To">
|
||||
<Value LanguageId="1" LanguageCultureAlias="en-US"><![CDATA[to]]></Value>
|
||||
</DictionaryItem>
|
||||
<DictionaryItem Key="[XSLTsearch]Score-Score">
|
||||
<Value LanguageId="1" LanguageCultureAlias="en-US"><![CDATA[score]]></Value>
|
||||
</DictionaryItem>
|
||||
<DictionaryItem Key="[XSLTsearch]Stats-PagesIn">
|
||||
<Value LanguageId="1" LanguageCultureAlias="en-US"><![CDATA[pages in]]></Value>
|
||||
</DictionaryItem>
|
||||
<DictionaryItem Key="[XSLTsearch]Stats-Searched">
|
||||
<Value LanguageId="1" LanguageCultureAlias="en-US"><![CDATA[Searched]]></Value>
|
||||
</DictionaryItem>
|
||||
<DictionaryItem Key="[XSLTsearch]Stats-Seconds">
|
||||
<Value LanguageId="1" LanguageCultureAlias="en-US"><![CDATA[seconds]]></Value>
|
||||
</DictionaryItem>
|
||||
<DictionaryItem Key="[XSLTsearch]Summary-Matches">
|
||||
<Value LanguageId="1" LanguageCultureAlias="en-US"><![CDATA[matches]]></Value>
|
||||
</DictionaryItem>
|
||||
<DictionaryItem Key="[XSLTsearch]Summary-NoMatchesWereFoundFor">
|
||||
<Value LanguageId="1" LanguageCultureAlias="en-US"><![CDATA[No matches were found for]]></Value>
|
||||
</DictionaryItem>
|
||||
<DictionaryItem Key="[XSLTsearch]Summary-Page">
|
||||
<Value LanguageId="1" LanguageCultureAlias="en-US"><![CDATA[page]]></Value>
|
||||
</DictionaryItem>
|
||||
<DictionaryItem Key="[XSLTsearch]Summary-Pages">
|
||||
<Value LanguageId="1" LanguageCultureAlias="en-US"><![CDATA[pages]]></Value>
|
||||
</DictionaryItem>
|
||||
<DictionaryItem Key="[XSLTsearch]Summary-YourSearchFor">
|
||||
<Value LanguageId="1" LanguageCultureAlias="en-US"><![CDATA[Your search for]]></Value>
|
||||
</DictionaryItem>
|
||||
</DictionaryItem>
|
||||
</DictionaryItems>
|
||||
<Languages>
|
||||
<Language Id="2" CultureAlias="en-US" FriendlyName="English (United States)" />
|
||||
</Languages>
|
||||
<DataTypes />
|
||||
<Actions>
|
||||
<Action runat="install" alias="addStringToHtmlElement" templateAlias="RunwayMaster" htmlElementId="head" position="end"><![CDATA[ <link rel="stylesheet" type="text/css" href="/css/XSLTsearch.css" />]]></Action>
|
||||
<Action runat="install" alias="publishRootDocument" documentName="Search" />
|
||||
<Action runat="install" alias="allowDocumenttype" documentTypeAlias="XSLTsearch" parentDocumentTypeAlias="RunwayHomepage" />
|
||||
<Action runat="install" alias="moveRootDocument" documentName="Search" parentDocumentType="RunwayHomepage" />
|
||||
</Actions>
|
||||
</umbPackage>
|
||||
@@ -494,6 +494,7 @@
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<Content Include="Services\Importing\uBlogsy-Package.xml" />
|
||||
<Content Include="Services\Importing\XsltSearch-Package.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
||||
@@ -378,6 +378,13 @@
|
||||
<DependentUpon>Title.ascx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Umbraco\Create.aspx.cs">
|
||||
<DependentUpon>create.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Umbraco\Create.aspx.designer.cs">
|
||||
<DependentUpon>create.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Umbraco\Create\PartialViewMacro.ascx.cs">
|
||||
<DependentUpon>PartialViewMacro.ascx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
@@ -552,6 +559,7 @@
|
||||
<Content Include="Umbraco\Config\Lang\ru.xml" />
|
||||
<Content Include="Umbraco\Config\Lang\zh.xml" />
|
||||
<Content Include="Umbraco\Controls\Tree\CustomTreeService.asmx" />
|
||||
<Content Include="Umbraco\create.aspx" />
|
||||
<Content Include="Umbraco\Create\PartialViewMacro.ascx" />
|
||||
<Content Include="Umbraco\Dashboard\ExamineManagement.ascx" />
|
||||
<Content Include="Umbraco\Dashboard\Images\access-denied.png" />
|
||||
@@ -2041,7 +2049,6 @@
|
||||
<Content Include="Umbraco\Translation\default.aspx" />
|
||||
<Content Include="Umbraco\Translation\preview.aspx" />
|
||||
<Content Include="Umbraco\Translation\xml.aspx" />
|
||||
<Content Include="Umbraco\create.aspx" />
|
||||
<Content Include="Umbraco\Create\content.ascx" />
|
||||
<Content Include="Umbraco\Create\language.ascx">
|
||||
<SubType>UserControl</SubType>
|
||||
|
||||
@@ -94,6 +94,20 @@
|
||||
error handler is defined then you'll see the Yellow Screen Of Death (YSOD) error page.
|
||||
Note the error can also be handled by the umbraco.macro.Error event, where you can log/alarm with your own code and change the behaviour per event. -->
|
||||
<MacroErrors>inline</MacroErrors>
|
||||
|
||||
<!-- How Umbraco should show icons in the document type editor. Historically, the list has included all the files in
|
||||
/Umbraco/Images/Umbraco plus a CSS sprite defined in Umbraco_Client/Tree/treeIcons.css, unfortunately these
|
||||
contain many duplicates. The DocumentTypeIconList setting allows you to favor one list over the other.
|
||||
|
||||
Can be one of the following values:
|
||||
- ShowDuplicates - Show duplicates in files and sprites. Historial Umbraco behaviour.
|
||||
- HideSpriteDuplicates - If a file exists on disk with the same name as one in the sprite
|
||||
then the file on disk overrules the one in the sprite, the
|
||||
sprite icon will not be shown
|
||||
- HideFileDuplicates - If a file exists on disk with the same name as one in the sprite
|
||||
then the file in the sprite overrules the one on disk, the file
|
||||
on disk will be shown (recommended) -->
|
||||
<DocumentTypeIconList>ShowDuplicates</DocumentTypeIconList>
|
||||
</content>
|
||||
|
||||
<security>
|
||||
|
||||
@@ -88,6 +88,20 @@
|
||||
error handler is defined then you'll see the Yellow Screen Of Death (YSOD) error page.
|
||||
Note the error can also be handled by the umbraco.macro.Error event, where you can log/alarm with your own code and change the behaviour per event. -->
|
||||
<MacroErrors>inline</MacroErrors>
|
||||
|
||||
<!-- How Umbraco should show icons in the document type editor. Historically, the list has included all the files in
|
||||
/Umbraco/Images/Umbraco plus a CSS sprite defined in Umbraco_Client/Tree/treeIcons.css, unfortunately these
|
||||
contain many duplicates. The DocumentTypeIconList setting allows you to favor one list over the other.
|
||||
|
||||
Can be one of the following values:
|
||||
- ShowDuplicates - Show duplicates in files and sprites. Historial Umbraco behaviour.
|
||||
- HideSpriteDuplicates - If a file exists on disk with the same name as one in the sprite
|
||||
then the file on disk overrules the one in the sprite, the
|
||||
sprite icon will not be shown
|
||||
- HideFileDuplicates - If a file exists on disk with the same name as one in the sprite
|
||||
then the file in the sprite overrules the one on disk, the file
|
||||
on disk will be shown (recommended) -->
|
||||
<DocumentTypeIconList>HideFileDuplicates</DocumentTypeIconList>
|
||||
</content>
|
||||
|
||||
<security>
|
||||
|
||||
44
src/Umbraco.Web.UI/umbraco/Create.aspx.cs
Normal file
44
src/Umbraco.Web.UI/umbraco/Create.aspx.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Xml;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.IO;
|
||||
using umbraco.cms.presentation.Trees;
|
||||
|
||||
namespace Umbraco.Web.UI.Umbraco
|
||||
{
|
||||
public partial class CreateDialog : global::umbraco.cms.presentation.Create
|
||||
{
|
||||
|
||||
//protected override void OnLoad(EventArgs e)
|
||||
//{
|
||||
// if (SecurityCheck(Request.QueryString["nodeType"]))
|
||||
// {
|
||||
// //if we're allowed, then continue
|
||||
// base.OnLoad(e);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //otherwise show an error
|
||||
// UI.Visible = false;
|
||||
// AccessError.Visible = true;
|
||||
// }
|
||||
//}
|
||||
|
||||
//private bool SecurityCheck(string treeAlias)
|
||||
//{
|
||||
// var tree = TreeDefinitionCollection.Instance.FindTree(treeAlias);
|
||||
// if (tree != null)
|
||||
// {
|
||||
// //does the current user have access to the current app?
|
||||
// var user = this.getUser();
|
||||
// var userApps = user.Applications;
|
||||
// return userApps.Any(x => x.alias.InvariantEquals(tree.App.alias));
|
||||
// }
|
||||
// return false;
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
25
src/Umbraco.Web.UI/umbraco/Create.aspx.designer.cs
generated
Normal file
25
src/Umbraco.Web.UI/umbraco/Create.aspx.designer.cs
generated
Normal file
@@ -0,0 +1,25 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Umbraco.Web.UI.Umbraco {
|
||||
|
||||
|
||||
public partial class CreateDialog
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// AccessError control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.PlaceHolder AccessError;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<%@ Page Language="c#" MasterPageFile="masterpages/umbracoDialog.Master" Codebehind="create.aspx.cs" AutoEventWireup="True" Inherits="umbraco.cms.presentation.Create" %>
|
||||
<%@ Page Language="c#" MasterPageFile="masterpages/umbracoDialog.Master" Codebehind="CreateDialog.aspx.cs" AutoEventWireup="True" Inherits="Umbraco.Web.UI.Umbraco.CreateDialog" %>
|
||||
|
||||
<%@ Register Namespace="umbraco" TagPrefix="umb" Assembly="umbraco" %>
|
||||
|
||||
@@ -18,6 +18,13 @@
|
||||
|
||||
<asp:Content runat="server" ContentPlaceHolderID="body">
|
||||
<asp:PlaceHolder ID="UI" runat="server"></asp:PlaceHolder>
|
||||
<asp:PlaceHolder runat="server" Visible="False" ID="AccessError">
|
||||
<div class="error">
|
||||
<p>
|
||||
The current user does not have access to create this type of object
|
||||
</p>
|
||||
</div>
|
||||
</asp:PlaceHolder>
|
||||
</asp:Content>
|
||||
|
||||
<asp:Content runat="server" ContentPlaceHolderID="footer">
|
||||
|
||||
@@ -13,7 +13,7 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls");
|
||||
function getHashFragment(frag) {
|
||||
//tests for xss and ensures only the first alphanumeric chars are matched
|
||||
var result = hashFragmentRegex.exec(frag);
|
||||
if (result.length > 0) {
|
||||
if (result != null && result.length > 0) {
|
||||
return result[0];
|
||||
}
|
||||
return "";
|
||||
|
||||
@@ -97,9 +97,8 @@
|
||||
var t = "";
|
||||
var clsName = "";
|
||||
var pH = ""; //addition html
|
||||
if (options.useSprite != false) {
|
||||
|
||||
clsName = ' ' + options.useSprite + ' ' + currentOptOption.className;
|
||||
} else {
|
||||
arrow = $(currentOptOption).prop("title");
|
||||
var reg = new RegExp(/^\{.*\}$/);
|
||||
var isJson = reg.test(arrow);
|
||||
@@ -114,7 +113,7 @@
|
||||
} else {
|
||||
arrow = (arrow.length == 0) ? "" : '<img src="' + arrow + '" align="absmiddle" /> ';
|
||||
};
|
||||
};
|
||||
|
||||
var sText = $(currentOptOption).text();
|
||||
var sValue = $(currentOptOption).val();
|
||||
var sEnabledClass = ($(currentOptOption).prop("disabled") == true) ? "disabled" : "enabled";
|
||||
|
||||
@@ -334,7 +334,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
{
|
||||
if (_previewContent == null)
|
||||
{
|
||||
_previewContent = new PreviewContent(user, new Guid(global::umbraco.BusinessLogic.StateHelper.Cookies.Preview.GetValue()), true);
|
||||
_previewContent = new PreviewContent(user, new Guid(StateHelper.Cookies.Preview.GetValue()), true);
|
||||
if (_previewContent.ValidPreviewSet)
|
||||
_previewContent.LoadPreviewset();
|
||||
}
|
||||
|
||||
@@ -1878,7 +1878,9 @@
|
||||
<Content Include="umbraco.presentation\umbraco\dialogs\AssignDomain.aspx">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Content>
|
||||
<Content Include="umbraco.presentation\umbraco\dialogs\create.aspx" />
|
||||
<Content Include="umbraco.presentation\umbraco\dialogs\create.aspx">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Content>
|
||||
<Content Include="umbraco.presentation\umbraco\dialogs\cruds.aspx" />
|
||||
<Content Include="umbraco.presentation\umbraco\dialogs\emptyTrashcan.aspx" />
|
||||
<Content Include="umbraco.presentation\umbraco\dialogs\exportDocumenttype.aspx" />
|
||||
|
||||
@@ -5,6 +5,7 @@ using Umbraco.Core.Services;
|
||||
using Umbraco.Core.CodeAnnotations;
|
||||
using Umbraco.Web.PublishedCache;
|
||||
using Umbraco.Web.Routing;
|
||||
using Umbraco.Web.Security;
|
||||
using umbraco;
|
||||
using umbraco.IO;
|
||||
using umbraco.presentation;
|
||||
@@ -314,7 +315,7 @@ namespace Umbraco.Web
|
||||
{
|
||||
get
|
||||
{
|
||||
return UmbracoEnsuredPage.CurrentUser;
|
||||
return WebSecurity.CurrentUser;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -335,7 +336,7 @@ namespace Umbraco.Web
|
||||
return
|
||||
StateHelper.Cookies.Preview.HasValue // has preview cookie
|
||||
&& UmbracoUser != null // has user
|
||||
&& !currentUrl.StartsWith(Umbraco.Core.IO.IOHelper.ResolveUrl(Umbraco.Core.IO.SystemDirectories.Umbraco)); // is not in admin UI
|
||||
&& !currentUrl.StartsWith(Core.IO.IOHelper.ResolveUrl(Core.IO.SystemDirectories.Umbraco)); // is not in admin UI
|
||||
}
|
||||
|
||||
private HttpRequestBase GetRequestFromContext()
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Web.Media.ThumbnailProviders;
|
||||
using umbraco.BasePages;
|
||||
using umbraco.BusinessLogic;
|
||||
using umbraco.IO;
|
||||
using umbraco.cms.businesslogic.Tags;
|
||||
using umbraco.cms.businesslogic.media;
|
||||
using Umbraco.Web.BaseRest;
|
||||
|
||||
namespace Umbraco.Web.WebServices
|
||||
@@ -23,7 +21,10 @@ namespace Umbraco.Web.WebServices
|
||||
[RestExtensionMethod(ReturnXml = false)]
|
||||
public static string GetChildren(int parentId)
|
||||
{
|
||||
var parentMedia = new global::umbraco.cms.businesslogic.media.Media(parentId);
|
||||
var service = ApplicationContext.Current.Services.EntityService;
|
||||
var parentMedia = service.Get(parentId, UmbracoObjectTypes.Media);
|
||||
var mediaPath = parentMedia == null ? parentId.ToString(CultureInfo.InvariantCulture) : parentMedia.Path;
|
||||
|
||||
var currentUser = User.GetCurrent();
|
||||
var data = new List<object>();
|
||||
|
||||
@@ -32,32 +33,27 @@ namespace Umbraco.Web.WebServices
|
||||
throw new UnauthorizedAccessException("You must be logged in to use this service");
|
||||
|
||||
// Check user is allowed to access selected media item
|
||||
if(!("," + parentMedia.Path + ",").Contains("," + currentUser.StartMediaId + ","))
|
||||
if (!("," + mediaPath + ",").Contains("," + currentUser.StartMediaId + ","))
|
||||
throw new UnauthorizedAccessException("You do not have access to this Media node");
|
||||
|
||||
// Get children and filter
|
||||
var entities = service.GetChildren(parentId, UmbracoObjectTypes.Media);
|
||||
//TODO: Only fetch files, not containers
|
||||
//TODO: Cache responses to speed up susequent searches
|
||||
foreach (var child in parentMedia.Children)
|
||||
foreach (UmbracoEntity entity in entities)
|
||||
{
|
||||
var fileProp = child.getProperty(Constants.Conventions.Media.File) ??
|
||||
child.GenericProperties.FirstOrDefault(x =>
|
||||
x.PropertyType.DataTypeDefinition.DataType.Id == new Guid(Constants.PropertyEditors.UploadField));
|
||||
|
||||
var fileUrl = fileProp != null ? fileProp.Value.ToString() : "";
|
||||
var thumbUrl = ThumbnailProvidersResolver.Current.GetThumbnailUrl(fileUrl);
|
||||
var thumbUrl = ThumbnailProvidersResolver.Current.GetThumbnailUrl(entity.UmbracoFile);
|
||||
var item = new
|
||||
{
|
||||
Id = child.Id,
|
||||
Path = child.Path,
|
||||
Name = child.Text,
|
||||
Tags = string.Join(",", Tag.GetTags(child.Id).Select(x => x.TagCaption)),
|
||||
MediaTypeAlias = child.ContentType.Alias,
|
||||
EditUrl = string.Format("editMedia.aspx?id={0}", child.Id),
|
||||
FileUrl = fileUrl,
|
||||
Id = entity.Id,
|
||||
Path = entity.Path,
|
||||
Name = entity.Name,
|
||||
Tags = string.Join(",", Tag.GetTags(entity.Id).Select(x => x.TagCaption)),
|
||||
MediaTypeAlias = entity.ContentTypeAlias,
|
||||
EditUrl = string.Format("editMedia.aspx?id={0}", entity.Id),
|
||||
FileUrl = entity.UmbracoFile,
|
||||
ThumbnailUrl = !string.IsNullOrEmpty(thumbUrl)
|
||||
? thumbUrl
|
||||
: IOHelper.ResolveUrl(SystemDirectories.Umbraco + "/images/thumbnails/" + child.ContentType.Thumbnail)
|
||||
: IOHelper.ResolveUrl(SystemDirectories.Umbraco + "/images/thumbnails/" + entity.ContentTypeThumbnail)
|
||||
};
|
||||
|
||||
data.Add(item);
|
||||
|
||||
@@ -1,26 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using umbraco.BasePages;
|
||||
using umbraco.BusinessLogic;
|
||||
using umbraco.BusinessLogic.Actions;
|
||||
using umbraco.cms.businesslogic.media;
|
||||
using umbraco.cms.businesslogic.property;
|
||||
using umbraco.interfaces;
|
||||
using Umbraco.Core;
|
||||
using Media = umbraco.cms.businesslogic.media.Media;
|
||||
using Property = umbraco.cms.businesslogic.property.Property;
|
||||
|
||||
namespace umbraco.cms.presentation.Trees
|
||||
{
|
||||
public abstract class BaseMediaTree : BaseTree
|
||||
{
|
||||
private DisposableTimer _timer;
|
||||
private User _user;
|
||||
|
||||
public BaseMediaTree(string application)
|
||||
: base(application)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private User m_user;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current User. This ensures that we don't instantiate a new User object
|
||||
/// each time.
|
||||
@@ -29,11 +33,10 @@ namespace umbraco.cms.presentation.Trees
|
||||
{
|
||||
get
|
||||
{
|
||||
return (m_user == null ? (m_user = UmbracoEnsuredPage.CurrentUser) : m_user);
|
||||
return (_user == null ? (_user = UmbracoEnsuredPage.CurrentUser) : _user);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void RenderJS(ref StringBuilder Javascript)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(this.FunctionToCall))
|
||||
@@ -53,8 +56,81 @@ function openMedia(id) {
|
||||
}
|
||||
}
|
||||
|
||||
//Updated Render method for improved performance, but currently not usable because of backwards compatibility
|
||||
//with the OnBeforeTreeRender/OnAfterTreeRender events, which sends an array for legacy Media items.
|
||||
/*public override void Render(ref XmlTree tree)
|
||||
{
|
||||
_timer = DisposableTimer.Start(x => LogHelper.Debug<BaseMediaTree>("Media tree loaded" + " (took " + x + "ms)"));
|
||||
|
||||
var service = base.Services.EntityService;
|
||||
var entities = service.GetChildren(m_id, UmbracoObjectTypes.Media);
|
||||
|
||||
var args = new TreeEventArgs(tree);
|
||||
OnBeforeTreeRender(entities, args);
|
||||
|
||||
foreach (UmbracoEntity entity in entities)
|
||||
{
|
||||
XmlTreeNode xNode = XmlTreeNode.Create(this);
|
||||
xNode.NodeID = entity.Id.ToString(CultureInfo.InvariantCulture);
|
||||
xNode.Text = entity.Name;
|
||||
|
||||
xNode.HasChildren = entity.HasChildren;
|
||||
xNode.Source = this.IsDialog ? GetTreeDialogUrl(entity.Id) : GetTreeServiceUrl(entity.Id);
|
||||
|
||||
xNode.Icon = entity.ContentTypeIcon;
|
||||
xNode.OpenIcon = entity.ContentTypeIcon;
|
||||
|
||||
xNode.Menu = this.ShowContextMenu ? new List<IAction>(new IAction[] { ActionRefresh.Instance }) : null;
|
||||
|
||||
if (IsDialog == false)
|
||||
{
|
||||
xNode.Action = "javascript:openMedia(" + entity.Id + ");";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.DialogMode == TreeDialogModes.fulllink)
|
||||
{
|
||||
if (string.IsNullOrEmpty(entity.UmbracoFile) == false)
|
||||
{
|
||||
xNode.Action = "javascript:openMedia('" + entity.UmbracoFile + "');";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.Equals(entity.ContentTypeAlias, Constants.Conventions.MediaTypes.Folder, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
xNode.Action = "javascript:jQuery('.umbTree #" + entity.Id.ToString(CultureInfo.InvariantCulture) + "').click();";
|
||||
}
|
||||
else
|
||||
{
|
||||
xNode.Action = null;
|
||||
xNode.Style.DimNode();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
xNode.Action = "javascript:openMedia('" + entity.Id.ToString(CultureInfo.InvariantCulture) + "');";
|
||||
}
|
||||
}
|
||||
|
||||
OnBeforeNodeRender(ref tree, ref xNode, EventArgs.Empty);
|
||||
if (xNode != null)
|
||||
{
|
||||
tree.Add(xNode);
|
||||
OnAfterNodeRender(ref tree, ref xNode, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
//stop the timer and log the output
|
||||
_timer.Dispose();
|
||||
|
||||
OnAfterTreeRender(entities, args);
|
||||
}*/
|
||||
|
||||
public override void Render(ref XmlTree tree)
|
||||
{
|
||||
//_timer = DisposableTimer.Start(x => LogHelper.Debug<BaseMediaTree>("Media tree loaded" + " (took " + x + "ms)"));
|
||||
|
||||
Media[] docs = new Media(m_id).Children;
|
||||
|
||||
var args = new TreeEventArgs(tree);
|
||||
@@ -124,6 +200,7 @@ function openMedia(id) {
|
||||
OnAfterNodeRender(ref tree, ref xNode, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
//_timer.Dispose();
|
||||
OnAfterTreeRender(docs, args);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,28 +1,9 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Xml;
|
||||
using System.Configuration;
|
||||
using umbraco.BasePages;
|
||||
using umbraco.BusinessLogic;
|
||||
using umbraco.businesslogic;
|
||||
using umbraco.cms.businesslogic;
|
||||
using umbraco.cms.businesslogic.cache;
|
||||
using umbraco.cms.businesslogic.contentitem;
|
||||
using umbraco.cms.businesslogic.datatype;
|
||||
using umbraco.cms.businesslogic.language;
|
||||
using umbraco.cms.businesslogic.media;
|
||||
using umbraco.cms.businesslogic.member;
|
||||
using umbraco.cms.businesslogic.property;
|
||||
using umbraco.cms.businesslogic.web;
|
||||
using umbraco.interfaces;
|
||||
using umbraco.DataLayer;
|
||||
using umbraco.BusinessLogic.Actions;
|
||||
using umbraco.BusinessLogic.Utils;
|
||||
using umbraco.cms.presentation.Trees;
|
||||
using Umbraco.Core;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ using umbraco.cms.businesslogic.propertytype;
|
||||
using umbraco.cms.businesslogic.web;
|
||||
using umbraco.cms.helpers;
|
||||
using umbraco.controls.GenericProperties;
|
||||
using umbraco.IO;
|
||||
using Umbraco.Core.IO;
|
||||
using umbraco.presentation;
|
||||
using umbraco.BasePages;
|
||||
using ContentType = umbraco.cms.businesslogic.ContentType;
|
||||
@@ -253,43 +253,62 @@ namespace umbraco.controls
|
||||
InfoTabPage.Style.Add("text-align", "center");
|
||||
|
||||
ImageButton Save = InfoTabPage.Menu.NewImageButton();
|
||||
Save.Click += new System.Web.UI.ImageClickEventHandler(save_click);
|
||||
Save.Click += save_click;
|
||||
|
||||
Save.ImageUrl = UmbracoPath + "/images/editor/save.gif";
|
||||
Save.AlternateText = ui.Text("save");
|
||||
Save.ID = "save";
|
||||
var listOfIcons = new List<ListItem>();
|
||||
// Get icons
|
||||
// nh css file update, add support for css sprites
|
||||
foreach (string iconClass in cms.businesslogic.CMSNode.DefaultIconClasses)
|
||||
{
|
||||
var liText = iconClass
|
||||
.Substring(1)
|
||||
.SplitPascalCasing().ToFirstUpperInvariant()
|
||||
.Replace("Spr Tree", "")
|
||||
.Trim();
|
||||
ListItem li = new ListItem(liText, iconClass);
|
||||
li.Attributes.Add("class", "spriteBackground sprTree " + iconClass.Trim('.'));
|
||||
li.Attributes.Add("style", "padding-left:20px !important; background-repeat:no-repeat;");
|
||||
|
||||
if (!this.Page.IsPostBack && li.Value == _contentType.IconUrl) li.Selected = true;
|
||||
listOfIcons.Add(li);
|
||||
var dirInfo = new DirectoryInfo(UmbracoContext.Current.Server.MapPath(SystemDirectories.Umbraco + "/images/umbraco"));
|
||||
var fileInfo = dirInfo.GetFiles();
|
||||
|
||||
var spriteFileNames = new List<string>();
|
||||
foreach (var iconClass in cms.businesslogic.CMSNode.DefaultIconClasses)
|
||||
spriteFileNames.Add(IconClassToIconFileName(iconClass));
|
||||
|
||||
var diskFileNames = new List<string>();
|
||||
foreach (var file in fileInfo)
|
||||
diskFileNames.Add(FileNameToIconFileName(file));
|
||||
|
||||
var listOfIcons = new List<ListItem>();
|
||||
|
||||
foreach (var iconClass in cms.businesslogic.CMSNode.DefaultIconClasses)
|
||||
{
|
||||
// .sprNew was never intended to be in the document type editor
|
||||
if (iconClass.ToLowerInvariant() == ".sprNew".ToLowerInvariant())
|
||||
continue;
|
||||
|
||||
if (_contentType.IconUrl == iconClass)
|
||||
{
|
||||
AddSpriteListItem(iconClass, listOfIcons);
|
||||
continue;
|
||||
}
|
||||
|
||||
DirectoryInfo dirInfo = new DirectoryInfo(UmbracoContext.Current.Server.MapPath(SystemDirectories.Umbraco + "/images/umbraco"));
|
||||
FileInfo[] fileInfo = dirInfo.GetFiles();
|
||||
for (int i = 0; i < fileInfo.Length; i++)
|
||||
if (UmbracoSettings.IconPickerBehaviour == IconPickerBehaviour.HideSpriteDuplicates
|
||||
&& diskFileNames.Contains(IconClassToIconFileName(iconClass)))
|
||||
continue;
|
||||
|
||||
AddSpriteListItem(iconClass, listOfIcons);
|
||||
}
|
||||
|
||||
foreach (var file in fileInfo)
|
||||
{
|
||||
// NH: don't show the sprite file
|
||||
if (fileInfo[i].Name != "sprites.png" && fileInfo[i].Name != "sprites_ie6.gif")
|
||||
{
|
||||
ListItem li = new ListItem(fileInfo[i].Name, fileInfo[i].Name);
|
||||
li.Attributes.Add("title", this.ResolveClientUrl(SystemDirectories.Umbraco + "/images/umbraco/" + fileInfo[i].Name));
|
||||
if (file.Name.ToLowerInvariant() == "sprites.png".ToLowerInvariant() || file.Name.ToLowerInvariant() == "sprites_ie6.gif".ToLowerInvariant())
|
||||
continue;
|
||||
|
||||
if (li.Value == _contentType.IconUrl)
|
||||
li.Selected = true;
|
||||
listOfIcons.Add(li);
|
||||
var listItemValue = this.ResolveClientUrl(SystemDirectories.Umbraco + "/images/umbraco/" + file.Name);
|
||||
if (_contentType.IconUrl == listItemValue)
|
||||
{
|
||||
AddFileListItem(file.Name, listItemValue, listOfIcons);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (UmbracoSettings.IconPickerBehaviour == IconPickerBehaviour.HideFileDuplicates
|
||||
&& spriteFileNames.Contains(FileNameToIconFileName(file)))
|
||||
continue;
|
||||
|
||||
AddFileListItem(file.Name, listItemValue, listOfIcons);
|
||||
}
|
||||
|
||||
ddlIcons.Items.AddRange(listOfIcons.OrderBy(o => o.Text).ToArray());
|
||||
@@ -297,11 +316,15 @@ namespace umbraco.controls
|
||||
// Get thumbnails
|
||||
dirInfo = new DirectoryInfo(IOHelper.MapPath(SystemDirectories.Umbraco + "/images/thumbnails"));
|
||||
fileInfo = dirInfo.GetFiles();
|
||||
for (int i = 0; i < fileInfo.Length; i++)
|
||||
|
||||
foreach (var file in fileInfo)
|
||||
{
|
||||
ListItem li = new ListItem(fileInfo[i].Name);
|
||||
li.Attributes.Add("title", this.ResolveClientUrl(SystemDirectories.Umbraco + "/images/thumbnails/" + fileInfo[i].Name));
|
||||
if (!this.Page.IsPostBack && li.Value == _contentType.Thumbnail) li.Selected = true;
|
||||
var li = new ListItem(file.Name);
|
||||
li.Attributes.Add("title", this.ResolveClientUrl(SystemDirectories.Umbraco + "/images/thumbnails/" + file.Name));
|
||||
|
||||
if (this.Page.IsPostBack == false && li.Value == _contentType.Thumbnail)
|
||||
li.Selected = true;
|
||||
|
||||
ddlThumbnails.Items.Add(li);
|
||||
}
|
||||
|
||||
@@ -318,6 +341,46 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
|
||||
|
||||
}
|
||||
|
||||
private void AddSpriteListItem(string iconClass, ICollection<ListItem> listOfIcons)
|
||||
{
|
||||
var li = new ListItem(
|
||||
helper.SpaceCamelCasing((iconClass.Substring(1, iconClass.Length - 1)))
|
||||
.Replace("Spr Tree", "")
|
||||
.Trim(), iconClass);
|
||||
|
||||
li.Attributes.Add("class", "spriteBackground sprTree " + iconClass.Trim('.'));
|
||||
li.Attributes.Add("style", "padding-left:24px !important; background-repeat:no-repeat; width:auto; height:auto;");
|
||||
|
||||
AddListItem(listOfIcons, li);
|
||||
}
|
||||
|
||||
private void AddFileListItem(string fileName, string listItemValue, ICollection<ListItem> listOfIcons)
|
||||
{
|
||||
var li = new ListItem(fileName, fileName);
|
||||
|
||||
li.Attributes.Add("title", listItemValue);
|
||||
|
||||
AddListItem(listOfIcons, li);
|
||||
}
|
||||
|
||||
private void AddListItem(ICollection<ListItem> listOfIcons, ListItem li)
|
||||
{
|
||||
if (this.Page.IsPostBack == false && li.Value == _contentType.IconUrl)
|
||||
li.Selected = true;
|
||||
|
||||
listOfIcons.Add(li);
|
||||
}
|
||||
|
||||
private static string IconClassToIconFileName(string iconClass)
|
||||
{
|
||||
return iconClass.Substring(1, iconClass.Length - 1).ToLowerInvariant().Replace("sprTree".ToLowerInvariant(), "");
|
||||
}
|
||||
|
||||
private static string FileNameToIconFileName(FileInfo file)
|
||||
{
|
||||
return file.Name.Substring(0, file.Name.LastIndexOf(".", StringComparison.Ordinal)).ToLowerInvariant();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region "Structure" Pane
|
||||
|
||||
@@ -11,34 +11,35 @@ using System.Web.UI.HtmlControls;
|
||||
|
||||
using System.Xml.XPath;
|
||||
using System.Xml;
|
||||
using umbraco.IO;
|
||||
using Umbraco.Core.IO;
|
||||
|
||||
namespace umbraco.cms.presentation
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for create.
|
||||
/// </summary>
|
||||
public partial class Create : BasePages.UmbracoEnsuredPage
|
||||
|
||||
public class Create : BasePages.UmbracoEnsuredPage
|
||||
{
|
||||
[Obsolete("This property is no longer used")]
|
||||
protected umbWindow createWindow;
|
||||
protected System.Web.UI.WebControls.Label helpText;
|
||||
protected System.Web.UI.WebControls.TextBox rename;
|
||||
protected System.Web.UI.WebControls.Label Label1;
|
||||
protected System.Web.UI.WebControls.ListBox nodeType;
|
||||
protected Label helpText;
|
||||
protected TextBox rename;
|
||||
protected Label Label1;
|
||||
protected ListBox nodeType;
|
||||
protected PlaceHolder UI;
|
||||
|
||||
protected void Page_Load(object sender, System.EventArgs e)
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
// Load create definitions
|
||||
string nodeType = Request.QueryString["nodeType"];
|
||||
base.OnLoad(e);
|
||||
|
||||
XmlDocument createDef = new XmlDocument();
|
||||
XmlTextReader defReader = new XmlTextReader(IOHelper.MapPath(SystemFiles.CreateUiXml));
|
||||
// Load create definitions
|
||||
var nodeType = Request.QueryString["nodeType"];
|
||||
|
||||
var createDef = new XmlDocument();
|
||||
var defReader = new XmlTextReader(IOHelper.MapPath(SystemFiles.CreateUiXml));
|
||||
createDef.Load(defReader);
|
||||
defReader.Close();
|
||||
|
||||
// Find definition for current nodeType
|
||||
XmlNode def = createDef.SelectSingleNode("//nodeType [@alias = '" + nodeType + "']");
|
||||
var def = createDef.SelectSingleNode("//nodeType [@alias = '" + nodeType + "']");
|
||||
if (def == null)
|
||||
{
|
||||
throw new ArgumentException("The create dialog for \"" + nodeType + "\" does not match anything defined in the \"" + SystemFiles.CreateUiXml + "\". This could mean an incorrectly installed package or a corrupt UI file");
|
||||
@@ -47,7 +48,7 @@ namespace umbraco.cms.presentation
|
||||
try
|
||||
{
|
||||
//headerTitle.Text = title.Text;
|
||||
UI.Controls.Add(new UserControl().LoadControl(SystemDirectories.Umbraco + def.SelectSingleNode("./usercontrol").FirstChild.Value));
|
||||
UI.Controls.Add(LoadControl(SystemDirectories.Umbraco + def.SelectSingleNode("./usercontrol").FirstChild.Value));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -55,13 +56,6 @@ namespace umbraco.cms.presentation
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// UI control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.PlaceHolder UI;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,35 +12,19 @@ namespace umbraco
|
||||
{
|
||||
public class userTasks : interfaces.ITaskReturnUrl
|
||||
{
|
||||
|
||||
private string _alias;
|
||||
private int _parentID;
|
||||
private int _typeID;
|
||||
private int _userID;
|
||||
private string _returnUrl = "";
|
||||
|
||||
public int UserId
|
||||
{
|
||||
set { _userID = value; }
|
||||
}
|
||||
public int TypeID
|
||||
{
|
||||
set { _typeID = value; }
|
||||
get { return _typeID; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public int TypeID { get; set; }
|
||||
|
||||
public string Alias
|
||||
{
|
||||
set { _alias = value; }
|
||||
get { return _alias; }
|
||||
}
|
||||
|
||||
public int ParentID
|
||||
{
|
||||
set { _parentID = value; }
|
||||
get { return _parentID; }
|
||||
}
|
||||
public string Alias { get; set; }
|
||||
|
||||
public int ParentID { get; set; }
|
||||
|
||||
public string ReturnUrl
|
||||
{
|
||||
@@ -54,11 +38,11 @@ namespace umbraco
|
||||
//BusinessLogic.User.MakeNew(Alias, Alias, "", BusinessLogic.UserType.GetUserType(1));
|
||||
//return true;
|
||||
|
||||
MembershipCreateStatus status = MembershipCreateStatus.ProviderError;
|
||||
var status = MembershipCreateStatus.ProviderError;
|
||||
try
|
||||
{
|
||||
// Password is auto-generated. They are they required to change the password by editing the user information.
|
||||
MembershipUser u = Membership.Providers[UmbracoSettings.DefaultBackofficeProvider].CreateUser(Alias,
|
||||
var u = Membership.Providers[UmbracoSettings.DefaultBackofficeProvider].CreateUser(Alias,
|
||||
Membership.GeneratePassword(
|
||||
Membership.Providers[UmbracoSettings.DefaultBackofficeProvider].MinRequiredPasswordLength,
|
||||
Membership.Providers[UmbracoSettings.DefaultBackofficeProvider].MinRequiredNonAlphanumericCharacters),
|
||||
@@ -70,23 +54,16 @@ namespace umbraco
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error<userTasks>(String.Format("Failed to create the user. Error from provider: {0}", status.ToString()), ex);
|
||||
LogHelper.Error<userTasks>(string.Format("Failed to create the user. Error from provider: {0}", status.ToString()), ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Delete()
|
||||
{
|
||||
BusinessLogic.User u = BusinessLogic.User.GetUser(ParentID);
|
||||
var u = User.GetUser(ParentID);
|
||||
u.disable();
|
||||
return true;
|
||||
}
|
||||
|
||||
public userTasks()
|
||||
{
|
||||
//
|
||||
// TODO: Add constructor logic here
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Web.UI.HtmlControls;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using Umbraco.Core;
|
||||
using umbraco.IO;
|
||||
using Umbraco.Core.IO;
|
||||
|
||||
namespace umbraco.presentation.umbraco.dialogs
|
||||
{
|
||||
@@ -69,12 +69,10 @@ namespace umbraco.presentation.umbraco.dialogs
|
||||
|
||||
private void import_Click(object sender, EventArgs e)
|
||||
{
|
||||
/*XmlDocument xd = new XmlDocument();
|
||||
var xd = new XmlDocument();
|
||||
xd.Load(tempFile.Value);
|
||||
cms.businesslogic.packager.Installer.ImportDocumentType(xd.DocumentElement, base.getUser(), true);
|
||||
dtNameConfirm.Text = xd.DocumentElement.SelectSingleNode("/DocumentType/Info/Name").FirstChild.Value;*/
|
||||
|
||||
var element = XElement.Parse(tempFile.Value);
|
||||
var element = XElement.Parse(xd.InnerXml);
|
||||
var importContentTypes = ApplicationContext.Current.Services.PackagingService.ImportContentTypes(element);
|
||||
var contentType = importContentTypes.FirstOrDefault();
|
||||
if (contentType != null)
|
||||
@@ -85,25 +83,22 @@ namespace umbraco.presentation.umbraco.dialogs
|
||||
done.Visible = true;
|
||||
}
|
||||
|
||||
private void submit_Click(object sender, System.EventArgs e)
|
||||
private void submit_Click(object sender, EventArgs e)
|
||||
{
|
||||
tempFileName = "justDelete_" + Guid.NewGuid().ToString() + ".udt";
|
||||
string fileName = IOHelper.MapPath(SystemDirectories.Data + "/" + tempFileName);
|
||||
var fileName = IOHelper.MapPath(SystemDirectories.Data + "/" + tempFileName);
|
||||
tempFile.Value = fileName;
|
||||
|
||||
documentTypeFile.PostedFile.SaveAs(fileName);
|
||||
|
||||
XmlDocument xd = new XmlDocument();
|
||||
var xd = new XmlDocument();
|
||||
xd.Load(fileName);
|
||||
dtName.Text = xd.DocumentElement.SelectSingleNode("/DocumentType/Info/Name").FirstChild.Value;
|
||||
dtAlias.Text = xd.DocumentElement.SelectSingleNode("/DocumentType/Info/Alias").FirstChild.Value;
|
||||
|
||||
dtName.Text = xd.DocumentElement.SelectSingleNode("//DocumentType/Info/Name").FirstChild.Value;
|
||||
dtAlias.Text = xd.DocumentElement.SelectSingleNode("//DocumentType/Info/Alias").FirstChild.Value;
|
||||
|
||||
Wizard.Visible = false;
|
||||
done.Visible = false;
|
||||
Confirm.Visible = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ using System.Xml;
|
||||
using Umbraco.Core.Macros;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.PublishedCache;
|
||||
using Umbraco.Web.PublishedCache.XmlPublishedCache;
|
||||
using Umbraco.Web.Routing;
|
||||
using Umbraco.Web.Templates;
|
||||
using umbraco.cms.businesslogic;
|
||||
@@ -91,49 +92,20 @@ namespace umbraco.presentation.templateControls
|
||||
/// <returns>A string of field contents (macros not parsed)</returns>
|
||||
protected virtual string GetFieldContents(Item item)
|
||||
{
|
||||
string tempElementContent = String.Empty;
|
||||
var tempElementContent = string.Empty;
|
||||
|
||||
// if a nodeId is specified we should get the data from another page than the current one
|
||||
if (!String.IsNullOrEmpty(item.NodeId))
|
||||
if (string.IsNullOrEmpty(item.NodeId) == false)
|
||||
{
|
||||
int? tempNodeId = item.GetParsedNodeId();
|
||||
var tempNodeId = item.GetParsedNodeId();
|
||||
if (tempNodeId != null && tempNodeId.Value != 0)
|
||||
{
|
||||
|
||||
//moved the following from the catch block up as this will allow fallback options alt text etc to work
|
||||
|
||||
//get the publishedcontent item
|
||||
var publishedContent = Umbraco.Web.UmbracoContext.Current.ContentCache.GetById(tempNodeId.Value);
|
||||
|
||||
var itemPage = new page(publishedContent);
|
||||
tempElementContent = new item(publishedContent, itemPage.Elements, item.LegacyAttributes).FieldContent;
|
||||
|
||||
/*removed as would fail as there is a incorrect cast in the method called.
|
||||
Also the following code does not respect any of Umbraco Items fallback and formatting options */
|
||||
|
||||
//string currentField = helper.FindAttribute(item.LegacyAttributes, "field");
|
||||
// check for a cached instance of the content
|
||||
//object contents = GetContentFromCache(tempNodeId.Value, currentField);
|
||||
//if (contents != null)
|
||||
// tempElementContent = (string)contents;
|
||||
//else
|
||||
//{
|
||||
// // as the field can be used for both documents, media and even members we'll use the
|
||||
// // content class to lookup field items
|
||||
// try
|
||||
// {
|
||||
// tempElementContent = GetContentFromDatabase(item.LegacyAttributes, tempNodeId.Value, currentField);
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
// // content was not found in property fields,
|
||||
// // so the last place to look for is page fields
|
||||
// page itemPage = new page(content.Instance.XmlContent.GetElementById(tempNodeId.ToString()));
|
||||
// tempElementContent = new item(itemPage.Elements, item.LegacyAttributes).FieldContent;
|
||||
// }
|
||||
//}
|
||||
var xml = ((PublishedContentCache) PublishedContentCacheResolver.Current.ContentCache)
|
||||
.GetXml(Umbraco.Web.UmbracoContext.Current);
|
||||
var itemPage = new page(xml.GetElementById(tempNodeId.ToString()));
|
||||
tempElementContent = new item(itemPage.Elements, item.LegacyAttributes).FieldContent;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace umbraco.presentation.webservices
|
||||
|
||||
|
||||
//deletes the old css file if the name was changed...
|
||||
if (fileName != oldName)
|
||||
if (fileName.ToLowerInvariant() != oldName.ToLowerInvariant())
|
||||
{
|
||||
string p = IOHelper.MapPath(SystemDirectories.Css + "/" + oldName + ".css");
|
||||
if (System.IO.File.Exists(p))
|
||||
|
||||
@@ -562,6 +562,18 @@ namespace umbraco
|
||||
get { return Umbraco.Core.Configuration.UmbracoSettings.MacroErrorBehaviour; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This configuration setting defines how to show icons in the document type editor.
|
||||
/// - ShowDuplicates - Show duplicates in files and sprites. (default and current Umbraco 'normal' behaviour)
|
||||
/// - HideSpriteDuplicates - Show files on disk and hide duplicates from the sprite
|
||||
/// - HideFileDuplicates - Show files in the sprite and hide duplicates on disk
|
||||
/// </summary>
|
||||
/// <value>MacroErrorBehaviour enum defining how to show icons in the document type editor.</value>
|
||||
public static IconPickerBehaviour IconPickerBehaviour
|
||||
{
|
||||
get { return Umbraco.Core.Configuration.UmbracoSettings.IconPickerBehaviour; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configuration regarding webservices
|
||||
/// </summary>
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace umbraco.cms.businesslogic
|
||||
/// 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 readonly ConcurrentDictionary<Tuple<string, string>, Guid> PropertyTypeCache = new ConcurrentDictionary<Tuple<string, string>, Guid>();
|
||||
private static readonly ConcurrentDictionary<System.Tuple<string, string>, Guid> PropertyTypeCache = new ConcurrentDictionary<System.Tuple<string, string>, Guid>();
|
||||
|
||||
/// <summary>
|
||||
/// Returns a content type's columns alias -> name mapping
|
||||
@@ -113,7 +113,7 @@ namespace umbraco.cms.businesslogic
|
||||
{
|
||||
return AliasToNames.GetOrAdd(contentTypeAlias, s =>
|
||||
{
|
||||
var ct = ContentType.GetByAlias(contentTypeAlias);
|
||||
var ct = GetByAlias(contentTypeAlias);
|
||||
var userFields = ct.PropertyTypes.ToDictionary(x => x.Alias, x => x.Name);
|
||||
return userFields;
|
||||
});
|
||||
@@ -125,7 +125,7 @@ namespace umbraco.cms.businesslogic
|
||||
/// <param name="contentTypeAlias"></param>
|
||||
public static void RemoveFromDataTypeCache(string contentTypeAlias)
|
||||
{
|
||||
var toDelete = PropertyTypeCache.Keys.Where(key => string.Equals(key.first, contentTypeAlias)).ToList();
|
||||
var toDelete = PropertyTypeCache.Keys.Where(key => string.Equals(key.Item1, contentTypeAlias)).ToList();
|
||||
foreach (var key in toDelete)
|
||||
{
|
||||
Guid id;
|
||||
@@ -139,20 +139,18 @@ namespace umbraco.cms.businesslogic
|
||||
/// </summary>
|
||||
internal static void RemoveAllDataTypeCache()
|
||||
{
|
||||
|
||||
AliasToNames.Clear();
|
||||
PropertyTypeCache.Clear();
|
||||
}
|
||||
|
||||
public static Guid GetDataType(string contentTypeAlias, string propertyTypeAlias)
|
||||
{
|
||||
var key = new Tuple<string, string>()
|
||||
{
|
||||
first = contentTypeAlias,
|
||||
second = propertyTypeAlias
|
||||
};
|
||||
var key = new System.Tuple<string, string>(contentTypeAlias, propertyTypeAlias);
|
||||
|
||||
return PropertyTypeCache.GetOrAdd(key, tuple =>
|
||||
|
||||
return PropertyTypeCache.GetOrAdd(
|
||||
key,
|
||||
tuple =>
|
||||
{
|
||||
// With 4.10 we can't do this via direct SQL as we have content type mixins
|
||||
var controlId = Guid.Empty;
|
||||
@@ -166,7 +164,6 @@ namespace umbraco.cms.businesslogic
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of the content.
|
||||
/// </summary>
|
||||
@@ -175,7 +172,7 @@ namespace umbraco.cms.businesslogic
|
||||
public static ContentType GetContentType(int id)
|
||||
{
|
||||
return ApplicationContext.Current.ApplicationCache.GetCacheItem
|
||||
(string.Format("UmbracoContentType{0}", id.ToString()),
|
||||
(string.Format("UmbracoContentType{0}", id),
|
||||
TimeSpan.FromMinutes(30),
|
||||
() => new ContentType(id));
|
||||
}
|
||||
@@ -228,24 +225,22 @@ namespace umbraco.cms.businesslogic
|
||||
object tmp = SqlHelper.ExecuteScalar<object>("Select propertyTypeGroupId from cmsPropertyType where id = " + pt.Id.ToString());
|
||||
if (tmp == DBNull.Value)
|
||||
return 0;
|
||||
else return int.Parse(tmp.ToString());
|
||||
return int.Parse(tmp.ToString());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Members
|
||||
|
||||
//private bool _optimizedMode = false;
|
||||
private bool _allowAtRoot;
|
||||
private string _alias;
|
||||
private string _iconurl;
|
||||
private string _description;
|
||||
private string _thumbnail;
|
||||
List<int> m_masterContentTypes;
|
||||
private bool _isContainerContentType = false;
|
||||
|
||||
private List<int> m_AllowedChildContentTypeIDs = null;
|
||||
private List<TabI> m_VirtualTabs = null;
|
||||
private bool _isContainerContentType;
|
||||
private List<int> _allowedChildContentTypeIDs;
|
||||
private List<TabI> _virtualTabs;
|
||||
|
||||
protected internal IContentTypeComposition ContentTypeItem;
|
||||
|
||||
@@ -380,9 +375,7 @@ namespace umbraco.cms.businesslogic
|
||||
{
|
||||
if (!_description.StartsWith("#"))
|
||||
return _description;
|
||||
else
|
||||
{
|
||||
Language lang = Language.GetByCultureCode(Thread.CurrentThread.CurrentCulture.Name);
|
||||
var lang = Language.GetByCultureCode(Thread.CurrentThread.CurrentCulture.Name);
|
||||
if (lang != null)
|
||||
{
|
||||
if (Dictionary.DictionaryItem.hasKey(_description.Substring(1, _description.Length - 1)))
|
||||
@@ -392,7 +385,6 @@ namespace umbraco.cms.businesslogic
|
||||
return di.Value(lang.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "[" + _description + "]";
|
||||
}
|
||||
@@ -450,6 +442,7 @@ namespace umbraco.cms.businesslogic
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Human readable name/label
|
||||
/// </summary>
|
||||
@@ -458,26 +451,21 @@ namespace umbraco.cms.businesslogic
|
||||
{
|
||||
get
|
||||
{
|
||||
string tempText = base.Text;
|
||||
var tempText = base.Text;
|
||||
if (!tempText.StartsWith("#"))
|
||||
return tempText;
|
||||
else
|
||||
{
|
||||
Language lang =
|
||||
Language.GetByCultureCode(Thread.CurrentThread.CurrentCulture.Name);
|
||||
var lang = Language.GetByCultureCode(Thread.CurrentThread.CurrentCulture.Name);
|
||||
if (lang != null)
|
||||
{
|
||||
if (Dictionary.DictionaryItem.hasKey(tempText.Substring(1, tempText.Length - 1)))
|
||||
{
|
||||
Dictionary.DictionaryItem di =
|
||||
new Dictionary.DictionaryItem(tempText.Substring(1, tempText.Length - 1));
|
||||
var di = new Dictionary.DictionaryItem(tempText.Substring(1, tempText.Length - 1));
|
||||
return di.Value(lang.id);
|
||||
}
|
||||
}
|
||||
|
||||
return "[" + tempText + "]";
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Text = value;
|
||||
@@ -536,8 +524,8 @@ namespace umbraco.cms.businesslogic
|
||||
{
|
||||
foreach (var mct in MasterContentTypes)
|
||||
{
|
||||
var pts = ContentType.GetContentType(mct).PropertyTypes;
|
||||
foreach (PropertyType pt in pts)
|
||||
var pts = GetContentType(mct).PropertyTypes;
|
||||
foreach (var pt in pts)
|
||||
{
|
||||
if (result.ContainsKey(pt.Id) == false)
|
||||
result.Add(pt.Id, pt);
|
||||
@@ -715,7 +703,7 @@ namespace umbraco.cms.businesslogic
|
||||
get
|
||||
{
|
||||
EnsureVirtualTabs();
|
||||
return m_VirtualTabs.ToArray();
|
||||
return _virtualTabs.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -727,10 +715,11 @@ namespace umbraco.cms.businesslogic
|
||||
public void ClearVirtualTabs()
|
||||
{
|
||||
//NOTE: SD: There is no cache to clear so this doesn't actually do anything
|
||||
foreach (TabI t in getVirtualTabs)
|
||||
//NOTE: SD: There is no cache to clear so this doesn't actually do anything
|
||||
foreach (var t in getVirtualTabs)
|
||||
Tab.FlushCache(t.Id, Id);
|
||||
|
||||
m_VirtualTabs = null;
|
||||
_virtualTabs = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -742,25 +731,23 @@ namespace umbraco.cms.businesslogic
|
||||
get
|
||||
{
|
||||
//optimize this property so it lazy loads the data only one time.
|
||||
if (m_AllowedChildContentTypeIDs == null)
|
||||
if (_allowedChildContentTypeIDs == null)
|
||||
{
|
||||
m_AllowedChildContentTypeIDs = new List<int>();
|
||||
using (IRecordsReader dr = SqlHelper.ExecuteReader(
|
||||
"Select AllowedId from cmsContentTypeAllowedContentType where id=" +
|
||||
Id))
|
||||
_allowedChildContentTypeIDs = new List<int>();
|
||||
using (var dr = SqlHelper.ExecuteReader("Select AllowedId from cmsContentTypeAllowedContentType where id=" + Id))
|
||||
{
|
||||
while (dr.Read())
|
||||
{
|
||||
m_AllowedChildContentTypeIDs.Add(dr.GetInt("AllowedId"));
|
||||
_allowedChildContentTypeIDs.Add(dr.GetInt("AllowedId"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return m_AllowedChildContentTypeIDs.ToArray();
|
||||
return _allowedChildContentTypeIDs.ToArray();
|
||||
}
|
||||
set
|
||||
{
|
||||
m_AllowedChildContentTypeIDs = value.ToList();
|
||||
_allowedChildContentTypeIDs = value.ToList();
|
||||
|
||||
//This switches between using new vs. legacy api.
|
||||
//Note that this is currently only done to support both DocumentType and MediaType, which use the new api and MemberType that doesn't.
|
||||
@@ -822,13 +809,13 @@ namespace umbraco.cms.businesslogic
|
||||
{
|
||||
var contentTypes = new List<ContentType>();
|
||||
|
||||
using (IRecordsReader dr =
|
||||
SqlHelper.ExecuteReader(m_SQLOptimizedGetAll.Trim(), SqlHelper.CreateParameter("@nodeObjectType", base.nodeObjectType)))
|
||||
using (var dr =
|
||||
SqlHelper.ExecuteReader(m_SQLOptimizedGetAll.Trim(), SqlHelper.CreateParameter("@nodeObjectType", nodeObjectType)))
|
||||
{
|
||||
while (dr.Read())
|
||||
{
|
||||
//create the ContentType object without setting up
|
||||
ContentType ct = new ContentType(dr.Get<int>("id"), true);
|
||||
var ct = new ContentType(dr.Get<int>("id"), true);
|
||||
//populate it's CMSNode properties
|
||||
ct.PopulateCMSNodeFromReader(dr);
|
||||
//populate it's ContentType properties
|
||||
@@ -853,10 +840,10 @@ namespace umbraco.cms.businesslogic
|
||||
PropertyType pt = PropertyType.MakeNew(dt, this, Name, Alias);
|
||||
|
||||
// Optimized call
|
||||
populatePropertyData(pt, this.Id);
|
||||
PopulatePropertyData(pt, Id);
|
||||
|
||||
// Inherited content types (document types only)
|
||||
populateMasterContentTypes(pt, this.Id);
|
||||
PopulateMasterContentTypes(pt, Id);
|
||||
|
||||
// foreach (Content c in Content.getContentOfContentType(this))
|
||||
// c.addProperty(pt,c.Version);
|
||||
@@ -952,7 +939,7 @@ namespace umbraco.cms.businesslogic
|
||||
/// Updates the sort order of the Tab
|
||||
/// </summary>
|
||||
/// <param name="tabId">The Id of the Tab to be updated</param>
|
||||
/// <param name="Caption">The new order number</param>
|
||||
/// <param name="sortOrder">The new order number</param>
|
||||
[Obsolete("Use PropertyTypeGroup methods instead", false)]
|
||||
public void SetTabSortOrder(int tabId, int sortOrder)
|
||||
{
|
||||
@@ -972,18 +959,14 @@ namespace umbraco.cms.businesslogic
|
||||
public PropertyType getPropertyType(string alias)
|
||||
{
|
||||
// NH 22-08-08, Get from the property type stack to ensure support of master document types
|
||||
object o = this.PropertyTypes.Find(pt => pt.Alias == alias);
|
||||
object o = PropertyTypes.Find(pt => pt.Alias == alias);
|
||||
|
||||
if (o == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (PropertyType)o;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the current ContentType
|
||||
/// </summary>
|
||||
@@ -993,9 +976,9 @@ namespace umbraco.cms.businesslogic
|
||||
FlushFromCache(Id);
|
||||
|
||||
// Delete all propertyTypes
|
||||
foreach (PropertyType pt in PropertyTypes)
|
||||
foreach (var pt in PropertyTypes)
|
||||
{
|
||||
if (pt.ContentTypeId == this.Id)
|
||||
if (pt.ContentTypeId == Id)
|
||||
{
|
||||
pt.delete();
|
||||
}
|
||||
@@ -1080,8 +1063,7 @@ namespace umbraco.cms.businesslogic
|
||||
}
|
||||
|
||||
// TODO: Load master content types
|
||||
using (IRecordsReader dr =
|
||||
SqlHelper.ExecuteReader("Select allowAtRoot, isContainer, Alias,icon,thumbnail,description from cmsContentType where nodeid=" + Id)
|
||||
using (var dr = SqlHelper.ExecuteReader("Select allowAtRoot, isContainer, Alias,icon,thumbnail,description from cmsContentType where nodeid=" + Id)
|
||||
)
|
||||
{
|
||||
if (dr.Read())
|
||||
@@ -1134,7 +1116,6 @@ namespace umbraco.cms.businesslogic
|
||||
ApplicationContext.Current.ApplicationCache.ClearCacheByKeySearch(CacheKeys.ContentTypePropertiesCacheKey);
|
||||
|
||||
RemoveAllDataTypeCache();
|
||||
|
||||
ClearVirtualTabs();
|
||||
}
|
||||
|
||||
@@ -1163,12 +1144,12 @@ namespace umbraco.cms.businesslogic
|
||||
// If that happens, the m_VirtualTabs will contain duplicates.
|
||||
// We must prevent two threads from running InitializeVirtualTabs at the same time.
|
||||
// We must also prevent m_VirtualTabs from being modified while it is being populated.
|
||||
if (m_VirtualTabs == null || m_VirtualTabs.Count == 0)
|
||||
if (_virtualTabs == null || _virtualTabs.Count == 0)
|
||||
{
|
||||
lock (_virtualTabLoadLock)
|
||||
{
|
||||
//optimize, lazy load the data only one time
|
||||
if (m_VirtualTabs == null || m_VirtualTabs.Count == 0)
|
||||
if (_virtualTabs == null || _virtualTabs.Count == 0)
|
||||
{
|
||||
InitializeVirtualTabs();
|
||||
}
|
||||
@@ -1200,23 +1181,23 @@ namespace umbraco.cms.businesslogic
|
||||
temporaryList.Sort((a, b) => a.SortOrder.CompareTo(b.SortOrder));
|
||||
|
||||
// now that we aren't going to modify the list, we can set it to the class-scoped variable.
|
||||
m_VirtualTabs = temporaryList.DistinctBy(x => x.Id).ToList();
|
||||
_virtualTabs = temporaryList.DistinctBy(x => x.Id).ToList();
|
||||
}
|
||||
|
||||
private void populateMasterContentTypes(PropertyType pt, int docTypeId)
|
||||
private static void PopulateMasterContentTypes(PropertyType pt, int docTypeId)
|
||||
{
|
||||
foreach (web.DocumentType docType in web.DocumentType.GetAllAsList())
|
||||
foreach (var docType in DocumentType.GetAllAsList())
|
||||
{
|
||||
//TODO: Check for multiple references (mixins) not causing endless loops!
|
||||
if (docType.MasterContentTypes.Contains(docTypeId))
|
||||
{
|
||||
populatePropertyData(pt, docType.Id);
|
||||
populateMasterContentTypes(pt, docType.Id);
|
||||
PopulatePropertyData(pt, docType.Id);
|
||||
PopulateMasterContentTypes(pt, docType.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void populatePropertyData(PropertyType pt, int contentTypeId)
|
||||
private static void PopulatePropertyData(PropertyType pt, int contentTypeId)
|
||||
{
|
||||
// NH: PropertyTypeId inserted directly into SQL instead of as a parameter for SQL CE 4 compatibility
|
||||
SqlHelper.ExecuteNonQuery(
|
||||
@@ -1389,7 +1370,7 @@ namespace umbraco.cms.businesslogic
|
||||
[Obsolete("Please use GetPropertyTypes() instead", false)]
|
||||
public PropertyType[] PropertyTypes
|
||||
{
|
||||
get { return GetPropertyTypes(this.ContentType, true); }
|
||||
get { return GetPropertyTypes(ContentType, true); }
|
||||
}
|
||||
|
||||
|
||||
@@ -1429,17 +1410,12 @@ namespace umbraco.cms.businesslogic
|
||||
var tempCaption = SqlHelper.ExecuteScalar<string>("Select text from cmsPropertyTypeGroup where id = " + id.ToString());
|
||||
if (!tempCaption.StartsWith("#"))
|
||||
return tempCaption;
|
||||
else
|
||||
{
|
||||
Language lang =
|
||||
Language.GetByCultureCode(Thread.CurrentThread.CurrentCulture.Name);
|
||||
var lang = Language.GetByCultureCode(Thread.CurrentThread.CurrentCulture.Name);
|
||||
if (lang != null)
|
||||
return
|
||||
new Dictionary.DictionaryItem(tempCaption.Substring(1, tempCaption.Length - 1)).Value(
|
||||
lang.id);
|
||||
else
|
||||
return "[" + tempCaption + "]";
|
||||
{
|
||||
return new Dictionary.DictionaryItem(tempCaption.Substring(1, tempCaption.Length - 1)).Value(lang.id);
|
||||
}
|
||||
return "[" + tempCaption + "]";
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -1447,9 +1423,9 @@ namespace umbraco.cms.businesslogic
|
||||
}
|
||||
}
|
||||
|
||||
private int _id;
|
||||
private readonly int _id;
|
||||
|
||||
private int? _sortOrder = null;
|
||||
private int? _sortOrder;
|
||||
|
||||
/// <summary>
|
||||
/// The sortorder of the tab
|
||||
@@ -1482,10 +1458,10 @@ namespace umbraco.cms.businesslogic
|
||||
// hence moving it up.
|
||||
if (SortOrder > 0)
|
||||
{
|
||||
int newsortorder = SortOrder - 1;
|
||||
var newsortorder = SortOrder - 1;
|
||||
// Find the tab to switch with
|
||||
TabI[] Tabs = _contenttype.getVirtualTabs;
|
||||
foreach (Tab t in Tabs)
|
||||
var tabs = _contenttype.getVirtualTabs;
|
||||
foreach (Tab t in tabs)
|
||||
{
|
||||
if (t.SortOrder == newsortorder)
|
||||
t.SortOrder = SortOrder;
|
||||
@@ -1503,12 +1479,12 @@ namespace umbraco.cms.businesslogic
|
||||
FixTabOrder();
|
||||
// If this tab is not the last tab we can switch places with the next tab
|
||||
// hence moving it down.
|
||||
TabI[] Tabs = _contenttype.getVirtualTabs;
|
||||
if (SortOrder < Tabs.Length - 1)
|
||||
var tabs = _contenttype.getVirtualTabs;
|
||||
if (SortOrder < tabs.Length - 1)
|
||||
{
|
||||
int newsortorder = SortOrder + 1;
|
||||
var newsortorder = SortOrder + 1;
|
||||
// Find the tab to switch with
|
||||
foreach (Tab t in Tabs)
|
||||
foreach (Tab t in tabs)
|
||||
{
|
||||
if (t.SortOrder == newsortorder)
|
||||
t.SortOrder = SortOrder;
|
||||
@@ -1534,10 +1510,10 @@ namespace umbraco.cms.businesslogic
|
||||
/// </summary>
|
||||
private void FixTabOrder()
|
||||
{
|
||||
TabI[] Tabs = _contenttype.getVirtualTabs;
|
||||
for (int i = 0; i < Tabs.Length; i++)
|
||||
var tabs = _contenttype.getVirtualTabs;
|
||||
for (int i = 0; i < tabs.Length; i++)
|
||||
{
|
||||
Tab t = (Tab)Tabs[i];
|
||||
var t = (Tab)tabs[i];
|
||||
t.SortOrder = i;
|
||||
}
|
||||
}
|
||||
@@ -1572,17 +1548,13 @@ namespace umbraco.cms.businesslogic
|
||||
{
|
||||
if (!_caption.StartsWith("#"))
|
||||
return _caption;
|
||||
else
|
||||
{
|
||||
Language lang =
|
||||
Language.GetByCultureCode(Thread.CurrentThread.CurrentCulture.Name);
|
||||
|
||||
var lang = Language.GetByCultureCode(Thread.CurrentThread.CurrentCulture.Name);
|
||||
if (lang != null)
|
||||
{
|
||||
if (Dictionary.DictionaryItem.hasKey(_caption.Substring(1, _caption.Length - 1)))
|
||||
{
|
||||
var di =
|
||||
new Dictionary.DictionaryItem(_caption.Substring(1, _caption.Length - 1));
|
||||
if (di != null)
|
||||
var di = new Dictionary.DictionaryItem(_caption.Substring(1, _caption.Length - 1));
|
||||
return di.Value(lang.id);
|
||||
}
|
||||
}
|
||||
@@ -1591,7 +1563,6 @@ namespace umbraco.cms.businesslogic
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
@@ -6,11 +6,9 @@ using System.Xml;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Logging;
|
||||
using umbraco.cms.businesslogic.cache;
|
||||
using umbraco.DataLayer;
|
||||
using umbraco.BusinessLogic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace umbraco.cms.businesslogic.language
|
||||
{
|
||||
@@ -56,9 +54,7 @@ namespace umbraco.cms.businesslogic.language
|
||||
/// <param name="id">The id.</param>
|
||||
public Language(int id)
|
||||
{
|
||||
var lang = GetAllAsList()
|
||||
.Where(x => x.id == id)
|
||||
.SingleOrDefault();
|
||||
var lang = GetAllAsList().SingleOrDefault(x => x.id == id);
|
||||
if (lang == null)
|
||||
{
|
||||
throw new ArgumentException("No language found with the specified id");
|
||||
@@ -184,17 +180,14 @@ namespace umbraco.cms.businesslogic.language
|
||||
/// <returns></returns>
|
||||
public static Language Import(XmlNode xmlData)
|
||||
{
|
||||
string cA = xmlData.Attributes["CultureAlias"].Value;
|
||||
var cA = xmlData.Attributes["CultureAlias"].Value;
|
||||
if (GetByCultureCode(cA) == null)
|
||||
{
|
||||
MakeNew(cA);
|
||||
return GetByCultureCode(cA);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -282,10 +275,6 @@ namespace umbraco.cms.businesslogic.language
|
||||
/// </remarks>
|
||||
public void Delete()
|
||||
{
|
||||
//if (this.id == DefaultLanguageId)
|
||||
//{
|
||||
// throw new InvalidOperationException("You cannot delete the default language: en-US");
|
||||
//}
|
||||
lock (Locker)
|
||||
{
|
||||
if (SqlHelper.ExecuteScalar<int>("SELECT count(id) FROM umbracoDomains where domainDefaultLanguage = @id",
|
||||
@@ -322,10 +311,10 @@ namespace umbraco.cms.businesslogic.language
|
||||
/// <returns></returns>
|
||||
public XmlNode ToXml(XmlDocument xd)
|
||||
{
|
||||
XmlNode language = xd.CreateElement("Language");
|
||||
language.Attributes.Append(xmlHelper.addAttribute(xd, "Id", this.id.ToString()));
|
||||
language.Attributes.Append(xmlHelper.addAttribute(xd, "CultureAlias", this.CultureAlias));
|
||||
language.Attributes.Append(xmlHelper.addAttribute(xd, "FriendlyName", this.FriendlyName));
|
||||
var language = xd.CreateElement("Language");
|
||||
language.Attributes.Append(XmlHelper.AddAttribute(xd, "Id", id.ToString()));
|
||||
language.Attributes.Append(XmlHelper.AddAttribute(xd, "CultureAlias", CultureAlias));
|
||||
language.Attributes.Append(XmlHelper.AddAttribute(xd, "FriendlyName", FriendlyName));
|
||||
|
||||
return language;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user