1 | <?php |
||
22 | class Config { |
||
23 | use |
||
24 | CRUD, |
||
25 | Singleton; |
||
26 | const INIT_STATE_METHOD = 'init'; |
||
27 | const SYSTEM_MODULE = 'System'; |
||
28 | const SYSTEM_THEME = 'CleverStyle'; |
||
29 | /** |
||
30 | * @var Cache\Prefix |
||
31 | */ |
||
32 | protected $cache; |
||
33 | /** |
||
34 | * Most of general configuration properties |
||
35 | * |
||
36 | * @var array |
||
37 | */ |
||
38 | public $core = []; |
||
39 | /** |
||
40 | * @var array |
||
41 | */ |
||
42 | protected $core_internal = []; |
||
43 | /** |
||
44 | * @var string |
||
45 | */ |
||
46 | protected $last_language; |
||
47 | /** |
||
48 | * Configuration of databases, except the main database, parameters of which are stored in configuration file |
||
49 | * |
||
50 | * @var mixed[] |
||
51 | */ |
||
52 | public $db = []; |
||
53 | /** |
||
54 | * Configuration of storages, except the main storage, parameters of which are stored in configuration file |
||
55 | * |
||
56 | * @var mixed[] |
||
57 | */ |
||
58 | public $storage = []; |
||
59 | /** |
||
60 | * Internal structure of components parameters |
||
61 | * |
||
62 | * @var array[] |
||
63 | */ |
||
64 | public $components = []; |
||
65 | /** |
||
66 | * Array of all domains, which allowed to access the site |
||
67 | * |
||
68 | * Contains keys: |
||
69 | * * count - Total count |
||
70 | * * http - Insecure (http) domains |
||
71 | * * https - Secure (https) domains |
||
72 | * |
||
73 | * @var array |
||
74 | */ |
||
75 | public $mirrors; |
||
76 | protected $data_model = [ |
||
77 | 'domain' => 'text', |
||
78 | 'core' => 'json', |
||
79 | 'db' => 'json', |
||
80 | 'storage' => 'json', |
||
81 | 'components' => 'json' |
||
82 | ]; |
||
83 | protected $table = '[prefix]config'; |
||
84 | 4 | protected function cdb () { |
|
87 | /** |
||
88 | * Update multilingual options when language changes |
||
89 | */ |
||
90 | 54 | protected function init () { |
|
99 | /** |
||
100 | * Loading of configuration, initialization of $Config, $Cache, $L and Page objects, Routing processing |
||
101 | * |
||
102 | * @throws ExitException |
||
103 | */ |
||
104 | 54 | protected function construct () { |
|
115 | /** |
||
116 | * Reloading of settings cache |
||
117 | * |
||
118 | * @throws ExitException |
||
119 | */ |
||
120 | 54 | protected function load_configuration () { |
|
142 | /** |
||
143 | * Is used to fill `$this->mirrors` using current configuration |
||
144 | */ |
||
145 | 54 | protected function fill_mirrors () { |
|
178 | /** |
||
179 | * Applying settings without saving changes into db |
||
180 | * |
||
181 | * @return bool |
||
182 | * |
||
183 | * @throws ExitException |
||
184 | */ |
||
185 | 2 | public function apply () { |
|
202 | /** |
||
203 | * Applying settings without saving changes into db |
||
204 | * |
||
205 | * @param bool $cache_not_saved_mark |
||
206 | * |
||
207 | * @return bool |
||
208 | * |
||
209 | * @throws ExitException |
||
210 | */ |
||
211 | 2 | protected function apply_internal ($cache_not_saved_mark = true) { |
|
242 | /** |
||
243 | * Saving settings |
||
244 | * |
||
245 | * @return bool |
||
246 | * |
||
247 | * @throws ExitException |
||
248 | */ |
||
249 | 2 | public function save () { |
|
260 | /** |
||
261 | * Whether configuration was applied (not saved) and can be canceled |
||
262 | * |
||
263 | * @return bool |
||
264 | */ |
||
265 | public function cancel_available () { |
||
268 | /** |
||
269 | * Canceling of applied settings |
||
270 | * |
||
271 | * @throws ExitException |
||
272 | */ |
||
273 | 2 | public function cancel () { |
|
277 | /** |
||
278 | * Get base url of current mirror including language suffix |
||
279 | * |
||
280 | * @return string |
||
281 | */ |
||
282 | 8 | public function base_url () { |
|
293 | /** |
||
294 | * Get base url of main domain |
||
295 | * |
||
296 | * @return string |
||
297 | */ |
||
298 | 14 | public function core_url () { |
|
302 | /** |
||
303 | * Get object for getting db and storage configuration of module |
||
304 | * |
||
305 | * @param string $module_name |
||
306 | * |
||
307 | * @return Config\Module_Properties |
||
308 | */ |
||
309 | 54 | public function module ($module_name) { |
|
316 | } |
||
317 |