@@ -57,17 +57,17 @@ discard block |
||
| 57 | 57 | public function check() |
| 58 | 58 | { |
| 59 | 59 | // check if user is auth'd or guest name is defined |
| 60 | - if (!App::$User->isAuth() && ((int)$this->_configs['guestAdd'] !== 1 || Str::length($this->guestName) < 2)) { |
|
| 60 | + if (!App::$User->isAuth() && ((int) $this->_configs['guestAdd'] !== 1 || Str::length($this->guestName) < 2)) { |
|
| 61 | 61 | throw new JsonException(__('Guest name is not defined')); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | // check if target app_name or id is empty |
| 65 | - if (Str::likeEmpty($this->appName) || Str::likeEmpty($this->appId) || (int)$this->appId < 0) { |
|
| 65 | + if (Str::likeEmpty($this->appName) || Str::likeEmpty($this->appId) || (int) $this->appId < 0) { |
|
| 66 | 66 | throw new JsonException(__('Wrong target name or id')); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | // check if message length is correct |
| 70 | - if (Str::length($this->message) < (int)$this->_configs['minLength'] || Str::length($this->message) > (int)$this->_configs['maxLength']) { |
|
| 70 | + if (Str::length($this->message) < (int) $this->_configs['minLength'] || Str::length($this->message) > (int) $this->_configs['maxLength']) { |
|
| 71 | 71 | throw new JsonException(__('Message length is incorrect. Current: %cur%, min - %min%, max - %max%', [ |
| 72 | 72 | 'cur' => Str::length($this->message), |
| 73 | 73 | 'min' => $this->_configs['minLength'], |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | // guest moderation |
| 79 | - if (!App::$User->isAuth() && (bool)$this->_configs['guestModerate']) { |
|
| 79 | + if (!App::$User->isAuth() && (bool) $this->_configs['guestModerate']) { |
|
| 80 | 80 | $captcha = App::$Request->request->get('captcha'); |
| 81 | 81 | if (!App::$Captcha->validate($captcha)) { |
| 82 | 82 | throw new JsonException(__('Captcha is incorrect! Click on image to refresh and try again')); |
@@ -110,13 +110,13 @@ discard block |
||
| 110 | 110 | { |
| 111 | 111 | $record = new CommentPost(); |
| 112 | 112 | $record->app_name = $this->appName; |
| 113 | - $record->app_relation_id = (int)$this->appId; |
|
| 113 | + $record->app_relation_id = (int) $this->appId; |
|
| 114 | 114 | $record->user_id = $this->_userId; |
| 115 | 115 | $record->guest_name = $this->guestName; |
| 116 | 116 | $record->message = $this->message; |
| 117 | 117 | $record->lang = App::$Request->getLanguage(); |
| 118 | 118 | // check if pre moderation is enabled and user is guest |
| 119 | - if ((int)$this->_configs['guestModerate'] === 1 && $this->_userId < 1) { |
|
| 119 | + if ((int) $this->_configs['guestModerate'] === 1 && $this->_userId < 1) { |
|
| 120 | 120 | $record->moderate = 1; |
| 121 | 121 | } |
| 122 | 122 | $record->save(); |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | $this->setJsonHeader(); |
| 32 | 32 | $configs = AppRecord::getConfigs('widget', 'Comments'); |
| 33 | 33 | |
| 34 | - $replayTo = (int)$this->request->request->get('replay-to'); |
|
| 34 | + $replayTo = (int) $this->request->request->get('replay-to'); |
|
| 35 | 35 | $model = null; |
| 36 | 36 | // check if its a answer (comment answer type) |
| 37 | 37 | if ($replayTo > 0) { |
@@ -40,15 +40,15 @@ discard block |
||
| 40 | 40 | } else { // sounds like new comment row |
| 41 | 41 | $model = new CommentPostAdd($configs); |
| 42 | 42 | $model->appName = App::$Security->strip_tags($this->request->request->get('app_name')); |
| 43 | - $model->appId = (int)$this->request->request->get('app_id'); |
|
| 43 | + $model->appId = (int) $this->request->request->get('app_id'); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | // pass general comment params to model |
| 47 | - $model->message = App::$Security->secureHtml((string)$this->request->request->get('message')); |
|
| 47 | + $model->message = App::$Security->secureHtml((string) $this->request->request->get('message')); |
|
| 48 | 48 | $model->guestName = App::$Security->strip_tags($this->request->request->get('guest-name')); |
| 49 | 49 | |
| 50 | 50 | // check model conditions before add new row |
| 51 | - if (!$model|| !$model->check()) { |
|
| 51 | + if (!$model || !$model->check()) { |
|
| 52 | 52 | throw new NativeException('Unknown error'); |
| 53 | 53 | } |
| 54 | 54 | |
@@ -43,7 +43,7 @@ |
||
| 43 | 43 | $records = CommentAnswer::with(['user', 'user.profile', 'user.role']) |
| 44 | 44 | ->where('comment_id', $commentId) |
| 45 | 45 | ->where('moderate', false); |
| 46 | - if ((bool)$configs['onlyLocale']) { |
|
| 46 | + if ((bool) $configs['onlyLocale']) { |
|
| 47 | 47 | $records = $records->where('lang', '=', $this->request->getLanguage()); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -34,9 +34,9 @@ discard block |
||
| 34 | 34 | // get configs |
| 35 | 35 | $configs = AppRecord::getConfigs('widget', 'Comments'); |
| 36 | 36 | // items per page |
| 37 | - $perPage = (int)$configs['perPage']; |
|
| 37 | + $perPage = (int) $configs['perPage']; |
|
| 38 | 38 | // offset can be only integer |
| 39 | - $index = (int)$this->request->query->get('offset', 0); |
|
| 39 | + $index = (int) $this->request->query->get('offset', 0); |
|
| 40 | 40 | $offset = $perPage * $index; |
| 41 | 41 | |
| 42 | 42 | // select comments from db and check it |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | ->where('moderate', false); |
| 46 | 46 | |
| 47 | 47 | // check if comments is depend of language locale |
| 48 | - if ((bool)$configs['onlyLocale']) { |
|
| 48 | + if ((bool) $configs['onlyLocale']) { |
|
| 49 | 49 | $query = $query->where('lang', '=', $this->request->getLanguage()); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -40,14 +40,14 @@ |
||
| 40 | 40 | // for each item in path array calculate comments count |
| 41 | 41 | foreach ($ids as $id) { |
| 42 | 42 | $query = CommentPost::where('app_name', $appName) |
| 43 | - ->where('app_relation_id', (int)$id) |
|
| 43 | + ->where('app_relation_id', (int) $id) |
|
| 44 | 44 | ->where('moderate', '=', 0); |
| 45 | 45 | // check if comments is depend of language locale |
| 46 | - if ((bool)$configs['onlyLocale']) { |
|
| 46 | + if ((bool) $configs['onlyLocale']) { |
|
| 47 | 47 | $query = $query->where('lang', '=', $this->request->getLanguage()); |
| 48 | 48 | } |
| 49 | 49 | // set itemId => count |
| 50 | - $count[(int)$id] = $query->count(); |
|
| 50 | + $count[(int) $id] = $query->count(); |
|
| 51 | 51 | } |
| 52 | 52 | // render json response |
| 53 | 53 | return json_encode(['status' => 1, 'count' => $count]); |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | public function init(): void |
| 21 | 21 | { |
| 22 | 22 | if (App::$Request->getLanguage() !== 'en') { |
| 23 | - App::$Translate->append('/i18n/Front/' . App::$Request->getLanguage() . '/CommentWidget.php'); |
|
| 23 | + App::$Translate->append('/i18n/Front/'.App::$Request->getLanguage().'/CommentWidget.php'); |
|
| 24 | 24 | } |
| 25 | 25 | } |
| 26 | 26 | |
@@ -30,14 +30,14 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | public function display(): ?string |
| 32 | 32 | { |
| 33 | - if (!$this->name || (int)$this->id < 1) { |
|
| 33 | + if (!$this->name || (int) $this->id < 1) { |
|
| 34 | 34 | return null; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | return App::$View->render('widgets/comments/show', [ |
| 38 | 38 | 'configs' => $this->getConfigs(), |
| 39 | - 'name' => (string)$this->name, |
|
| 40 | - 'id' => (int)$this->id, |
|
| 39 | + 'name' => (string) $this->name, |
|
| 40 | + 'id' => (int) $this->id, |
|
| 41 | 41 | ]); |
| 42 | 42 | } |
| 43 | 43 | } |
@@ -11,12 +11,12 @@ |
||
| 11 | 11 | mb_internal_encoding('UTF-8'); |
| 12 | 12 | |
| 13 | 13 | // load composer packages |
| 14 | -$loader = require root . '/vendor/autoload.php'; |
|
| 14 | +$loader = require root.'/vendor/autoload.php'; |
|
| 15 | 15 | // enable autoload for general namespaces user apps |
| 16 | 16 | $loader->add('Apps\\', root); |
| 17 | 17 | $loader->add('Extend\\', root); |
| 18 | 18 | $loader->add('Widgets\\', root); |
| 19 | 19 | |
| 20 | 20 | // tmp @todo |
| 21 | -$loader->add('Widgets\\', root . '/vendor/phpffcms/ffcms-tinymce/src'); |
|
| 22 | -$loader->add('Apps\\', root . '/vendor/phpffcms/ffcms-tinymce/src'); |
|
| 23 | 21 | \ No newline at end of file |
| 22 | +$loader->add('Widgets\\', root.'/vendor/phpffcms/ffcms-tinymce/src'); |
|
| 23 | +$loader->add('Apps\\', root.'/vendor/phpffcms/ffcms-tinymce/src'); |
|
| 24 | 24 | \ No newline at end of file |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // check in cache |
| 64 | - if (MainApp::$Memory->get('profile.object.cache.' . $userId) !== null) { |
|
| 65 | - return MainApp::$Memory->get('profile.object.cache.' . $userId); |
|
| 64 | + if (MainApp::$Memory->get('profile.object.cache.'.$userId) !== null) { |
|
| 65 | + return MainApp::$Memory->get('profile.object.cache.'.$userId); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | // find row |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | $object = $profile->first(); |
| 77 | - MainApp::$Memory->set('profile.object.cache.' . $userId, $object); |
|
| 77 | + MainApp::$Memory->set('profile.object.cache.'.$userId, $object); |
|
| 78 | 78 | |
| 79 | 79 | return $object; |
| 80 | 80 | } |
@@ -86,17 +86,17 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | public function getAvatarUrl($type = 'small') |
| 88 | 88 | { |
| 89 | - $default = '/upload/user/avatar/' . $type . '/default.jpg'; |
|
| 89 | + $default = '/upload/user/avatar/'.$type.'/default.jpg'; |
|
| 90 | 90 | if (!Arr::in($type, ['small', 'big', 'medium'])) { |
| 91 | - return MainApp::$Alias->scriptUrl . $default; |
|
| 91 | + return MainApp::$Alias->scriptUrl.$default; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - $route = '/upload/user/avatar/' . $type . '/' . $this->user_id . '.jpg'; |
|
| 94 | + $route = '/upload/user/avatar/'.$type.'/'.$this->user_id.'.jpg'; |
|
| 95 | 95 | if (File::exist($route)) { |
| 96 | - return MainApp::$Alias->scriptUrl . $route . '?mtime=' . File::mTime($route); |
|
| 96 | + return MainApp::$Alias->scriptUrl.$route.'?mtime='.File::mTime($route); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - return MainApp::$Alias->scriptUrl . $default; |
|
| 99 | + return MainApp::$Alias->scriptUrl.$default; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | { |
| 108 | 108 | $userNick = $this->nick; |
| 109 | 109 | if (!$userNick || Str::likeEmpty($userNick)) { |
| 110 | - $userNick = 'id' . $this->id; |
|
| 110 | + $userNick = 'id'.$this->id; |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | return $userNick; |
@@ -68,15 +68,15 @@ |
||
| 68 | 68 | public function getAnswerCount() |
| 69 | 69 | { |
| 70 | 70 | // check if count is cached |
| 71 | - if (MainApp::$Memory->get('commentpost.answer.count.' . $this->id) !== null) { |
|
| 72 | - return MainApp::$Memory->get('commentpost.answer.count.' . $this->id); |
|
| 71 | + if (MainApp::$Memory->get('commentpost.answer.count.'.$this->id) !== null) { |
|
| 72 | + return MainApp::$Memory->get('commentpost.answer.count.'.$this->id); |
|
| 73 | 73 | } |
| 74 | 74 | // get count from db |
| 75 | 75 | $count = CommentAnswer::where('comment_id', $this->id) |
| 76 | 76 | ->where('moderate', 0) |
| 77 | 77 | ->count(); |
| 78 | 78 | // save in cache |
| 79 | - MainApp::$Memory->set('commentpost.answer.count.' . $this->id, $count); |
|
| 79 | + MainApp::$Memory->set('commentpost.answer.count.'.$this->id, $count); |
|
| 80 | 80 | return $count; |
| 81 | 81 | } |
| 82 | 82 | } |