From 46e70ee2c43b9c4c1a39ffc674f3e82b58d6adae Mon Sep 17 00:00:00 2001 From: Campii <dominik.chrzanowski183@gmail.com> Date: Wed, 5 Oct 2022 13:00:40 +0200 Subject: [PATCH] feat: Added new setting (formContent) [SimpleContact] quiqqer/package-bricks#132 --- bricks.xml | 3 +++ locale.xml | 5 +++++ src/QUI/Bricks/Controls/SimpleContact.css | 4 ++++ src/QUI/Bricks/Controls/SimpleContact.html | 6 ++++++ src/QUI/Bricks/Controls/SimpleContact.php | 23 ++++++++++++---------- 5 files changed, 31 insertions(+), 10 deletions(-) diff --git a/bricks.xml b/bricks.xml index d6290f1..b081434 100644 --- a/bricks.xml +++ b/bricks.xml @@ -30,6 +30,9 @@ <setting name="useCaptcha" type="checkbox"> <locale group="quiqqer/bricks" var="brick.control.simpleContact.useCaptcha"/> </setting> + <setting name="formContent" data-qui="controls/editors/Input" type="text"> + <locale group="quiqqer/bricks" var="brick.control.simpleContact.formContent"/> + </setting> </settings> </brick> diff --git a/locale.xml b/locale.xml index 505d707..c8e172c 100644 --- a/locale.xml +++ b/locale.xml @@ -187,6 +187,11 @@ <en> <![CDATA[Protect form submit from spam with a CAPTCHA (requires <b>quiqqer/captcha</b> to be installed!)]]></en> </locale> + <locale name="brick.control.simpleContact.formContent"> + <de><![CDATA[Inhalt des Formulars]]></de> + <en><![CDATA[Form content]]></en> + <pl><![CDATA[Zawartość formularza]]></pl> + </locale> <locale name="brick.control.simpleContact.mail.privacyPolicy_accepted"> <de><![CDATA[Der Benutzer hat die Datenschutzbestimmungen akzeptiert.]]></de> <en><![CDATA[The user has accepted the Privacy Policy.]]></en> diff --git a/src/QUI/Bricks/Controls/SimpleContact.css b/src/QUI/Bricks/Controls/SimpleContact.css index 718d448..1ae1e66 100644 --- a/src/QUI/Bricks/Controls/SimpleContact.css +++ b/src/QUI/Bricks/Controls/SimpleContact.css @@ -25,6 +25,10 @@ margin-bottom: 10px; } +.qui-contact-formContent { + margin-bottom: 2rem; +} + /* Message & Message color ================================================================= */ diff --git a/src/QUI/Bricks/Controls/SimpleContact.html b/src/QUI/Bricks/Controls/SimpleContact.html index e876382..3361193 100644 --- a/src/QUI/Bricks/Controls/SimpleContact.html +++ b/src/QUI/Bricks/Controls/SimpleContact.html @@ -31,6 +31,12 @@ </style> </noscript> + {if $formContent} + <div class="qui-contact-formContent default-content"> + {$formContent} + </div> + {/if} + {if $this->getAttribute('labels')} <label for="qui-contact-name"> {locale group="quiqqer/bricks" value="control.simpleContact.name"} diff --git a/src/QUI/Bricks/Controls/SimpleContact.php b/src/QUI/Bricks/Controls/SimpleContact.php index 33f75b5..3d91b5a 100644 --- a/src/QUI/Bricks/Controls/SimpleContact.php +++ b/src/QUI/Bricks/Controls/SimpleContact.php @@ -32,7 +32,8 @@ public function __construct($attributes = []) 'data-brickid' => false, 'mailTo' => '', // receiver email 'showPrivacyPolicyCheckbox' => false, - 'useCaptcha' => false + 'useCaptcha' => false, + 'formContent' => '' ]); parent::__construct($attributes); @@ -51,7 +52,7 @@ public function __construct($attributes = []) } $this->addCSSFile( - dirname(__FILE__).'/SimpleContact.css' + dirname(__FILE__) . '/SimpleContact.css' ); } @@ -69,6 +70,7 @@ public function getBody() $message = ''; $privacyPolicyCheckbox = $this->getAttribute('showPrivacyPolicyCheckbox'); $useCaptcha = $this->getAttribute('useCaptcha'); + $formContent = $this->getAttribute('formContent'); $error = false; // Is javascript disabled? @@ -127,7 +129,7 @@ public function getBody() $label = preg_replace( '#\[([^\]]*)\]#i', - '<a href="'.$url.'" target="_blank">$1</a>', + '<a href="' . $url . '" target="_blank">$1</a>', $label ); @@ -160,13 +162,14 @@ public function getBody() } $Engine->assign([ - 'this' => $this, - 'name' => $name, - 'email' => $email, - 'message' => $message + 'this' => $this, + 'name' => $name, + 'email' => $email, + 'message' => $message, + 'formContent' => $formContent ]); - return $Engine->fetch(dirname(__FILE__).'/SimpleContact.html'); + return $Engine->fetch(dirname(__FILE__) . '/SimpleContact.html'); } /** @@ -193,7 +196,7 @@ public function sendMail($Engine) } $receiver = $this->getAttribute('mailTo'); - $url = $this->getProject()->getHost().$Site->getUrlRewritten(); + $url = $this->getProject()->getHost() . $Site->getUrlRewritten(); // fallback: admin email if (!QUI\Utils\Security\Orthos::checkMailSyntax($receiver)) { @@ -204,7 +207,7 @@ public function sendMail($Engine) $Mailer->addRecipient($receiver); $Mailer->addReplyTo($_POST['email']); - $Mailer->setSubject($Site->getAttribute('title').' | '.$url); + $Mailer->setSubject($Site->getAttribute('title') . ' | ' . $url); $body = " <span style=\"font-weight: bold;\">From:</span> {$_POST['name']}<br /> -- GitLab