|
using System; |
|
using System.Collections.Generic; |
|
using System.Linq; |
|
using System.Web.UI; |
|
using System.Web.UI.WebControls; |
|
using Telerik.Sitefinity.Web.UI; |
|
using Telerik.Sitefinity.Web.UI.Fields; |
|
using Telerik.Sitefinity.Web.UI.Fields.Enums; |
|
|
|
namespace SitefinityWebApp.CustomPaymentProcessor |
|
{ |
|
public class CustomPaymentSettingsField : FieldControl |
|
{ |
|
#region Properties |
|
|
|
protected override WebControl TitleControl |
|
{ |
|
get { return this.Container.GetControl<Label>("titleLabel", true); } |
|
} |
|
|
|
protected override WebControl DescriptionControl |
|
{ |
|
get { return this.Container.GetControl<Label>("descriptionLabel", this.DisplayMode == FieldDisplayMode.Write); } |
|
} |
|
|
|
protected override WebControl ExampleControl |
|
{ |
|
get { return this.Container.GetControl<Label>("exampleLabel", this.DisplayMode == FieldDisplayMode.Write); } |
|
} |
|
|
|
protected virtual HiddenField PaymentMethodIdHidden |
|
{ |
|
get |
|
{ |
|
return this.Container.GetControl<HiddenField>("paymentMethodId", this.DisplayMode == FieldDisplayMode.Write); |
|
} |
|
} |
|
|
|
protected virtual TextField TestPasswordControl |
|
{ |
|
get |
|
{ |
|
return this.Container.GetControl<TextField>("testPassword", true); |
|
} |
|
} |
|
|
|
protected virtual TextField TestUsernameControl |
|
{ |
|
get |
|
{ |
|
return this.Container.GetControl<TextField>("testUsername", true); |
|
} |
|
} |
|
|
|
protected virtual TextField LivePasswordControl |
|
{ |
|
get |
|
{ |
|
return this.Container.GetControl<TextField>("livePassword", true); |
|
} |
|
} |
|
|
|
protected virtual TextField LiveUsernameControl |
|
{ |
|
get |
|
{ |
|
return this.Container.GetControl<TextField>("liveUsername", true); |
|
} |
|
} |
|
|
|
protected virtual TextField Timeout |
|
{ |
|
get |
|
{ |
|
return this.Container.GetControl<TextField>("timeout", true); |
|
} |
|
} |
|
|
|
protected virtual ChoiceField PaymentType |
|
{ |
|
get |
|
{ |
|
return this.Container.GetControl<ChoiceField>("paymentType", true); |
|
} |
|
} |
|
|
|
protected virtual ChoiceField ProcessingMode |
|
{ |
|
get |
|
{ |
|
return this.Container.GetControl<ChoiceField>("processingMode", true); |
|
} |
|
} |
|
|
|
protected virtual ChoiceField ProcessorCreditCards |
|
{ |
|
get |
|
{ |
|
return this.Container.GetControl<ChoiceField>("processorCreditCards", true); |
|
} |
|
} |
|
|
|
protected override string LayoutTemplateName |
|
{ |
|
get |
|
{ |
|
return "SitefinityWebApp.CustomPaymentProcessor.CustomPaymentSettingsFieldTemplate.ascx"; |
|
} |
|
} |
|
|
|
public override object Value |
|
{ |
|
get |
|
{ |
|
if (base.Value == null) |
|
return Guid.Empty; |
|
return base.Value; |
|
} |
|
set |
|
{ |
|
base.Value = value; |
|
} |
|
} |
|
|
|
#endregion |
|
|
|
protected override void InitializeControls(GenericContainer container) |
|
{ |
|
((ITextControl)this.TitleControl).Text = this.Title; |
|
((ITextControl)this.ExampleControl).Text = this.Example; |
|
((ITextControl)this.DescriptionControl).Text = this.Description; |
|
|
|
this.PaymentMethodIdHidden.Value = this.Value.ToString(); |
|
} |
|
|
|
public override IEnumerable<ScriptDescriptor> GetScriptDescriptors() |
|
{ |
|
var descriptors = new List<ScriptDescriptor>(base.GetScriptDescriptors()); |
|
var descriptor = (ScriptControlDescriptor)descriptors.Last(); |
|
|
|
descriptor.AddComponentProperty("testPasswordControl", this.TestPasswordControl.ClientID); |
|
descriptor.AddComponentProperty("testUsernameControl", this.TestUsernameControl.ClientID); |
|
|
|
descriptor.AddComponentProperty("livePasswordControl", this.LivePasswordControl.ClientID); |
|
descriptor.AddComponentProperty("liveUsernameControl", this.LiveUsernameControl.ClientID); |
|
|
|
descriptor.AddComponentProperty("timeoutControl", this.Timeout.ClientID); |
|
|
|
descriptor.AddComponentProperty("processingModeControl", this.ProcessingMode.ClientID); |
|
|
|
descriptor.AddComponentProperty("processorCreditCardsControl", this.ProcessorCreditCards.ClientID); |
|
|
|
descriptor.AddComponentProperty("paymentTypeControl", this.PaymentType.ClientID); |
|
|
|
return descriptors; |
|
} |
|
|
|
public override IEnumerable<ScriptReference> GetScriptReferences() |
|
{ |
|
var scripts = new List<ScriptReference>(base.GetScriptReferences()); |
|
scripts.Add(new ScriptReference("SitefinityWebApp.CustomPaymentProcessor.CustomPaymentSettingsFieldScript.js", typeof(CustomPaymentSettingsField).Assembly.FullName)); |
|
return scripts; |
|
} |
|
} |
|
} |