1 | <?php |
||
32 | class App { |
||
33 | use |
||
34 | Singleton, |
||
35 | Router; |
||
36 | const INIT_STATE_METHOD = 'init'; |
||
37 | 12 | protected function init () { |
|
38 | 12 | $this->init_router(); |
|
39 | 12 | } |
|
40 | /** |
||
41 | * Executes blocks and module page generation |
||
42 | * |
||
43 | * @throws ExitException |
||
44 | */ |
||
45 | 10 | public function execute () { |
|
46 | 10 | $Config = Config::instance(); |
|
47 | 10 | $Request = Request::instance(); |
|
48 | 10 | if (!preg_match('/^[0-9a-z_]+$/i', $Request->method)) { |
|
49 | throw new ExitException(400); |
||
50 | } |
||
51 | 10 | $this->handle_closed_site(!$Config->core['site_mode'], $Request); |
|
52 | 8 | if (!$this->check_permission($Request, 'index')) { |
|
53 | 2 | throw new ExitException(403); |
|
54 | } |
||
55 | 6 | Event::instance()->fire('System/App/render/before'); |
|
56 | 6 | $this->render($Request); |
|
57 | 6 | Event::instance()->fire('System/App/render/after'); |
|
58 | 6 | Page::instance()->render(); |
|
59 | 6 | } |
|
60 | /** |
||
61 | * @param bool $closed_site |
||
62 | * @param Request $Request |
||
63 | * |
||
64 | * @throws ExitException |
||
65 | */ |
||
66 | 10 | protected function handle_closed_site ($closed_site, $Request) { |
|
87 | /** |
||
88 | * Check if visitor is allowed to make current request to closed site |
||
89 | * |
||
90 | * @param Request $Request |
||
91 | * |
||
92 | * @return bool |
||
93 | */ |
||
94 | 4 | protected function allow_closed_site_request ($Request) { |
|
104 | /** |
||
105 | * Check whether user allowed to access to specified label |
||
106 | * |
||
107 | * @param Request $Request |
||
108 | * @param string $label |
||
109 | * |
||
110 | * @return bool |
||
111 | */ |
||
112 | 8 | protected function check_permission ($Request, $label) { |
|
124 | /** |
||
125 | * @param Request $Request |
||
126 | * |
||
127 | * @throws ExitException |
||
128 | */ |
||
129 | 6 | protected function render ($Request) { |
|
139 | /** |
||
140 | * Render page title |
||
141 | * |
||
142 | * @param Request $Request |
||
143 | * @param Page $Page |
||
144 | */ |
||
145 | 2 | protected function render_title ($Request, $Page) { |
|
157 | /** |
||
158 | * Blocks rendering |
||
159 | * |
||
160 | * @param Page $Page |
||
161 | */ |
||
162 | 2 | protected function render_blocks ($Page) { |
|
223 | /** |
||
224 | * Check whether to render block or not based on its properties (active state, when start to show, when it expires and permissions) |
||
225 | * |
||
226 | * @param array $block |
||
227 | * |
||
228 | * @return bool |
||
229 | */ |
||
230 | protected function should_block_be_rendered ($block) { |
||
240 | /** |
||
241 | * @param string $text |
||
242 | * |
||
243 | * @return string |
||
244 | */ |
||
245 | protected function ml_process ($text) { |
||
248 | /** |
||
249 | * Getter for `controller_path` property (no other properties supported currently) |
||
250 | * |
||
251 | * @param string $property |
||
252 | * |
||
253 | * @return false|string[] |
||
254 | */ |
||
255 | 4 | public function __get ($property) { |
|
261 | } |
||
262 |