1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace Icybee\Operation\Module;
13
14 use ICanBoogie\I18n;
15 use ICanBoogie\Operation;
16
17 class Blocks extends Operation
18 {
19 protected function get_controls()
20 {
21 return array
22 (
23 self::CONTROL_AUTHENTICATION => true
24 )
25
26 + parent::get_controls();
27 }
28
29 protected function validate(\ICanboogie\Errors $errors)
30 {
31 if (!$this->request['name'])
32 {
33 $errors['name'] = I18n\t('Missing block name');
34
35 return false;
36 }
37
38 return true;
39 }
40
41 protected function process()
42 {
43 global $core, $document;
44
45
46
47 $document = $core->document;
48
49 if ($core->user_id && $core->user->language)
50 {
51 $core->locale = $core->user->language;
52 }
53
54 $request = $this->request;
55 $name = $request['name'];
56 $module = $core->modules[$request['module']];
57
58 $block = $module->getBlock($name, $request->params);
59
60 $this->response['assets'] = $document->assets;
61
62 return (string) $block;
63 }
64 }