1 | <?php |
||
2 | |||
3 | /** |
||
4 | * Callbacks module |
||
5 | * |
||
6 | * @author Alexey Krupskiy <[email protected]> |
||
7 | * @link http://inji.ru/ |
||
8 | * @copyright 2015 Alexey Krupskiy |
||
9 | * @license https://github.com/injitools/cms-Inji/blob/master/LICENSE |
||
10 | */ |
||
11 | class Callbacks extends Module { |
||
12 | |||
13 | public function init() { |
||
14 | $callbacksData = filter_input(INPUT_POST, 'Callbacks', FILTER_REQUIRE_ARRAY); |
||
15 | if (!empty($callbacksData)) { |
||
16 | $callback = new \Callbacks\Callback(); |
||
17 | $error = false; |
||
18 | if (empty($callbacksData['text'])) { |
||
19 | $error = true; |
||
20 | \Inji\Msg::add('Вы не написали текст отзыва'); |
||
21 | } else { |
||
22 | $callback->text = nl2br(htmlspecialchars($callbacksData['text'])); |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
23 | } |
||
24 | if (empty($callbacksData['name'])) { |
||
25 | $error = true; |
||
26 | \Inji\Msg::add('Вы не указали свое имя'); |
||
27 | } else { |
||
28 | $callback->name = htmlspecialchars($callbacksData['name']); |
||
0 ignored issues
–
show
The property
name does not exist on Callbacks\Callback . Since you implemented __set , consider adding a @property annotation.
![]() |
|||
29 | } |
||
30 | if (empty($callbacksData['phone'])) { |
||
31 | $error = true; |
||
32 | \Inji\Msg::add('Вы не указали свой номер телефона'); |
||
33 | } else { |
||
34 | $callback->phone = htmlspecialchars($callbacksData['phone']); |
||
0 ignored issues
–
show
The property
phone does not exist on Callbacks\Callback . Since you implemented __set , consider adding a @property annotation.
![]() |
|||
35 | } |
||
36 | $files = filter_var($_FILES['Callbacks'], FILTER_REQUIRE_ARRAY); |
||
37 | if (!empty($files['tmp_name']['photo'])) { |
||
38 | $callback->image_file_id = App::$cur->files->upload([ |
||
0 ignored issues
–
show
The property
image_file_id does not exist on Callbacks\Callback . Since you implemented __set , consider adding a @property annotation.
![]() |
|||
39 | 'name' => $files['name']['photo'], |
||
40 | 'tmp_name' => $files['tmp_name']['photo'], |
||
41 | ]); |
||
42 | } |
||
43 | $callback->mail = htmlspecialchars($callbacksData['mail']); |
||
0 ignored issues
–
show
The property
mail does not exist on Callbacks\Callback . Since you implemented __set , consider adding a @property annotation.
![]() |
|||
44 | $callback->type_id = (int) $callbacksData['type']; |
||
0 ignored issues
–
show
The property
type_id does not exist on Callbacks\Callback . Since you implemented __set , consider adding a @property annotation.
![]() |
|||
45 | if (!$error) { |
||
46 | $callback->save(); |
||
47 | if (!empty(App::$cur->config['site']['email'])) { |
||
48 | $subject = 'Новый отзыв'; |
||
49 | $text = 'Вы можете его посмотреть по этому адресу: <a href = "http://' . idn_to_utf8(INJI_DOMAIN_NAME) . '/admin/callbacks">http://' . idn_to_utf8(INJI_DOMAIN_NAME) . '/admin/callbacks</a>'; |
||
50 | Tools::sendMail('noreply@' . INJI_DOMAIN_NAME, App::$cur->config['site']['email'], $subject, $text); |
||
0 ignored issues
–
show
The type
Tools was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
51 | } |
||
52 | Tools::redirect('/', 'Ваш отзыв был получен и появится после обработки администратором', 'success'); |
||
53 | } |
||
54 | } |
||
55 | } |
||
56 | |||
57 | public function viewsCategoryList($inherit = true) { |
||
58 | $return = []; |
||
59 | if ($inherit) { |
||
60 | $return['inherit'] = 'Как у родителя'; |
||
61 | } |
||
62 | $return['index'] = 'Обычная странциа'; |
||
63 | $conf = App::$primary->view->template->config; |
||
64 | if (!empty($conf['files']['modules']['Callbacks'])) { |
||
65 | foreach ($conf['files']['modules']['Callbacks'] as $file) { |
||
66 | if ($file['type'] == 'Category') { |
||
67 | $return[$file['file']] = $file['name']; |
||
68 | } |
||
69 | } |
||
70 | } |
||
71 | return $return; |
||
72 | } |
||
73 | |||
74 | public function templatesCategoryList() { |
||
75 | $return = [ |
||
76 | 'inherit' => 'Как у родителя', |
||
77 | 'current' => 'Текущая тема' |
||
78 | ]; |
||
79 | |||
80 | $conf = App::$primary->view->template->config; |
||
81 | |||
82 | if (!empty($conf['files']['aditionTemplateFiels'])) { |
||
83 | foreach ($conf['files']['aditionTemplateFiels'] as $file) { |
||
84 | $return[$file['file']] = '- ' . $file['name']; |
||
85 | } |
||
86 | } |
||
87 | return $return; |
||
88 | } |
||
89 | |||
90 | } |
||
91 |