Skip to content

Commit

Permalink
Fix for XP 9.0.2 / SXA 1.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonKechashin committed Jan 13, 2021
1 parent c65a7c3 commit f84d616
Show file tree
Hide file tree
Showing 8 changed files with 190 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .editorconfig
@@ -0,0 +1,5 @@
root = true

[*.{cs,sln,csproj,config,xml}]
indent_size = 4
indent_style = space
22 changes: 22 additions & 0 deletions src/Sitecore.Support.247754.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("{526067C8-DAAB-45DD-9B7F-16CAC12B32FB}") = "Sitecore.Support.247754", "Sitecore.Support.247754\Sitecore.Support.247754.csproj", "{DF9FC498-50E4-4F2B-9A0B-5B4456390B20}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DF9FC498-50E4-4F2B-9A0B-5B4456390B20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DF9FC498-50E4-4F2B-9A0B-5B4456390B20}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DF9FC498-50E4-4F2B-9A0B-5B4456390B20}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DF9FC498-50E4-4F2B-9A0B-5B4456390B20}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
@@ -0,0 +1,9 @@
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
<sitecore role:require="Standalone OR ContentManagement OR ContentDelivery">
<pipelines>
<getVariants>
<processor type="Sitecore.XA.Foundation.Variants.Abstractions.Pipelines.GetVariants.FilterVariants, Sitecore.XA.Foundation.Variants.Abstractions" set:type="Sitecore.Support.XA.Foundation.Variants.Abstractions.Pipelines.GetVariants.FilterVariants, Sitecore.Support.247754" />
</getVariants>
</pipelines>
</sitecore>
</configuration>
6 changes: 6 additions & 0 deletions src/Sitecore.Support.247754/Properties/AssemblyInfo.cs
@@ -0,0 +1,6 @@
using System.Reflection;
using System.Runtime.InteropServices;

[assembly: AssemblyTitle("Sitecore.Support.247754")]
[assembly: AssemblyProduct("Sitecore.Support.247754")]
[assembly: ComVisible(false)]
100 changes: 100 additions & 0 deletions src/Sitecore.Support.247754/Sitecore.Support.247754.csproj
@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{DF9FC498-50E4-4F2B-9A0B-5B4456390B20}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Sitecore.Support</RootNamespace>
<AssemblyName>Sitecore.Support.247754</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<UseIISExpress>true</UseIISExpress>
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
<UseGlobalApplicationHostFile />
<TargetFrameworkProfile />
<LangVersion>6</LangVersion>
<Use64BitIISExpress />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Sitecore.Kernel">
<HintPath>..\packages\SC.Sitecore.Kernel.9.0.2\lib\Sitecore.Kernel.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Sitecore.XA.Foundation.Caching, Version=3.8.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SXA90.Sitecore.XA.Foundation.Caching.1.8.0\lib\Sitecore.XA.Foundation.Caching.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Sitecore.XA.Foundation.SitecoreExtensions, Version=3.8.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SXA90.Sitecore.XA.Foundation.SitecoreExtensions.1.8.0\lib\Sitecore.XA.Foundation.SitecoreExtensions.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Sitecore.XA.Foundation.Variants.Abstractions, Version=3.8.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SXA90.Sitecore.XA.Foundation.Variants.Abstractions.1.8.0\lib\Sitecore.XA.Foundation.Variants.Abstractions.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="XA\Foundation\Variants\Abstractions\Pipelines\GetVariants\FilterVariants.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="App_Config\Include\zzz\Sitecore.Support.247754.config" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="web.config" />
</ItemGroup>
<ItemGroup />
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>True</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>0</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:4389/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
</Project>
@@ -0,0 +1,37 @@
using Sitecore.Data;
using Sitecore.Data.Fields;
using Sitecore.Data.Items;
using Sitecore.XA.Foundation.SitecoreExtensions.Extensions;
using Sitecore.XA.Foundation.SitecoreExtensions.Repositories;
using System.Linq;

namespace Sitecore.Support.XA.Foundation.Variants.Abstractions.Pipelines.GetVariants
{
public class FilterVariants : Sitecore.XA.Foundation.Variants.Abstractions.Pipelines.GetVariants.FilterVariants
{
public FilterVariants(IContentRepository contentRepository) :base(contentRepository)
{

}

protected override bool AllowedInTemplate(Item item, string pageTemplateId)
{
var field = item.Fields[Sitecore.XA.Foundation.Variants.Abstractions.Templates.IVariantDefinition.Fields.AllowedInTemplates];
if (field != null)
{
if (field.Value == string.Empty && InheritsFromAllowedTemplate(pageTemplateId))
{
return true;
}
return field.Value.Contains(pageTemplateId) || InheritsFromSelectedTemplates(field, pageTemplateId);
}
return true;
}

protected virtual bool InheritsFromSelectedTemplates(MultilistField field, string pageTemplateId)
{
var templateItem = ContentRepository.GetTemplate(new ID(pageTemplateId));
return field.TargetIDs.Any(id => templateItem.DoesTemplateInheritFrom(id));
}
}
}
7 changes: 7 additions & 0 deletions src/Sitecore.Support.247754/packages.config
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="SC.Sitecore.Kernel" version="9.0.2" targetFramework="net462" />
<package id="SXA90.Sitecore.XA.Foundation.Caching" version="1.8.0" targetFramework="net462" />
<package id="SXA90.Sitecore.XA.Foundation.SitecoreExtensions" version="1.8.0" targetFramework="net462" />
<package id="SXA90.Sitecore.XA.Foundation.Variants.Abstractions" version="1.8.0" targetFramework="net462" />
</packages>
4 changes: 4 additions & 0 deletions src/Sitecore.Support.247754/web.config
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!-- Do not change this file - it must be empty, see https://github.com/SitecoreSupport/PatchCreator/issues/13 -->
</configuration>

0 comments on commit f84d616

Please sign in to comment.