]> _ Git - bloomsburie.git/commitdiff
wait #7261 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 17 Jan 2025 13:31:24 +0000 (14:31 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 17 Jan 2025 13:31:24 +0000 (14:31 +0100)
framework/application/Bootstrap.php
framework/application/configs/application.ini
framework/application/controllers/AjaxController.php
framework/application/forms/CMS/Contact.php
framework/application/views/scripts/templates/contact.phtml
less/contact.less

index ea088f51be53f075904ac39c5142937a41fdaf74..8fb58dc38df1cbd94519ccd930721d2df838421d 100644 (file)
@@ -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
index 71645b0da3351d19f5f7d579f39ae05432f28aba..0ba315c361a75e5f569df1a82b703068019af497 100644 (file)
@@ -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
index e2183c532633e1c11ca9925d463bf0baada2136f..0dca2cf1da854c0493b049cbe69bd4a735505f6f 100644 (file)
@@ -1,51 +1,91 @@
 <?php
 
-class AjaxController extends CubeIT_Controller_AjaxController {
+class AjaxController extends CubeIT_Controller_AjaxController
+{
 
-        public function displayCaseStudies() {
-                $studies = $_GET['studies'];
-        }
+    public function displayCaseStudies()
+    {
+        $studies = $_GET['studies'];
+    }
 
-        public function displayRealisation() {
-                $rea_id = $_GET['realisation_id'];
+    public function displayRealisation()
+    {
+        $rea_id = $_GET['realisation_id'];
 
-                $db = $this->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', '<div id="success">' . $page['form_success'] . '</div>');
+        } catch (Exception $e) {
+            $this->_datas->addContent('message', $e->getMessage());
         }
 
+    }
+
 }
index 958753808f963db15cb7668456e4df40e7449f2b..9c6c20e82993a22de8d6ff648e4cfc2019a8bb6a 100644 (file)
@@ -1,5 +1,16 @@
 <?php
 
-class Cubedesigners_Form_CMS_Contact extends Cubedesigners_Form_CMS_Twocolumns {
+class Cubedesigners_Form_CMS_Contact extends Cubedesigners_Form_CMS_Twocolumns
+{
+    public function init()
+    {
+        parent::init();
+        $recipient=new CubeIT_Form_Element_Text('form_recipient');
+        $recipient->setLabel('Form Recipients');
+        $this->addElement($recipient);
 
+        $success=new CubeIT_Form_Element_Text('form_success');
+        $success->setLabel('Form Success message');
+        $this->addElement($success);
+    }
 }
index 93c99c48bece4ed84ef9474a1791269f8675d5a3..328258b70605fbe77b7cb0686d88f641e6370da9 100644 (file)
@@ -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++;
 }
 ?>
 
 <div class="title content"><?php echo $this->markupDotclear($this->titre); ?></div>
 
-<div class="content" id="form" class="ajax">
-    <form action="" method="post" class="ajax">
+<div class="content" id="form">
+    <form method="post" action="/ajax/contact" class="ajax">
         <div class="line3">
-            <div><input type="text" name="name" placeholder="Your name" /></div>
-            <div><input type="email" name="email" placeholder="Your email" /></div>
-            <div><input type="text" name="company" placeholder="Your company" /></div>
+            <div><input type="text" name="name" placeholder="Your name"/></div>
+            <div><input type="email" name="email" placeholder="Your email"/></div>
+            <div><input type="text" name="company" placeholder="Your company"/></div>
         </div>
         <div>
-            <input type="text" name="subject" placeholder="Subject" />
+            <input type="text" name="subject" placeholder="Subject"/>
         </div>
         <div>
             <textarea name="message" rows="5" placeholder="Message"></textarea>
@@ -30,6 +30,7 @@ foreach ($bureaux as $bureau) {
         <div>
             <a href="#" class="submit animated-arrow discreet"><?php echo $this->linkArrow('Submit') ?></a>
         </div>
+        <div id="message"></div>
     </form>
 </div>
 
index f251bafa65ec768518078e08f0572c072609dc28..34e5ff1a8d93ebbfcd40cbf55210c18c21767409 100644 (file)
 
 #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;
     font-weight: 300;
   }
 
-  .submit{
+  .submit {
     margin-top: 30px;
   }
 
         width: 100%;
         padding-right: 0;
         margin-bottom: 15px;
-        &:last-child{
+        &:last-child {
           padding-right: 0;
           margin-bottom: 0;
           width: 100%;
 
     }
   }
+}
+
+#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