OSDN Git Service

157d2ea3bbf10eba501c3a82fbdd37513eea14d2
[invent/invent.git] / config / web.php
1 <?php
2
3 use yii\helpers\Html;
4 use kartik\mpdf\Pdf;
5 //use yii\rbac\Role;
6
7 $params = require __DIR__ . '/params.php';
8 $db = require __DIR__ . '/db.php';
9
10 require_once __DIR__ . '/myfunctions.php';
11
12 $config = [
13     'version' => '1.31',
14     'name' => 'Inventory',
15     'id' => 'basic',
16     'basePath' => dirname(__DIR__),
17     'language' => 'ru-RU',
18     'bootstrap' => ['log'],
19     'aliases' => [
20         '@bower' => '@vendor/bower-asset',
21         '@npm'   => '@vendor/npm-asset',
22     ],
23     'container' => [
24         'definitions' => [
25             'yii\widgets\LinkPager' => [
26                 'firstPageLabel' => Html::tag('span', '', [ 'class' => 'glyphicon glyphicon-fast-backward', ]),
27                 'prevPageLabel' => Html::tag('span', '', [ 'class' => 'glyphicon glyphicon-backward', ]),
28                 'nextPageLabel' => Html::tag('span', '', [ 'class' => 'glyphicon glyphicon-forward', ]),
29                 'lastPageLabel' => Html::tag('span', '', [ 'class' => 'glyphicon glyphicon-fast-forward', ]),
30             ],
31         ],
32     ],
33     'components' => [
34         'request' => [
35             // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
36             'cookieValidationKey' => '4u6WczdipA-FIzbuf8PYgjoiid_6zdNy',
37         ],
38         'pdf' => [                                 // Формирование PDF по умолчанию
39             'mode' => Pdf::MODE_UTF8,              // Кодировка
40             'class' => Pdf::className(),
41             'format' => Pdf::FORMAT_A4,            // Лист А4
42             'orientation' => Pdf::ORIENT_PORTRAIT, // Напраление - по вертикали большая сторона
43             'destination' => Pdf::DEST_BROWSER,    // Результат показать в браузере
44             'cssFile' => '@vendor/kartik-v/yii2-mpdf/src/assets/kv-mpdf-bootstrap.min.css',
45             'cssInline' => '.kv-heading-1{font-size:18px}',
46             'methods' => [
47                 'SetHeader' => [Yii::t('app', Yii::$app->name)], // Верхний колонтитул
48                 'SetFooter' => ['{PAGENO}'],                     // Нижний колонтитул
49             ],
50             // refer settings section for all configuration options
51         ],
52
53         'cache' => [
54             'class' => 'yii\caching\FileCache',
55         ],
56
57         'user' => [
58             'identityClass' => 'app\models\User',
59             'enableAutoLogin' => true,
60         ],
61         // Авторизация пользователей из БД
62         'authManager' => [
63             'class' => 'yii\rbac\DbManager',
64             'defaultRoles' => [ 'admin', 'woker' ],
65         ], // */
66
67         'errorHandler' => [
68             'errorAction' => 'site/error',
69         ],
70
71         'mailer' => [
72             'class' => 'yii\swiftmailer\Mailer',
73             // send all mails to a file by default. You have to set
74             // 'useFileTransport' to false and configure a transport
75             // for the mailer to send real emails.
76             'useFileTransport' => false,
77         ],
78
79         'log' => [
80             'traceLevel' => YII_DEBUG ? 3 : 0,
81             'targets' => [
82                 [
83                     'class' => 'yii\log\FileTarget',
84                     'levels' => ['error', 'warning'],
85                 ],
86             ],
87         ],
88
89         'i18n' => [ // Переводы сообщений
90             'translations' => [
91                 '*' => [                                 // Для всех разделов
92                     'class' => 'yii\i18n\PhpMessageSource',
93                     'sourceLanguage' => 'en-US',            // Исходный текст на английском
94                     'basePath' => '@app/messages',
95                     'fileMap' => [
96                         'app'       => 'app.php',           // Для преложения
97                         'app/error' => 'error.php',         // Для ошибок
98                         'contact'   => 'contact.php',       // Для обратной связи
99                         'import'    => 'import.php',        // Для импорта. Обозначение полей таблицы
100                         'items'     => 'items.php',         // Для предметов/оборудования
101                         'locations' => 'locations.php',     // Для мета расположения
102                         'models'    => 'models.php',        // Для моделей предметов/оборудования
103                         'moving'    => 'moving.php',        // Для перемещений
104                         'regions'   => 'regions.php',       // Для регионов/подразделений
105                         'status'    => 'status.php',        // Для состояний предметов/оборудования
106                         'types'     => 'types.php',         // Для типов предметов/оборудования
107                         'users'     => 'users.php',         // Для пользователей
108                     ],
109                 ],
110             ],
111         ],
112         'db' => $db,
113         /*
114         'urlManager' => [
115             'enablePrettyUrl' => true,
116             'showScriptName' => false,
117             'rules' => [
118             ],
119         ],
120         */
121     ],
122     'params' => $params,
123 ];
124
125 if (YII_ENV_DEV) {
126     // configuration adjustments for 'dev' environment
127     $config['bootstrap'][] = 'debug';
128     $config['modules']['debug'] = [
129         'class' => 'yii\debug\Module',
130         // uncomment the following to add your IP if you are not connecting from localhost.
131         'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.68', ],
132     ];
133
134     $config['bootstrap'][] = 'gii';
135     $config['modules']['gii'] = [
136         'class' => 'yii\gii\Module',
137         // uncomment the following to add your IP if you are not connecting from localhost.
138         'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.68'],
139     ];
140 }
141
142 return $config;