Revert thumbnail changes
This commit is contained in:
@@ -39,8 +39,6 @@ namespace Umbraco.Core.IO
|
||||
|
||||
public static string Preview => Data + "/preview";
|
||||
|
||||
public static string Thumbnails => Config + "/thumbnails";
|
||||
|
||||
private static string _root;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
using Umbraco.Core.Strings;
|
||||
|
||||
@@ -22,6 +20,7 @@ namespace Umbraco.Core.Models
|
||||
private string _alias;
|
||||
private string _description;
|
||||
private string _icon = "icon-folder";
|
||||
private string _thumbnail = "folder.png";
|
||||
private bool _allowedAsRoot; // note: only one that's not 'pure element type'
|
||||
private bool _isContainer;
|
||||
private bool _isElement;
|
||||
@@ -153,14 +152,8 @@ namespace Umbraco.Core.Models
|
||||
[DataMember]
|
||||
public string Thumbnail
|
||||
{
|
||||
get
|
||||
{
|
||||
var thumbsFolder = new DirectoryInfo(IOHelper.MapPath(SystemDirectories.Thumbnails));
|
||||
var files = Directory.GetFiles(thumbsFolder.FullName, $"{Alias}.*");
|
||||
|
||||
return files.Length == 1 ?
|
||||
IOHelper.ResolveVirtualUrl($"{SystemDirectories.Thumbnails}/{System.IO.Path.GetFileName(files[0])}") : null;
|
||||
}
|
||||
get => _thumbnail;
|
||||
set => SetPropertyValueAndDetectChanges(value, ref _thumbnail, nameof(Thumbnail));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -479,7 +472,7 @@ namespace Umbraco.Core.Models
|
||||
{
|
||||
base.PerformDeepClone(clone);
|
||||
|
||||
var clonedEntity = (ContentTypeBase)clone;
|
||||
var clonedEntity = (ContentTypeBase) clone;
|
||||
|
||||
if (clonedEntity._noGroupPropertyTypes != null)
|
||||
{
|
||||
@@ -488,14 +481,14 @@ namespace Umbraco.Core.Models
|
||||
// we end up with duplicates, see: http://issues.umbraco.org/issue/U4-4842
|
||||
|
||||
clonedEntity._noGroupPropertyTypes.CollectionChanged -= PropertyTypesChanged; //clear this event handler if any
|
||||
clonedEntity._noGroupPropertyTypes = (PropertyTypeCollection)_noGroupPropertyTypes.DeepClone(); //manually deep clone
|
||||
clonedEntity._noGroupPropertyTypes = (PropertyTypeCollection) _noGroupPropertyTypes.DeepClone(); //manually deep clone
|
||||
clonedEntity._noGroupPropertyTypes.CollectionChanged += clonedEntity.PropertyTypesChanged; //re-assign correct event handler
|
||||
}
|
||||
|
||||
if (clonedEntity._propertyGroups != null)
|
||||
{
|
||||
clonedEntity._propertyGroups.CollectionChanged -= PropertyGroupsChanged; //clear this event handler if any
|
||||
clonedEntity._propertyGroups = (PropertyGroupCollection)_propertyGroups.DeepClone(); //manually deep clone
|
||||
clonedEntity._propertyGroups = (PropertyGroupCollection) _propertyGroups.DeepClone(); //manually deep clone
|
||||
clonedEntity._propertyGroups.CollectionChanged += clonedEntity.PropertyGroupsChanged; //re-assign correct event handler
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Umbraco.Core.Models
|
||||
/// <summary>
|
||||
/// Gets or Sets the Thumbnail for the ContentType
|
||||
/// </summary>
|
||||
string Thumbnail { get; }
|
||||
string Thumbnail { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets a boolean indicating whether this ContentType is allowed at the root
|
||||
|
||||
@@ -572,6 +572,7 @@ namespace Umbraco.Core.Packaging
|
||||
|
||||
contentType.Name = infoElement.Element("Name").Value;
|
||||
contentType.Icon = infoElement.Element("Icon").Value;
|
||||
contentType.Thumbnail = infoElement.Element("Thumbnail").Value;
|
||||
contentType.Description = infoElement.Element("Description").Value;
|
||||
|
||||
//NOTE AllowAtRoot is a new property in the package xml so we need to verify it exists before using it.
|
||||
|
||||
@@ -110,6 +110,7 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
entity.Alias = dto.Alias;
|
||||
entity.Name = dto.NodeDto.Text;
|
||||
entity.Icon = dto.Icon;
|
||||
entity.Thumbnail = dto.Thumbnail;
|
||||
entity.SortOrder = dto.NodeDto.SortOrder;
|
||||
entity.Description = dto.Description;
|
||||
entity.CreateDate = dto.NodeDto.CreateDate;
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace Umbraco.Core.Persistence.Mappers
|
||||
DefineMap<ContentType, ContentTypeDto>(nameof(ContentType.Icon), nameof(ContentTypeDto.Icon));
|
||||
DefineMap<ContentType, ContentTypeDto>(nameof(ContentType.IsContainer), nameof(ContentTypeDto.IsContainer));
|
||||
DefineMap<ContentType, ContentTypeDto>(nameof(ContentType.IsElement), nameof(ContentTypeDto.IsElement));
|
||||
DefineMap<ContentType, ContentTypeDto>(nameof(ContentType.Thumbnail), nameof(ContentTypeDto.Thumbnail));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,6 +184,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
target.Name = source.Name;
|
||||
target.ParentId = source.ParentId;
|
||||
target.Path = source.Path;
|
||||
target.Thumbnail = source.Thumbnail;
|
||||
target.Trashed = source.Trashed;
|
||||
target.UpdateDate = source.UpdateDate;
|
||||
}
|
||||
@@ -386,6 +387,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
target.Name = source.Name;
|
||||
target.ParentId = source.ParentId;
|
||||
target.Path = source.Path;
|
||||
target.Thumbnail = source.Thumbnail;
|
||||
|
||||
target.AllowedAsRoot = source.AllowAsRoot;
|
||||
target.AllowedContentTypes = source.AllowedContentTypes.Select((t, i) => new ContentTypeSort(t, i));
|
||||
@@ -481,6 +483,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
target.Name = source.Name;
|
||||
target.ParentId = source.ParentId;
|
||||
target.Path = source.Path;
|
||||
target.Thumbnail = source.Thumbnail;
|
||||
target.Udi = MapContentTypeUdi(source);
|
||||
target.UpdateDate = source.UpdateDate;
|
||||
|
||||
@@ -517,6 +520,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
target.Name = source.Name;
|
||||
target.ParentId = source.ParentId;
|
||||
target.Path = source.Path;
|
||||
target.Thumbnail = source.Thumbnail;
|
||||
target.Trashed = source.Trashed;
|
||||
target.Udi = source.Udi;
|
||||
}
|
||||
|
||||
@@ -75,6 +75,48 @@ namespace Umbraco.Web.Models.Trees
|
||||
[DataMember(Name = "menuUrl")]
|
||||
public string MenuUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the icon represents a CSS class instead of a file path
|
||||
/// </summary>
|
||||
[DataMember(Name = "iconIsClass")]
|
||||
public bool IconIsClass
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Icon.IsNullOrWhiteSpace())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Icon.StartsWith(".."))
|
||||
return false;
|
||||
|
||||
|
||||
//if it starts with a '.' or doesn't contain a '.' at all then it is a class
|
||||
return Icon.StartsWith(".") || Icon.Contains(".") == false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the icon file path if the icon is not a class, otherwise returns an empty string
|
||||
/// </summary>
|
||||
[DataMember(Name = "iconFilePath")]
|
||||
public string IconFilePath
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IconIsClass)
|
||||
return string.Empty;
|
||||
|
||||
//absolute path with or without tilde
|
||||
if (Icon.StartsWith("~") || Icon.StartsWith("/"))
|
||||
return IOHelper.ResolveUrl("~" + Icon.TrimStart('~'));
|
||||
|
||||
//legacy icon path
|
||||
return string.Format("{0}images/umbraco/{1}", Current.Configs.Global().Path.EnsureEndsWith("/"), Icon);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A list of additional/custom css classes to assign to the node
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user