Commit ab8e0667 authored by Viet Hoang's avatar Viet Hoang

Merge branch 'develop' into 'master'

Develop

See merge request !11
parents 7f7fd892 98fb82e6
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<controlSources>
<source mode="on" namespace="Vhs.MediaPublicUrlPickerField.Fields"
assembly="Vhs.MediaPublicUrlPickerField" prefix="vhs" />
</controlSources>
<settings>
<setting name="Vhs.MediaPublicUrlPickerField.DialogWidth" value="800"/>
<setting name="Vhs.MediaPublicUrlPickerField.DialogHeight" value="150"/>
<setting name="Vhs.MediaPublicUrlPickerField.DomainFieldName" value="PublicDomain|MainDomain"/>
<setting name="Vhs.MediaPublicUrlPickerField.DefaultPublicDomain" value="http://viethoang.local"/>
</settings>
</sitecore>
</configuration>
\ No newline at end of file
namespace Vhs.MediaPublicUrlPickerField.Constants
{
public static class QueryStringKeys
{
public const string Value = "value";
public const string ContainerId = "containerId";
public const string Code = "code";
public const string View = "view";
}
}
\ No newline at end of file
using System;
using SC = Sitecore;
using Sitecore.Configuration;
using Sitecore.Data;
using Sitecore.Resources.Media;
using Sitecore.Web;
using Sitecore.Web.UI.Pages;
using Vhs.MediaPublicUrlPickerField.Constants;
using Vhs.MediaPublicUrlPickerField.Services;
namespace Vhs.MediaPublicUrlPickerField.Dialogs
{
public class MediaPublicUrlPickerDialog : DialogForm
{
private const string Separator = "|";
private readonly Database _masterDb = Factory.GetDatabase("master");
public SC.Web.UI.HtmlControls.Image ImageFrame;
public SC.Web.UI.HtmlControls.Edit TextBoxPublicUrl;
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (TextBoxPublicUrl == null) return;
var containerId = WebUtil.GetQueryString(QueryStringKeys.ContainerId);
var currentItem = _masterDb.Items.GetItem(containerId);
if (currentItem == null) return;
var medialUrl = MediaManager.GetMediaUrl(_masterDb.Items.GetItem(currentItem.ID));
var itemHasDomain = currentItem.Parent;
var domainCandidate = string.Empty;
while (itemHasDomain != null)
{
var domainFieldNames = ConfigurationService.DomainFieldName.Split(new[] { Separator },
StringSplitOptions.RemoveEmptyEntries);
foreach (var domainFieldName in domainFieldNames)
{
domainCandidate = itemHasDomain.Fields[domainFieldName] != null
? itemHasDomain.Fields[domainFieldName].Value
: string.Empty;
if (!string.IsNullOrWhiteSpace(domainCandidate)) break;
}
if (string.IsNullOrWhiteSpace(domainCandidate)) itemHasDomain = itemHasDomain.Parent;
else break;
}
var publicDomain = !string.IsNullOrWhiteSpace(domainCandidate)
? domainCandidate
: ConfigurationService.DefaultPublicDomain;
TextBoxPublicUrl.Value = medialUrl.Replace("/sitecore/shell/",
SC.StringUtil.EnsurePostfix('/', publicDomain));
}
}
}
\ No newline at end of file
using System.Collections.Specialized;
using Sitecore.Shell.Applications.ContentEditor;
using Sitecore.Web.UI.Sheer;
using Vhs.MediaPublicUrlPickerField.Constants;
using Vhs.MediaPublicUrlPickerField.Services;
using SC = Sitecore;
namespace Vhs.MediaPublicUrlPickerField.Fields
{
public class MediaPublicUrlPickerField : Custom, IContentField
{
public string GetValue()
{
return this.Value;
}
public void SetValue(string value)
{
this.Value = value;
}
public override void HandleMessage(Message message)
{
base.HandleMessage(message);
if (!message.Name.Equals("vhs:GetPublicUrl"))
return;
// manage to get the container id (Sitecore item id) of this field
// onFocus attribute's value will be like this
// javascript:return scContent.activate(this,event,'sitecore://master/{6DB97A83-480E-4F51-A9D5-B6C688C651B3}?lang=en&ver=1&fld={AA29FFC7-DEA0-4053-87A3-967C198AB652}&ctl=FIELD313682656')
// in this case, container id = 6DB97A83-480E-4F51-A9D5-B6C688C651B3
var onFocus = this.Attributes["onfocus"];
var containerId = onFocus.Split('?')[0].Split('{')[1].Replace("}", string.Empty);
SC.Context.ClientPage.Start(
this,
"GetPublicUrl",
new NameValueCollection { { QueryStringKeys.ContainerId, containerId } });
}
protected void GetPublicUrl(ClientPipelineArgs args)
{
if (args.IsPostBack)
{
if (args.HasResult && args.Result != this.Value)
{
this.SetModified();
this.SetValue(args.Result);
}
}
else
{
var uri = string.Format(
"{0}&{1}={2}&{3}={4}",
SC.UIUtil.GetUri("control:MediaPublicUrlPickerDialog"),
QueryStringKeys.Value,
this.GetValue(),
QueryStringKeys.ContainerId,
args.Parameters[QueryStringKeys.ContainerId]);
SheerResponse.ShowModalDialog(uri, ConfigurationService.DialogWidth, ConfigurationService.DialogHeight,
string.Empty, true);
args.WaitForPostBack();
}
}
}
}
\ No newline at end of file
using System.Reflection;
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("Vhs.MediaPublicUrlPickerField")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Vhs.MediaPublicUrlPickerField")]
[assembly: AssemblyCopyright("Copyright © viet.hoang.sitecore@gmail.com 2017")]
[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("2B410063-2D95-4177-A3D0-1437358DD400")]
// 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 Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
using SC = Sitecore;
namespace Vhs.MediaPublicUrlPickerField.Services
{
public static class ConfigurationService
{
public static string DialogWidth
=> SC.Configuration.Settings.GetSetting("Vhs.MediaPublicUrlPickerField.DialogWidth", "800");
public static string DialogHeight
=> SC.Configuration.Settings.GetSetting("Vhs.MediaPublicUrlPickerField.DialogHeight", "150");
public static string DomainFieldName
=>
SC.Configuration.Settings.GetSetting("Vhs.MediaPublicUrlPickerField.DomainFieldName",
string.Empty);
public static string DefaultPublicDomain
=>
SC.Configuration.Settings.GetSetting("Vhs.MediaPublicUrlPickerField.DefaultPublicDomain",
string.Empty);
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
<Import Project="..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" />
<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>{74E54048-8F7F-4599-AB06-FB729CDAFCAA}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Vhs.MediaPublicUrlPickerField</RootNamespace>
<AssemblyName>Vhs.MediaPublicUrlPickerField</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<UseIISExpress>true</UseIISExpress>
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
<UseGlobalApplicationHostFile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</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="Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Sitecore.Kernel, Version=10.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Sitecore.Kernel.NoReferences.8.2.170407\lib\NET452\Sitecore.Kernel.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Core" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<Reference Include="System.Web.Services" />
<Reference Include="System.EnterpriseServices" />
</ItemGroup>
<ItemGroup>
<Content Include="App_Config\Include\z.Vhs.MediaPublicUrlPickerField.config">
<SubType>Designer</SubType>
</Content>
<None Include="packages.config" />
<None Include="Properties\PublishProfiles\Local.pubxml" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</None>
<None Include="Web.Release.config">
<DependentUpon>Web.config</DependentUpon>
</None>
</ItemGroup>
<ItemGroup>
<None Include="Web.config" />
</ItemGroup>
<ItemGroup>
<Compile Include="Constants\QueryStringKeys.cs" />
<Compile Include="Dialogs\MediaPublicUrlPickerDialog.cs" />
<Compile Include="Fields\MediaPublicUrlPickerField.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\ConfigurationService.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Content Include="sitecore modules\Shell\Vhs Apps\MediaPublicUrlPickerField\MediaPublicUrlPickerDialog.xml">
<SubType>Designer</SubType>
</Content>
</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>11655</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:11655/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your web.config file.
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your web.config file.
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.6"/>
<httpRuntime targetFramework="4.6"/>
</system.web>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701"/>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/>
</compilers>
</system.codedom>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.0" targetFramework="net46" />
<package id="Microsoft.Net.Compilers" version="1.0.0" targetFramework="net46" developmentDependency="true" />
<package id="Sitecore.Kernel.NoReferences" version="8.2.170407" targetFramework="net46" developmentDependency="true" />
</packages>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<control xmlns:def="Definition" xmlns="http://schemas.sitecore.net/Visual-Studio-Intellisense">
<MediaPublicUrlPickerDialog>
<FormDialog ID="Dialog" Icon="Network/32x32/environment_view.png" Header="Media Public URL Picker" OkButton="Close" CancelButton="false"
Text="Please press Ctrl + A then Ctrl + C to copy the public URL inside the texbox below.">
<!--Define Code Beside-->
<CodeBeside Type="Vhs.MediaPublicUrlPickerField.Dialogs.MediaPublicUrlPickerDialog, Vhs.MediaPublicUrlPickerField"/>
<Groupbox Header="Media Public URL (Please press Ctrl + A then Ctrl + C to copy it inside the texbox below)" Style="height:50px;">
<table width="100%">
<tr valign="center">
<td width="70%">
<div class="form-element">
<Edit ID="TextBoxPublicUrl" ReadOnly="false" Width="100%" MaxLength="200"/>
</div>
</td>
</tr>
</table>
</Groupbox>
</FormDialog>
</MediaPublicUrlPickerDialog>
</control>
......@@ -14,6 +14,7 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vhs.PrePopulationItemVersion", "Vhs.PrePopulationItemVersion\Vhs.PrePopulationItemVersion.csproj", "{AE2C750D-CE50-47DD-9900-1A53351C0B38}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vhs.CustomIconsInjector", "Vhs.CustomIconsInjector\Vhs.CustomIconsInjector.csproj", "{6A952CC3-A869-4A2E-97B6-CBCEC9C23CF4}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vhs.MediaPublicUrlPickerField", "Vhs.MediaPublicUrlPickerField\Vhs.MediaPublicUrlPickerField.csproj", "{74E54048-8F7F-4599-AB06-FB729CDAFCAA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
......@@ -45,6 +46,10 @@ Global
{6A952CC3-A869-4A2E-97B6-CBCEC9C23CF4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6A952CC3-A869-4A2E-97B6-CBCEC9C23CF4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6A952CC3-A869-4A2E-97B6-CBCEC9C23CF4}.Release|Any CPU.Build.0 = Release|Any CPU
{74E54048-8F7F-4599-AB06-FB729CDAFCAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{74E54048-8F7F-4599-AB06-FB729CDAFCAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{74E54048-8F7F-4599-AB06-FB729CDAFCAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{74E54048-8F7F-4599-AB06-FB729CDAFCAA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment