|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace app\modules\core; |
|
4
|
|
|
|
|
5
|
|
|
use app; |
|
6
|
|
|
use app\components\BaseModule; |
|
7
|
|
|
use app\modules\core\models\ContentDecorator; |
|
8
|
|
|
use Yii; |
|
9
|
|
|
use yii\base\Application; |
|
10
|
|
|
use yii\base\BootstrapInterface; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Core module handles base DotPlant2 functions |
|
14
|
|
|
* @package app\modules\user |
|
15
|
|
|
*/ |
|
16
|
|
|
class CoreModule extends BaseModule implements BootstrapInterface |
|
17
|
|
|
{ |
|
18
|
|
|
// To be implemented! |
|
19
|
|
|
public $themeExtensionId = 0; |
|
20
|
|
|
|
|
21
|
|
|
public $themeModuleName = ''; |
|
22
|
|
|
|
|
23
|
|
|
public $themeModuleLocation = ''; |
|
24
|
|
|
|
|
25
|
|
|
public $controllerMap = [ |
|
26
|
|
|
'backend-extensions' => 'app\modules\core\backend\ExtensionsController', |
|
27
|
|
|
'backend-routing' => 'app\modules\core\backend\RoutingController', |
|
28
|
|
|
'backend-wysiwyg' => 'app\modules\core\backend\WysiwygController', |
|
29
|
|
|
]; |
|
30
|
|
|
|
|
31
|
|
|
public $autoCompleteResultsCount = 5; |
|
32
|
|
|
|
|
33
|
|
|
public $fileUploadPath = '@webroot/upload/files/'; |
|
34
|
|
|
public $visitorsFileUploadPath = '@app/visitors-uploaded/'; |
|
35
|
|
|
public $removeUploadedFiles = true; |
|
36
|
|
|
public $overwriteUploadedFiles = false; |
|
37
|
|
|
|
|
38
|
|
|
public $spamCheckerApiKey; |
|
39
|
|
|
|
|
40
|
|
|
public $serverName = 'localhost'; |
|
41
|
|
|
public $serverPort = 80; |
|
42
|
|
|
|
|
43
|
|
|
public $daysToStoreSubmissions = 28; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @var string Internal encoding. It's used for mbstring functions. |
|
47
|
|
|
*/ |
|
48
|
|
|
public $internalEncoding = 'UTF-8'; |
|
49
|
|
|
|
|
50
|
|
|
public $errorMonitorEnabled = false; |
|
51
|
|
|
public $emailNotifyEnabled = false; |
|
52
|
|
|
public $devmail = ''; |
|
53
|
|
|
public $notifyOnlyHttpCodes = ''; |
|
54
|
|
|
public $numberElementsToStore = 5; |
|
55
|
|
|
public $immediateNotice = false; |
|
56
|
|
|
public $immediateNoticeLimitPerUrl = 10; |
|
57
|
|
|
public $httpCodesForImmediateNotify = '404,500'; |
|
58
|
|
|
|
|
59
|
|
|
public $searchHandlers = [ |
|
60
|
|
|
'query_search_products_by_description' => [ |
|
61
|
|
|
'app\components\search\SearchProductsByDescriptionHandler' |
|
62
|
|
|
], |
|
63
|
|
|
'query_search_products_by_property' => [ |
|
64
|
|
|
'app\components\search\SearchProductsByPropertyHandler' |
|
65
|
|
|
], |
|
66
|
|
|
'query_search_pages_by_description' => [ |
|
67
|
|
|
'app\components\search\SearchPagesByDescriptionHandler' |
|
68
|
|
|
] |
|
69
|
|
|
]; |
|
70
|
|
|
|
|
71
|
|
|
public $emailConfig = [ |
|
72
|
|
|
'transport' => 'Swift_MailTransport', |
|
73
|
|
|
'host' => 'localhost', |
|
74
|
|
|
'username' => 'login', |
|
75
|
|
|
'password' => 'password', |
|
76
|
|
|
'port' => '25', |
|
77
|
|
|
'encryption' => '', |
|
78
|
|
|
'mailFrom' => 'login', |
|
79
|
|
|
'sendMail' => '', |
|
80
|
|
|
]; |
|
81
|
|
|
|
|
82
|
|
|
public $wysiwyg_id = 1; |
|
83
|
|
|
|
|
84
|
|
|
/** @var string|null Active WYSIWYG editor class name for use in backend forms */ |
|
85
|
|
|
private $wysiwyg_class_name = ''; |
|
86
|
|
|
|
|
87
|
|
|
/** @var array|null Active WYSIWYG editor params for use in backend forms */ |
|
88
|
|
|
private $wysiwyg_params = null; |
|
89
|
|
|
|
|
90
|
|
|
/** @var bool Attach file properties to form email message */ |
|
91
|
|
|
public $attachFilePropertiesToFormEmail = false; |
|
|
|
|
|
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* @inheritdoc |
|
95
|
|
|
*/ |
|
96
|
|
|
public function behaviors() |
|
97
|
|
|
{ |
|
98
|
|
|
return [ |
|
99
|
|
|
'configurableModule' => [ |
|
100
|
|
|
'class' => 'app\modules\config\behaviors\ConfigurableModuleBehavior', |
|
101
|
|
|
'configurationView' => '@app/modules/core/views/configurable/_config', |
|
102
|
|
|
'configurableModel' => 'app\modules\core\models\ConfigConfigurationModel', |
|
103
|
|
|
] |
|
104
|
|
|
]; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* Bootstrap method to be called during application bootstrap stage. |
|
109
|
|
|
* @param Application $app the application currently running |
|
110
|
|
|
*/ |
|
111
|
|
|
public function bootstrap($app) |
|
112
|
|
|
{ |
|
113
|
|
|
mb_internal_encoding($this->internalEncoding); |
|
114
|
|
|
if ($app instanceof \yii\web\Application === true) { |
|
|
|
|
|
|
115
|
|
|
$app->on( |
|
116
|
|
|
Application::EVENT_BEFORE_ACTION, |
|
117
|
|
|
function () use ($app) { |
|
118
|
|
|
$controller = Yii::$app->requestedAction->controller; |
|
119
|
|
|
|
|
120
|
|
|
$decorators = ContentDecorator::getAllDecorators(); |
|
121
|
|
|
foreach ($decorators as $decorator) { |
|
122
|
|
|
$decorator->subscribe($app, $controller); |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
|
|
126
|
|
|
} |
|
127
|
|
|
); |
|
128
|
|
|
} |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
/** |
|
132
|
|
|
* @inheritdoc |
|
133
|
|
|
*/ |
|
134
|
|
|
public function init() |
|
135
|
|
|
{ |
|
136
|
|
|
parent::init(); |
|
137
|
|
|
if (Yii::$app instanceof \yii\console\Application) { |
|
|
|
|
|
|
138
|
|
|
$this->controllerMap = []; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* @return string Active WYSIWYG widget class name for use in backend forms |
|
|
|
|
|
|
145
|
|
|
*/ |
|
146
|
|
|
public function wysiwyg_class_name() |
|
147
|
|
|
{ |
|
148
|
|
|
if (empty($this->wysiwyg_class_name)) { |
|
149
|
|
|
$this->fetchWYSIWYG(); |
|
150
|
|
|
if (class_exists($this->wysiwyg_class_name) === false) { |
|
151
|
|
|
$this->wysiwyg_id = 1; |
|
152
|
|
|
$this->fetchWYSIWYG(); |
|
153
|
|
|
} |
|
154
|
|
|
} |
|
155
|
|
|
return $this->wysiwyg_class_name; |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
/** |
|
159
|
|
|
* @return array WYSIWYG params for widget |
|
|
|
|
|
|
160
|
|
|
*/ |
|
161
|
|
|
public function wysiwyg_params() |
|
162
|
|
|
{ |
|
163
|
|
|
if ($this->wysiwyg_params === null) { |
|
164
|
|
|
$this->fetchWYSIWYG(); |
|
165
|
|
|
} |
|
166
|
|
|
return $this->wysiwyg_params; |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
private function fetchWYSIWYG() |
|
|
|
|
|
|
170
|
|
|
{ |
|
171
|
|
|
$data = app\modules\core\models\Wysiwyg::getClassNameAndParamsById($this->wysiwyg_id); |
|
172
|
|
|
if (!isset($data['class_name'])) { |
|
173
|
|
|
if ($this->wysiwyg_id > 1) { |
|
174
|
|
|
$this->wysiwyg_id = 1; |
|
175
|
|
|
} else { |
|
176
|
|
|
Yii::$app->cache->delete('WysiwygClassName:' . $this->wysiwyg_id); |
|
177
|
|
|
} |
|
178
|
|
|
return $this->fetchWYSIWYG(); |
|
179
|
|
|
} |
|
180
|
|
|
$this->wysiwyg_class_name = $data['class_name']; |
|
181
|
|
|
$this->wysiwyg_params = $data['params']; |
|
182
|
|
|
} |
|
183
|
|
|
|
|
184
|
|
|
/** |
|
185
|
|
|
* @return string |
|
186
|
|
|
*/ |
|
187
|
|
|
public function getServerPort() |
|
188
|
|
|
{ |
|
189
|
|
|
return $this->serverPort == 80 ? "" : ":{$this->serverPort}"; |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
/** |
|
193
|
|
|
* Returns compiled baseUrl without schema servername:port |
|
194
|
|
|
* |
|
195
|
|
|
* @return string |
|
196
|
|
|
*/ |
|
197
|
|
|
public function getBaseUrl() |
|
198
|
|
|
{ |
|
199
|
|
|
return $this->serverName . $this->getServerPort(); |
|
200
|
|
|
} |
|
201
|
|
|
} |
|
202
|
|
|
|
Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.