-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes: U4-5943 Cannot render a macro on a virtual page when using Umb…
…racoVirtualNodeRouteHandler and assigning virtual Ids
- Loading branch information
Showing
8 changed files
with
284 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Data; | ||
using System.Linq; | ||
using Umbraco.Core.Models; | ||
using Umbraco.Core.Models.PublishedContent; | ||
using umbraco.interfaces; | ||
|
||
namespace Umbraco.Web.Models | ||
{ | ||
/// <summary> | ||
/// A legacy INode that wraps IPublishedContent | ||
/// </summary> | ||
internal class LegacyConvertedNode : PublishedContentWrapped, INode | ||
{ | ||
private readonly IPublishedContent _publishedContent; | ||
private readonly int _id; | ||
private readonly int _template; | ||
private readonly int _sortOrder; | ||
private readonly string _name; | ||
private readonly string _urlName; | ||
private readonly string _nodeTypeAlias; | ||
private readonly string _writerName; | ||
private readonly string _creatorName; | ||
private readonly int _writerId; | ||
private readonly int _creatorId; | ||
private readonly string _path; | ||
private readonly DateTime _createDate; | ||
private readonly DateTime _updateDate; | ||
private readonly Guid _version; | ||
private readonly int _level; | ||
|
||
public LegacyConvertedNode(IPublishedContent publishedContent) : base(publishedContent) | ||
{ | ||
_publishedContent = publishedContent; | ||
|
||
if (publishedContent == null) | ||
{ | ||
_id = 0; | ||
return; | ||
} | ||
|
||
_template = publishedContent.TemplateId; | ||
_id = publishedContent.Id; | ||
_path = publishedContent.Path; | ||
_creatorName = publishedContent.CreatorName; | ||
_sortOrder = publishedContent.SortOrder; | ||
_updateDate = publishedContent.UpdateDate; | ||
_name = publishedContent.Name; | ||
_nodeTypeAlias = publishedContent.DocumentTypeAlias; | ||
_createDate = publishedContent.CreateDate; | ||
_creatorId = publishedContent.CreatorId; | ||
_level = publishedContent.Level; | ||
_urlName = publishedContent.UrlName; | ||
_version = publishedContent.Version; | ||
_writerId = publishedContent.WriterId; | ||
_writerName = publishedContent.WriterName; | ||
} | ||
|
||
INode INode.Parent | ||
{ | ||
get { return _publishedContent.Parent == null ? null : LegacyNodeHelper.ConvertToNode(_publishedContent.Parent); } | ||
} | ||
|
||
int INode.Id | ||
{ | ||
get { return _id; } | ||
} | ||
|
||
int INode.template | ||
{ | ||
get { return _template; } | ||
} | ||
|
||
int INode.SortOrder | ||
{ | ||
get { return _sortOrder; } | ||
} | ||
|
||
string INode.Name | ||
{ | ||
get { return _name; } | ||
} | ||
|
||
string INode.UrlName | ||
{ | ||
get { return _urlName; } | ||
} | ||
|
||
string INode.NodeTypeAlias | ||
{ | ||
get { return _nodeTypeAlias; } | ||
} | ||
|
||
string INode.WriterName | ||
{ | ||
get { return _writerName; } | ||
} | ||
|
||
string INode.CreatorName | ||
{ | ||
get { return _creatorName; } | ||
} | ||
|
||
int INode.WriterID | ||
{ | ||
get { return _writerId; } | ||
} | ||
|
||
int INode.CreatorID | ||
{ | ||
get { return _creatorId; } | ||
} | ||
|
||
string INode.Path | ||
{ | ||
get { return _path; } | ||
} | ||
|
||
DateTime INode.CreateDate | ||
{ | ||
get { return _createDate; } | ||
} | ||
|
||
DateTime INode.UpdateDate | ||
{ | ||
get { return _updateDate; } | ||
} | ||
|
||
Guid INode.Version | ||
{ | ||
get { return _version; } | ||
} | ||
|
||
string INode.NiceUrl | ||
{ | ||
get { return _publishedContent.Url; } | ||
} | ||
|
||
string INode.Url | ||
{ | ||
get { return _publishedContent.Url; } | ||
} | ||
|
||
int INode.Level | ||
{ | ||
get { return _level; } | ||
} | ||
|
||
List<IProperty> INode.PropertiesAsList | ||
{ | ||
get { return _publishedContent.Properties.Select(LegacyNodeHelper.ConvertToNodeProperty).ToList(); } | ||
} | ||
|
||
List<INode> INode.ChildrenAsList | ||
{ | ||
get { return _publishedContent.Children.Select(LegacyNodeHelper.ConvertToNode).ToList(); } | ||
} | ||
|
||
IProperty INode.GetProperty(string alias) | ||
{ | ||
return ((INode)this).PropertiesAsList.Cast<global::umbraco.NodeFactory.Property>().FirstOrDefault(p => p.Alias == alias); | ||
} | ||
|
||
IProperty INode.GetProperty(string alias, out bool propertyExists) | ||
{ | ||
var prop = _publishedContent.GetProperty(alias); | ||
propertyExists = prop != null; | ||
return prop == null ? null : LegacyNodeHelper.ConvertToNodeProperty(prop); | ||
} | ||
|
||
DataTable INode.ChildrenAsTable() | ||
{ | ||
return _publishedContent.ChildrenAsTable(); | ||
} | ||
|
||
DataTable INode.ChildrenAsTable(string nodeTypeAliasFilter) | ||
{ | ||
return _publishedContent.ChildrenAsTable(nodeTypeAliasFilter); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System; | ||
using System.Web; | ||
using Umbraco.Core.Models; | ||
using umbraco.interfaces; | ||
|
||
namespace Umbraco.Web.Models | ||
{ | ||
/// <summary> | ||
/// A legacy IProperty that wraps IPublishedProperty | ||
/// </summary> | ||
internal class LegacyConvertedNodeProperty : IProperty, IHtmlString | ||
{ | ||
public IPublishedProperty PublishedProperty { get; private set; } | ||
|
||
public LegacyConvertedNodeProperty(IPublishedProperty prop) | ||
{ | ||
PublishedProperty = prop; | ||
} | ||
|
||
public string Alias | ||
{ | ||
get { return PublishedProperty.PropertyTypeAlias; } | ||
} | ||
|
||
public string Value | ||
{ | ||
get { return PublishedProperty.DataValue == null ? null : PublishedProperty.DataValue.ToString(); } | ||
} | ||
|
||
public Guid Version | ||
{ | ||
get { return Guid.Empty; } | ||
} | ||
|
||
public bool IsNull() | ||
{ | ||
return Value == null; | ||
} | ||
|
||
public bool HasValue() | ||
{ | ||
return PublishedProperty.HasValue; | ||
} | ||
|
||
public int ContextId { get; set; } | ||
public string ContextAlias { get; set; } | ||
|
||
// implements IHtmlString.ToHtmlString | ||
public string ToHtmlString() | ||
{ | ||
return Value; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Umbraco.Core.Models; | ||
using umbraco.interfaces; | ||
|
||
namespace Umbraco.Web.Models | ||
{ | ||
/// <summary> | ||
/// Used to convert to/from the legacy INode from IPublishedContent | ||
/// </summary> | ||
internal static class LegacyNodeHelper | ||
{ | ||
// NOTE - moved from umbraco.MacroEngines to avoid circ. references | ||
|
||
public static INode ConvertToNode(IPublishedContent doc) | ||
{ | ||
var node = new LegacyConvertedNode(doc); | ||
return node; | ||
} | ||
|
||
public static IProperty ConvertToNodeProperty(IPublishedProperty prop) | ||
{ | ||
return new LegacyConvertedNodeProperty(prop); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.