From: Vincent Vanwaelscappel Date: Fri, 17 Jan 2025 13:31:24 +0000 (+0100) Subject: wait #7261 @2 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=bf536222ec8a100b66dd83a7773b6cb26ac0b05f;p=bloomsburie.git wait #7261 @2 --- diff --git a/framework/application/Bootstrap.php b/framework/application/Bootstrap.php index ea088f5..8fb58dc 100644 --- a/framework/application/Bootstrap.php +++ b/framework/application/Bootstrap.php @@ -248,6 +248,11 @@ class Bootstrap extends CubeIT_Bootstrap return false; } + protected function __initDefaultMailTransport() + { + return new Zend_Mail_Transport_Smtp($this->getOpt('mail.host'), ['port' => $this->getOpt('mail.port'), 'auth' => 'login', 'ssl' => 'tls', 'username' => $this->getOpt('mail.username'), 'password' => $this->getOpt('mail.password')]); + } + public function run() { // run have to be the last call of bootstrap diff --git a/framework/application/configs/application.ini b/framework/application/configs/application.ini index 71645b0..0ba315c 100644 --- a/framework/application/configs/application.ini +++ b/framework/application/configs/application.ini @@ -52,6 +52,13 @@ privacy.analytics = 1 [testing : production] dev = false +mail.from = external@cubedesigners.com +mail.host=mail2.cubedesigners.com +mail.port=587 +mail.username=external@cubedesigners.com +mail.password=z6hfYZJEfFZp48pza3 +mail.encryption=tls + database.params.host = bloomsburie-mariadb database.params.password = 0b0uezljtKO7RrjR database.params.dbname = bloomsburie diff --git a/framework/application/controllers/AjaxController.php b/framework/application/controllers/AjaxController.php index e2183c5..0dca2cf 100644 --- a/framework/application/controllers/AjaxController.php +++ b/framework/application/controllers/AjaxController.php @@ -1,51 +1,91 @@ getDb(); - $s = $db->select()->from('realisations') - ->order('id ASC'); - $s->where('id = ?', $rea_id); + $db = $this->getDb(); + $s = $db->select()->from('realisations') + ->order('id ASC'); + $s->where('id = ?', $rea_id); - $q = $s->query(); - $r = $q->fetch(); + $q = $s->query(); + $r = $q->fetch(); - $r = CubeIT_Util_Cms::unserialize($r); + $r = CubeIT_Util_Cms::unserialize($r); - for ($i = 0; $i < count($r->visuel_detail); $i++) { - $image_url = $this->view->imageProcess()->imageProcessGetUrl($r->visuel_detail[$i], '', null, 440); - $r->visuel_detail[$i] = $image_url; - } + for ($i = 0; $i < count($r->visuel_detail); $i++) { + $image_url = $this->view->imageProcess()->imageProcessGetUrl($r->visuel_detail[$i], '', null, 440); + $r->visuel_detail[$i] = $image_url; + } - $db = Zend_Db_Table::getDefaultAdapter(); - $s_tags = $db->select()->from('tags') - ->order('name ASC'); - $q_tags = $s_tags->query(); + $db = Zend_Db_Table::getDefaultAdapter(); + $s_tags = $db->select()->from('tags') + ->order('name ASC'); + $q_tags = $s_tags->query(); - $litteralTags = array(); - while ($r_tags = $q_tags->fetch()) { - if (in_array($r_tags->id, $r->tags_secondaires)) { - array_push($litteralTags, $r_tags->name); - } - } - $r->tags_secondaires = $litteralTags; + $litteralTags = array(); + while ($r_tags = $q_tags->fetch()) { + if (in_array($r_tags->id, $r->tags_secondaires)) { + array_push($litteralTags, $r_tags->name); + } + } + $r->tags_secondaires = $litteralTags; - $r->description = $this->view->markupDotclear($r->description); + $r->description = $this->view->markupDotclear($r->description); - $this->_datas->addVariable("rea", $r); + $this->_datas->addVariable("rea", $r); + } + + public function alertMessageDismiss() + { + $session = Bootstrap::getInstance()->getSession(); + $session->hideAlertMessage = true; + return true; + } + + public function contact() + { + $field = ['name' => 'Name', 'company' => 'Company', 'email' => 'Email', 'subject' => 'Subject', 'message' => 'Message']; + foreach ($field as $f => $label) { + if (!isset($_POST[$f]) || trim($_POST[$f]) == '') { + $this->_datas->addContent('message', __('Please fill all fields.')); + return; + } } - public function alertMessageDismiss() { - $session = Bootstrap::getInstance()->getSession(); - $session->hideAlertMessage = true; - return true; + $this->_datas->addContent('message', ''); + + try { + $page = Bootstrap::getInstance()->getCMSDatasOfPage('contact', 'en'); + $mail = new CubeIT_Mail(); + $mail->setReplyTo(Bootstrap::getInstance()->getOpt('mail.from')); + $mail->setSubject('[Bloomsburie.com contact form] ' . $_POST['subject']); + $mail->setFrom($_POST['email'], $_POST['name']); + foreach (explode(',', $page['form_recipient']) as $recipient) { + if (CubeIT_Text::isEmail($recipient)) { + $mail->addTo(trim($recipient)); + } + } + $message = ''; + foreach ($field as $f => $label) { + $message .= $label . ': ' . str_replace("\n", "\r\n", CubeIT_Text::normalizeLines($_POST[$f])) . "\r\n"; + } + $mail->setBodyText($message); + $mail->send(); + $this->_datas->addReplace('form', '
' . $page['form_success'] . '
'); + } catch (Exception $e) { + $this->_datas->addContent('message', $e->getMessage()); } + } + } diff --git a/framework/application/forms/CMS/Contact.php b/framework/application/forms/CMS/Contact.php index 9587538..9c6c20e 100644 --- a/framework/application/forms/CMS/Contact.php +++ b/framework/application/forms/CMS/Contact.php @@ -1,5 +1,16 @@ setLabel('Form Recipients'); + $this->addElement($recipient); + $success=new CubeIT_Form_Element_Text('form_success'); + $success->setLabel('Form Success message'); + $this->addElement($success); + } } diff --git a/framework/application/views/scripts/templates/contact.phtml b/framework/application/views/scripts/templates/contact.phtml index 93c99c4..328258b 100644 --- a/framework/application/views/scripts/templates/contact.phtml +++ b/framework/application/views/scripts/templates/contact.phtml @@ -5,24 +5,24 @@ $this->headScript()->addScriptAndStyle('contact'); $bureaux = $this->option('contact')['bureaux']; $i = 0; foreach ($bureaux as $bureau) { - $this->headScriptVariables()->setVariable('map' . $i, $bureaux[$i]['map']); - $this->headScriptVariables()->setVariable('coordonnees' . $i, $bureaux[$i]['coordonnees']); - $this->headScriptVariables()->setVariable('markers' . $i, $bureaux[$i]['markers']); - $i++; + $this->headScriptVariables()->setVariable('map' . $i, $bureaux[$i]['map']); + $this->headScriptVariables()->setVariable('coordonnees' . $i, $bureaux[$i]['coordonnees']); + $this->headScriptVariables()->setVariable('markers' . $i, $bureaux[$i]['markers']); + $i++; } ?>
markupDotclear($this->titre); ?>
-
-
+
+
-
-
-
+
+
+
- +
@@ -30,6 +30,7 @@ foreach ($bureaux as $bureau) { +
diff --git a/less/contact.less b/less/contact.less index f251baf..34e5ff1 100644 --- a/less/contact.less +++ b/less/contact.less @@ -93,12 +93,14 @@ #form { margin: 30px 0 80px; + position: relative; form > div { margin: 15px 0; } input, textarea { + font-family: @Klavika; padding: 15px; border: 1px solid @black; color: @black; @@ -106,7 +108,7 @@ font-weight: 300; } - .submit{ + .submit { margin-top: 30px; } @@ -126,7 +128,7 @@ width: 100%; padding-right: 0; margin-bottom: 15px; - &:last-child{ + &:last-child { padding-right: 0; margin-bottom: 0; width: 100%; @@ -139,4 +141,18 @@ } } +} + +#success { + text-align: center; + font-size: 30px; + margin: 167px 0; +} + +#message { + color: #f00; + position: absolute; + bottom: 0; + left: 350px; + margin: 0 !important;; } \ No newline at end of file