<?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());
}
+ }
+
}
$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>
<div>
<a href="#" class="submit animated-arrow discreet"><?php echo $this->linkArrow('Submit') ?></a>
</div>
+ <div id="message"></div>
</form>
</div>