main.php 13 KB
<?php
    use artbox\core\components\SeoComponent;
    use frontend\components\UrlManager;
    
    $params = array_merge(
        require( __DIR__ . '/../../common/config/params.php' ),
        require( __DIR__ . '/../../common/config/params-local.php' ),
        require( __DIR__ . '/params.php' ),
        require( __DIR__ . '/params-local.php' )
    );
    
    return [
        'id'                  => 'app-frontend',
        'homeUrl'             => '/',
        'basePath'            => dirname(__DIR__),
        'bootstrap'           => [ 'log' ],
        'controllerNamespace' => 'frontend\controllers',
        'container' => [
            'singletons' => [
                'artbox\core\services\Languages' =>'artbox\core\services\Languages',
            ]
        ],
        'modules'             => [
            'feedback' => [
                'class'      => 'artbox\core\forms\Module',
                'activeRecord' => "artbox\core\models\Feedback",
                'attributes' => [
                    'name',
                    'phone',
                    'message',
                ],
                'rules'      => [
                    [
                        [
                            'name',
                            'phone',
                        ],
                        'required',
                    ]
                ],
                'labels'     => [
                    'name'    => 'Name',
                    'message' => 'Message',
                    'phone'   => 'Phone'
                ],
    
                'inputOptions'    => [
                    'name'   => [
                      'template' => '<div class="input-wr">{input}</div>'
                    ],
                    'phone'   => [
                        'template' => '<div class="input-wr phones_mask">{input}</div>'
                    ],
                    'message' => [
                        'type'    => 'textarea',
                        'options' => [],
                        'template' => '<div class="input-wr">{input}</div>'
                    ],
                ],
                'buttonTemplate'  => '<div class="button-wr">{button}</div>',
                'buttonOptions'   => [],
                'buttonContent'   => 'Send',
                'sendEmail'       => false,
                'ajax'            => true,
                'formId'          => 'feedback-form',
                'scenario'        => 'callback',
                'successCallback' => 'function (data) {
                 document.getElementById("feedback-form").reset();
                              $(".close").click();
                              if (data.status == "success"){
                              document.getElementById("feedback-form").reset();
                              $(".success_").animate({opacity: 1, top: \'40\'}, 200).addClass("done_");
                              setTimeout(function(){$(".success_").animate({opacity: 0, top: \'0\'}, 200,function(){
                                  $(this).removeClass("done_");
                              })}, 4000);
                               var data = $("#feedback-form").data(\'yiiActiveForm\');
                              data.validated = false;
                              }
                    }',
                
            ],

            'comments' => [
                'class'      => 'artbox\core\forms\Module',
                'activeRecord' => "common\models\Comment",
                'attributes' => [
                    'name',
                    'email',
                    'comment',
                    'service_id'
                ],
                'rules'      => [
                    [
                        [
                            'name',
                            'email',
                        ],
                        'required',
                    ]
                ],
                'labels'     => [
                    'name'    => 'ФИО',
                    'email' => 'Email',
                    'comment' => 'Ваш отзыв',
                    'service_id' => false
                ],
    
                'inputOptions'    => [
                    'name'   => [
                        'template' => '<div class="input-wr required">{input}</div>'
                    ],
                    'email'   => [
                        'template' => '<div class="input-wr required">{input}</div>'
                    ],
                    'comment' => [
                        'type'    => 'textarea',
                        'options' => [],
                        'template' => '<div class="input-wr">{input}</div>'
                    ],
                ],
                'buttonTemplate'  => '<div class="button-wr submit-close-wr-c-a">{button} <div class="submit-close-c-a"><span>Закрыть окно</span></div></div>',
                'buttonOptions'   => [],
                'buttonContent'   => 'Отправить отзыв',
                'sendEmail'       => false,
                'ajax'            => true,
                'formId'          => 'comment-form',
                'scenario'        => 'default',
                'successCallback' => 'function (data) {
                 document.getElementById("comment-form").reset();
                              var data = $("#comment-form").data(\'yiiActiveForm\');
                              $("#comment-form").find(".submit-close-c-a span").click();
                              $("#comment-form").parent().parent().parent().find(".service-c-a-btns").after("<p>Ваш отзыв появиться после проверки модератором</p>")
                              data.validated = false;
                    }',

            ],
            'questions' => [
                'class'      => 'artbox\core\forms\Module',
                'activeRecord' => "common\models\Question",
                'attributes' => [
                    'name',
                    'email',
                    'question',
                    'service_id'
                ],
                'rules'      => [
                    [
                        [
                            'name',
                            'email',
                        ],
                        'required',
                    ]
                ],
                'labels'     => [
                    'name'    => 'ФИО',
                    'email' => 'Email',
                    'question' => 'Ваш вопрос',
                    'service_id' => false
                ],
    
                'inputOptions'    => [
                    'name'   => [
                        'template' => '<div class="input-wr required">{input}</div>'
                    ],
                    'email'   => [
                        'template' => '<div class="input-wr required">{input}</div>'
                    ],
                    'question' => [
                        'type'    => 'textarea',
                        'options' => [],
                        'template' => '<div class="input-wr">{input}</div>'
                    ],
                ],
                'buttonTemplate'  => '<div class="button-wr submit-close-wr-c-a">{button} <div class="submit-close-c-a"><span>Закрыть окно</span></div></div>',
                'buttonOptions'   => [],
                'buttonContent'   => 'Отправить вопрос',
                'sendEmail'       => false,
                'ajax'            => true,
                'formId'          => 'question-form',
                'scenario'        => 'question',
                'successCallback' => 'function (data) {
                 document.getElementById("question-form").reset();
                              var data = $("#question-form").data(\'yiiActiveForm\');
                              $("#question-form").find(".submit-close-c-a span").click();
                              $("#question-form").parent().parent().parent().find(".service-c-a-btns").after("<p>Спасибо за Вваш вопрос. Мы обязательно на него ответим</p>")
                              data.validated = false;
                    }',

            ],

            'visit' => [
                'class'      => 'artbox\core\forms\Module',
                'activeRecord' => "common\models\Visit",
                'attributes' => [
                    'name',
                    'phone',
                    'email',
                    'message',
                    
                    'entity',
                    'entity_id'
                ],
                'rules'      => [
                    [
                        [
                            'phone',
                        ],
                        'required',
                    ]
                ],
                'labels'     => [
                    'name'    => 'ФИО',
                    'email' => 'Email',
                    'phone' => 'Телефон',
                    'message' => 'Сообщение',
                    'entity_id' => false,
                    'entity' => false
                ],
    
                'inputOptions'    => [
                    'entity' => [
                       'type' => 'hiddenInput'
                    ],
                    'entity_id' => [
                        'type' => 'hiddenInput'
                    ],
                    'name'   => [
                        'template' => '<div class="input-wr">{input}</div>'
                    ],
                    'email'   => [
                        'template' => '<div class="input-wr">{input}</div>'
                    ],
                    'phone'   => [
                        'template' => '<div class="input-wr required phones_mask">{input}</div>',
                        'options' => [
                            'placeholder' => '(0__)___-__-__'
                        ]
                    ],
                    'message' => [
                        'type'    => 'textarea',
                        'options' => ['cols' => 30, 'rows'=> 10],
                        'template' => '<div class="input-wr">{input}</div>'
                    ],
                ],
                'buttonTemplate'  => '<div class="button-wr submit-close-wr-c-a">{button} <div class="submit-close-c-a"><span>Закрыть окно</span></div></div>',
                'buttonOptions'   => [],
                'buttonContent'   => 'Отправить',
                'sendEmail'       => false,
                'ajax'            => true,
                'formId'          => 'visit-form',
                'scenario'        => 'default',
                'successCallback' => 'function (data) {
                 document.getElementById("visit-form").reset();
                              var data = $("#visit-form").data(\'yiiActiveForm\');
                              data.validated = false;
                              success();
                    }',

            ],
        ],
        'components'          => [
            'assetManager'       => [
                'bundles'         => [
                    'yii\bootstrap\BootstrapAsset' => [
                        'basePath' => '@webroot',
                        'baseUrl'  => '@web',
                        'css'       => [],
                    ],
                    'frontend\assets\ArtboxModalAsset' => [
                        'basePath' => '@webroot',
                        'baseUrl'  => '@web',
                        'css'       => [],
                    ],
                ],
                'appendTimestamp' => true,
            ],
            'request'      => [
                'csrfParam' => '_csrf-frontend',
                'baseUrl'   => '',
            ],
            'user'         => [
                'identityClass'   => 'common\models\User',
                'enableAutoLogin' => true,
                'identityCookie'  => [
                    'name'     => '_identity-frontend',
                    'httpOnly' => true,
                ],
            ],
            'session'      => [
                // this is the name of the session cookie used for login on the frontend
                'name' => 'advanced-frontend',
            ],
            'log'          => [
                'traceLevel' => YII_DEBUG ? 3 : 0,
                'targets'    => [
                    [
                        'class'  => 'yii\log\FileTarget',
                        'levels' => [
                            'error',
                            'warning',
                        ],
                    ],
                ],
            ],
            'seo'                => [
                'class' => SeoComponent::className(),
            ],
            'errorHandler' => [
                'errorAction' => 'site/error',
            ],
            'urlManager'   => [
                'class'           => UrlManager::className(),
                'baseUrl'         => '/',
                'enablePrettyUrl' => true,
                'showScriptName'  => false,
                'rules'           => [],
                'hideDefaultLanguagePrefix' => true,
            ],
        ],
        
        'params'              => $params,
    ];