1 | <?php |
||
20 | class Config { |
||
21 | use |
||
22 | CRUD, |
||
23 | Singleton; |
||
24 | const SYSTEM_MODULE = 'System'; |
||
25 | const SYSTEM_THEME = 'CleverStyle'; |
||
26 | /** |
||
27 | * Most of general configuration properties |
||
28 | * |
||
29 | * @var mixed[] |
||
30 | */ |
||
31 | public $core = []; |
||
32 | /** |
||
33 | * Configuration of databases, except the main database, parameters of which are stored in configuration file |
||
34 | * |
||
35 | * @var mixed[] |
||
36 | */ |
||
37 | public $db = []; |
||
38 | /** |
||
39 | * Configuration of storages, except the main storage, parameters of which are stored in configuration file |
||
40 | * |
||
41 | * @var mixed[] |
||
42 | */ |
||
43 | public $storage = []; |
||
44 | /** |
||
45 | * Internal structure of components parameters |
||
46 | * |
||
47 | * @var mixed[] |
||
48 | */ |
||
49 | public $components = []; |
||
50 | /** |
||
51 | * Array of all domains, which allowed to access the site |
||
52 | * |
||
53 | * Contains keys: |
||
54 | * * count - Total count |
||
55 | * * http - Insecure (http) domains |
||
56 | * * https - Secure (https) domains |
||
57 | * |
||
58 | * @var array |
||
59 | */ |
||
60 | public $mirrors; |
||
61 | protected $data_model = [ |
||
62 | 'domain' => 'text', |
||
63 | 'core' => 'json', |
||
64 | 'db' => 'json', |
||
65 | 'storage' => 'json', |
||
66 | 'components' => 'json' |
||
67 | ]; |
||
68 | protected $table = '[prefix]config'; |
||
69 | 2 | protected function cdb () { |
|
70 | 2 | return 0; |
|
71 | } |
||
72 | /** |
||
73 | * Loading of configuration, initialization of $Config, $Cache, $L and Page objects, Routing processing |
||
74 | * |
||
75 | * @throws ExitException |
||
76 | */ |
||
77 | 16 | protected function construct () { |
|
78 | 16 | Event::instance()->fire('System/Config/init/before'); |
|
79 | 16 | $this->load_configuration(); |
|
80 | 16 | date_default_timezone_set($this->core['timezone']); |
|
81 | 16 | $this->fill_mirrors(); |
|
82 | 16 | Event::instance()->fire('System/Config/init/after'); |
|
83 | 16 | if (!file_exists(MODULES.'/'.$this->core['default_module'])) { |
|
84 | $this->core['default_module'] = self::SYSTEM_MODULE; |
||
85 | $this->save(); |
||
86 | } |
||
87 | 16 | } |
|
88 | /** |
||
89 | * Is used to fill `$this->mirrors` using current configuration |
||
90 | */ |
||
91 | 16 | protected function fill_mirrors () { |
|
104 | /** |
||
105 | * Reloading of settings cache |
||
106 | * |
||
107 | * @throws ExitException |
||
108 | */ |
||
109 | 16 | protected function load_configuration () { |
|
126 | /** |
||
127 | * Applying settings without saving changes into db |
||
128 | * |
||
129 | * @return bool |
||
130 | * |
||
131 | * @throws ExitException |
||
132 | */ |
||
133 | function apply () { |
||
136 | /** |
||
137 | * Applying settings without saving changes into db |
||
138 | * |
||
139 | * @param bool $cache_not_saved_mark |
||
140 | * |
||
141 | * @return bool |
||
142 | * |
||
143 | * @throws ExitException |
||
144 | */ |
||
145 | protected function apply_internal ($cache_not_saved_mark = true) { |
||
170 | /** |
||
171 | * Saving settings |
||
172 | * |
||
173 | * @return bool |
||
174 | * |
||
175 | * @throws ExitException |
||
176 | */ |
||
177 | function save () { |
||
193 | /** |
||
194 | * Whether configuration was applied (not saved) and can be canceled |
||
195 | * |
||
196 | * @return bool |
||
197 | */ |
||
198 | function cancel_available () { |
||
201 | /** |
||
202 | * Canceling of applied settings |
||
203 | * |
||
204 | * @throws ExitException |
||
205 | */ |
||
206 | function cancel () { |
||
210 | /** |
||
211 | * Get base url of current mirror including language suffix |
||
212 | * |
||
213 | * @return string |
||
214 | */ |
||
215 | 2 | function base_url () { |
|
226 | /** |
||
227 | * Get base url of main domain |
||
228 | * |
||
229 | * @return string |
||
230 | */ |
||
231 | 4 | function core_url () { |
|
235 | /** |
||
236 | * Get object for getting db and storage configuration of module |
||
237 | * |
||
238 | * @param string $module_name |
||
239 | * |
||
240 | * @return Config\Module_Properties |
||
241 | */ |
||
242 | 10 | function module ($module_name) { |
|
248 | } |
||
249 |