public function commentEditAction() { SxCms_Acl::requireAcl('news', 'news.comments.edit'); $mapper = new SxCms_Comment_DataMapper(); $comment = $mapper->getById($this->_getParam('id')); if ($this->getRequest()->isPost()) { $author = $comment->getCommenter(); $author->setName($this->_getParam('name'))->setEmail($this->_getParam('email'))->setWebsite($this->_getParam('website')); $comment->setMessage($this->_getParam('message'))->setApproved($this->_getParam('approved')); if ($comment->isApproved() && !$comment->getDateApproved()) { $comment->setDateApproved(date('Y-m-d H:i:s')); } $validator = new SxCms_Comment_UpdateValidator(); if ($validator->validate($comment)) { $mapper->save($comment); $flashMessenger = $this->_helper->getHelper('FlashMessenger'); $flashMessenger->addMessage($this->admin_tmx->_('messageeditedsuccess')); $this->_helper->redirector->gotoSimple('comments', 'page'); } } $this->view->messages = Sanmax_MessageStack::getInstance('SxCms_Comments'); $this->view->comment = $comment; }
public function contentAction() { $this->view->messages = $this->_helper->flashMessenger->getMessages(); $url = $this->_getParam('url'); $proxy = new SxCms_Page_Proxy(); $page = $proxy->getPageByUrl($url, null, $this->_getParam('lng', 'nl')); if ($page->getId() === false) { throw new Zend_Controller_Action_Exception('Page not found', 404); } $identity = Zend_Auth::getInstance()->getIdentity(); if (!$page->isAllowed($identity)) { $this->_forward('unauthorized', 'index', null, array('url' => $this->view->url())); return; } if ($page->isExpired()) { throw new Zend_Controller_Action_Exception('Page expired', 404); } if ($page->getInvisible()) { throw new Zend_Controller_Action_Exception('Page expired', 404); } /** Gebruik Nederlandse vertaling indien nodig * */ if ($page->hasContentFallback()) { $pageFallback = $proxy->getPageById($page->getId(), 'nl'); $page->setContent($pageFallback->getContent()); } $this->view->page = $page; $this->_helper->layout->setLayout($page->getLayout()); if ($page->getType() == SxCms_Page::SUMMARY) { $children = $proxy->getPagesByParentId($page->getId(), null, $this->_getParam('lng', 'nl'), true, true); $childrenArr = array(); foreach ($children as $child) { $pageFallback = false; if ($child->hasSummaryFallback()) { $pageFallback = $proxy->getPageById($child->getId(), 'nl'); $child->setSummary($pageFallback->getSummary()); } array_push($childrenArr, $child); } $this->view->children = $childrenArr; $this->renderScript('index/summary.phtml'); return; } if ($page->getType() == SxCms_Page::ARTICLE) { $this->view->comment = new SxCms_Comment(); $captchaSession = new Zend_Session_Namespace('captcha'); $captchaSession->setExpirationHops(3); if ($captchaSession->token) { $captcha = $captchaSession->token; } else { $captcha = new Zend_Captcha_Image(); $captcha->setName('captcha')->setWordLen(6)->setDotNoiseLevel(20)->setLineNoiseLevel(0)->setFont(APPLICATION_PATH . '/var/fonts/BRLNSR.TTF')->setImgDir(APPLICATION_ROOT . '/public_html/images/captcha'); $captcha->generate(); $captchaSession->token = $captcha; } $this->view->captcha = $captcha; } if ($page->getPageform()) { if ($this->getRequest()->isGet()) { $this->view->captchaId = $this->generateCaptcha(); } $pageformproxy = new SxModule_Pageform_Proxy(); $subscription = new SxModule_Pageform_Subscription(); $pageform = $pageformproxy->getActiveById($page->getPageform(), $_SESSION['System']['lng']); $this->view->pageform = $pageform; if ($this->getRequest()->isPost() && $this->_getParam('comment-submit')) { $this->view->errors = array(); $validator = new SxCms_Comment_BaseValidator(); $validator->setCaptcha($captcha)->setUserCaptcha($this->_getParam('captcha')); $comment = new SxCms_Comment(); $comment->setMessage($this->_getParam('message')); $author = new SxCms_Comment_Author(); $author->setName($this->_getParam('name'))->setEmail($this->_getParam('email'))->setWebsite($this->_getParam('website')); $comment->setPage($page); $comment->setCommenter($author); if (!$validator->validate($comment)) { $this->view->errors = $validator->getErrors(); $this->view->comment = $comment; $this->view->userCaptcha = $this->_getParam('captcha'); } else { $mapper = new SxCms_Comment_DataMapper(); $mapper->save($comment); $captchaSession->unsetAll(); $this->_helper->flashMessenger->addMessage('Uw bericht werd succcesvol verwerk. Na goedkeuring door een administrator zal dit op de website verschijnen.'); $this->_helper->redirector->gotoRoute(array('url' => $page->getLink()), 'content'); } } if ($this->getRequest()->isPost() && $this->_getParam('pageform-submit')) { $data = $this->_getParam('pageform'); $subscription->setPageformId($pageform->getId())->setPageformname($pageform->getName())->setIp($this->getRequest()->getServer('REMOTE_ADDR'))->setAgent($this->getRequest()->getServer('HTTP_USER_AGENT'))->setLng($this->_getParam('lng'))->setUrl('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); foreach ($pageform->getField() as $field) { if (isset($data[$field->getKey()])) { # Tijd instellen if ($field->getFieldType() == 'text' && $field->getValidation() == 'time' && is_array($data[$field->getKey()])) { $data[$field->getKey()] = $data[$field->getKey()]['hh'] . ':' . $data[$field->getKey()]['mm']; } # Tijd & datum instellen if ($field->getFieldType() == 'text' && $field->getValidation() == 'datetime' && is_array($data[$field->getKey()])) { $data[$field->getKey()] = $data[$field->getKey()]['date'] . ' ' . $data[$field->getKey()]['hh'] . ':' . $data[$field->getKey()]['mm']; } } $metaObject = new SxModule_Pageform_Subscription_Meta(); $metaObject->setFieldId($field->getId())->setLabel($field->getTsl()->getName())->setName($field->getKey())->setValue(isset($data[$field->getKey()]) ? $data[$field->getKey()] : null); $subscription->addMeta($metaObject); } $fielderrors = APPLICATION_ROOT . '/application/var/locale/fielderrors.tmx'; $validator = new SxModule_Pageform_Subscription_Validator(); $validator->setTmx(new Zend_Translate('tmx', $fielderrors, $_SESSION['System']['lng'])); //$validator->setTmx( new Zend_Translate('tmx', APPLICATION_ROOT . '/application/var/locale/pageform.tmx', $_SESSION['System']['lng']) ); $captchaOk = true; if ($pageform->getCaptcha()) { $captchaOk = false; $captcha = $this->_getParam('captcha'); if ($this->validateCaptcha($captcha)) { $captchaOk = true; } } $this->view->captchaId = $this->generateCaptcha(); if ($captchaOk) { if ($validator->validate($subscription, $pageform)) { $subscription->save(); if ($pageform->getMailoption() == 1) { $mail = new Zend_Mail('utf-8'); $mail->setSubject('Formulier verzonden op website: ' . $pageform->getName())->setFrom(Zend_Registry::get('config')->company->email, "formulier: " . $pageform->getName()); $body = 'Datum : ' . date('Y-m-d H:i:s') . "\n"; foreach ($subscription->getMeta() as $meta) { $body .= " " . $meta->getLabel() . ": " . $meta->getValue() . "\n"; } $mail->setBodyText($body); $mail->addTo($pageform->getMailto()); $mail->send(); } if ($pageform->getTsl()->getConfirm() == 1) { foreach ($subscription->getMeta() as $meta) { if ($meta->getLabel() == $pageform->getTsl()->getConfirmto()) { $sendto = $meta->getValue(); } } $mail = new Zend_Mail('utf-8'); $mail->setSubject($pageform->getTsl()->getConfirmsubject())->setFrom(Zend_Registry::get('config')->company->email, Zend_Registry::get('config')->company->name); $mail->setBodyHtml($pageform->getTsl()->getConfirmcontent()); $mail->addTo($sendto); $mail->send(); } $subscription = new SxModule_Pageform_Subscription(); $this->view->message = "Formulier verzonden!"; } else { $this->view->error = "Er ging iets mis..."; //var_dump($subscription->getMeta()); //exit; } } else { $this->view->error = "Neem de captcha code correct over..."; } } $this->view->subscription = $subscription; } $this->view->mode = $this->_getParam('mode') ? $this->_getParam('mode') : ''; $this->view->messages = Sanmax_MessageStack::getInstance('SxModule_Pageform_Subscription'); }