<?php
$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',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'controllerNamespace' => 'frontend\controllers',
    'language' => 'ru-RU',
    'defaultRoute' => 'content/page/view',
    'modules' => [
        'content' => ['class' => 'common\modules\content\Module',],
        'reviews' => ['class' => 'common\modules\reviews\Module',],
        'request' => ['class' => 'common\modules\request\Module',],
	    'faq' => ['class' => 'common\modules\faq\Module'],
        'main' => ['class' => 'common\modules\main\main'],
        'school' => ['class' => 'common\modules\school\Module',],
        'bids' => ['class' => 'common\modules\bids\Module'],
        'testings' => ['class' => 'common\modules\testings\Module',],
        'users' => ['class' => 'common\modules\users\users',],
        'blog' => ['class' => 'common\modules\blog\Module'],
        'support' => ['class' => 'common\modules\support\Module'],
        'sessions' => ['class' => 'common\modules\sessions\Module'],
        'sitemap' => [
            'class' => 'frontend\modules\sitemap\Sitemap',
            'models' => [
                // your models
                'common\modules\content\models\CoContent',
            ],
            'urls'=> [
                // // your additional urls
                // [
                //     'loc' => '/faq',
                //     'changefreq' => \himiklab\sitemap\behaviors\SitemapBehavior::CHANGEFREQ_DAILY,
                //     'priority' => 0.8,
                //     'faq' => [
                //         'publication'   => [
                //             'name'          => 'Вопрос-Ответ',
                //             'language'      => 'ru',
                //         ],
                //     ],
                // ],
            ],
            'enableGzip' => true, // default is false
            'cacheExpire' => 1, // 1 second. Default is 24 hours
        ],
    ],
    'components' => [
        'request' => [
            'class' => 'common\components\LangRequest'
        ],
        'cache' => [
            'class' => 'yii\caching\FileCache',
        ],
        'view' => [
            'class' => '\mirocow\minify\View',
            'base_path' => '@app/web', // path alias to web base
            'minify_path' => '@app/web/minify', // path alias to save minify result
            'minify_css' => true,
            'minify_js' => true,
            'minify_html' => true,
            'js_len_to_minify' => 1000, // Больше этого размера inlinejs будет сжиматься и упаковываться в файл
            'force_charset' => 'UTF-8', // charset forcibly assign, otherwise will use all of the files found charset
            'expand_imports' => true, // whether to change @import on content
            //'css_linebreak_pos' => false,
        ],
        'user' => [
            'identityClass' => 'common\modules\users\models\User',
            'identityCookie' => [
                'name' => '_frontendIdentity'
            ],
            'enableAutoLogin' => true,
            'loginUrl' => ['/site/login'],
        ],
        'support' => [
            'class' => 'yii\web\User',
            'identityClass' => 'common\modules\users\models\User',
            'identityCookie' => [
                'name' => '_supportIdentity',
                'httpOnly' => true
            ],
            'idParam' => '__supportID',
            'enableAutoLogin' => true,
            'loginUrl' => ['/support/login'],
        ],
        'session' => [
            'class' => 'yii\web\Session',
            'timeout' => 3600,
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'i18n' => [
            'translations' => [
                '*' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                    'basePath' => '@frontend/messages',
                    'sourceLanguage' => 'en',
                    'fileMap' => [
                        //'main' => 'main.php',
                    ],
                ],
                'eauth' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                    'basePath' => '@eauth/messages',
                ],
            ],
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        'assetManager'=>[
            'linkAssets' => true,
            'bundles' => [
                'yii\web\YiiAsset' => [
                ],
                'yii\bootstrap\BootstrapPluginAsset' => [
                    'js' => [
                    ],
                ],
                'yii\web\JqueryAsset' => [
                    'sourcePath' => null,
                    'js' => [
                        '/js/libs/jquery/jquery-1.11.2.min.js'
                    ],
                    'jsOptions' => [
                        'position' => \yii\web\View::POS_HEAD,
                        // 'position' => \yii\web\View::POS_BEGIN,
                    ],
                ],
                'yii\jui\JuiAsset' => [
                    'sourcePath' => null,
                    'js' => [
                        'plugins/jquery-ui/ui/minified/jquery-ui.min.js',
                        //'plugins/jquery-ui/ui/minified/jquery.ui.widget.min.js',
                    ],
                    'jsOptions' => [
                        //'position' => \yii\web\View::POS_BEGIN,
                    ],
                    'css' => [],
                ],
                'yii\bootstrap\BootstrapAsset' => [
                    'css' => [],
                ]
            ]
        ],
        'urlManager' => [
            'class' => 'common\components\UrlManager',
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'enableStrictParsing' => true,
            'rules' => [
                'contacts' => 'site/contacts',
                ['pattern' => 'sitemap', 'route' => 'sitemap/default/index', 'suffix' => '.xml'],

                '' => 'content/page/view',
                'reviews' => 'reviews/review/index',
                'faq/view/all' => 'faq/faq/all',
                'faq/<url>' => 'faq/faq/view',
                'faq' => 'faq/faq/index',
                'blog' => 'blog/post/index',
                'blog/tag/<tag>' => 'blog/post/tag',
                'blog/<url>' => 'blog/post/view',
                'testing/<_a>/<id:\d+>' => 'testings/test/<_a>',
                'testing/<_a>' => 'testings/test/<_a>',
                'support/login' => 'support/default/login',
                'support/logout' => 'support/default/logout',
                'support' => 'support/support/index',
                'support/<_a>/<id:\d+>' => 'support/support/<_a>',
                'support/<_a>' => 'support/support/<_a>',
                'school/' => 'school/course/index',
                'school/course/<id>/<source>' => 'school/course/view',
                'school/course/<id>' => 'school/course/view',
                'school/lesson/download-documents/<id>' => 'school/lesson/download-documents',
                'school/lesson/<id>/<source>' => 'school/lesson/view',
                'school/lesson/<id>' => 'school/lesson/view',
                'login/eauth/<service_eauth:google|vk|facebook>' => 'site/login',
                'login' => 'site/login',
                'logout' => 'site/logout',
                'activate/<code>'=>'users/user/activate',
                '<page:(/)>' => 'content/page/view',
                
                '<_m>/<_c>/<_a>/<id:\d+>' => '<_m>/<_c>/<_a>',
                '<_m>/<_c>/<_a>/<page>' => '<_m>/<_c>/<_a>',
                '<_m>/<_c>/<_a>' => '<_m>/<_c>/<_a>',

                '<_c>/<_a>' => '<_c>/<_a>',

                //'module/<module:\w+>/<controller:\w+>/<action:\w+>' => '<module>/<controller>/<action>',
            ]
        ],
        'authManager' => [
            'class' => 'yii\rbac\DbManager',
            /*'connectionID' => 'db',*/
            'itemTable' => 'auth_item',
            'assignmentTable' => 'auth_assignment',
            'itemChildTable' => 'auth_item_child',
            'defaultRoles' => [
                'user',
                'moderator',
                'admin',
                'superadmin'
            ],
        ],
        'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'viewPath' => '@common/mail',
            // send all mails to a file by default. You have to set
            // 'useFileTransport' to false and configure a transport
            // for the mailer to send real emails.
            'useFileTransport' => false,
            /*'transport' => [
                'plugins' => [
                    [
                        'class' => 'Swift_Plugins_ThrottlerPlugin',
                        'constructArgs' => [20],
                    ],
                ],
            ],*/
        ],
        'formatter' => [
            'dateFormat' => 'dd.MM.yyyy',
            'decimalSeparator' => ',',
            'thousandSeparator' => ' ',
            'currencyCode' => 'EUR',
        ],
        'eauth' => [
            'class' => 'nodge\eauth\EAuth',
            'popup' => true, // Use the popup window instead of redirecting.
            'cache' => false, // Cache component name or false to disable cache. Defaults to 'cache' on production environments.
            'cacheExpire' => 0, // Cache lifetime. Defaults to 0 - means unlimited.
            //'httpClient' => [
                // uncomment this to use streams in safe_mode
                //'useStreamsFallback' => true,
            //],
            'services' => [ // You can change the providers and their classes.
                'google' => [
                    // register your app here: https://code.google.com/apis/console/
                    'class' => 'common\modules\eauth\components\GoogleOAuth2Service',
                    'clientId' => '...',
                    'clientSecret' => '...',
                    'title' => 'Google',
                ],
                'vk' => [
                    // register your app here: https://vk.com/editapp?act=create&site=1
                    'class' => 'common\modules\eauth\components\VkOAuth2Service',
                    'clientId' => '...',
                    'clientSecret' => '...',
                ],
                'facebook' => [
                    // register your app here: https://developers.facebook.com/apps/
                    'class' => 'common\modules\eauth\components\FacebookOAuth2Service',
                    'clientId' => '...',
                    'clientSecret' => '...',
                ], 
                /*'twitter' => [
                    // register your app here: https://dev.twitter.com/apps/new
                    'class' => 'common\modules\eauth\components\TwitterOAuth1Service',
                    'key' => '...',
                    'secret' => '...',
                ],*/
            ],
        ],
    ],
    'params' => $params,
];
