Пример #1
0
 public function blogAction()
 {
     $ispost = $this->_getParam('idpost', false);
     $this->view->pageTitle = $this->view->tr(NULL, $this->view->lang, 'Наш Блог');
     if ($ispost) {
         $this->view->token = new Zend_Service_ReCaptcha($this->config->capcha->pub, $this->config->capcha->priv);
         if ($this->_request->isPost()) {
             $filter = new Zend_Filter();
             $filter = $filter->addFilter(new Zend_Filter_StripTags())->addFilter(new Zend_Filter_HtmlEntities());
             $name = $filter->filter($this->_getParam('name', ''));
             $email = $filter->filter($this->_getParam('email', ''));
             $message = $filter->filter($this->_getParam('message', ''));
             $token = $this->_getParam('token', '');
             $data = array('name' => $name, 'email' => $email, 'message' => $message, 'idpage' => $ispost);
             $recaptcha_challenge_field = $this->_getParam('recaptcha_challenge_field', 'default');
             $recaptcha_response_field = $this->_getParam('recaptcha_response_field', 'default');
             $result = $this->view->token->verify($recaptcha_challenge_field, $recaptcha_response_field);
             //var_dump($recaptcha_challenge_field, $recaptcha_response_field);
             if ($result->isValid()) {
                 Model_Comment::updatepage($data);
                 // send mail
                 try {
                     $mail = new Zend_Mail($charset = 'utf-8');
                     $mail->addTo($this->view->config->resources->mail->admin);
                     $mail->setFrom($this->view->config->resources->mail->sender);
                     $text = $this->view->config->resources->mail->template;
                     $text = "Був доданий коментар до сторінки " . $this->view->config->baseurl . $this->getRequest()->getRequestUri() . "\n";
                     $text .= "Дата: " . $this->view->localDate(time(), $this->view->lang) . "\n";
                     $text .= "Имя: {$name} \n";
                     $text .= "Email: {$email} \n";
                     $text .= "Текст: {$message} \n";
                     $mail->setSubject('Коментар на сайті Party Zone');
                     $mail->setBodyText($text);
                     $t = $mail->send();
                 } catch (Zend_Mail_Exception $e) {
                     echo json_encode(array('status' => 'error', 'msg' => $e->getMessages()));
                     // exit;
                 }
                 $this->_redirect($this->getRequest()->getRequestUri());
             }
         }
         $this->view->comments = Model_Comment::getAll($ispost, 'asc');
         $this->view->post = Model_Blogentry::getById($ispost, $this->view->lang);
         if (is_object($this->view->post)) {
             $this->view->pageTitle = $this->view->post->title;
             $this->view->headMeta()->appendName('keywords', $this->view->post->keyword);
             $this->view->headMeta()->appendName('description', $this->view->post->description);
         }
         return $this->renderScript('/index/blogentry.phtml');
     }
     $this->view->blogs = $this->setPaginator(Model_Blogentry::getBlogs($this->view->lang));
     $this->view->blogmenu = Model_Menu::getById(16, $this->view->lang);
 }
Пример #2
0
 public function savemenuAction()
 {
     if ($this->_request->isPost()) {
         $t = Model_Menu::getById($this->_getParam('idmenu'));
         if ($t->blockedit == $this->_getParam('blockedit') && $t->blockedit == 'block') {
             $this->_redirect('/admin/menu/item/' . $this->_getParam('idmenu'));
         }
         //var_dump($_POST);exit;
         $input = $this->menuvalid($_POST);
         if ($input->isValid()) {
             $res = Model_Menu::updatemenu($input);
             if ($res[0] > 0) {
                 // Якщо це створення нового обєкта та збережено з мовою по запиту,
                 // зберігаємо варіант для інших мов
                 //if ($_POST['idmenu'] == 'new') {
                 $ll = $input->lang;
                 foreach ($this->view->langs as $key) {
                     $t = Model_Menu::getById($this->_getParam('idmenu'), $key);
                     if (!is_null($t->idmenu)) {
                         continue;
                     }
                     if ($key !== $ll) {
                         $data = $_POST;
                         $data['idmenu'] = $res[1];
                         $data['lang'] = $key;
                         $input = $this->menuvalid($data);
                         Model_Menu::updatemenu($input);
                     }
                 }
                 //}
                 // Якщо ні просто переходимо до редактування обєкту
                 $this->_redirect('/admin/menu/item/' . $res[1] . '/lang/' . $_POST['lang']);
             } else {
                 if (count($res[1]) > 1) {
                     echo "Ошибка! " . $res[1];
                     exit;
                 } else {
                     echo "Редагування цього запису заблоковано.";
                     exit;
                 }
             }
         }
         $t = $input->getMessages();
         if (count($t) > 0) {
             echo "Ошибка! " . var_dump($t);
             exit;
         } else {
             echo "Редагування цього запису заблоковано2.";
             exit;
         }
     }
 }