@@ -5,14 +5,12 @@ |
||
5 | 5 | use Apps\ActiveRecord\CommentPost; |
6 | 6 | use Apps\ActiveRecord\CommentAnswer; |
7 | 7 | use Apps\ActiveRecord\App as AppRecord; |
8 | -use Apps\Model\Api\Comments\CommentAdd; |
|
9 | 8 | use Apps\Model\Api\Comments\CommentAnswerAdd; |
10 | 9 | use Apps\Model\Api\Comments\CommentPostAdd; |
11 | 10 | use Apps\Model\Api\Comments\EntityCommentData; |
12 | 11 | use Extend\Core\Arch\ApiController; |
13 | 12 | use Ffcms\Core\App; |
14 | 13 | use Ffcms\Core\Exception\JsonException; |
15 | -use Ffcms\Core\Helper\Date; |
|
16 | 14 | use Ffcms\Core\Helper\Type\Obj; |
17 | 15 | use Ffcms\Core\Helper\Type\Str; |
18 | 16 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | $this->setJsonHeader(); |
26 | 26 | $configs = AppRecord::getConfigs('widget', 'Comments'); |
27 | 27 | |
28 | - $replayTo = (int)App::$Request->request->get('replay-to'); |
|
28 | + $replayTo = (int) App::$Request->request->get('replay-to'); |
|
29 | 29 | $model = null; |
30 | 30 | // check if its a answer (comment answer type) |
31 | 31 | if ($replayTo > 0) { |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | } |
38 | 38 | |
39 | 39 | // pass general comment params to model |
40 | - $model->message = App::$Security->secureHtml((string)App::$Request->request->get('message')); |
|
40 | + $model->message = App::$Security->secureHtml((string) App::$Request->request->get('message')); |
|
41 | 41 | $model->guestName = App::$Security->strip_tags(App::$Request->request->get('guest-name')); |
42 | 42 | |
43 | 43 | // check model conditions before add new row |
@@ -61,12 +61,12 @@ discard block |
||
61 | 61 | // set header |
62 | 62 | $this->setJsonHeader(); |
63 | 63 | // get config count per page |
64 | - $perPage = (int)AppRecord::getConfig('widget', 'Comments', 'perPage'); |
|
64 | + $perPage = (int) AppRecord::getConfig('widget', 'Comments', 'perPage'); |
|
65 | 65 | // offset can be only integer |
66 | - $index = (int)$index; |
|
66 | + $index = (int) $index; |
|
67 | 67 | $offset = $perPage * $index; |
68 | 68 | // get comment target path and check |
69 | - $path = (string)App::$Request->query->get('path'); |
|
69 | + $path = (string) App::$Request->query->get('path'); |
|
70 | 70 | if (Str::likeEmpty($path)) { |
71 | 71 | throw new JsonException('Wrong path'); |
72 | 72 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | public function actionShowanswers($commentId) |
110 | 110 | { |
111 | 111 | // check input data |
112 | - if (!Obj::isLikeInt($commentId) || (int)$commentId < 1) { |
|
112 | + if (!Obj::isLikeInt($commentId) || (int) $commentId < 1) { |
|
113 | 113 | throw new JsonException('Input data is incorrect'); |
114 | 114 | } |
115 | 115 |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | // cache some data |
33 | 33 | $rootSize = App::$Cache->get('root.size'); |
34 | 34 | if ($rootSize === null) { |
35 | - $rootSize = round(Directory::getSize('/') / (1024*1000), 2) . ' mb'; |
|
35 | + $rootSize = round(Directory::getSize('/') / (1024 * 1000), 2) . ' mb'; |
|
36 | 36 | App::$Cache->set('root.size', $rootSize, 60 * 60 * 24); // 24 hours caching |
37 | 37 | } |
38 | 38 | $loadAvg = App::$Cache->get('load.average'); |
39 | 39 | if ($loadAvg === null) { |
40 | 40 | $loadAvg = Environment::loadAverage(); |
41 | - App::$Cache->set('load.average', $loadAvg, 60*2); // 2 min cache |
|
41 | + App::$Cache->set('load.average', $loadAvg, 60 * 2); // 2 min cache |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | $stats = [ |
@@ -145,9 +145,9 @@ discard block |
||
145 | 145 | */ |
146 | 146 | public function actionDeleteroute() |
147 | 147 | { |
148 | - $type = (string)App::$Request->query->get('type'); |
|
149 | - $loader = (string)App::$Request->query->get('loader'); |
|
150 | - $source = Str::lowerCase((string)App::$Request->query->get('path')); |
|
148 | + $type = (string) App::$Request->query->get('type'); |
|
149 | + $loader = (string) App::$Request->query->get('loader'); |
|
150 | + $source = Str::lowerCase((string) App::$Request->query->get('path')); |
|
151 | 151 | |
152 | 152 | $model = new EntityDeleteRoute($type, $loader, $source); |
153 | 153 | if ($model->send()) { |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | public function check() |
52 | 52 | { |
53 | 53 | // check if user is auth'd or guest name is defined |
54 | - if (!App::$User->isAuth() && ((int)$this->_configs['guestAdd'] !== 1 || Str::length($this->guestName) < 2)) { |
|
54 | + if (!App::$User->isAuth() && ((int) $this->_configs['guestAdd'] !== 1 || Str::length($this->guestName) < 2)) { |
|
55 | 55 | throw new JsonException(__('Guest name is not defined')); |
56 | 56 | } |
57 | 57 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | // check if message length is correct |
64 | - if (Str::length($this->message) < (int)$this->_configs['minLength'] || Str::length($this->message) > (int)$this->_configs['maxLength']) { |
|
64 | + if (Str::length($this->message) < (int) $this->_configs['minLength'] || Str::length($this->message) > (int) $this->_configs['maxLength']) { |
|
65 | 65 | throw new JsonException(__('Message length is incorrect. Current: %cur% , min - %min%, max - %max%', [ |
66 | 66 | 'cur' => Str::length($this->message), |
67 | 67 | 'min' => $this->_configs['minLength'], |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | public function check() |
48 | 48 | { |
49 | 49 | // check if user is auth'd or guest name is defined |
50 | - if (!App::$User->isAuth() && ((int)$this->_configs['guestAdd'] !== 1 || Str::length($this->guestName) < 2)) { |
|
50 | + if (!App::$User->isAuth() && ((int) $this->_configs['guestAdd'] !== 1 || Str::length($this->guestName) < 2)) { |
|
51 | 51 | throw new JsonException(__('Guest name is not defined')); |
52 | 52 | } |
53 | 53 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | } |
57 | 57 | |
58 | 58 | // check if message length is correct |
59 | - if (Str::length($this->message) < (int)$this->_configs['minLength'] || Str::length($this->message) > (int)$this->_configs['maxLength']) { |
|
59 | + if (Str::length($this->message) < (int) $this->_configs['minLength'] || Str::length($this->message) > (int) $this->_configs['maxLength']) { |
|
60 | 60 | throw new JsonException(__('Message length is incorrect. Current: %cur% , min - %min%, max - %max%', [ |
61 | 61 | 'cur' => Str::length($this->message), |
62 | 62 | 'min' => $this->_configs['minLength'], |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | public function check() |
57 | 57 | { |
58 | 58 | // check if user is auth'd or guest name is defined |
59 | - if (!App::$User->isAuth() && ((int)$this->_configs['guestAdd'] !== 1 || Str::length($this->guestName) < 2)) { |
|
59 | + if (!App::$User->isAuth() && ((int) $this->_configs['guestAdd'] !== 1 || Str::length($this->guestName) < 2)) { |
|
60 | 60 | throw new JsonException(__('Guest name is not defined')); |
61 | 61 | } |
62 | 62 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | // check if message length is correct |
69 | - if (Str::length($this->message) < (int)$this->_configs['minLength'] || Str::length($this->message) > (int)$this->_configs['maxLength']) { |
|
69 | + if (Str::length($this->message) < (int) $this->_configs['minLength'] || Str::length($this->message) > (int) $this->_configs['maxLength']) { |
|
70 | 70 | throw new JsonException(__('Message length is incorrect. Current: %cur% , min - %min%, max - %max%', [ |
71 | 71 | 'cur' => Str::length($this->message), |
72 | 72 | 'min' => $this->_configs['minLength'], |