Commit 1d1650df authored by Viet Hoang's avatar Viet Hoang

add Sitecore package

parent a10e8e3f
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<controlSources>
<source mode="on" namespace="Vhs.MediaPublicUrlPickerField.Fields"
assembly="Vhs.MediaPublicUrlPickerField" prefix="vhs" />
</controlSources>
<sitecore>
<controlSources>
<source mode="on" namespace="Vhs.MediaPublicUrlPickerField.Fields"
assembly="Vhs.MediaPublicUrlPickerField" prefix="vhs" />
</controlSources>
<settings>
<setting name="Vhs.MediaPublicUrlPickerField.DialogWidth" value="1000"/>
<setting name="Vhs.MediaPublicUrlPickerField.DialogHeight" value="150"/>
<setting name="Vhs.MediaPublicUrlPickerField.PublicDomain" value="http://viethoang.local"/>
</settings>
</sitecore>
<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
......@@ -5,7 +5,6 @@
using Sitecore.Resources.Media;
using Sitecore.Web;
using Sitecore.Web.UI.Pages;
using Sitecore.Web.UI.Sheer;
using Vhs.MediaPublicUrlPickerField.Constants;
using Vhs.MediaPublicUrlPickerField.Services;
......@@ -31,17 +30,35 @@ protected override void OnLoad(EventArgs e)
var currentItem = _masterDb.Items.GetItem(containerId);
if (currentItem != null)
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 medialUrl = MediaManager.GetMediaUrl(_masterDb.Items.GetItem(currentItem.ID));
TextBoxPublicUrl.Value = medialUrl.Replace("/sitecore/shell", ConfigurationService.PublicDomain);
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;
}
}
protected override void OnOK(object sender, EventArgs args)
{
SheerResponse.SetDialogValue(this.TextBoxPublicUrl.Value);
base.OnOK(sender, args);
var publicDomain = !string.IsNullOrWhiteSpace(domainCandidate)
? domainCandidate
: ConfigurationService.DefaultPublicDomain;
TextBoxPublicUrl.Value = medialUrl.Replace("/sitecore/shell/",
SC.StringUtil.EnsurePostfix('/', publicDomain));
}
}
}
\ No newline at end of file
......@@ -8,11 +8,16 @@ public static string DialogWidth
=> SC.Configuration.Settings.GetSetting("Vhs.MediaPublicUrlPickerField.DialogWidth", "800");
public static string DialogHeight
=> SC.Configuration.Settings.GetSetting("Vhs.MediaPublicUrlPickerField.DialogHeight", "600");
=> SC.Configuration.Settings.GetSetting("Vhs.MediaPublicUrlPickerField.DialogHeight", "150");
public static string PublicDomain
public static string DomainFieldName
=>
SC.Configuration.Settings.GetSetting("Vhs.MediaPublicUrlPickerField.PublicDomain",
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
......@@ -97,7 +97,6 @@
<Content Include="sitecore modules\Shell\Vhs Apps\MediaPublicUrlPickerField\MediaPublicUrlPickerDialog.xml">
<SubType>Designer</SubType>
</Content>
<Content Include="sitecore modules\Shell\Vhs Apps\MediaPublicUrlPickerField\js\jquery-2.1.0.min.js" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
......
<?xml version="1.0" encoding="utf-8" ?>
<control xmlns:def="Definition" xmlns="http://schemas.sitecore.net/Visual-Studio-Intellisense">
<MediaPublicUrlPickerDialog>
<!--Init Script-->
<Script src="/sitecore modules/Shell/Vhs Apps/MediaPublicUrlPickerField/js/jquery-2.1.0.min.js" key="mediaPublicUrlPicker" Language="javascript"></Script>
<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.">
......
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