-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a652bf
commit fe145a2
Showing
8 changed files
with
335 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
root = true | ||
|
||
[*.{cs,sln,csproj,config,xml}] | ||
indent_size = 4 | ||
indent_style = space |
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,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 14 | ||
VisualStudioVersion = 14.0.25123.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{3C37EC03-5AB1-4191-8F87-CD4F923F90D6}") = "Sitecore.Support.409554", "Sitecore.Support.409554\Sitecore.Support.409554.csproj", "{584D9292-FD6F-4399-A116-0EF143823224}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{584D9292-FD6F-4399-A116-0EF143823224}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{584D9292-FD6F-4399-A116-0EF143823224}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{584D9292-FD6F-4399-A116-0EF143823224}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{584D9292-FD6F-4399-A116-0EF143823224}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
9 changes: 9 additions & 0 deletions
9
src/Sitecore.Support.409554/App_Config/Include/zzz/Sitecore.Support.409554.config
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,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"> | ||
<services> | ||
<register serviceType="Sitecore.XA.Foundation.Multisite.Services.IPushCloneService, Sitecore.XA.Foundation.Multisite" > | ||
<patch:attribute name="implementationType">Sitecore.Support.XA.Foundation.Multisite.Services.PushCloneService, Sitecore.Support.409554</patch:attribute> | ||
</register> | ||
</services> | ||
</sitecore> | ||
</configuration> |
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,6 @@ | ||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
|
||
[assembly: AssemblyTitle("Sitecore.Support.409554")] | ||
[assembly: AssemblyProduct("Sitecore.Support.409554")] | ||
[assembly: ComVisible(false)] |
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,184 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Sitecore.Data.Comparers; | ||
using Sitecore.Data.Items; | ||
using Sitecore.Pipelines; | ||
using Sitecore.XA.Foundation.Multisite.Pipelines.PushCloneChanges; | ||
using Sitecore.XA.Foundation.Multisite.Services; | ||
|
||
namespace Sitecore.Support.XA.Foundation.Multisite.Services | ||
{ | ||
public class PushCloneService : IPushCloneService | ||
{ | ||
private readonly IPushCloneCoordinatorService _coordinatorService; | ||
|
||
public PushCloneService(IPushCloneCoordinatorService pushCloneCoordinatorService) | ||
{ | ||
_coordinatorService = pushCloneCoordinatorService; | ||
} | ||
|
||
public void AddChild(Item item) | ||
{ | ||
var parent = item.Parent; | ||
|
||
#region Support Fix 409554 | ||
if (parent == null) | ||
{ | ||
return; | ||
} | ||
#endregion | ||
var clones = parent.GetClones(); | ||
|
||
foreach (var clone in clones) | ||
{ | ||
if (!_coordinatorService.ShouldProcess(clone)) | ||
{ | ||
continue; | ||
} | ||
|
||
if (item.Versions.GetVersionNumbers().Length > 0) | ||
{ | ||
var cloneItem = item.CloneTo(clone); | ||
ProtectItem(cloneItem); | ||
} | ||
} | ||
} | ||
|
||
public void Move(Item item) | ||
{ | ||
if (item.Parent.HasClones) | ||
{ | ||
var parentClones = GetCloneItem(item.Parent); | ||
foreach (var parentClone in parentClones.ToList()) | ||
{ | ||
if (!_coordinatorService.ShouldProcess(parentClone)) | ||
{ | ||
return; | ||
} | ||
|
||
var clones = GetCloneItem(item); | ||
foreach (var clone in clones) | ||
{ | ||
if (parentClone.Paths.FullPath.Contains(clone.Paths.FullPath) || clone.Paths.FullPath.Contains(parentClone.Paths.FullPath)) | ||
{ | ||
clone.MoveTo(parentClone); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
public void Remove(Item item) | ||
{ | ||
var clones = item.GetClones(); | ||
foreach (var clone in clones) | ||
{ | ||
if (_coordinatorService.ShouldProcess(clone)) | ||
{ | ||
clone.Delete(); | ||
} | ||
} | ||
} | ||
|
||
public void SaveClone(Item item, ItemChanges changes) | ||
{ | ||
var clones = GetCloneItem(item); | ||
foreach (var clone in clones) | ||
{ | ||
if (!_coordinatorService.ShouldProcess(clone)) | ||
{ | ||
return; | ||
} | ||
|
||
var args = new PushCloneChangesArgs() | ||
{ | ||
Item = item, | ||
Changes = changes, | ||
Clone = clone | ||
}; | ||
|
||
CorePipeline.Run("pushCloneChanges", args); | ||
} | ||
} | ||
|
||
public void AddVersion(Item item) | ||
{ | ||
var parent = item.Parent; | ||
#region Support Fix 409554 | ||
|
||
if (parent == null) | ||
{ | ||
return; | ||
} | ||
if (item.Versions.Count == 0) | ||
{ | ||
return; | ||
} | ||
#endregion | ||
var latest = item.Versions.GetLatestVersion(); | ||
var versionUri = latest.Uri; | ||
var clones = GetCloneItem(latest); | ||
var enumerable = clones as IList<Item> ?? clones.ToList(); | ||
if (!enumerable.Any() && parent.HasClones) | ||
{ | ||
var parentClones = GetCloneItem(parent); | ||
foreach (var parentClone in parentClones) | ||
{ | ||
if (!_coordinatorService.ShouldProcess(parentClone)) | ||
{ | ||
continue; | ||
} | ||
|
||
var cloneItem = item.CloneTo(parentClone); | ||
CopyWorkflow(item, cloneItem); | ||
ProtectItem(cloneItem); | ||
} | ||
} | ||
else | ||
{ | ||
foreach (var clone in enumerable) | ||
{ | ||
if (!_coordinatorService.ShouldProcess(clone)) | ||
{ | ||
continue; | ||
} | ||
|
||
var versionedClone = clone.Database.GetItem(clone.ID, latest.Language); | ||
using (new SecurityModel.SecurityDisabler()) | ||
{ | ||
var newVersion = versionedClone.Versions.AddVersion(); | ||
newVersion.Editing.BeginEdit(); | ||
newVersion[FieldIDs.Source] = versionUri.ToString(); | ||
newVersion[FieldIDs.SourceItem] = versionUri.ToString(false); | ||
newVersion.Editing.EndEdit(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
protected virtual void CopyWorkflow(Item source, Item target) | ||
{ | ||
var item = source.Database.GetItem(source.ID); | ||
target.Editing.BeginEdit(); | ||
target[FieldIDs.Workflow] = item[FieldIDs.Workflow]; | ||
target[FieldIDs.WorkflowState] = item[FieldIDs.WorkflowState]; | ||
target.Editing.EndEdit(); | ||
} | ||
|
||
protected virtual void ProtectItem(Item item) | ||
{ | ||
item.Editing.BeginEdit(); | ||
item.Appearance.ReadOnly = true; | ||
item.Editing.EndEdit(); | ||
} | ||
|
||
protected virtual IEnumerable<Item> GetCloneItem(Item item) | ||
{ | ||
return item.GetClones().Distinct(new ItemIdComparer()); | ||
} | ||
|
||
public void RemoveVersion(Item commandItem) | ||
{ | ||
} | ||
} | ||
} |
99 changes: 99 additions & 0 deletions
99
src/Sitecore.Support.409554/Sitecore.Support.409554.csproj
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,99 @@ | ||
<?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>{584D9292-FD6F-4399-A116-0EF143823224}</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.409554</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>false</DebugSymbols> | ||
<DebugType>none</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.Common"> | ||
<HintPath>..\packages\SXA90.Sitecore.XA.Foundation.Common.1.8.0\lib\Sitecore.XA.Foundation.Common.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="Sitecore.XA.Foundation.Multisite, Version=3.8.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\SXA90.Sitecore.XA.Foundation.Multisite.1.8.0\lib\Sitecore.XA.Foundation.Multisite.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Drawing" /> | ||
<Reference Include="System.Web" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="System.Configuration" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="PushCloneService.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Content Include="App_Config\Include\zzz\Sitecore.Support.409554.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
<None Include="web.config" /> | ||
</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:50707/</IISUrl> | ||
<NTLMAuthentication>False</NTLMAuthentication> | ||
<UseCustomServer>False</UseCustomServer> | ||
<CustomServerUrl> | ||
</CustomServerUrl> | ||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile> | ||
</WebProjectProperties> | ||
</FlavorProperties> | ||
</VisualStudio> | ||
</ProjectExtensions> | ||
</Project> |
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,6 @@ | ||
<?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.Common" version="1.8.0" targetFramework="net462" /> | ||
<package id="SXA90.Sitecore.XA.Foundation.Multisite" version="1.8.0" targetFramework="net462" /> | ||
</packages> |
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,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> |