Skip to content

Commit

Permalink
v1.3 released.
Browse files Browse the repository at this point in the history
v1.3 released with new features and improvements.
  • Loading branch information
actuallyakash authored Apr 2, 2019
2 parents 421b7d2 + afe91e6 commit 87291fa
Show file tree
Hide file tree
Showing 19 changed files with 300 additions and 110 deletions.
3 changes: 0 additions & 3 deletions .gitignore

This file was deleted.

16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@
![AUR](https://img.shields.io/aur/license/yaourt.svg)
[![GitHub release](https://img.shields.io/github/release/joomdev/JD-Simple-Contact-Form.svg)](https://github.com/joomdev/JD-Simple-Contact-Form/releases)

# JD Simple Contact Form
JD Simple Contact form extension is a simple form builder for the Joomla ideally suited for beginners and also meets the basic requirements for every developer and designer. It allows creating various types of form like the mailing list, survey, contact and more.
<center><a target="_blank" href="https://www.joomdev.com/products/extensions/jd-simple-contact-form"><img src="https://www.joomdev.com/images/extensions/jd-simple-contact-form/banner.jpg" /></a></center>

# Requirements
* Joomla: 3.8 +
* PHP : 5.6+

# JD Simple Contact Form
JD Simple Contact form extension is simple form builder for a Joomla ideally suited for beginners and also meets the basic requirements for every developers and designers. It allows to create various types of form like mailing list, survey, contact and more.
## Here is what's included:
- Unlimited number of form fields.
- 10+ different field types.
- Ability to make fields required with custom error messages.
- Ability to order fields.
- Ability to configure thank you message.
- Ability to redirect to another page after form submission.
- Custom email messages.
- Ability to CC, BCC messages.
- Ajax Submission.

# [Documentation](https://github.com/joomdev/JD-Simple-Contact-Form/wiki)
7 changes: 7 additions & 0 deletions forms/fielditem.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
showon="required:1"
name="custom_error"
type="text"
label="MOD_JDSCF_CUSTOM_ERROR_LBL"
description="MOD_JDSCF_CUSTOM_ERROR_DESC"
/>
<field
name="show_label"
type="radio"
Expand Down
57 changes: 48 additions & 9 deletions helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,14 @@ public static function submitForm($ajax = false) {
if(is_array($value)) {
if(isset($value['email'])) {
$values[$name] = $value['email'];
//multiple cc
if(isset($value['cc']) && $value['cc'] == 1) {
$cc_emails[] = $value['email'];
}
//single cc
if(isset($value['single_cc']) && $value['single_cc'] == 1) {
$cc_emails[] = $value['email'];
}
}
} else {
$values[$name] = $value;
Expand All @@ -121,8 +126,10 @@ public static function submitForm($ajax = false) {
}
}

if ($fld['type'] == 'checkbox') {
$value = $_POST['jdscf'][$name]['cb'];
if ($fld['type'] == 'checkbox') {
if (isset($_POST['jdscf'][$name]['cb'])){
$value = $_POST['jdscf'][$name]['cb'];
}
if (is_array($value)) {
$value = implode(',', $value);
} else {
Expand Down Expand Up @@ -208,6 +215,19 @@ public static function submitForm($ajax = false) {
if (!empty($recipients)) {
$mailer->addRecipient($recipients);
}

// Reply-To
if (!empty($params->get('reply_to', ''))) {
$reply_to = $params->get('reply_to', '');
$reply_to = self::renderVariables($contents, $reply_to);
if (!filter_var($reply_to, FILTER_VALIDATE_EMAIL)) {
$reply_to = '';
}
$mailer->addReplyTo($reply_to);
} else {
$reply_to = '';
}

// CC
$cc = !empty($params->get('email_cc', '')) ? $params->get('email_cc') : '';
$cc = empty($cc) ? [] : explode(",", $cc);
Expand All @@ -233,6 +253,7 @@ public static function submitForm($ajax = false) {
}
if(!empty($errors)) {
$app = JFactory::getApplication();
$send = false;
//showing all the validation errors
foreach ($errors as $error) {
$app->enqueueMessage(\JText::_($error), 'error');
Expand All @@ -243,7 +264,13 @@ public static function submitForm($ajax = false) {
}

if ($send !== true) {
throw new \Exception(JText::_('MOD_JDSCFEMAIL_SEND_ERROR'));
switch($params->get('ajaxsubmit'))
{
case 0: throw new \Exception(JText::_('MOD_JDSCFEMAIL_SEND_ERROR'));
break;
case 1: throw new \Exception(json_encode($errors));
break;
}
}
$message = $params->get('thankyou_message', '');
if (empty($message)) {
Expand All @@ -264,7 +291,7 @@ public static function submitForm($ajax = false) {
}
$app->redirect($return);
}
return ['message' => $message, 'redirect' => $redirect_url];
return ['message' => $message, 'redirect' => $redirect_url, 'errors' => json_encode($errors)];
}

public static function renderVariables($variables, $source) {
Expand Down Expand Up @@ -344,13 +371,25 @@ public static function getJS($moduleid) {
return $GLOBALS['mod_jdscf_js_' . $moduleid];
}

public static function isCCMail($field, $params){
//for single email field (at bottom)
public static function isSingleCCMail($params) {
$singlesendcopy_email = $params->get('single_sendcopy_email', 0);
$singlesendcopyemail_field = $params->get('singleSendCopyEmail_field', '');
if($singlesendcopy_email && !empty($singlesendcopyemail_field)){
return true;
} else {
return false;
}
}

//for multiple email fields
public static function isCCMail($field, $params) {
$sendcopy_email = $params->get('sendcopy_email', 0);
$sendcopyemail_field = $params->get('sendcopyemail_field', '');
$sendcopyemail_fields = explode(",", $sendcopyemail_field);
if($sendcopy_email && !empty($sendcopyemail_fields) && in_array($field->name, $sendcopyemail_fields)){
return true;
}else{
} else {
return false;
}
}
Expand All @@ -373,17 +412,17 @@ public static function uploadFile($name, $src) {
else
{
$tmppath = JPATH_SITE . '/tmp';
if(!file_exists($tmppath.'/jdscf')){
if (!file_exists($tmppath.'/jdscf')) {
mkdir($tmppath.'/jdscf',0777);
}
$folder = md5(time().'-'.$filename.rand(0,99999));
if(!file_exists($tmppath.'/jdscf/'.$folder)){
if (!file_exists($tmppath.'/jdscf/'.$folder)) {
mkdir($tmppath.'/jdscf/'.$folder,0777);
}
$dest = $tmppath.'/jdscf/'.$folder.'/'.$filename;

$return = null;
if (JFile::upload($src, $dest)){
if (JFile::upload($src, $dest)) {
$return = $dest;
}
return $return;
Expand Down
36 changes: 26 additions & 10 deletions language/en-GB/en-GB.mod_jdsimplecontactform.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ MOD_JDSIMPLECONTACTFORM_XML_DESCRIPTION="JD Simple Contact form provides you wit
Here is what's included:
<ul>
<li>Unlimited number of form fields.</li>
<li>9 different field types.</li>
<li>Ability to make fields required.</li>
<li>10+ different field types.</li>
<li>Ability to make fields required with custom error messages.</li>
<li>Ability to order fields.</li>
<li>Ability to configure thank you message.</li>
<li>Ability to redirect to another page after form submission.</li>
<li>Custom email messages.</li>
<li>Ability to CC, BCC messages.</li>
<li>Ability to CC, BCC, Reply-To messages.</li>
<li>Ajax Submission.</li>
</ul>"

Expand Down Expand Up @@ -48,19 +48,25 @@ MOD_JDSCF_SHOW_LABEL_DESC="Select to display the label before the field."
MOD_JDSCF_OPTIONS_LAYOUT_LBL="Options Layout"
MOD_JDSCF_OPTIONS_LAYOUT_DESC="Select to display checkboxes and radios in vertically or stacked layout."

MOD_JDSCF_FORM_SUBMIT_LBL="Submit button text"
MOD_JDSCF_FORM_SUBMIT_LBL="Submit Button Text"
MOD_JDSCF_FORM_SUBMIT_DESC="Enter to change text for the submit button. Default is <b>Submit</b>."
MOD_JDSCF_FORM_SUBMIT_DEFAULT="Submit"

MOD_JDSCF_REQUIRED_LBL="Required"
MOD_JDSCF_REQUIRED_DESC="Select to make the input of the field required."

MOD_JDSCF_CUSTOM_ERROR_LBL="Custom Required Error"
MOD_JDSCF_CUSTOM_ERROR_DESC="Enter to show a custom error message when fields are required."

MOD_JDSCF_TYPE_LBL="Type"
MOD_JDSCF_TYPE_DESC="Select the type of the field."

MOD_JDSCF_WIDTH_LBL="Width"
MOD_JDSCF_WIDTH_DESC="Select a width between 2 - 12, This is based on bootstrap grid system, More info at <a href="https://getbootstrap.com/docs/">https://getbootstrap.com/docs/</a>."

MOD_JDSCF_SUBMIT_WIDTH_LBL="Submit Button Width"
MOD_JDSCF_SUBMIT_WIDTH_DESC="Select a width between 2 - 12, This is based on bootstrap grid system, More info at <a href="https://getbootstrap.com/docs/">https://getbootstrap.com/docs/</a>."

MOD_JDSCF_PLACEHOLDER_LBL="Placeholder"
MOD_JDSCF_PLACEHOLDER_DESC="Enter to add placeholder on this input."

Expand All @@ -77,10 +83,10 @@ MOD_JDSCF_TYPE_CALENDAR_LBL="Calendar"
MOD_JDSCF_TYPE_LIST_LBL="List"

MOD_JDSCF_OPTIONS_LBL="Options"
MOD_JDSCF_OPTIONS_DESC="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin ac ligula ipsum."
MOD_JDSCF_OPTIONS_DESC="Enter return seperated values."

MOD_JDSCF_CSS_LBL="Load CSS"
MOD_JDSCF_CSS_DESC="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin ac ligula ipsum."
MOD_JDSCF_CSS_DESC=""


MOD_JDSCF_REQUIRED_ERROR="%s is required."
Expand Down Expand Up @@ -114,6 +120,9 @@ MOD_JDSCF_EMAIL_SUBJECT_DESC="Subject of the email (<b>You can use {field:label}
MOD_JDSCF_EMAIL_TO_LBL="Email Address"
MOD_JDSCF_EMAIL_TO_DESC="Enter the email address to recieve submissions. Use comma to seperate multiple emails."

MOD_JDSCF_REPLY_TO_LBL="Reply-to Email"
MOD_JDSCF_REPLY_TO_DESC="Enter the Reply-to email address"

MOD_JDSCF_EMAIL_CC_LBL="CC Email"
MOD_JDSCF_EMAIL_CC_DESC="CC email address to recieve submissions. Use comma to seperate multiple emails."

Expand All @@ -123,10 +132,17 @@ MOD_JDSCF_EMAIL_BCC_DESC="BCC email address to recieve submissions. Use comma to
MOD_JDSCF_EMAIL_TEMPLATE_LBL="Email Template"
MOD_JDSCF_EMAIL_TEMPLATE_DESC="Select the email template, The <b>default</b> template lists all fields in the order they exist in <br><b>{field:label}: {field:value}</b></br> format."

MOD_JDSCF_SEND_COPY="Send Copy of Email"
MOD_JDSCF_SEND_COPY_LBL_TITLE="Send me a copy"
MOD_JDSCF_SEND_COPY_DESCRIPTION="Displays a checkbox for users to send a copy of email to themselves."
; Single Email Fields
MOD_JDSCF_SINGLE_SEND_COPY="Send Copy of Email (Single)"
MOD_JDSCF_SINGLE_SEND_COPY_LBL_TITLE="Send me a copy"
MOD_JDSCF_SINGLE_SEND_COPY_DESCRIPTION="Displays a checkbox on bottom for users to send a copy of email to themselves."
MOD_JDSCF_SINGLE_SEND_COPY_EMAIL_FIELD="Enter Single Email Field Name"
MOD_JDSCF_SINGLE_SEND_COPY_LABEL="Enter Send Copy Label"

; Multiple Email Fields
MOD_JDSCF_SEND_COPY="Send Copy of Email (Multiple)"
MOD_JDSCF_SEND_COPY_LBL_TITLE="Send me a copy"
MOD_JDSCF_SEND_COPY_DESCRIPTION="Displays a checkboxes for users to send a copy of email to themselves under Email Fields."
MOD_JDSCF_SEND_COPY_EMAIL_FIELD="Enter Email Field Name"
MOD_JDSCF_SEND_COPY_LABEL="Enter Send Copy Label"

Expand All @@ -142,7 +158,7 @@ MOD_JDSCF_THANKYOU_MESSAGE_DESC="Enter a Thank you message to be displayed after
MOD_JDSCF_REDIRECT_LBL="Redirect URL"
MOD_JDSCF_REDIRECT_DESC="Enter a URL to redirect users after submission. Leave blank to if not required. (<b>You can use {field:label} & {field:value} to render dynamic values in this field</b>)"

MOD_JDSCF_SUBMITBTN_CLASS_LBL="Submit button class"
MOD_JDSCF_SUBMITBTN_CLASS_LBL="Submit Button Class"
MOD_JDSCF_SUBMITBTN_CLASS_DESC=""

MOD_JDSCF_UNSUPPORTED_FILE_ERROR="Unsupported Filetype"
Expand Down
6 changes: 3 additions & 3 deletions language/en-GB/en-GB.mod_jdsimplecontactform.sys.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ MOD_JDSIMPLECONTACTFORM_XML_DESCRIPTION="JD Simple Contact form provides you wit
Here is what's included:
<ul>
<li>Unlimited number of form fields.</li>
<li>9 different field types.</li>
<li>Ability to make fields required.</li>
<li>10+ different field types.</li>
<li>Ability to make fields required with custom error messages.</li>
<li>Ability to order fields.</li>
<li>Ability to configure thank you message.</li>
<li>Ability to redirect to another page after form submission.</li>
<li>Custom email messages.</li>
<li>Ability to CC, BCC messages.</li>
<li>Ability to CC, BCC, Reply-To messages.</li>
<li>Ajax Submission.</li>
</ul>
"
2 changes: 1 addition & 1 deletion layouts/emails/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
<table role="presentation" border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;" width="100%">
<tr>
<td class="content-block powered-by" style="font-family: sans-serif; vertical-align: top; padding-bottom: 10px; padding-top: 10px; color: #999999; font-size: 12px; text-align: center;" valign="top" align="center">
Powered by <a href="https://www.joomdev.com/products/extensions/jd-simplecontactform" style="color: #999999; font-size: 12px; text-align: center; text-decoration: none;"><?php echo JText::_('MOD_JDSIMPLECONTACTFORM'); ?></a>.
Powered by <a href="https://www.joomdev.com/products/extensions/jd-simple-contact-form" style="color: #999999; font-size: 12px; text-align: center; text-decoration: none;"><?php echo JText::_('MOD_JDSIMPLECONTACTFORM'); ?></a>.
</td>
</tr>
</table>
Expand Down
32 changes: 18 additions & 14 deletions layouts/fields/calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,29 @@
extract($displayData);
$attrs = [];
if (isset($field->placeholder) && !empty($field->placeholder)) {
$attrs[] = 'placeholder="' . $field->placeholder . '"';
$attrs[] = 'placeholder="' . $field->placeholder . '"';
}

if (!empty($field->id)) {
$attrs[] = 'id="' . $field->id . '"';
$attrs[] = 'id="' . $field->id . '"';
}

if ($field->required) {
$attrs[] = 'required';
$attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"';
$attrs[] = 'required';
if (!empty(trim($field->custom_error))) {
$attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"';
} else {
$attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"';
}
}

$document = JFactory::getDocument();
$style = 'label.calendar_icon {'
. 'display: inherit;'
. 'cursor: pointer;'
. 'margin: 0px;'
. 'border-radius: 0;'
. '}';
. 'display: inherit;'
. 'cursor: pointer;'
. 'margin: 0px;'
. 'border-radius: 0;'
. '}';
$document->addStyleDeclaration($style);
?>

Expand All @@ -45,17 +49,17 @@

<?php
$js = 'var jdscf_picker_' . $module->id . ' = new Pikaday({'
. 'field: document.getElementById("' . $field->id . '")';
. 'field: document.getElementById("' . $field->id . '")';
if (isset($field->calendar_min) && !empty($field->calendar_min) && $field->calendar_min != '0000-00-00 00:00:00') {
$js .= ',minDate: moment("' . $field->calendar_min . '").toDate()';
$js .= ',minDate: moment("' . $field->calendar_min . '").toDate()';
}
if (isset($field->calendar_max) && !empty($field->calendar_max) && $field->calendar_max != '0000-00-00 00:00:00') {
$js .= ',maxDate: moment("' . $field->calendar_max . '").toDate()';
$js .= ',maxDate: moment("' . $field->calendar_max . '").toDate()';
}
if (isset($field->calendar_format) && !empty($field->calendar_format)) {
$js .= ',format: "' . $field->calendar_format . '"';
$js .= ',format: "' . $field->calendar_format . '"';
} else {
$js .= ',format: "MM-DD-YYYY"';
$js .= ',format: "MM-DD-YYYY"';
}

$js .= ',defaultDate: moment("' . date('Y-m-d') . '").toDate(),setDefaultDate:true';
Expand Down
9 changes: 7 additions & 2 deletions layouts/fields/checkbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@
extract($displayData);
$options = ModJDSimpleContactFormHelper::getOptions($field->options);
$attrs = [];

if ($field->required) {
$attrs[] = 'required';
$attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"';
$attrs[] = 'required';
if (!empty(trim($field->custom_error))) {
$attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"';
} else {
$attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"';
}
}
?>
<div class="form-check form-check-inline">
Expand Down
6 changes: 5 additions & 1 deletion layouts/fields/checkboxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
$attrs = [];
if ($field->required) {
$attrs[] = 'required';
$attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"';
if (!empty(trim($field->custom_error))) {
$attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"';
} else {
$attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"';
}
}
$optionslayout = isset($field->optionslayout) ? $field->optionslayout : 'vertical';
?>
Expand Down
Loading

0 comments on commit 87291fa

Please sign in to comment.