From 164398a7c6b533185cf0771269f451d4af5a7f3d Mon Sep 17 00:00:00 2001 From: yevhen_povzlo Date: Tue, 15 Dec 2020 16:12:43 +0200 Subject: [PATCH] Initial code --- .editorconfig | 5 + src/Sitecore.Support.430451.sln | 22 +++ .../zzz/Sitecore.Support.430451.config | 4 + .../Properties/AssemblyInfo.cs | 6 + src/Sitecore.Support.430451/Rendering.cs | 170 ++++++++++++++++++ .../Sitecore.Support.430451.csproj | 111 ++++++++++++ src/Sitecore.Support.430451/packages.config | 9 + src/Sitecore.Support.430451/web.config | 4 + 8 files changed, 331 insertions(+) create mode 100644 .editorconfig create mode 100644 src/Sitecore.Support.430451.sln create mode 100644 src/Sitecore.Support.430451/App_Config/Include/zzz/Sitecore.Support.430451.config create mode 100644 src/Sitecore.Support.430451/Properties/AssemblyInfo.cs create mode 100644 src/Sitecore.Support.430451/Rendering.cs create mode 100644 src/Sitecore.Support.430451/Sitecore.Support.430451.csproj create mode 100644 src/Sitecore.Support.430451/packages.config create mode 100644 src/Sitecore.Support.430451/web.config diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..20f59eb --- /dev/null +++ b/.editorconfig @@ -0,0 +1,5 @@ +root = true + +[*.{cs,sln,csproj,config,xml}] +indent_size = 4 +indent_style = space diff --git a/src/Sitecore.Support.430451.sln b/src/Sitecore.Support.430451.sln new file mode 100644 index 0000000..91a814d --- /dev/null +++ b/src/Sitecore.Support.430451.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25123.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{B2C04B42-19BB-4F74-AC3F-9AA8951F9142}") = "Sitecore.Support.430451", "Sitecore.Support.430451\Sitecore.Support.430451.csproj", "{A01DCA8E-339C-4462-872F-991715429EFC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A01DCA8E-339C-4462-872F-991715429EFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A01DCA8E-339C-4462-872F-991715429EFC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A01DCA8E-339C-4462-872F-991715429EFC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A01DCA8E-339C-4462-872F-991715429EFC}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/src/Sitecore.Support.430451/App_Config/Include/zzz/Sitecore.Support.430451.config b/src/Sitecore.Support.430451/App_Config/Include/zzz/Sitecore.Support.430451.config new file mode 100644 index 0000000..07a20b1 --- /dev/null +++ b/src/Sitecore.Support.430451/App_Config/Include/zzz/Sitecore.Support.430451.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/Sitecore.Support.430451/Properties/AssemblyInfo.cs b/src/Sitecore.Support.430451/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..ea56126 --- /dev/null +++ b/src/Sitecore.Support.430451/Properties/AssemblyInfo.cs @@ -0,0 +1,6 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Sitecore.Support.430451")] +[assembly: AssemblyProduct("Sitecore.Support.430451")] +[assembly: ComVisible(false)] diff --git a/src/Sitecore.Support.430451/Rendering.cs b/src/Sitecore.Support.430451/Rendering.cs new file mode 100644 index 0000000..be7e473 --- /dev/null +++ b/src/Sitecore.Support.430451/Rendering.cs @@ -0,0 +1,170 @@ +namespace Sitecore.XA.Foundation.Mvc.Wrappers +{ + using Sitecore.Data; + using Sitecore.Data.Items; + using Sitecore.Mvc.Presentation; + using Sitecore.XA.Foundation.Mvc; + using Sitecore.XA.Foundation.Mvc.Wrappers; + using Sitecore.XA.Foundation.Presentation.Services; + using Sitecore.XA.Foundation.SitecoreExtensions.Interfaces; + + public class Rendering : IRendering + { + private Parameters _parameters; + + private readonly Sitecore.Mvc.Presentation.Rendering _sitecoreRendering; + + public RenderingProperties Properties => _sitecoreRendering.Properties; + + public Item Item + { + get + { + Item item = DataSourceItem; + if (item == null) + { + RenderingModel obj = _sitecoreRendering.Model as RenderingModel; + if (obj == null) + { + return null; + } + item = obj.PageItem; + } + return item; + } + } + + public Item DataSourceItem + { + get + { + if (!string.IsNullOrEmpty(_sitecoreRendering.DataSource)) + { + return _sitecoreRendering.Item; + } + return PlaceholderDatasourceContext.CurrentOrNull?.ContextItem; + } + } + + public string DataSource => _sitecoreRendering.DataSource; + + public virtual IParameters Parameters => _parameters ?? (_parameters = new Parameters(_sitecoreRendering.Parameters)); + + public string Name + { + get + { + if (_sitecoreRendering?.RenderingItem != null) + { + return _sitecoreRendering.RenderingItem.Name; + } + return string.Empty; + } + } + + public ID SnippetId + { + get + { + string id = _sitecoreRendering.Properties["sid"]; + if (ID.IsID(id)) + { + return new ID(id); + } + return null; + } + } + + public ID UniqueId + { + get + { + string id = Properties["uid"]; + if (ID.IsID(id)) + { + return new ID(id); + } + return null; + } + } + + public string UniqueIdString + { + get + { + if (!(UniqueId == (ID)null)) + { + return UniqueId.ToString(); + } + return string.Empty; + } + } + + public bool IsFromSnippet => !ID.IsNullOrEmpty(SnippetId); + + public string OriginalDataSource => Properties["ods"]; + + public ID RenderingId + { + get + { + string id = Properties["id"]; + if (ID.IsID(id)) + { + return new ID(id); + } + return null; + } + } + + public string RenderingCssClass + { + get + { + string text = _sitecoreRendering.RenderingItem.InnerItem[Templates.ExtendedOptions.Fields.RenderingCssClass]; + if (!string.IsNullOrWhiteSpace(text)) + { + return text; + } + return null; + } + } + + public string RenderingViewPath + { + get + { + string text = _sitecoreRendering.RenderingItem.InnerItem[Templates.ExtendedOptions.Fields.RenderingViewPath]; + if (!string.IsNullOrWhiteSpace(text)) + { + return text; + } + return null; + } + } + + public string ControllerType + { + get + { + string text = _sitecoreRendering.RenderingItem.InnerItem[Templates.ControllerRendering.Fields.Controller]; + if (string.IsNullOrWhiteSpace(text)) + { + return null; + } + return text; + } + } + + public Rendering() + { + RenderingContext currentOrNull = RenderingContext.CurrentOrNull; + _sitecoreRendering = ((currentOrNull != null) ? currentOrNull.Rendering : new Sitecore.Mvc.Presentation.Rendering()); + } + + public Rendering(Sitecore.Mvc.Presentation.Rendering sitecoreRendering) + { + _sitecoreRendering = sitecoreRendering; + } + } +} \ No newline at end of file diff --git a/src/Sitecore.Support.430451/Sitecore.Support.430451.csproj b/src/Sitecore.Support.430451/Sitecore.Support.430451.csproj new file mode 100644 index 0000000..8f6a782 --- /dev/null +++ b/src/Sitecore.Support.430451/Sitecore.Support.430451.csproj @@ -0,0 +1,111 @@ + + + + + Debug + AnyCPU + + + 2.0 + {A01DCA8E-339C-4462-872F-991715429EFC} + {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + Sitecore.Support + Sitecore.Support.430451 + v4.6.2 + true + + + + + + + 6 + + + + true + full + false + bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\ + TRACE + prompt + 4 + + + + ..\packages\SC.Sitecore.Kernel.9.0.2\lib\Sitecore.Kernel.dll + False + + + ..\packages\SC.Sitecore.Mvc.9.0.2\lib\Sitecore.Mvc.dll + False + + + ..\packages\SXA90.Sitecore.XA.Foundation.Common.1.8.0\lib\Sitecore.XA.Foundation.Common.dll + False + + + ..\packages\SXA90.Sitecore.XA.Foundation.Mvc.1.8.0\lib\Sitecore.XA.Foundation.Mvc.dll + False + + + ..\packages\SXA90.Sitecore.XA.Foundation.Presentation.1.8.0\lib\Sitecore.XA.Foundation.Presentation.dll + False + + + ..\packages\SXA90.Sitecore.XA.Foundation.SitecoreExtensions.1.8.0\lib\Sitecore.XA.Foundation.SitecoreExtensions.dll + False + + + + + + + + + + + + + + + + + + + + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + + + + + True + True + 0 + / + http://localhost:56279/ + False + False + + + False + + + + + \ No newline at end of file diff --git a/src/Sitecore.Support.430451/packages.config b/src/Sitecore.Support.430451/packages.config new file mode 100644 index 0000000..a42771b --- /dev/null +++ b/src/Sitecore.Support.430451/packages.config @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/Sitecore.Support.430451/web.config b/src/Sitecore.Support.430451/web.config new file mode 100644 index 0000000..7e1d425 --- /dev/null +++ b/src/Sitecore.Support.430451/web.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file