-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/1.1.0'
- Loading branch information
Showing
26 changed files
with
570 additions
and
19 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
15 changes: 15 additions & 0 deletions
15
src/WFFM.ConversionTool.Extensions.SitecoreFormsExtensions/Constants/MediaItemConstants.cs
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,15 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace WFFM.ConversionTool.Extensions.SitecoreFormsExtensions.Constants | ||
{ | ||
public class MediaItemConstants | ||
{ | ||
public const string ExtensionFieldId = "{C06867FE-9A43-4C7D-B739-48780492D06F}"; | ||
public const string MimeTypeFieldId = "{6F47A0A5-9C94-4B48-ABEB-42D38DEF6054}"; | ||
public const string SizeFieldId = "{6954B7C7-2487-423F-8600-436CB3B6DC0E}"; | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
....Extensions.SitecoreFormsExtensions/Converters/FieldValueConverter/FileUploadConverter.cs
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,64 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Text.RegularExpressions; | ||
using System.Threading.Tasks; | ||
using WFFM.ConversionTool.Extensions.SitecoreFormsExtensions.Constants; | ||
using WFFM.ConversionTool.Library.Converters; | ||
using WFFM.ConversionTool.Library.Logging; | ||
using WFFM.ConversionTool.Library.Models.Metadata; | ||
using WFFM.ConversionTool.Library.Repositories; | ||
|
||
namespace WFFM.ConversionTool.Extensions.SitecoreFormsExtensions.Converters.FieldValueConverter | ||
{ | ||
public class FileUploadConverter : BaseFieldConverter | ||
{ | ||
private ISourceMasterRepository _sourceMasterRepository; | ||
private AppSettings _appSettings; | ||
private ILogger _logger; | ||
|
||
public FileUploadConverter(ISourceMasterRepository sourceMasterRepository, AppSettings appSettings, ILogger logger) | ||
{ | ||
_sourceMasterRepository = sourceMasterRepository; | ||
_appSettings = appSettings; | ||
_logger = logger; | ||
} | ||
|
||
public override string ConvertValue(string sourceValue) | ||
{ | ||
// Parse the value to get the media item ID | ||
// Example: sitecore://master/{A1207618-AFC1-465A-A45A-5F1C47A59B34}?lang=en&ver=1 | ||
var mediaItemRegexMatch = Regex.Match(sourceValue, @"sitecore:\/\/master\/(.*)\?lang=(.*)&ver=1"); | ||
var mediaItemId = mediaItemRegexMatch.Groups[1].Value; | ||
var mediaItemLanguage = mediaItemRegexMatch.Groups[2].Value; | ||
|
||
if (string.IsNullOrEmpty(mediaItemId) || !Guid.TryParse(mediaItemId, out var mediaItemGuid)) | ||
{ | ||
return sourceValue; | ||
} | ||
|
||
// Get the media item from source master db and map fields | ||
var mediaItem = _sourceMasterRepository.GetSitecoreItem(mediaItemGuid); | ||
|
||
if (string.IsNullOrEmpty(mediaItem.Name)) return sourceValue; | ||
|
||
var mediaItemName = mediaItem.Name; | ||
var mediaItemExtension = | ||
mediaItem.Fields.FirstOrDefault(f => f.FieldId == new Guid(MediaItemConstants.ExtensionFieldId))?.Value; | ||
var mediaItemContentType = | ||
mediaItem.Fields.FirstOrDefault(f => f.FieldId == new Guid(MediaItemConstants.MimeTypeFieldId))?.Value; | ||
var mediaItemContentLength = | ||
mediaItem.Fields.FirstOrDefault(f => f.FieldId == new Guid(MediaItemConstants.SizeFieldId))?.Value; | ||
|
||
var useItemIdForFileName = | ||
_appSettings.extensions["sitecoreFormsExtensions_UseItemIdForFilename"].ToLower() == "true"; | ||
var mediaItemFileName = useItemIdForFileName ? $"{mediaItemGuid.ToString("D").ToLower()}.{mediaItemExtension}" : $"{mediaItemName}.{mediaItemExtension}"; | ||
|
||
var mediaItemUrl = _appSettings.extensions["sitecoreFormsExtensions_FileDownloadUrlBase"] | ||
.Replace("{0}", mediaItemFileName); | ||
|
||
return $"{{\"Url\":\"{mediaItemUrl}\",\"OriginalFileName\":\"{mediaItemName}.{mediaItemExtension}\",\"ContentType\":\"{mediaItemContentType}\",\"ContentLength\":{mediaItemContentLength},\"StoredFileName\":\"{mediaItemFileName}\",\"StoredFilePath\":\"\"}}"; | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/WFFM.ConversionTool.Extensions.SitecoreFormsExtensions/Metadata/Custom/FileUpload.json
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,33 @@ | ||
{ | ||
"sourceMappingFieldValue": "{827BDF4A-D886-4B36-9D32-C443EBCA1806}", // File Upload | ||
"destTemplateId": "{27686F73-AA5C-4E0E-AC6B-E3000D129E4F}", | ||
"destTemplateName": "FileUploadField", | ||
"baseTemplateMetadataFileName": "Input.json", | ||
"dataValueType": "Feature.FormsExtensions.Business.FileUpload.StoredFile", | ||
"dataValueConverter": "FileUploadConverter", | ||
"fields": { | ||
"newFields": [ | ||
{ | ||
"fieldType": "shared", | ||
"destFieldId": "{589A7ADE-81D4-4A60-B9E2-7EAF6AE8A563}", // Field Type | ||
"value": "{687A7B09-47E3-4FAA-AB2D-A4BF83DB0F1B}" | ||
} | ||
], | ||
"convertedFields": [ | ||
{ | ||
"fieldConverter": "", | ||
"sourceFieldId": "{358E7AA0-E3E6-4EF6-92DF-EC1301737B50}", // Parameters | ||
"destFields": [ | ||
|
||
] | ||
}, | ||
{ | ||
"fieldConverter": "", | ||
"sourceFieldId": "{26CDC7C2-5307-4591-A7F9-5C034A05630A}", // Localized Parameters | ||
"destFields": [ | ||
|
||
] | ||
} | ||
] | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/WFFM.ConversionTool.Extensions.SitecoreFormsExtensions/Metadata/Custom/ReCaptcha.json
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,31 @@ | ||
{ | ||
"sourceMappingFieldValue": "{7FB270BE-FEFC-49C3-8CB4-947878C099E5}", // Captcha | ||
"destTemplateId": "{5A59C481-E3C3-4A03-A471-B5D1FB45181A}", // ReCaptcha | ||
"destTemplateName": "CaptchaField", | ||
"baseTemplateMetadataFileName": "Field.json", | ||
"fields": { | ||
"newFields": [ | ||
{ | ||
"fieldType": "shared", | ||
"destFieldId": "{589A7ADE-81D4-4A60-B9E2-7EAF6AE8A563}", // Field Type | ||
"value": "{E383BDE2-BC88-4278-83EF-832A15C9E94A}" | ||
} | ||
], | ||
"convertedFields": [ | ||
{ | ||
"fieldConverter": "", | ||
"sourceFieldId": "{358E7AA0-E3E6-4EF6-92DF-EC1301737B50}", // Parameters | ||
"destFields": [ | ||
|
||
] | ||
}, | ||
{ | ||
"fieldConverter": "", | ||
"sourceFieldId": "{26CDC7C2-5307-4591-A7F9-5C034A05630A}", // Localized Parameters | ||
"destFields": [ | ||
|
||
] | ||
} | ||
] | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/WFFM.ConversionTool.Extensions.SitecoreFormsExtensions/Properties/AssemblyInfo.cs
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,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("WFFM.ConversionTool.Extensions.SitecoreFormsExtensions")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("WFFM.ConversionTool.Extensions.SitecoreFormsExtensions")] | ||
[assembly: AssemblyCopyright("Copyright © 2019")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("b0f28bbf-bcdf-491b-a6d3-406f7b042c24")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
68 changes: 68 additions & 0 deletions
68
...ons.SitecoreFormsExtensions/WFFM.ConversionTool.Extensions.SitecoreFormsExtensions.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,68 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" 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> | ||
<ProjectGuid>{B0F28BBF-BCDF-491B-A6D3-406F7B042C24}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>WFFM.ConversionTool.Extensions.SitecoreFormsExtensions</RootNamespace> | ||
<AssemblyName>WFFM.ConversionTool.Extensions.SitecoreFormsExtensions</AssemblyName> | ||
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</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\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Constants\MediaItemConstants.cs" /> | ||
<Compile Include="Converters\FieldValueConverter\FileUploadConverter.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\WFFM.ConversionTool.Library\WFFM.ConversionTool.Library.csproj"> | ||
<Project>{670ad498-f9f3-45bc-81a5-4c5841249298}</Project> | ||
<Name>WFFM.ConversionTool.Library</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Content Include="readme_SitecoreFormsExtensions.txt"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
<ItemGroup /> | ||
<ItemGroup> | ||
<None Include="Metadata\Custom\FileUpload.json"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Include="Metadata\Custom\Recaptcha.json"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
20 changes: 20 additions & 0 deletions
20
...WFFM.ConversionTool.Extensions.SitecoreFormsExtensions/readme_SitecoreFormsExtensions.txt
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,20 @@ | ||
+------------------------------------------------------+ | ||
| Installation Instructions | | ||
+------------------------------------------------------+ | ||
|
||
1) Copy the entire module extension folder in the WFFM Conversion Tool root folder. When prompted, choose to merge the existing folders. | ||
|
||
2) Open the AppSettings.json file located in the WFFM Conversion Tool root folder and uncomment the following JSON object in the "converters" property: | ||
|
||
//, | ||
//{ | ||
// "name": "FileUploadConverter", | ||
// "converterType": "WFFM.ConversionTool.Extensions.SitecoreFormsExtensions.Converters.FieldValueConverter.FileUploadConverter, WFFM.ConversionTool.Extensions.SitecoreFormsExtensions" | ||
//} | ||
|
||
3) In the AppSettings.json file, modify the following settings to configure the File Upload field data conversion process: | ||
|
||
"extensions": { | ||
"sitecoreFormsExtensions_FileDownloadUrlBase": "https://myfile.com/{0}", // File Download Url Base for Sitecore Forms Extensions File Upload data. | ||
"sitecoreFormsExtensions_UseItemIdForFilename": "false" // Default value: "false". If "true", the media item filename for the Sitecore Forms Extension File Upload data is built using the media item ID instead of the media item name. | ||
} |
Oops, something went wrong.