Browse Source

Project information

master
Egorka 6 years ago
parent
commit
17838b1f23
  1. 38
      common/modules/forms/controllers/FormController.php
  2. 15
      composer.json

38
common/modules/forms/controllers/FormController.php

@ -6,7 +6,6 @@
namespace common\modules\forms\controllers;
use common\modules\forms\entities\Form;
use common\modules\forms\services\FormMessageManageService;
use frontend\components\FrontendController;
@ -22,8 +21,14 @@ class FormController extends FrontendController
public $mailer;
public $message_service;
public function __construct( string $id, $module, MailerInterface $mailer, FormMessageManageService $message_service, array $config = [] ) {
parent::__construct( $id, $module, $config );
public function __construct(
string $id,
$module,
MailerInterface $mailer,
FormMessageManageService $message_service,
array $config = []
) {
parent::__construct($id, $module, $config);
$this->mailer = $mailer;
$this->message_service = $message_service;
}
@ -45,9 +50,11 @@ class FormController extends FrontendController
if ($form->complete_page_id) {
return $this->redirect(['/pages/page/view', 'id' => $form->complete_page_id]);
}
//return $form->complete_text;
return $this->render('view', ['text' => $form->complete_text]);
}
return $this->redirect(Yii::$app->request->referrer);
}
@ -57,9 +64,9 @@ class FormController extends FrontendController
// save message
$this->message_service->create($form->id, Json::encode($messageItems, JSON_UNESCAPED_UNICODE));
//prepare e-mail message
$to = isset($form->return) && $form->return ? explode(',',$form->return) : [Yii::$app->params['adminEmail']];
$from = isset($form->from) && $form->from ? explode(',',$form->from) : [Yii::$app->params['adminEmail']];
$reply = isset($form->reply) && $form->reply ? explode(',',$form->reply) : $from;
$to = isset($form->return) && $form->return ? explode(',', $form->return) : [Yii::$app->params['adminEmail']];
$from = isset($form->from) && $form->from ? explode(',', $form->from) : [Yii::$app->params['adminEmail']];
$reply = isset($form->reply) && $form->reply ? explode(',', $form->reply) : $from;
$sent = $this->mailer->compose(
['html' => '@common/modules/forms/mail/form-html', 'text' => '@common/modules/forms/mail/form-text'],
@ -80,16 +87,25 @@ class FormController extends FrontendController
$items = [];
$json = Json::decode($json_string, true);
foreach ($json as $item) {
if ($item['type'] == 'button') {continue;}
if ($item['type'] == 'paragraph') {continue;}
if ($item['type'] == 'header') {continue;}
if ($item['type'] == 'button') {
continue;
}
if ($item['type'] == 'paragraph') {
continue;
}
if ($item['type'] == 'header') {
continue;
}
$item['name'] = str_replace( '-', '_', $item['name'] );
$item['name'] = str_replace('-', '_', $item['name']);
$items[] = [
'key' => isset($item['label']) ? $item['label'] : '',
'value' => is_array($dynaForm->{$item['name']}) ? implode(', ', array_map(function($el){return Html::encode($el);}, $dynaForm->{$item['name']})) : Html::encode($dynaForm->{$item['name']}),
'value' => is_array($dynaForm->{$item['name']}) ? implode(', ', array_map(function ($el) {
return Html::encode($el);
}, $dynaForm->{$item['name']})) : Html::encode($dynaForm->{$item['name']}),
];
}
return $items;
}

15
composer.json

@ -1,16 +1,13 @@
{
"name": "yiisoft/yii2-app-advanced",
"description": "Yii 2 Advanced Project Template",
"keywords": ["yii2", "framework", "advanced", "project template"],
"homepage": "http://www.yiiframework.com/",
"name": "zertex/zxcms",
"description": "Zertex CMS",
"keywords": ["Zertex", "CMS", "yii2", "framework", "advanced"],
"homepage": "https://cms.zertex.ru/",
"type": "project",
"license": "BSD-3-Clause",
"support": {
"issues": "https://github.com/yiisoft/yii2/issues?state=open",
"forum": "http://www.yiiframework.com/forum/",
"wiki": "http://www.yiiframework.com/wiki/",
"irc": "irc://irc.freenode.net/yii",
"source": "https://github.com/yiisoft/yii2"
"issues": "https://gitlab.com/zertex/zxcms/issues",
"source": "https://gitlab.com/zertex/zxcms"
},
"minimum-stability": "stable",
"require": {

Loading…
Cancel
Save