@@ -50,13 +50,13 @@ discard block |
||
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | // check if id is looks like integer |
| 53 | - if (!Any::isInt($id) || (int)$id < 1) { |
|
| 53 | + if (!Any::isInt($id) || (int) $id < 1) { |
|
| 54 | 54 | return null; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | // check in memory cache object |
| 58 | - if (MainApp::$Memory->get('user.object.cache.' . $id)) { |
|
| 59 | - return MainApp::$Memory->get('user.object.cache.' . $id); |
|
| 58 | + if (MainApp::$Memory->get('user.object.cache.'.$id)) { |
|
| 59 | + return MainApp::$Memory->get('user.object.cache.'.$id); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | // not founded in memory? lets make query |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | ->find($id); |
| 65 | 65 | |
| 66 | 66 | // store cache and return object |
| 67 | - MainApp::$Memory->set('user.object.cache.' . $user->id, $user); |
|
| 67 | + MainApp::$Memory->set('user.object.cache.'.$user->id, $user); |
|
| 68 | 68 | return $user; |
| 69 | 69 | } |
| 70 | 70 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | public function getId(): ?int |
| 76 | 76 | { |
| 77 | - return (int)$this->id; |
|
| 77 | + return (int) $this->id; |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | public static function isAuth(): bool |
| 96 | 96 | { |
| 97 | 97 | // get data from session |
| 98 | - $sessionUserId = (int)MainApp::$Session->get('ff_user_id', 0); |
|
| 98 | + $sessionUserId = (int) MainApp::$Session->get('ff_user_id', 0); |
|
| 99 | 99 | |
| 100 | 100 | // check if session contains user id data |
| 101 | 101 | if ($sessionUserId < 1) { |
@@ -128,13 +128,13 @@ discard block |
||
| 128 | 128 | return false; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - $find = MainApp::$Memory->get('user.counter.cache.' . $id); |
|
| 131 | + $find = MainApp::$Memory->get('user.counter.cache.'.$id); |
|
| 132 | 132 | if (!$find) { |
| 133 | 133 | $find = self::where('id', $id)->count(); |
| 134 | - MainApp::$Memory->set('user.counter.cache.' . $id, $find); |
|
| 134 | + MainApp::$Memory->set('user.counter.cache.'.$id, $find); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - return (int)$find === 1; |
|
| 137 | + return (int) $find === 1; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | */ |
| 232 | 232 | public function inBlacklist(?string $target = null): bool |
| 233 | 233 | { |
| 234 | - if (!$target || (int)$target < 1) { |
|
| 234 | + if (!$target || (int) $target < 1) { |
|
| 235 | 235 | return false; |
| 236 | 236 | } |
| 237 | 237 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public static function all($columns = ['*']) |
| 40 | 40 | { |
| 41 | - $cacheName = 'activerecord.contentcategory.all.' . implode('.', $columns); |
|
| 41 | + $cacheName = 'activerecord.contentcategory.all.'.implode('.', $columns); |
|
| 42 | 42 | $records = MemoryObject::instance()->get($cacheName); |
| 43 | 43 | if (!$records) { |
| 44 | 44 | $records = parent::all($columns); |
@@ -54,12 +54,12 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public static function getByPath($path = '') |
| 56 | 56 | { |
| 57 | - if (MainApp::$Memory->get('cache.content.category.path.' . $path) !== null) { |
|
| 58 | - return MainApp::$Memory->get('cache.content.category.path.' . $path); |
|
| 57 | + if (MainApp::$Memory->get('cache.content.category.path.'.$path) !== null) { |
|
| 58 | + return MainApp::$Memory->get('cache.content.category.path.'.$path); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | $record = self::where('path', $path)->first(); |
| 62 | - MainApp::$Memory->set('cache.content.category.path.' . $path, $record); |
|
| 62 | + MainApp::$Memory->set('cache.content.category.path.'.$path, $record); |
|
| 63 | 63 | return $record; |
| 64 | 64 | } |
| 65 | 65 | |
@@ -70,12 +70,12 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public static function getById($id) |
| 72 | 72 | { |
| 73 | - if (MainApp::$Memory->get('cache.content.category.id.' . $id) !== null) { |
|
| 74 | - return MainApp::$Memory->get('cache.content.category.id.' . $id); |
|
| 73 | + if (MainApp::$Memory->get('cache.content.category.id.'.$id) !== null) { |
|
| 74 | + return MainApp::$Memory->get('cache.content.category.id.'.$id); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | $record = self::find($id); |
| 78 | - MainApp::$Memory->set('cache.content.category.id.' . $id, $record); |
|
| 78 | + MainApp::$Memory->set('cache.content.category.id.'.$id, $record); |
|
| 79 | 79 | return $record; |
| 80 | 80 | } |
| 81 | 81 | |
@@ -94,12 +94,12 @@ discard block |
||
| 94 | 94 | } else { |
| 95 | 95 | // set level marker based on slashes count in pathway |
| 96 | 96 | $slashCount = Str::entryCount($path, '/'); |
| 97 | - for ($i=-1; $i <= $slashCount; $i++) { |
|
| 97 | + for ($i = -1; $i <= $slashCount; $i++) { |
|
| 98 | 98 | $title .= '--'; |
| 99 | 99 | } |
| 100 | 100 | } |
| 101 | 101 | // add canonical title from db |
| 102 | - $title .= ' ' . $data->getLocaled('title'); |
|
| 102 | + $title .= ' '.$data->getLocaled('title'); |
|
| 103 | 103 | // set response as array [id => title, ... ] |
| 104 | 104 | $response[$data->id] = $title; |
| 105 | 105 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | public static function all($columns = ['*']) |
| 35 | 35 | { |
| 36 | - $cacheName = 'activerecords.role.all.' . implode('.', $columns); |
|
| 36 | + $cacheName = 'activerecords.role.all.'.implode('.', $columns); |
|
| 37 | 37 | $records = MemoryObject::instance()->get($cacheName); |
| 38 | 38 | if ($records === null) { |
| 39 | 39 | $records = parent::all($columns); |
@@ -50,12 +50,12 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | public static function get($roleId) |
| 52 | 52 | { |
| 53 | - $role = MainApp::$Memory->get('user.role.cache.' . $roleId); |
|
| 53 | + $role = MainApp::$Memory->get('user.role.cache.'.$roleId); |
|
| 54 | 54 | |
| 55 | 55 | // not founded in cache |
| 56 | 56 | if ($role === null) { |
| 57 | 57 | $role = self::find($roleId); |
| 58 | - MainApp::$Memory->set('user.role.cache.' . $roleId, $role); |
|
| 58 | + MainApp::$Memory->set('user.role.cache.'.$roleId, $role); |
|
| 59 | 59 | } |
| 60 | 60 | return $role; |
| 61 | 61 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | public function __construct($record, $calcAnswers = true) |
| 31 | 31 | { |
| 32 | 32 | $this->_record = $record; |
| 33 | - $this->_calcAnswers = (bool)$calcAnswers; |
|
| 33 | + $this->_calcAnswers = (bool) $calcAnswers; |
|
| 34 | 34 | if ($this->_record instanceof CommentPost) { |
| 35 | 35 | $this->_type = 'post'; |
| 36 | 36 | } elseif ($this->_record instanceof CommentAnswer) { |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | // build user data |
| 55 | 55 | $userName = __('Unknown'); |
| 56 | - $userAvatar = App::$Alias->scriptUrl . '/upload/user/avatar/small/default.jpg'; |
|
| 56 | + $userAvatar = App::$Alias->scriptUrl.'/upload/user/avatar/small/default.jpg'; |
|
| 57 | 57 | $userColor = 0; |
| 58 | 58 | if ($this->_record->user && $this->_record->user->id > 0) { |
| 59 | 59 | $userName = $this->_record->user->profile->getNickname(); |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | 'date' => Date::convertToDatetime($this->_record->created_at, Date::FORMAT_TO_HOUR), |
| 74 | 74 | 'app_name' => $this->_record->app_name, |
| 75 | 75 | 'app_id' => $this->_record->app_relation_id, |
| 76 | - 'moderate' => (int)$this->_record->moderate, |
|
| 76 | + 'moderate' => (int) $this->_record->moderate, |
|
| 77 | 77 | 'user' => [ |
| 78 | 78 | 'id' => $this->_record->user_id, |
| 79 | 79 | 'name' => $userName, |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | // build full path |
| 35 | - $path = '/content/read/' . $content->getPath() . '#comments-list'; |
|
| 35 | + $path = '/content/read/'.$content->getPath().'#comments-list'; |
|
| 36 | 36 | |
| 37 | 37 | // redirect to comment. todo: load all comments and scroll to target by id |
| 38 | 38 | $this->response->redirect($path); |
@@ -25,13 +25,13 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | public function display(string $id): void |
| 27 | 27 | { |
| 28 | - $status = (bool)$this->request->query->get('status', 0); |
|
| 28 | + $status = (bool) $this->request->query->get('status', 0); |
|
| 29 | 29 | $content = \Apps\ActiveRecord\Content::find($id); |
| 30 | 30 | if (!$content) { |
| 31 | 31 | throw new NotFoundException(__('Content {%id%} are not exist', ['id' => $id])); |
| 32 | 32 | } |
| 33 | 33 | // make update query if status is different than required |
| 34 | - if ((bool)$content->display !== $status) { |
|
| 34 | + if ((bool) $content->display !== $status) { |
|
| 35 | 35 | $content->display = $status; |
| 36 | 36 | $content->save(); |
| 37 | 37 | } |
@@ -24,13 +24,13 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | public function important(string $id): void |
| 26 | 26 | { |
| 27 | - $status = (bool)$this->request->query->get('status', 0); |
|
| 27 | + $status = (bool) $this->request->query->get('status', 0); |
|
| 28 | 28 | $content = \Apps\ActiveRecord\Content::find($id); |
| 29 | 29 | if (!$content) { |
| 30 | 30 | throw new NotFoundException(__('Content {%id%} are not exist', ['id' => $id])); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - if ((bool)$content->important !== $status) { |
|
| 33 | + if ((bool) $content->important !== $status) { |
|
| 34 | 34 | $content->important = $status; |
| 35 | 35 | $content->save(); |
| 36 | 36 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | ?> |
| 33 | 33 | |
| 34 | 34 | <?php |
| 35 | -foreach($records as $role) { |
|
| 35 | +foreach ($records as $role) { |
|
| 36 | 36 | $permissions = explode(';', $role->permissions); |
| 37 | 37 | $permissionsLabel = null; |
| 38 | 38 | foreach ($permissions as $perm) { |
@@ -44,12 +44,12 @@ discard block |
||
| 44 | 44 | } else { |
| 45 | 45 | $labelMark = 'badge-secondary'; |
| 46 | 46 | } |
| 47 | - $permissionsLabel .= '<span class="badge ' . $labelMark . '">' . $perm . '</span> '; |
|
| 47 | + $permissionsLabel .= '<span class="badge '.$labelMark.'">'.$perm.'</span> '; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | $roleColor = '-'; |
| 51 | 51 | if ($role->color) { |
| 52 | - $roleColor = '<span class="badge badge-light" style="color: ' . $role->color . '">' . $role->color . '</span>'; |
|
| 52 | + $roleColor = '<span class="badge badge-light" style="color: '.$role->color.'">'.$role->color.'</span>'; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | $table->row([ |
@@ -29,9 +29,9 @@ discard block |
||
| 29 | 29 | <div class="col-md-6"> |
| 30 | 30 | <?php |
| 31 | 31 | if ($type === 'trash') { |
| 32 | - echo Url::a(['content/clear'], '<i class="fa fa-minus"></i> ' . __('Remove all'), ['class' => 'btn btn-danger', 'html' => true]); |
|
| 32 | + echo Url::a(['content/clear'], '<i class="fa fa-minus"></i> '.__('Remove all'), ['class' => 'btn btn-danger', 'html' => true]); |
|
| 33 | 33 | } else { |
| 34 | - echo Url::a(['content/update'], '<i class="fa fa-plus"></i> ' . __('Add content'), ['class' => 'btn btn-primary', 'html' => true]); |
|
| 34 | + echo Url::a(['content/update'], '<i class="fa fa-plus"></i> '.__('Add content'), ['class' => 'btn btn-primary', 'html' => true]); |
|
| 35 | 35 | } |
| 36 | 36 | ?> |
| 37 | 37 | </div> |
@@ -54,9 +54,9 @@ discard block |
||
| 54 | 54 | <i class="fa fa-filter"></i> <?= __('Filters') ?> |
| 55 | 55 | </button> |
| 56 | 56 | <div class="dropdown-menu" aria-labelledby="btnCategories"> |
| 57 | - <?= Url::a(['content/index', null, ['type' => 'all']], '<i class="fa fa-list"></i> ' . __('All'), ['class' => 'dropdown-item', 'html' => true]) ?> |
|
| 58 | - <?= Url::a(['content/index', null, ['type' => 'moderate']], '<i class="fa fa-exclamation"></i> ' . __('Moderate'), ['class' => 'dropdown-item', 'html' => true]) ?> |
|
| 59 | - <?= Url::a(['content/index', null, ['type' => 'trash']], '<i class="fa fa-trash"></i> ' . __('Trash'), ['class' => 'dropdown-item', 'html' => true]) ?> |
|
| 57 | + <?= Url::a(['content/index', null, ['type' => 'all']], '<i class="fa fa-list"></i> '.__('All'), ['class' => 'dropdown-item', 'html' => true]) ?> |
|
| 58 | + <?= Url::a(['content/index', null, ['type' => 'moderate']], '<i class="fa fa-exclamation"></i> '.__('Moderate'), ['class' => 'dropdown-item', 'html' => true]) ?> |
|
| 59 | + <?= Url::a(['content/index', null, ['type' => 'trash']], '<i class="fa fa-trash"></i> '.__('Trash'), ['class' => 'dropdown-item', 'html' => true]) ?> |
|
| 60 | 60 | </div> |
| 61 | 61 | </div> |
| 62 | 62 | </div> |
@@ -85,14 +85,14 @@ discard block |
||
| 85 | 85 | if (!$content->category) { |
| 86 | 86 | continue; |
| 87 | 87 | } |
| 88 | - $frontLink = \App::$Alias->scriptUrl . '/content/read'; |
|
| 88 | + $frontLink = \App::$Alias->scriptUrl.'/content/read'; |
|
| 89 | 89 | if (!Str::likeEmpty($content->category->path)) { |
| 90 | - $frontLink .= '/' . $content->category->path; |
|
| 90 | + $frontLink .= '/'.$content->category->path; |
|
| 91 | 91 | } |
| 92 | - $frontLink .= '/' . $content->path; |
|
| 92 | + $frontLink .= '/'.$content->path; |
|
| 93 | 93 | |
| 94 | 94 | $actionMenu = $this->bootstrap()->btngroup(['class' => 'btn-group btn-group-sm', 'dropdown' => ['class' => 'btn-group btn-group-sm']], 2); |
| 95 | - if (!(bool)$content->display) { |
|
| 95 | + if (!(bool) $content->display) { |
|
| 96 | 96 | $actionMenu->add('<i class="fa fa-eye-slash" style="color: #ff0000;"></i>', ['content/display', [$content->id], ['status' => 1]], [ |
| 97 | 97 | 'html' => true, |
| 98 | 98 | 'class' => 'btn btn-light', |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | ]); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - if (!(bool)$content->important) { |
|
| 111 | + if (!(bool) $content->important) { |
|
| 112 | 112 | $actionMenu->add('<i class="fa fa-star-o"></i>', ['content/important', [$content->id], ['status' => 1]], [ |
| 113 | 113 | 'html' => true, |
| 114 | 114 | 'class' => 'btn btn-light', |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | $hiddenExist = true; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - $contentInfo = '<div>' . Url::a(['content/update', [$content->id]], $content->getLocaled('title')) . '</div>'; |
|
| 141 | + $contentInfo = '<div>'.Url::a(['content/update', [$content->id]], $content->getLocaled('title')).'</div>'; |
|
| 142 | 142 | $contentInfo .= '<div class="small">'; |
| 143 | 143 | $contentInfo .= __('Category: <a href="%url%">%name%</a>', ['name' => $content->category->getLocaled('title'), 'url' => Url::to('content/categoryupdate', [$content->category_id])]); |
| 144 | 144 | $contentInfo .= '</div>'; |