Skip to content
Code-Schnipsel Gruppen Projekte
Commit 3c753c16 erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

Merge branch 'dev' of https://dev.quiqqer.com/quiqqer/package-bricks into dev

Übergeordnete d5965bc8 a8274f52
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
......@@ -13,14 +13,14 @@
*/
QUI::$Ajax->registerFunction(
'package_quiqqer_bricks_ajax_contact',
function ($brickId, $project, $siteId, $message, $email, $name) {
function ($brickId, $project, $siteId, $message, $name, $email) {
// check if email correct
if (!QUI\Utils\Security\Orthos::checkMailSyntax($email)) {
throw new QUI\Exception(
QUI::getLocale()->get(
'quiqqer/system',
'exception.contact.wrong.email'
'quiqqer/bricks',
'brick.control.simpleContact.error.wrongEmail'
)
);
}
......@@ -38,7 +38,8 @@ function ($brickId, $project, $siteId, $message, $email, $name) {
$receiver = $Brick->getSetting('mailTo');
}
if ($receiver == '') {
// fallback: admin email
if (!QUI\Utils\Security\Orthos::checkMailSyntax($receiver)) {
$receiver = (QUI::conf('mail', 'admin_mail'));
}
......@@ -60,14 +61,16 @@ function ($brickId, $project, $siteId, $message, $email, $name) {
try {
$Mailer->send();
} catch (\Exception $Exception) {
\QUI\System\Log::writeException($Exception);
throw new QUI\Exception(
$Exception->getMessage(),
$Exception->getCode()
QUI::getLocale()->get('quiqqer/bricks', 'brick.control.simpleContact.error.serverError')
);
}
return true;
},
array('brickId', 'project', 'siteId', 'message', 'email', 'name'),
array('brickId', 'project', 'siteId', 'message', 'name', 'email'),
false
);
......@@ -374,9 +374,6 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
if (unload === 'content' && this.$Editor) {
data.attributes.content = this.$Editor.getContent();
this.$Editor.destroy();
this.$Editor = false;
}
this.setAttribute('data', data);
......
......@@ -54,18 +54,20 @@ define('package/quiqqer/bricks/bin/Controls/SimpleContact', [
var self = this;
this.Loader.inject(this.$Elm);
var Button = this.$Elm.getElement('.quiqqer-simple-contact-button');
Button.set('disabled', false);
Button.set('html', QUILocale.get('quiqqer/bricks', 'control.simpleContact.sendButton'));
Button.addEvents({
click: function () {
self.$Elm.getElement('form').fireEvent('submit');
this.Form = this.$Elm.getElement('form');
var Button = new Element('button', {
'class' : 'quiqqer-simple-contact-button',
'type': 'button',
'html' : QUILocale.get('quiqqer/bricks', 'control.simpleContact.sendButton'),
events: {
click: function () {
self.$Elm.getElement('form').fireEvent('submit');
}
}
});
Button.inject(this.Form);
this.$Elm.getElement('form').addEvent('submit', function (event) {
if (typeof event !== 'undefined') {
......@@ -106,11 +108,10 @@ define('package/quiqqer/bricks/bin/Controls/SimpleContact', [
this.Loader.show();
Ajax.post('package_quiqqer_bricks_ajax_contact', function (result) {
if (result) {
var html = '<span class="fa fa-check fa-check-simple-contact control-color"></span>';
html += QUILocale.get('quiqqer/system', 'message.contact.successful');
self.$Elm.set('html', html);
html += QUILocale.get('quiqqer/bricks', 'brick.control.simpleContact.successful');
self.Form.set('html', html);
}
self.Loader.hide();
......@@ -128,6 +129,7 @@ define('package/quiqqer/bricks/bin/Controls/SimpleContact', [
self.Loader.hide();
QUI.getMessageHandler(function (MH) {
MH.options.displayTimeMessages = 8000;
MH.addError(Exception.getMessage(), self.$Elm);
});
}
......
......@@ -131,11 +131,34 @@
<pl><![CDATA[Wyślij]]></pl>
</locale>
<locale name="brick.control.simpleContact.mailTo">
<de><![CDATA[Ihre E-Mail Adresse]]></de>
<en><![CDATA[Your email]]></en>
<pl><![CDATA[Twój adres e-mail]]></pl>
<de><![CDATA[E-Mail Adresse, wo die Nachricht gesendet wird]]></de>
<en><![CDATA[Email where the message will send to]]></en>
<pl><![CDATA[Adres mailowy, na który zostanie wysłania wiadomość]]></pl>
</locale>
<locale name="brick.control.simpleContact.successful">
<de><![CDATA[Vielen Dank für Ihre E-Mail. Wir werden uns schnellstmöglich bei Ihnen melden.]]></de>
<en><![CDATA[Thank you for your email. We will contact you as soon as possible.]]></en>
<pl><![CDATA[Dziękujemy za wiadomość. Skontaktujemy się tak szybko, jak to możliwe.]]></pl>
</locale>
<locale name="brick.control.simpleContact.error.serverError">
<de><![CDATA[Ihre Nachricht konnte nicht gesendet werden. Bitte versuchen Sie es später noch einmal oder kontaktieren Sie den Support per E-Mail.]]></de>
<en><![CDATA[Your message could not be sent. Please try again later or contact our support by e-mail.]]></en>
<pl><![CDATA[Wiadomość nie mogła zostać wysłana. Spróbuj ponownie później lub skontaktuj się przez e-mail z naszym dzialem pomocy.]]></pl>
</locale>
<locale name="brick.control.simpleContact.error.serverError">
<de><![CDATA[Ihre Nachricht konnte nicht gesendet werden. Bitte versuchen Sie es später noch einmal oder kontaktieren Sie den Support per E-Mail.]]></de>
<en><![CDATA[Your message could not be sent. Please try again later or contact our support by e-mail.]]></en>
<pl><![CDATA[Wiadomość nie mogła zostać wysłana. Spróbuj ponownie później lub skontaktuj się przez e-mail z naszym dzialem pomocy.]]></pl>
</locale>
<locale name="brick.control.simpleContact.error.wrongEmail">
<de><![CDATA[Die eingegebene E-mail Adresse ist nicht korrekt. Bitte geben Sie eine korrekte E-Mail an.]]></de>
<en><![CDATA[The entered e-mail address is not correct. Please enter a correct one.]]></en>
<pl><![CDATA[Wprowadzony adres e-mail nie jest poprawny. Proszę podać prawidłowy adres e-mail.]]></pl>
</locale>
<locale name="brick.control.navigation.title">
<de><![CDATA[Bausteine: Navigation]]></de>
<en><![CDATA[Bricks: Navigation]]></en>
......
......@@ -32,7 +32,6 @@
.quiqqer-simple-contact-message {
border: 1px solid #555;
clear: both;
float: left;
margin: 1em 0;
padding: 0.8em;
position: relative;
......@@ -52,7 +51,6 @@
/* check icon */
.fa-check-simple-contact {
margin: 10% auto;
width: 60px;
......
<form class="quiqqer-simple-contact" method="POST" action="">
{if $this->getAttribute('showTitle') && $this->getAttribute('frontendTitle')}
<header class="control-header">
<h1>{$this->getAttribute('frontendTitle')}</h1>
</header>
{/if}
{if $this->getAttribute('showTitle') && $this->getAttribute('frontendTitle')}
<header class="control-header">
<h1>{$this->getAttribute('frontendTitle')}</h1>
</header>
{/if}
{if $this->getAttribute('content') != ""}
<div class="control-content">
{$this->getAttribute('content')}
</div>
{/if}
{if $this->getAttribute('content') != ""}
<div class="control-content">
{$this->getAttribute('content')}
</div>
{/if}
{if isset( $successMessage )}
<div class="quiqqer-simple-contact-message quiqqer-simple-contact-message-success">
{$successMessage}
</div>
{/if}
{if isset( $errorMessage )}
<div class="quiqqer-simple-contact-message quiqqer-simple-contact-message-error">
{$errorMessage}
</div>
{/if}
<form class="quiqqer-simple-contact" method="POST" action="">
{if $this->getAttribute('labels')}
<label for="qui-contact-name">
......@@ -21,7 +33,7 @@
name="name"
id="qui-contact-name"
required="required"
value=""
value="{$name}"
placeholder="{locale group="quiqqer/bricks" value="control.simpleContact.name.placeholder"}"
/>
......@@ -30,11 +42,11 @@
{locale group="quiqqer/bricks" value="control.simpleContact.email"}
</label>
{/if}
<input type="email"
<input type=""
name="email"
id="qui-contact-email"
required="required"
value=""
value="{$email}"
placeholder="{locale group="quiqqer/bricks" value="control.simpleContact.email.placeholder"}"
/>
......@@ -47,10 +59,11 @@
id="qui-contact-message"
required="required"
placeholder="{locale group="quiqqer/bricks" value="control.simpleContact.message.placeholder"}"
></textarea>
>{$message}</textarea>
<button class="quiqqer-simple-contact-button" type="button" disabled="disabled">
<span class="fa fa-spinner fa-spin"></span>
</button>
<noscript>
<input class="quiqqer-simple-contact-button" type="submit"
value="{locale group='quiqqer/bricks' value='control.simpleContact.sendButton'}" />
</noscript>
</form>
\ No newline at end of file
......@@ -12,7 +12,7 @@
* Mini contact control
* {control control="\QUI\Bricks\Controls\SimpleContact" labels=false}
*
* @author www.pcsg.de (Henning Leutz)
* @author www.pcsg.de (Henning Leutz, Michael Danielczok)
* @licence For copyright and license information, please view the /README.md
*/
class SimpleContact extends QUI\Control
......@@ -24,16 +24,20 @@ class SimpleContact extends QUI\Control
*/
public function __construct($attributes = array())
{
$this->setAttributes(array(
'class' => 'quiqqer-simple-contact',
'qui-class' => 'package/quiqqer/bricks/bin/Controls/SimpleContact',
'labels' => true,
'data-brickid' => true,
'mailTo' => '' // receiver email
));
parent::__construct($attributes);
$this->addCSSFile(
dirname(__FILE__) . '/SimpleContact.css'
);
$this->setAttribute('class', 'quiqqer-simple-contact');
$this->setAttribute('qui-class', "package/quiqqer/bricks/bin/Controls/SimpleContact");
$this->setAttribute('labels', true);
$this->setAttribute('data-brickid', true);
}
/**
......@@ -43,12 +47,116 @@ public function __construct($attributes = array())
*/
public function getBody()
{
$Engine = QUI::getTemplateManager()->getEngine();
$Engine = QUI::getTemplateManager()->getEngine();
$name = '';
$email = '';
$message = '';
// is javascript disabled?
if (isset($_POST['name'])
&& isset($_POST['email'])
&& isset($_POST['message'])
) {
try {
$this->sendMail($Engine);
} catch (\Exception $Exception) {
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$Engine->assign(array(
'errorMessage' => $Exception->getMessage()
));
}
}
$Engine->assign(array(
'this' => $this
'this' => $this,
'name' => $name,
'email' => $email,
'message' => $message
));
return $Engine->fetch(dirname(__FILE__) . '/SimpleContact.html');
}
/**
* Send email per post request if javascript is disabled
*
* @param $Engine
* @throws QUI\Exception
*/
public function sendMail($Engine)
{
$Site = $this->getSite();
// email correct?
if (!QUI\Utils\Security\Orthos::checkMailSyntax($_POST['email'])) {
throw new QUI\Exception(
QUI::getLocale()->get(
'quiqqer/bricks',
'brick.control.simpleContact.error.wrongEmail'
)
);
}
$receiver = $this->getAttribute('mailTo');
$url = $this->getProject()->getHost() . $Site->getUrlRewritten();
// fallback: admin email
if (!QUI\Utils\Security\Orthos::checkMailSyntax($receiver)) {
$receiver = (QUI::conf('mail', 'admin_mail'));
}
$Mailer = QUI::getMailManager()->getMailer();
$Mailer->addRecipient($receiver);
$Mailer->addReplyTo($_POST['email']);
$Mailer->setSubject($Site->getAttribute('title') . ' | ' . $url);
$Mailer->setBody("
<span style=\"font-weight: bold;\">From:</span> {$_POST['name']}<br />
<span style=\"font-weight: bold;\">E-mail:</span> {$_POST['email']}<br />
<span style=\"font-weight: bold;\">Message:</span><br /><br />
<div style=\"white-space: pre-line;\">{$_POST['message']}
</div>
");
try {
$Mailer->send();
$Engine->assign(array(
'successMessage' => QUI::getLocale()->get(
'quiqqer/bricks', 'brick.control.simpleContact.successful'
)
));
} catch (\Exception $Exception) {
QUI\System\Log::writeException($Exception);
throw new QUI\Exception(
QUI::getLocale()->get(
'quiqqer/bricks',
'brick.control.simpleContact.error.serverError'
)
);
}
}
/**
* @return mixed|QUI\Projects\Site
*/
protected function getSite()
{
if ($this->getAttribute('Site')) {
return $this->getAttribute('Site');
}
$Site = \QUI::getRewrite()->getSite();
$this->setAttribute('Site', $Site);
return $Site;
}
}
......@@ -24,6 +24,7 @@ class Events
* Create site brick cache, for inheritance
*
* @param Site|Edit $Site
* @throws QUI\Exception
*/
public static function onSiteSave($Site)
{
......@@ -164,6 +165,7 @@ public static function onSiteSave($Site)
* add new brickarea function
*
* @param \Smarty $Smarty
* @throws \SmartyException
*/
public static function onSmartyInit($Smarty)
{
......@@ -219,7 +221,7 @@ public static function onPackageSetup(QUI\Package\Package $Package)
if ($Package->getName() !== 'quiqqer/bricks') {
return;
}
$php = 'php';
if (defined('PHP_BINARY')) {
......
......@@ -106,6 +106,8 @@ public static function getUIDTable()
* @param Brick $Brick
*
* @return integer - Brick-ID
*
* @throws QUI\Exception
*/
public function createBrickForProject(Project $Project, Brick $Brick)
{
......@@ -133,10 +135,12 @@ public function createBrickForProject(Project $Project, Brick $Brick)
* @param Site $Site
* @param array $brickData
* @return string - Unique ID
*
* @throws QUI\Exception
*/
public function createUniqueSiteBrick(Site $Site, $brickData = array())
{
if (isset($brickData['uid']) || empty($brickData['uid'])) {
if (!empty($brickData['uid'])) {
$uid = $brickData['uid'];
if ($this->existsUniqueBrickId($uid) === false) {
......@@ -172,6 +176,8 @@ public function createUniqueSiteBrick(Site $Site, $brickData = array())
* @param integer $brickId - Brick ID
* @param Site $Site - Current Site
* @return bool
*
* @throws QUI\Exception
*/
protected function createUniqueBrickId($brickId, $Site)
{
......@@ -222,6 +228,7 @@ public function clearCache()
* Delete the brick
*
* @param integer $brickId - Brick-ID
* @throws QUI\Exception
*/
public function deleteBrick($brickId)
{
......@@ -687,8 +694,9 @@ public function getBricksByArea($brickArea, QUI\Interfaces\Projects\Site $Site)
* Return a list with \QUI\Bricks\Brick which are assigned to a project
*
* @param Project $Project
*
* @return array
*
* @throws QUI\Exception
*/
public function getBricksFromProject(Project $Project)
{
......@@ -712,6 +720,7 @@ public function getBricksFromProject(Project $Project)
/**
* @param string|integer $brickId - Brick-ID
* @param array $brickData - Brick data
* @throws QUI\Exception
*/
public function saveBrick($brickId, array $brickData)
{
......
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren