diff --git a/.gitignore b/.gitignore index 2030aa0..c2aaad0 100644 --- a/.gitignore +++ b/.gitignore @@ -176,4 +176,7 @@ BuiltFiles_*.txt lib/Sitecore*.dll # we want to include the root 'release' directory since that is where we supply the latest release -!/release/ \ No newline at end of file +!/release/ +src/packages/Sitecore.6.5.0.120706/Sitecore.6.5.0.120706.nupkg +src/packages/Sitecore.6.5.0.120706/tools/install.ps1 +src/.vs/config/applicationhost.config diff --git a/README.md b/README.md index c8a3413..ff5ed0a 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ Field Fallback is the ability for a field's value to come from somewhere other t * Lateral Fallback - A field falls back to the value of another field, or chain of fields * Default Fallback - A field falls back to a text value or a token that is transformed at render time (not item creation time!) * Language fallback - This is based on [Alex Shyba's Language Fallback module](http://trac.sitecore.net/LanguageFallback) +* Default Value Fallback - A field falls back to a Content Item that is created when the template is created The concept for this module came about when Alex Shyba released his Language Fallback module. While the initial prototype, written by [Elena Zlateva](http://twitter.com/ezlateva), was heavily based on Alex' work there isn't too much remaining in the FieldFallback.Kernel project. However, to support language fallback while using the Field Fallback module we have provided Partial Language Fallback in the Processors.Globalization project. This code is still very much original to Alex. [Charles Turano](http://sdn.sitecore.net/MVP/MVPs/Charles%20Turano.aspx) also provided some much appreciated help around performance tuning and getting this to be as fast as possible. diff --git a/lib/Readme.txt b/lib/Readme.txt deleted file mode 100644 index 4c272a5..0000000 --- a/lib/Readme.txt +++ /dev/null @@ -1,8 +0,0 @@ -Required Dlls: -Ensure the following files are in $(SolutionDir)\lib - -> Sitecore.Kernel.dll -> Sitecore.Client.dll -> Sitecore.Update.dll (Required to generate package in TDS) -> Sitecore.Logging.dll (Required to generate package in TDS) -> Sitecore.Zip.dll (Required to generate package in TDS) \ No newline at end of file diff --git a/src/Demo.Sitecore.Master/Demo.Sitecore.Master.scproj b/src/Demo.Sitecore.Master/Demo.Sitecore.Master.scproj index 5b6d1be..594a717 100644 --- a/src/Demo.Sitecore.Master/Demo.Sitecore.Master.scproj +++ b/src/Demo.Sitecore.Master/Demo.Sitecore.Master.scproj @@ -1,4 +1,5 @@ - + + Debug AnyCPU @@ -134,6 +135,10 @@ KeepAllChildrenSynchronized AlwaysUpdate + + KeepAllChildrenSynchronized + AlwaysUpdate + /temp/IconCache/Applications/16x16/lightbulb_on.png KeepAllChildrenSynchronized @@ -302,6 +307,10 @@ KeepAllChildrenSynchronized AlwaysUpdate + + KeepAllChildrenSynchronized + AlwaysUpdate + /temp/IconCache/Applications/16x16/lightbulb_on.png KeepAllChildrenSynchronized @@ -406,7 +415,7 @@ Demo.Web - + diff --git a/src/Demo.Sitecore.Master/sitecore/content/FieldFallbackDemo/DefaultItemsDemoFolder.item b/src/Demo.Sitecore.Master/sitecore/content/FieldFallbackDemo/DefaultItemsDemoFolder.item new file mode 100644 index 0000000..67532a8 --- /dev/null +++ b/src/Demo.Sitecore.Master/sitecore/content/FieldFallbackDemo/DefaultItemsDemoFolder.item @@ -0,0 +1,44 @@ +----item---- +version: 1 +id: {0E261AC4-227A-4B25-AA38-EC4AF10AA989} +database: master +path: /sitecore/content/FieldFallbackDemo/DefaultItemsDemoFolder +parent: {1C980364-5C74-4CDD-9C08-E718672C8ED5} +name: DefaultItemsDemoFolder +master: {00000000-0000-0000-0000-000000000000} +template: {0EF07759-6627-43BD-A7C7-AE6C0EFB985A} +templatekey: Folder + +----version---- +language: en +version: 1 +revision: fd774789-9e28-45fa-b94b-7614e6e49e76 + +----field---- +field: {25BED78C-4957-4165-998A-CA1B52F67497} +name: __Created +key: __created +content-length: 15 + +20160329T100623 +----field---- +field: {8CDC337E-A112-42FB-BBB4-4143751E123F} +name: __Revision +key: __revision +content-length: 36 + +fd774789-9e28-45fa-b94b-7614e6e49e76 +----field---- +field: {D9CF14B1-FA16-4BA6-9288-E8A174D4D522} +name: __Updated +key: __updated +content-length: 34 + +20160329T100623:635948427832628422 +----field---- +field: {BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A} +name: __Updated by +key: __updated by +content-length: 14 + +sitecore\admin diff --git a/src/Demo.Sitecore.Master/sitecore/templates/FieldFallbackDemo/DefaultTemplatesDemoFolder.item b/src/Demo.Sitecore.Master/sitecore/templates/FieldFallbackDemo/DefaultTemplatesDemoFolder.item new file mode 100644 index 0000000..a69a64e --- /dev/null +++ b/src/Demo.Sitecore.Master/sitecore/templates/FieldFallbackDemo/DefaultTemplatesDemoFolder.item @@ -0,0 +1,11 @@ +----item---- +version: 1 +id: {4328FA62-B0B8-4410-8ECA-8616D5487926} +database: master +path: /sitecore/templates/FieldFallbackDemo/DefaultTemplatesDemoFolder +parent: {FCB3EB2F-2EAE-45E0-9653-5CC9DF7F114B} +name: DefaultTemplatesDemoFolder +master: {00000000-0000-0000-0000-000000000000} +template: {0437FEE2-44C9-46A6-ABE9-28858D9FEE8C} +templatekey: Template Folder + diff --git a/src/Demo.Web/Demo.Web.csproj b/src/Demo.Web/Demo.Web.csproj index 641073c..2b98c14 100644 --- a/src/Demo.Web/Demo.Web.csproj +++ b/src/Demo.Web/Demo.Web.csproj @@ -20,6 +20,7 @@ + true @@ -39,17 +40,111 @@ 4 - - ..\..\lib\Sitecore.Client.dll + + ..\packages\Sitecore.6.5.0.120706\lib\ComponentArt.Web.UI.dll + False - - ..\..\lib\Sitecore.Kernel.dll + + ..\packages\Sitecore.6.5.0.120706\lib\HtmlAgilityPack.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\ITHit.WebDAV.Server.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Lucene.Net.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Mvp.Xml.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Newtonsoft.Json.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\RadEditor.Net2.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Analytics.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Apps.Loader.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Automation.MarketingAutomation.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Client.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Kernel.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Logging.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\sitecore.nexus.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.NVelocity.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Oracle.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Publishing.WebDeploy.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Update.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Zip.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Stimulsoft.Base.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Stimulsoft.Database.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Stimulsoft.Report.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Stimulsoft.Report.Web.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Stimulsoft.Report.WebDesign.dll + False + + ..\packages\Sitecore.6.5.0.120706\lib\Telerik.Web.UI.dll + False + @@ -93,6 +188,7 @@ + web.config @@ -109,7 +205,6 @@ - 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) diff --git a/src/Demo.Web/packages.config b/src/Demo.Web/packages.config new file mode 100644 index 0000000..b37d796 --- /dev/null +++ b/src/Demo.Web/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/FieldFallback.sln b/src/FieldFallback.sln index 0b0f5ef..792865a 100644 --- a/src/FieldFallback.sln +++ b/src/FieldFallback.sln @@ -1,8 +1,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.40629.0 +# Visual Studio 14 +VisualStudioVersion = 14.0.25123.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "02. General Fallback", "02. General Fallback", "{2B3D124A-AB61-411E-B2A0-AACB4BBDB224}" + ProjectSection(SolutionItems) = preProject + ReadMe.md = ReadMe.md + EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "03. Language Fallback", "03. Language Fallback", "{331B2DC2-D515-42EB-9FD9-D2C7A3CB9658}" EndProject diff --git a/src/Kernel.Sitecore.Master/Kernel.Sitecore.Master.scproj b/src/Kernel.Sitecore.Master/Kernel.Sitecore.Master.scproj index f9f0643..681c54a 100644 --- a/src/Kernel.Sitecore.Master/Kernel.Sitecore.Master.scproj +++ b/src/Kernel.Sitecore.Master/Kernel.Sitecore.Master.scproj @@ -1,4 +1,5 @@ - + + Debug AnyCPU @@ -104,7 +105,7 @@ Kernel - + diff --git a/src/Kernel/Configuration/Config.cs b/src/Kernel/Configuration/Config.cs index a743f43..3b60d67 100644 --- a/src/Kernel/Configuration/Config.cs +++ b/src/Kernel/Configuration/Config.cs @@ -36,4 +36,4 @@ public static bool EditEnabled } } } -} +} \ No newline at end of file diff --git a/src/Kernel/Kernel.csproj b/src/Kernel/Kernel.csproj index 14a6df9..9a2e8a6 100644 --- a/src/Kernel/Kernel.csproj +++ b/src/Kernel/Kernel.csproj @@ -33,6 +33,7 @@ + true @@ -52,17 +53,109 @@ 4 - - ..\..\lib\Sitecore.Client.dll + + ..\packages\Sitecore.6.5.0.120706\lib\ComponentArt.Web.UI.dll False - - ..\..\lib\Sitecore.Kernel.dll + + ..\packages\Sitecore.6.5.0.120706\lib\HtmlAgilityPack.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\ITHit.WebDAV.Server.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Lucene.Net.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Mvp.Xml.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Newtonsoft.Json.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\RadEditor.Net2.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Analytics.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Apps.Loader.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Automation.MarketingAutomation.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Client.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Kernel.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Logging.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\sitecore.nexus.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.NVelocity.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Oracle.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Publishing.WebDeploy.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Update.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Zip.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Stimulsoft.Base.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Stimulsoft.Database.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Stimulsoft.Report.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Stimulsoft.Report.Web.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Stimulsoft.Report.WebDesign.dll False + + ..\packages\Sitecore.6.5.0.120706\lib\Telerik.Web.UI.dll + False + @@ -97,6 +190,9 @@ Designer + + + 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) diff --git a/src/Kernel/packages.config b/src/Kernel/packages.config new file mode 100644 index 0000000..b37d796 --- /dev/null +++ b/src/Kernel/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/Processors.Globalization.Sitecore.Master/Processors.Globalization.Sitecore.Master.scproj b/src/Processors.Globalization.Sitecore.Master/Processors.Globalization.Sitecore.Master.scproj index d2e09bd..a477e6a 100644 --- a/src/Processors.Globalization.Sitecore.Master/Processors.Globalization.Sitecore.Master.scproj +++ b/src/Processors.Globalization.Sitecore.Master/Processors.Globalization.Sitecore.Master.scproj @@ -1,4 +1,5 @@ - + + Debug AnyCPU @@ -135,7 +136,7 @@ http://TeamDevelopmentForSitecore.com - + diff --git a/src/Processors.Globalization/Processors.Globalization.csproj b/src/Processors.Globalization/Processors.Globalization.csproj index f0dec73..c8989ee 100644 --- a/src/Processors.Globalization/Processors.Globalization.csproj +++ b/src/Processors.Globalization/Processors.Globalization.csproj @@ -32,6 +32,7 @@ + true @@ -51,13 +52,109 @@ 4 - - ..\..\lib\Sitecore.Kernel.dll + + ..\packages\Sitecore.6.5.0.120706\lib\ComponentArt.Web.UI.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\HtmlAgilityPack.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\ITHit.WebDAV.Server.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Lucene.Net.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Mvp.Xml.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Newtonsoft.Json.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\RadEditor.Net2.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Analytics.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Apps.Loader.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Automation.MarketingAutomation.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Client.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Kernel.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Logging.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\sitecore.nexus.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.NVelocity.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Oracle.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Publishing.WebDeploy.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Update.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Zip.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Stimulsoft.Base.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Stimulsoft.Database.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Stimulsoft.Report.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Stimulsoft.Report.Web.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Stimulsoft.Report.WebDesign.dll False + + ..\packages\Sitecore.6.5.0.120706\lib\Telerik.Web.UI.dll + False + @@ -84,6 +181,9 @@ + + + 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) diff --git a/src/Processors.Globalization/packages.config b/src/Processors.Globalization/packages.config new file mode 100644 index 0000000..b37d796 --- /dev/null +++ b/src/Processors.Globalization/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/Processors.Sitecore.Master/Processors.Sitecore.Master.scproj b/src/Processors.Sitecore.Master/Processors.Sitecore.Master.scproj index 61c451f..cb670bb 100644 --- a/src/Processors.Sitecore.Master/Processors.Sitecore.Master.scproj +++ b/src/Processors.Sitecore.Master/Processors.Sitecore.Master.scproj @@ -1,4 +1,5 @@ - + + Debug AnyCPU @@ -84,6 +85,13 @@ http://TeamDevelopmentForSitecore.com NoChildSynchronization DeployOnce + + DeployOnce + NoChildSynchronization + + + DeployOnce + /temp/IconCache/Applications/16x16/folder_gear.png DeployOnce @@ -94,6 +102,9 @@ http://TeamDevelopmentForSitecore.com DeployOnce NoChildSynchronization + + DeployOnce + /temp/IconCache/Applications/16x16/form_blue.png AlwaysUpdate @@ -152,7 +163,7 @@ http://TeamDevelopmentForSitecore.com - + diff --git a/src/Processors.Sitecore.Master/sitecore/content/DefaultItems.item b/src/Processors.Sitecore.Master/sitecore/content/DefaultItems.item new file mode 100644 index 0000000..1ebbb0d --- /dev/null +++ b/src/Processors.Sitecore.Master/sitecore/content/DefaultItems.item @@ -0,0 +1,44 @@ +----item---- +version: 1 +id: {33426131-95A1-4A55-AB76-39F05E1A826D} +database: master +path: /sitecore/content/DefaultItems +parent: {0DE95AE4-41AB-4D01-9EB0-67441B7C2450} +name: DefaultItems +master: {00000000-0000-0000-0000-000000000000} +template: {C64EC785-84BD-4A73-AE00-559D991D1A75} +templatekey: New test + +----version---- +language: en +version: 1 +revision: a0f48296-7372-4c14-9bcf-0dce2e463eb8 + +----field---- +field: {25BED78C-4957-4165-998A-CA1B52F67497} +name: __Created +key: __created +content-length: 15 + +20160627T145634 +----field---- +field: {8CDC337E-A112-42FB-BBB4-4143751E123F} +name: __Revision +key: __revision +content-length: 36 + +a0f48296-7372-4c14-9bcf-0dce2e463eb8 +----field---- +field: {D9CF14B1-FA16-4BA6-9288-E8A174D4D522} +name: __Updated +key: __updated +content-length: 34 + +20160627T145634:636026361945346098 +----field---- +field: {BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A} +name: __Updated by +key: __updated by +content-length: 14 + +sitecore\admin diff --git a/src/Processors.Sitecore.Master/sitecore/templates/FieldFallbackDemo.item b/src/Processors.Sitecore.Master/sitecore/templates/FieldFallbackDemo.item new file mode 100644 index 0000000..d68225a --- /dev/null +++ b/src/Processors.Sitecore.Master/sitecore/templates/FieldFallbackDemo.item @@ -0,0 +1,65 @@ +----item---- +version: 1 +id: {FCB3EB2F-2EAE-45E0-9653-5CC9DF7F114B} +database: master +path: /sitecore/templates/FieldFallbackDemo +parent: {3C1715FE-6A13-4FCF-845F-DE308BA9741D} +name: FieldFallbackDemo +master: {00000000-0000-0000-0000-000000000000} +template: {0437FEE2-44C9-46A6-ABE9-28858D9FEE8C} +templatekey: Template Folder + +----field---- +field: {06D5295C-ED2F-4A54-9BF2-26228D113318} +name: __Icon +key: __icon +content-length: 34 + +Applications/32x32/folder_blue.png +----field---- +field: {BA3F86A2-4A1C-4D78-B63D-91C2779C1B5E} +name: __Sortorder +key: __sortorder +content-length: 3 + +500 +----version---- +language: en +version: 1 +revision: 2a5a8aea-0c5d-441f-b0b9-3da36c3cf17b + +----field---- +field: {25BED78C-4957-4165-998A-CA1B52F67497} +name: __Created +key: __created +content-length: 15 + +20120709T093544 +----field---- +field: {5DD74568-4D4B-44C1-B513-0AF5F4CDA34F} +name: __Created by +key: __created by +content-length: 14 + +sitecore\admin +----field---- +field: {8CDC337E-A112-42FB-BBB4-4143751E123F} +name: __Revision +key: __revision +content-length: 36 + +2a5a8aea-0c5d-441f-b0b9-3da36c3cf17b +----field---- +field: {D9CF14B1-FA16-4BA6-9288-E8A174D4D522} +name: __Updated +key: __updated +content-length: 34 + +20160405T224534:635954931343913773 +----field---- +field: {BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A} +name: __Updated by +key: __updated by +content-length: 14 + +sitecore\admin diff --git a/src/Processors.Sitecore.Master/sitecore/templates/FieldFallbackDemo/DefaultTemplatesDemoFolder.item b/src/Processors.Sitecore.Master/sitecore/templates/FieldFallbackDemo/DefaultTemplatesDemoFolder.item new file mode 100644 index 0000000..5f29ded --- /dev/null +++ b/src/Processors.Sitecore.Master/sitecore/templates/FieldFallbackDemo/DefaultTemplatesDemoFolder.item @@ -0,0 +1,58 @@ +----item---- +version: 1 +id: {F0BB8D81-5B69-429C-939B-745DDEE22A5A} +database: master +path: /sitecore/templates/FieldFallbackDemo/DefaultTemplatesDemoFolder +parent: {FCB3EB2F-2EAE-45E0-9653-5CC9DF7F114B} +name: DefaultTemplatesDemoFolder +master: {00000000-0000-0000-0000-000000000000} +template: {0437FEE2-44C9-46A6-ABE9-28858D9FEE8C} +templatekey: Template Folder + +----field---- +field: {1172F251-DAD4-4EFB-A329-0C63500E4F1E} +name: __Masters +key: __masters +content-length: 77 + +{78CF88BA-6957-4366-8368-12F3CED0184F}|{0437FEE2-44C9-46A6-ABE9-28858D9FEE8C} +----version---- +language: en +version: 1 +revision: 32325341-7696-44b1-bad6-a26ec83db7be + +----field---- +field: {25BED78C-4957-4165-998A-CA1B52F67497} +name: __Created +key: __created +content-length: 15 + +20160405T144300 +----field---- +field: {5DD74568-4D4B-44C1-B513-0AF5F4CDA34F} +name: __Created by +key: __created by +content-length: 14 + +sitecore\admin +----field---- +field: {8CDC337E-A112-42FB-BBB4-4143751E123F} +name: __Revision +key: __revision +content-length: 36 + +32325341-7696-44b1-bad6-a26ec83db7be +----field---- +field: {D9CF14B1-FA16-4BA6-9288-E8A174D4D522} +name: __Updated +key: __updated +content-length: 34 + +20160406T014654:635955040144856516 +----field---- +field: {BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A} +name: __Updated by +key: __updated by +content-length: 14 + +sitecore\admin diff --git a/src/Processors.Sitecore.Master/sitecore/templates/System/Templates/Fallback Defaults Folder.item b/src/Processors.Sitecore.Master/sitecore/templates/System/Templates/Fallback Defaults Folder.item new file mode 100644 index 0000000..7231c9e --- /dev/null +++ b/src/Processors.Sitecore.Master/sitecore/templates/System/Templates/Fallback Defaults Folder.item @@ -0,0 +1,65 @@ +----item---- +version: 1 +id: {01EDFB94-C2E5-4E9E-8CF7-C1A50F5D7331} +database: master +path: /sitecore/templates/System/Templates/Fallback Defaults Folder +parent: {633549D3-4B7D-40EB-B58F-EDA50BA5F7F0} +name: Fallback Defaults Folder +master: {00000000-0000-0000-0000-000000000000} +template: {AB86861A-6030-46C5-B394-E8F99E8B87DB} +templatekey: Template + +----field---- +field: {12C33F3F-86C5-43A5-AEB4-5598CEC45116} +name: __Base template +key: __base template +content-length: 38 + +{A87A00B1-E6DB-45AB-8B54-636FEC3B5523} +----field---- +field: {06D5295C-ED2F-4A54-9BF2-26228D113318} +name: __Icon +key: __icon +content-length: 29 + +applications/16x16/folder.png +----version---- +language: en +version: 1 +revision: 8519d9eb-74c7-4e76-bbba-76a91edca27d + +----field---- +field: {25BED78C-4957-4165-998A-CA1B52F67497} +name: __Created +key: __created +content-length: 15 + +20160406T012800 +----field---- +field: {5DD74568-4D4B-44C1-B513-0AF5F4CDA34F} +name: __Created by +key: __created by +content-length: 14 + +sitecore\admin +----field---- +field: {8CDC337E-A112-42FB-BBB4-4143751E123F} +name: __Revision +key: __revision +content-length: 36 + +8519d9eb-74c7-4e76-bbba-76a91edca27d +----field---- +field: {D9CF14B1-FA16-4BA6-9288-E8A174D4D522} +name: __Updated +key: __updated +content-length: 34 + +20160406T012935:635955029756667003 +----field---- +field: {BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A} +name: __Updated by +key: __updated by +content-length: 14 + +sitecore\admin diff --git a/src/Processors/App_Config/Include/FieldFallbackDefaults_00.config.example b/src/Processors/App_Config/Include/FieldFallbackDefaults_00.config.example new file mode 100644 index 0000000..ba03163 --- /dev/null +++ b/src/Processors/App_Config/Include/FieldFallbackDefaults_00.config.example @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Processors/App_Config/Include/FieldFallback_01.config b/src/Processors/App_Config/Include/FieldFallback_01.config index d46dd66..c10b37f 100644 --- a/src/Processors/App_Config/Include/FieldFallback_01.config +++ b/src/Processors/App_Config/Include/FieldFallback_01.config @@ -1,85 +1,98 @@ - + + + + + + + FieldFallback.Processors.Caching.FallbackValuesCache, FieldFallback.Processors + 10MB + true + + + + + + + + + + - - - - - - - - FieldFallback.Processors.Caching.FallbackValuesCache, FieldFallback.Processors - 10MB - true - - - - - - - - - - - - - - - - - - - + + + - - - - + + + - + \ No newline at end of file diff --git a/src/Processors/Configuration/DefaultValuesConfig.cs b/src/Processors/Configuration/DefaultValuesConfig.cs new file mode 100644 index 0000000..204f463 --- /dev/null +++ b/src/Processors/Configuration/DefaultValuesConfig.cs @@ -0,0 +1,80 @@ +using Sitecore.Configuration; +using Sitecore.Data.Items; + +namespace FieldFallback.Processors.Configuration +{ + public class DefaultValuesConfig + { + + /// + /// Gets the default template location. + /// + /// + /// + /// The default template location that is retrieved from the config file. + /// + + public static string DefaultTemplateLocation + { + get { return Settings.GetSetting("Fallback.Default.Template.Location"); } + } + + /// + /// Gets the default item location. + /// + /// + /// + /// The default item location that is retrieved from the config file. + /// + + public static string DefaultItemLocation + { + get { return Settings.GetSetting("Fallback.Default.Item.Location"); } + } + + /// + /// Gets the database name from the event config file + /// to compare the item that we are working with to. + /// We only work with the item if it is in the database + /// that is set in the config file + /// + /// + /// + /// The database set in the config file to work with + /// the items. + /// + + public static string Database + { + get { return Settings.GetSetting("Fallback.Default.Database"); } + } + /// + /// Gets the content item suffix that will be used when creating + /// the content item based off of the template. + /// + /// + /// + /// The content item suffix appended to the Template Name. + /// + + public static string ContentItemSuffix + { + get { return Settings.GetSetting("Fallback.Default.ContentItemSuffix"); } + } + + /// + /// Gets the Item ID of the fallback defaults folder from the + /// config file. + /// + /// + /// + /// The Item ID of the fallback defaults folder located under + /// . + /// + + public static string FallbackDefaultsFolderID + { + get { return Settings.GetSetting("Fallback.Default.Folder.ID"); } + } + } +} \ No newline at end of file diff --git a/src/Processors/Data/Items/DefaultValuesItem.cs b/src/Processors/Data/Items/DefaultValuesItem.cs new file mode 100644 index 0000000..f2cf7f9 --- /dev/null +++ b/src/Processors/Data/Items/DefaultValuesItem.cs @@ -0,0 +1,75 @@ +using FieldFallback.Processors.Configuration; +using Sitecore; +using Sitecore.Data.Items; + +namespace FieldFallback.Processors.Data.Items +{ + public class DefaultValuesItem : CustomItemBase + { + public DefaultValuesItem(Item innerItem) : base(innerItem) + { + } + + public string GetFullContentItemPath(TemplateItem item) + { + // Path of content item dynamically created by + // FieldFallback Processor Event + string itemPath = string.Format("{0}/{1}{2}", + GetDefaultContentPath(), + item.Name, + DefaultValuesConfig.ContentItemSuffix); + + return itemPath; + } + + /// + /// Get the parent of the content item path + /// that has to be created based off of the template. + /// + /// The template item. + /// + /// The parent content path of the item that + /// is going to be created. + /// + public string GetDefaultContentPath() + { + string itemPath = DefaultValuesConfig.DefaultItemLocation; + + return itemPath; + } + + /// + /// Query if 'item' is TemplateItem or a TemplateFolder . + /// + /// + /// The Sitecore item to evaluate + /// if it is a template. + /// + /// + /// true if the item is a TemplateItem or TemplateFolder, + /// false if it is not. + /// + public bool IsTemplate() + { + //Check if item it a TemplateItem + return this.InnerItem.TemplateID.ToString() == TemplateIDs.Template.ToString(); + } + + public bool IsFolderTemplate() + { + //Check if item it a TemplateFolder + return this.InnerItem.TemplateID.ToString() == TemplateIDs.TemplateFolder.ToString(); + } + + public bool IsInConfigDatabase() + { + return DefaultValuesConfig.Database == this.Database.Name; + } + + public bool IsInItemTemplatePath() + { + return this.InnerItem.Paths.FullPath.ToLower() + .Contains(DefaultValuesConfig.DefaultTemplateLocation.ToLower()); + } + } +} \ No newline at end of file diff --git a/src/Processors/DefaultValuesFallbackProcessor.cs b/src/Processors/DefaultValuesFallbackProcessor.cs new file mode 100644 index 0000000..d9a7be0 --- /dev/null +++ b/src/Processors/DefaultValuesFallbackProcessor.cs @@ -0,0 +1,46 @@ +using FieldFallback.Pipelines.FieldFallbackPipeline; +using FieldFallback.Processors.Data.Items; +using Sitecore.Data.Fields; +using Sitecore.Data.Items; +using Sitecore.Diagnostics; +using Sitecore.SecurityModel; + +namespace FieldFallback.Processors +{ + public class DefaultValuesFallbackProcessor : FieldFallbackProcessor + { + protected override bool IsEnabledForField(Field field) + { + //This processor is always enabled because it is processed + // for all fields that are part of the Item being created. + return true; + } + + protected override string GetFallbackValue(FieldFallbackPipelineArgs args) + { + Assert.IsNotNull(args.Field, "Field is null"); + Item fallbackItem = GetFallbackItem(args.Field); + + // if we have an Default Item with the field... + if (fallbackItem != null && fallbackItem.Fields[args.Field.ID] != null) + { + // get the value of the default item. + return fallbackItem.Fields[args.Field.ID].GetValueSafe(false, false, false); + } + return null; + } + + protected Item GetFallbackItem(Field field) + { + using (new SecurityDisabler()) + { + TemplateItem currentTemplate = field.Database.GetTemplate(field.Item.TemplateID); + + //Get the item from the database so we have the correct item + DefaultValuesItem contentPath = new DefaultValuesItem(field.Item); + + return field.Database.GetItem(contentPath.GetFullContentItemPath(currentTemplate)); + } + } + } +} \ No newline at end of file diff --git a/src/Processors/Events/DefaultValuesItemCreatedHandler.cs b/src/Processors/Events/DefaultValuesItemCreatedHandler.cs new file mode 100644 index 0000000..9d74c5b --- /dev/null +++ b/src/Processors/Events/DefaultValuesItemCreatedHandler.cs @@ -0,0 +1,138 @@ +using System; +using System.Threading; +using FieldFallback.Processors.Configuration; +using FieldFallback.Processors.Data.Items; +using Sitecore.Data; +using Sitecore.Data.Events; +using Sitecore.Data.Items; +using Sitecore.Diagnostics; +using Sitecore.Events; +using Sitecore.SecurityModel; + +namespace FieldFallback.Processors.Events +{ + /// + /// A field fall back item created handler. + /// This handler functions to create items based off + /// of templates that are created. It is documented + /// throughout. However, one key point is item:created + /// was chosen over item:saved specifically. Also note + /// that there is a background thread that runs on a + /// delay to create the item to ensure the SaveUI + /// Pipeline has time to process saving the TemplateItem + /// + public class DefaultValuesItemCreatedHandler + { + /// + /// Raises the item saved event. + /// This event will create an item based off of the + /// template in the same location in the content tree + /// as it is in the template tree. + /// + /// Source of the event. + /// Event information to send to registered event handlers. + public void OnItemSaved(object sender, EventArgs args) + { + // Get the item created event arguments. + // We are using the item:Created event over the item:Saved event + // The purpose of using the create over the save event is the + // complexity of the SaveUI Pipeline may cause adverse affects + // to creating the defaults for the dynamic template creation + ItemCreatedEventArgs eventArgs = + Event.ExtractParameter(args, 0) as ItemCreatedEventArgs; + + Assert.IsNotNull(eventArgs, "eventArgs"); + + if (eventArgs == null) + { + return; + } + + DefaultValuesItem item = new DefaultValuesItem(eventArgs.Item); + Assert.IsNotNull(item, "item"); + + // Validate that the item is in the database + // that is configured + if (!item.IsInConfigDatabase()) + { + return; + } + + // Check to see that the item is a template + // If it is not a template, we do not need to + // process it. + if (!(item.IsTemplate() || item.IsFolderTemplate())) + { + return; + } + + //If our new item is in our default template location, + // we are creating a template. Since we are creating a template, + // we need to create a default item to match it. + if (item.IsInItemTemplatePath()) + { + // We are creating the new item in a new thread + // This allows the Template time create and save + // to the database. + // It is important that the thread be ran in the + // background AND we allow the Thread to sleep + // giving time for the current process to complete. + Thread createdThread = new Thread(() => + { + Thread.CurrentThread.IsBackground = true; + Thread.Sleep(2000); + + CreateContentItem(item); + }); + + createdThread.Start(); + } + } + + /// + /// Creates content item based off of the template. + /// + /// + /// The TemplateItem that was just created. + /// + private void CreateContentItem(DefaultValuesItem item) + { + //Create a new item in the item location based off of the template + //that was just created. + using (new SecurityDisabler()) + { + //Get the database context + Database context = item.Database; + + //Get the parent item of the item we need to create + Item parentItem = context.Items.GetItem(item.GetDefaultContentPath()); + + if (parentItem == null) + { + Assert.IsNull(parentItem, "Fallback Item"); + } + + parentItem.Editing.BeginEdit(); + + string newItemName = item.Name + DefaultValuesConfig.ContentItemSuffix; + + // Create a new item based off of the template + // just created + if (item.IsTemplate()) + { + //Get the template to base the template + TemplateItem template = item.Database.GetTemplate(item.ID); + parentItem.Add(newItemName, template); + } + else if (item.IsFolderTemplate()) + { + //Get the base folder template + TemplateItem template = item.Database.GetItem(DefaultValuesConfig.FallbackDefaultsFolderID); + parentItem.Add(item.Name, template); + } + + parentItem.Editing.EndEdit(); + } + } + } +} \ No newline at end of file diff --git a/src/Processors/Pipeline/DefaultValuesDeleteItems.cs b/src/Processors/Pipeline/DefaultValuesDeleteItems.cs new file mode 100644 index 0000000..8606a9b --- /dev/null +++ b/src/Processors/Pipeline/DefaultValuesDeleteItems.cs @@ -0,0 +1,122 @@ +using System.Collections.Generic; +using System.Linq; +using FieldFallback.Processors.Configuration; +using Sitecore; +using Sitecore.Configuration; +using Sitecore.Data; +using Sitecore.Data.Items; +using Sitecore.Data.Proxies; +using Sitecore.Diagnostics; +using Sitecore.Links; +using Sitecore.Text; +using Sitecore.Web.UI.Sheer; + +namespace FieldFallback.Processors.Pipeline +{ + /// + /// This Pipeline Deletes Default Content Item. + /// + public class DefaultValuesDeleteItems + { + + /// + /// Process the delete items described by args. + /// + /// The arguments. + public void ProcessDeleteItems(ClientPipelineArgs args) + { + Item itemToDelete = GetItemToDelete(args); + + if (itemToDelete == null) + { + return; + } + + Assert.IsNotNull(itemToDelete, "Template Item Deleting"); + ItemLink[] referrerItemLinks = Globals.LinkDatabase.GetReferrers(itemToDelete); + if (referrerItemLinks.Count() > 2) + { + Assert.IsFalse(false, "Default Template Item Delete has child items", args); + args.AbortPipeline(); + } + + // As a note we are not expecting more than 2 items + foreach (Item referrerItem in referrerItemLinks.Select(referrer => referrer.GetSourceItem())) + { + if (referrerItem == null) + { + Assert.IsNull(referrerItem, "Referrer Item", args); + args.AbortPipeline(); + } + + // If the referrer item is in the Defaults path, we need to delete it + if (referrerItem.Paths.Path.StartsWith(DefaultValuesConfig.DefaultItemLocation)) + { + RecycleOrDeleteItem(referrerItem); + } + } + } + + /// + /// Recyle or delete item. + /// + /// + /// The referrer item. + private void RecycleOrDeleteItem(Item referrerItem) + { + if (Settings.RecycleBinActive) + { + Log.Audit(this, "Recycle item: {0}", AuditFormatter.FormatItem(referrerItem)); + referrerItem.Recycle(); + } + else + { + Log.Audit(this, "Delete item: {0}", AuditFormatter.FormatItem(referrerItem)); + referrerItem.Delete(); + } + } + + /// + /// Query if 'args' is fallback default template. + /// + /// + /// The arguments that were + /// passed in by the client. + /// + /// + /// true if fallback default template, false if not. + /// + public Item GetItemToDelete(ClientPipelineArgs args) + { + Assert.ArgumentNotNull(args, "args"); + List items = GetItems(args) as List; + + return items.FirstOrDefault(current => current.Paths.Path + .StartsWith(DefaultValuesConfig.DefaultTemplateLocation)); + } + + /// + /// Gets the items in this collection. + /// + /// + /// The arguments that were + /// passed in by the client. + /// + /// + /// + /// An enumerator that allows foreach to be used to get + /// the items in this collection. + /// + + private static IEnumerable GetItems(ClientPipelineArgs args) + { + Assert.ArgumentNotNull(args, "args"); + Database database = Factory.GetDatabase(args.Parameters["database"]); + Assert.IsNotNull(database, typeof(Database), "Name: {0}", args.Parameters["database"]); + + ListString listString = new ListString(args.Parameters["items"], '|'); + + return listString.Select(id => database.GetItem(id)).ToList(); + } + } +} \ No newline at end of file diff --git a/src/Processors/Processors.csproj b/src/Processors/Processors.csproj index 4bf8ec8..bc70d18 100644 --- a/src/Processors/Processors.csproj +++ b/src/Processors/Processors.csproj @@ -32,6 +32,7 @@ + true @@ -51,16 +52,113 @@ 4 - - ..\..\lib\Sitecore.Kernel.dll + + ..\packages\Sitecore.6.5.0.120706\lib\ComponentArt.Web.UI.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\HtmlAgilityPack.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\ITHit.WebDAV.Server.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Lucene.Net.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Mvp.Xml.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Newtonsoft.Json.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\RadEditor.Net2.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Analytics.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Apps.Loader.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Automation.MarketingAutomation.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Client.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Kernel.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Logging.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\sitecore.nexus.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.NVelocity.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Oracle.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Publishing.WebDeploy.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Update.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Sitecore.Zip.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Stimulsoft.Base.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Stimulsoft.Database.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Stimulsoft.Report.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Stimulsoft.Report.Web.dll + False + + + ..\packages\Sitecore.6.5.0.120706\lib\Stimulsoft.Report.WebDesign.dll False + + + ..\packages\Sitecore.6.5.0.120706\lib\Telerik.Web.UI.dll + False + @@ -68,10 +166,15 @@ + + + + + @@ -86,6 +189,15 @@ Designer + + + + + + + + + 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) diff --git a/src/Processors/packages.config b/src/Processors/packages.config new file mode 100644 index 0000000..b37d796 --- /dev/null +++ b/src/Processors/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/ReadMe.md b/src/ReadMe.md new file mode 100644 index 0000000..1c57f62 --- /dev/null +++ b/src/ReadMe.md @@ -0,0 +1,61 @@ +# Project Details# +|Project: |Sitecore Field Fallback | +|-----------------|--------------------------| +|Owner: |Hedgehog Development | + +## Project Summary +- Field Fallback is the ability for a field's +value to come from somewhere other than the field +itself, a clones source, or its standard values. +Various fallback scenarios have been provided in +this solution with the ability to customize it as +needed. +- The configuration of each Field Fallback is done +in the App_Config/Include folder. In the patch file +FieldFallback_01.config and FieldFallbackDefaults.00.config.example. + +## Field Fallbacks +#### FieldFallback.Processors.DefaultValuesFallbackProcessor +- A field's value should default to the value set on a field on a +Default Item in a Defaults Folder in the Content tree +- In order to use this type of Fallback, you will have to enable +the config file FieldFallbackDefaults_00.config.example. You +will also need to configure each setting in the config file. +- On the Default Item that was auto-created, each field can +have Standard Values inherited from the Template or Fallback Values +that you would set in the auto-created item. +- To leverage the Fallback values, create items based on the template +that the auto-created item uses. The Item you created will use the +DefaultValuesFallbackProcessor and set the field value based off of the +Fallback Value or Standard Value. + +#### FieldFallback.Processors.AncestorFallbackProcessor +- A field's value should default to the nearest set ancestor that has the same field +- Each field definition has a "EnableAncestorFallback" field. Set to 'true'. + +#### FieldFallback.Processors.LateralFieldFallbackProcessor +- A field's value should default to a different field in the same item. +- In order to use this type of fallback, the template must derive from the + '/sitecore/templates/System/Templates/Fallback template' template rather than the + '/sitecore/templates/System/Templates/Standard template' +- On the standard value (or the actual item) there is a "Fallback Fields" field within a "Fallback" section. + This is a single line text field that may be formatted as a Name/Value pair or XML. + Configure the 'name' part with the name of the field that should have fallback + Configure the 'value' part with the '|' separated list of fields it should check for a value + - Name/Value pair - Name=Value1|Value2&Name2=Value3 + - XML +``` + + + + ... + +``` + + +## Project Prerequisites +1. Access to a Nuget Store with Sitecore Packages + +## Visual Studio Project Setup +1. Restore Nuget Packages +2. Build the solution to ensure there are no issues.