Skip to content

Commit 6d50248

Browse files
committed
Merge branch 'release/v3.3'
2 parents b0df699 + 8980dcf commit 6d50248

29 files changed

+599
-432
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ install/
22
obj/
33
Package/
44
Resources.zip.manifest
5+
*.suo
6+
*.user

AlpacaFormBuilder.ascx

+7-7
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,13 @@
7575
//position: 'center'
7676
resizable: false,
7777
});
78-
//$(".form-builder .fb-container").css('position', 'relative');
79-
$(".form-builder .fb-wrap").height('100%').width('50%').css('overflow-y', 'auto').css('position', 'fixed');
80-
//$(".form-builder .dnnActions").css('position', 'fixed').css('bottom', '0').css('left', '0');
81-
//$(".fb-container > div > div").css('overflow-y:scroll');
78+
$('body').css('overflow', 'hidden');
79+
80+
$(".form-builder .fb-left .fb-wrap").height('100%').css('overflow', 'hidden');
81+
var formHeight = newHeight - 100 - 20;
82+
$(".form-builder .fb-left .fb-wrap #form").height(formHeight - 62 + 'px').css('overflow-y', 'auto').css('overflow-x', 'hidden');
83+
$(".form-builder .fb-left .fb-wrap #form > .alpaca-field-object").css('margin', '0');
84+
$(".form-builder .fb-right .fb-wrap #form2").height(formHeight + 'px').css('overflow-x', 'hidden').css('overflow-y', 'auto').css('overflow-x', 'hidden');
8285
}
8386
8487
var moduleScope = $('#<%=ScopeWrapper.ClientID %>'),
@@ -93,7 +96,6 @@
9396
data: getData,
9497
beforeSend: sf.setModuleHeaders
9598
}).done(function (res) {
96-
$('#builder').val(JSON.stringify(res.data, null, " "));
9799
if (!res.data) res.data = {};
98100
showForm(res.data);
99101
formbuilderConfig.data = res.data;
@@ -114,7 +116,6 @@
114116
});
115117
$("#<%=cmdSave.ClientID%>").click(function () {
116118
var href = $(this).attr('href');
117-
//var data = $('#builder').val();
118119
var form = $("#form").alpaca("get");
119120
var data = form.getValue();
120121
var schema = getSchema(data);
@@ -149,7 +150,6 @@
149150
return;
150151
}
151152
var value = form.getValue();
152-
$('#builder').val(JSON.stringify(value, null, " "));
153153
showForm(value);
154154
return false;
155155
});

AlpacaFormBuilder.ascx.cs

-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@
1212
using System;
1313
using DotNetNuke.Entities.Modules;
1414
using DotNetNuke.Common;
15-
using Satrabel.OpenContent.Components;
1615
using Satrabel.OpenContent.Components.Alpaca;
1716

1817
using DotNetNuke.Web.Client.ClientResourceManagement;
1918
using DotNetNuke.Web.Client;
20-
using System.Web.UI.WebControls;
2119

2220
#endregion
2321

AlpacaFormBuilder.ascx.designer.cs

+17-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

App_LocalResources/View.ascx.fr-FR.resx

+4-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
<value>Ajouter</value>
143143
</data>
144144
<data name="EditSettings.Action" xml:space="preserve">
145-
<value>Template Settings</value>
145+
<value>Paramètres du formulaire</value>
146146
</data>
147147
<data name="EditTemplate.Action" xml:space="preserve">
148148
<value>Edit Template Files</value>
@@ -156,4 +156,7 @@
156156
<data name="Sending.Text" xml:space="preserve">
157157
<value>Envoi en cours ...</value>
158158
</data>
159+
<data name="Builder.Action" xml:space="preserve">
160+
<value>Form Builder</value>
161+
</data>
159162
</root>

App_LocalResources/View.ascx.resx

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
<value>Add Item</value>
146146
</data>
147147
<data name="EditSettings.Action" xml:space="preserve">
148-
<value>Template Settings</value>
148+
<value>Form Settings</value>
149149
</data>
150150
<data name="EditTemplate.Action" xml:space="preserve">
151151
<value>Edit Template Files</value>

Components/FeatureController.cs

-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010
'
1111
*/
1212

13-
using System.Collections.Generic;
1413
//using System.Xml;
15-
using DotNetNuke.Entities.Modules;
16-
using DotNetNuke.Services.Search;
1714

1815
namespace Satrabel.OpenForm.Components
1916
{

Components/FormUtils.cs

+167
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Globalization;
4+
using System.Linq;
5+
using System.Net.Mail;
6+
using System.Text;
7+
using System.Text.RegularExpressions;
8+
using System.Web;
9+
using DotNetNuke.Entities.Host;
10+
using DotNetNuke.Entities.Portals;
11+
using DotNetNuke.Entities.Users;
12+
using DotNetNuke.Services.Mail;
13+
using Newtonsoft.Json.Linq;
14+
15+
namespace Satrabel.OpenForm.Components
16+
{
17+
public static class FormUtils
18+
{
19+
internal static MailAddress GenerateMailAddress(string typeOfAddress, string email, string name, string formEmailField, string formNameField, JObject form)
20+
{
21+
MailAddress adr = null;
22+
var portalSettings = PortalSettings.Current;
23+
24+
if (typeOfAddress == "host")
25+
{
26+
adr = GenerateMailAddress(Host.HostEmail, Host.HostTitle);
27+
}
28+
else if (typeOfAddress == "admin")
29+
{
30+
var user = UserController.GetUserById(portalSettings.PortalId, portalSettings.AdministratorId);
31+
adr = GenerateMailAddress(user.Email, user.DisplayName);
32+
}
33+
else if (typeOfAddress == "form")
34+
{
35+
if (string.IsNullOrEmpty(formNameField))
36+
formNameField = "name";
37+
if (string.IsNullOrEmpty(formEmailField))
38+
formEmailField = "email";
39+
40+
string formEmail = GetProperty(form, formEmailField);
41+
string formName = GetProperty(form, formNameField);
42+
adr = GenerateMailAddress(formEmail, formName);
43+
}
44+
else if (typeOfAddress == "custom")
45+
{
46+
adr = GenerateMailAddress(email, name);
47+
}
48+
else if (typeOfAddress == "current")
49+
{
50+
var userInfo = portalSettings.UserInfo;
51+
if (userInfo == null)
52+
throw new Exception($"Can't send email to current user, as there is no current user. Parameters were TypeOfAddress: [{typeOfAddress}], Email: [{email}], Name: [{name}], FormEmailField: [{formEmailField}], FormNameField: [{formNameField}], FormNameField: [{form}]");
53+
54+
adr = GenerateMailAddress(userInfo.Email, userInfo.DisplayName);
55+
if (adr == null)
56+
throw new Exception($"Can't send email to current user, as email address of current user is unknown. Parameters were TypeOfAddress: [{typeOfAddress}], Email: [{email}], Name: [{name}], FormEmailField: [{formEmailField}], FormNameField: [{formNameField}], FormNameField: [{form}]");
57+
}
58+
59+
if (adr == null)
60+
{
61+
throw new Exception($"Can't determine email address. Parameters were TypeOfAddress: [{typeOfAddress}], Email: [{email}], Name: [{name}], FormEmailField: [{formEmailField}], FormNameField: [{formNameField}], FormNameField: [{form}]");
62+
}
63+
64+
return adr;
65+
}
66+
67+
private static MailAddress GenerateMailAddress(string email, string title)
68+
{
69+
email = email.Trim(); //normalize email
70+
71+
return IsValidEmail(email) ? new MailAddress(email, title) : null;
72+
}
73+
74+
private static string GetProperty(JObject obj, string propertyName)
75+
{
76+
string propertyValue = "";
77+
var property = obj.Children<JProperty>().SingleOrDefault(p => p.Name.ToLower() == propertyName.ToLower());
78+
if (property != null)
79+
{
80+
propertyValue = property.Value.ToString();
81+
}
82+
return propertyValue;
83+
}
84+
85+
/// <summary>
86+
/// Determines whether email is valid.
87+
/// </summary>
88+
/// <remarks>
89+
/// https://technet.microsoft.com/nl-be/library/01escwtf(v=vs.110).aspx
90+
/// </remarks>
91+
public static bool IsValidEmail(string strIn)
92+
{
93+
if (string.IsNullOrEmpty(strIn)) return false;
94+
95+
bool invalid = false;
96+
97+
// Use IdnMapping class to convert Unicode domain names.
98+
try
99+
{
100+
strIn = Regex.Replace(strIn, @"(@)(.+)$", DomainMapper);
101+
}
102+
catch (Exception e)
103+
{
104+
invalid = true;
105+
}
106+
107+
if (invalid)
108+
return false;
109+
110+
// Return true if strIn is in valid e-mail format.
111+
return Regex.IsMatch(strIn,
112+
@"^(?("")(""[^""]+?""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" +
113+
@"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9]{2,17}))$",
114+
RegexOptions.IgnoreCase);
115+
}
116+
117+
private static string DomainMapper(Match match)
118+
{
119+
// IdnMapping class with default property values.
120+
IdnMapping idn = new IdnMapping();
121+
string domainName = match.Groups[2].Value;
122+
domainName = idn.GetAscii(domainName);
123+
return match.Groups[1].Value + domainName;
124+
}
125+
public static string SendMail(string mailFrom, string mailTo, string replyTo, string subject, string body, List<Attachment> attachments = null)
126+
{
127+
//string mailFrom
128+
//string mailTo,
129+
string cc = "";
130+
string bcc = "";
131+
//string replyTo,
132+
DotNetNuke.Services.Mail.MailPriority priority = DotNetNuke.Services.Mail.MailPriority.Normal;
133+
//string subject,
134+
MailFormat bodyFormat = MailFormat.Html;
135+
Encoding bodyEncoding = Encoding.UTF8;
136+
//string body,
137+
//List<Attachment> attachments = new List<Attachment>();
138+
if (attachments == null) attachments = new List<Attachment>();
139+
string smtpServer = Host.SMTPServer;
140+
string smtpAuthentication = Host.SMTPAuthentication;
141+
string smtpUsername = Host.SMTPUsername;
142+
string smtpPassword = Host.SMTPPassword;
143+
bool smtpEnableSSL = Host.EnableSMTPSSL;
144+
145+
string res = Mail.SendMail(mailFrom,
146+
mailTo,
147+
cc,
148+
bcc,
149+
replyTo,
150+
priority,
151+
subject,
152+
bodyFormat,
153+
bodyEncoding,
154+
body,
155+
attachments,
156+
smtpServer,
157+
smtpAuthentication,
158+
smtpUsername,
159+
smtpPassword,
160+
smtpEnableSSL);
161+
162+
//Mail.SendEmail(replyTo, mailFrom, mailTo, subject, body);
163+
return res;
164+
}
165+
}
166+
167+
}

Components/Logger.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Diagnostics;
33
using System.Net.Http;
4-
using ClientDependency.Core;
54
using DotNetNuke.Instrumentation;
65

76
namespace Satrabel.OpenForm.Components

0 commit comments

Comments
 (0)