@@ -11,7 +11,7 @@ |
||
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * FormCommentModerate constructor. Pass active record and type of comment system inside. |
| 14 | - * @param object $record |
|
| 14 | + * @param object $records |
|
| 15 | 15 | * @param string $type |
| 16 | 16 | */ |
| 17 | 17 | public function __construct($records, $type) |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | <?php |
| 29 | 29 | if ($records === null || $records->count() < 1) { |
| 30 | - echo '<p class="alert alert-warning">' . __('Answers is not founded') . '</p>'; |
|
| 30 | + echo '<p class="alert alert-warning">'.__('Answers is not founded').'</p>'; |
|
| 31 | 31 | return; |
| 32 | 32 | } |
| 33 | 33 | $items = []; |
@@ -36,21 +36,21 @@ discard block |
||
| 36 | 36 | $commentObject = $item->getCommentPost(); |
| 37 | 37 | $message = Text::cut(\App::$Security->strip_tags($item->message), 0, 75); |
| 38 | 38 | |
| 39 | - $moderate = (bool)$item->moderate; |
|
| 39 | + $moderate = (bool) $item->moderate; |
|
| 40 | 40 | if ($moderate) { |
| 41 | 41 | $moderateIsFound = true; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | $items[] = [ |
| 45 | 45 | 1 => ['text' => $item->id], |
| 46 | - 2 => ['text' => ($moderate ? '<i class="fa fa-exclamation text-warning"></i> ' : null) . Url::link(['comments/read', $commentObject->id, null, ['#' => '#answer-' . $item->id]], $message), 'html' => true], |
|
| 47 | - 3 => ['text' => Simplify::parseUserLink((int)$item->user_id, $item->guest_name, 'user/update'), 'html' => true], |
|
| 48 | - 4 => ['text' => '<a href="' . App::$Alias->scriptUrl . $commentObject->pathway . '" target="_blank">' . Str::sub($commentObject->pathway, 0, 20) . '...</a>', 'html' => true], |
|
| 46 | + 2 => ['text' => ($moderate ? '<i class="fa fa-exclamation text-warning"></i> ' : null).Url::link(['comments/read', $commentObject->id, null, ['#' => '#answer-'.$item->id]], $message), 'html' => true], |
|
| 47 | + 3 => ['text' => Simplify::parseUserLink((int) $item->user_id, $item->guest_name, 'user/update'), 'html' => true], |
|
| 48 | + 4 => ['text' => '<a href="'.App::$Alias->scriptUrl.$commentObject->pathway.'" target="_blank">'.Str::sub($commentObject->pathway, 0, 20).'...</a>', 'html' => true], |
|
| 49 | 49 | 5 => ['text' => Date::convertToDatetime($item->created_at, Date::FORMAT_TO_HOUR)], |
| 50 | - 6 => ['text' => Url::link(['comments/read', $commentObject->id], '<i class="fa fa-list fa-lg"></i>') . |
|
| 51 | - ' ' . Url::link(['comments/delete', 'answer', $item->id], '<i class="fa fa-trash-o fa-lg"></i>'), |
|
| 50 | + 6 => ['text' => Url::link(['comments/read', $commentObject->id], '<i class="fa fa-list fa-lg"></i>'). |
|
| 51 | + ' '.Url::link(['comments/delete', 'answer', $item->id], '<i class="fa fa-trash-o fa-lg"></i>'), |
|
| 52 | 52 | 'html' => true, 'property' => ['class' => 'text-center']], |
| 53 | - 'property' => ['class' => 'checkbox-row' . ($moderate !== false ? ' alert-warning' : null)] |
|
| 53 | + 'property' => ['class' => 'checkbox-row'.($moderate !== false ? ' alert-warning' : null)] |
|
| 54 | 54 | ]; |
| 55 | 55 | } |
| 56 | 56 | |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | <?php |
| 28 | 28 | if ($records === null || $records->count() < 1) { |
| 29 | - echo '<p class="alert alert-warning">' . __('Comments is not founded') . '</p>'; |
|
| 29 | + echo '<p class="alert alert-warning">'.__('Comments is not founded').'</p>'; |
|
| 30 | 30 | return; |
| 31 | 31 | } |
| 32 | 32 | $items = []; |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | foreach ($records as $item) { |
| 35 | 35 | $message = Text::cut(\App::$Security->strip_tags($item->message), 0, 75); |
| 36 | 36 | |
| 37 | - $moderate = (bool)$item->moderate; |
|
| 37 | + $moderate = (bool) $item->moderate; |
|
| 38 | 38 | // if even one moderate item is found - change global flag to true |
| 39 | 39 | if ($moderate) { |
| 40 | 40 | $moderateIsFound = true; |
@@ -42,16 +42,16 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | $items[] = [ |
| 44 | 44 | 1 => ['text' => $item->id], |
| 45 | - 2 => ['text' => ($moderate ? '<i class="fa fa-exclamation text-warning"></i> ' : null) . Url::link(['comments/read', $item->id], $message), 'html' => true], |
|
| 45 | + 2 => ['text' => ($moderate ? '<i class="fa fa-exclamation text-warning"></i> ' : null).Url::link(['comments/read', $item->id], $message), 'html' => true], |
|
| 46 | 46 | 3 => ['text' => $item->getAnswerCount()], |
| 47 | - 4 => ['text' => Simplify::parseUserLink((int)$item->user_id, $item->guest_name, 'user/update'), 'html' => true], |
|
| 48 | - 5 => ['text' => '<a href="' . App::$Alias->scriptUrl . $item->pathway . '" target="_blank">' . Str::sub($item->pathway, 0, 20) . '...</a>', 'html' => true], |
|
| 47 | + 4 => ['text' => Simplify::parseUserLink((int) $item->user_id, $item->guest_name, 'user/update'), 'html' => true], |
|
| 48 | + 5 => ['text' => '<a href="'.App::$Alias->scriptUrl.$item->pathway.'" target="_blank">'.Str::sub($item->pathway, 0, 20).'...</a>', 'html' => true], |
|
| 49 | 49 | 6 => ['text' => Date::convertToDatetime($item->created_at, Date::FORMAT_TO_HOUR)], |
| 50 | - 7 => ['text' => Url::link(['comments/read', $item->id], '<i class="fa fa-list fa-lg"></i>') . |
|
| 51 | - ' ' . Url::link(['comments/delete', 'comment', $item->id], '<i class="fa fa-trash-o fa-lg"></i>'), |
|
| 50 | + 7 => ['text' => Url::link(['comments/read', $item->id], '<i class="fa fa-list fa-lg"></i>'). |
|
| 51 | + ' '.Url::link(['comments/delete', 'comment', $item->id], '<i class="fa fa-trash-o fa-lg"></i>'), |
|
| 52 | 52 | 'html' => true, 'property' => ['class' => 'text-center']], |
| 53 | 53 | 'property' => [ |
| 54 | - 'class' => 'checkbox-row' . ($moderate !== false ? ' alert-warning' : null) |
|
| 54 | + 'class' => 'checkbox-row'.($moderate !== false ? ' alert-warning' : null) |
|
| 55 | 55 | ] |
| 56 | 56 | ]; |
| 57 | 57 | } |
@@ -29,16 +29,16 @@ discard block |
||
| 29 | 29 | $author = Url::link(['user/update', $record->user_id], $author); |
| 30 | 30 | } |
| 31 | 31 | ?> |
| 32 | - <?= $author . ', ' . Date::convertToDatetime($record->created_at, Date::FORMAT_TO_HOUR) ?> |
|
| 32 | + <?= $author.', '.Date::convertToDatetime($record->created_at, Date::FORMAT_TO_HOUR) ?> |
|
| 33 | 33 | <div class="pull-right"> |
| 34 | - <?php if ((bool)$record->moderate):?> |
|
| 34 | + <?php if ((bool) $record->moderate):?> |
|
| 35 | 35 | <?= Url::link(['comments/publish', 'comment', $record->id], __('Publish'), ['class' => 'label label-warning']) ?> |
| 36 | 36 | <?php endif; ?> |
| 37 | 37 | <?= Url::link(['comments/edit', 'comment', $record->id], __('Edit'), ['class' => 'label label-primary']) ?> |
| 38 | 38 | <?= Url::link(['comments/delete', 'comment', $record->id], __('Delete'), ['class' => 'label label-danger']) ?> |
| 39 | 39 | </div> |
| 40 | 40 | </div> |
| 41 | - <div class="panel-body<?= ((bool)$record->moderate ? ' text-warning' : null)?>"> |
|
| 41 | + <div class="panel-body<?= ((bool) $record->moderate ? ' text-warning' : null)?>"> |
|
| 42 | 42 | <?= $record->message ?> |
| 43 | 43 | </div> |
| 44 | 44 | </div> |
@@ -59,16 +59,16 @@ discard block |
||
| 59 | 59 | <?php |
| 60 | 60 | $answerAuthor = Simplify::parseUserLink($answer->user_id, $answer->guest_name, 'user/update'); |
| 61 | 61 | ?> |
| 62 | - <?= $answerAuthor . ', ' . Date::convertToDatetime($answer->created_at, Date::FORMAT_TO_HOUR) ?> |
|
| 62 | + <?= $answerAuthor.', '.Date::convertToDatetime($answer->created_at, Date::FORMAT_TO_HOUR) ?> |
|
| 63 | 63 | <div class="pull-right"> |
| 64 | - <?php if ((bool)$answer->moderate):?> |
|
| 64 | + <?php if ((bool) $answer->moderate):?> |
|
| 65 | 65 | <?= Url::link(['comments/publish', 'answer', $answer->id], __('Publish'), ['class' => 'label label-warning']) ?> |
| 66 | 66 | <?php endif; ?> |
| 67 | 67 | <?= Url::link(['comments/edit', 'answer', $answer->id], __('Edit'), ['class' => 'label label-primary']) ?> |
| 68 | 68 | <?= Url::link(['comments/delete', 'answer', $answer->id], __('Delete'), ['class' => 'label label-danger']) ?> |
| 69 | 69 | </div> |
| 70 | 70 | </div> |
| 71 | - <div class="panel-body<?= ((bool)$answer->moderate ? ' text-warning' : null)?>"> |
|
| 71 | + <div class="panel-body<?= ((bool) $answer->moderate ? ' text-warning' : null)?>"> |
|
| 72 | 72 | <?= $answer->message ?> |
| 73 | 73 | </div> |
| 74 | 74 | </div> |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | public function actionIndex() |
| 40 | 40 | { |
| 41 | 41 | // set current page and offset |
| 42 | - $page = (int)App::$Request->query->get('page'); |
|
| 42 | + $page = (int) App::$Request->query->get('page'); |
|
| 43 | 43 | $offset = $page * self::ITEM_PER_PAGE; |
| 44 | 44 | |
| 45 | 45 | // initialize active record model |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | public function actionDelete($type, $id = 0) |
| 135 | 135 | { |
| 136 | 136 | // sounds like a multiply delete definition |
| 137 | - if ($id === 0 || (int)$id < 1) { |
|
| 137 | + if ($id === 0 || (int) $id < 1) { |
|
| 138 | 138 | $ids = App::$Request->query->get('selected'); |
| 139 | 139 | if (Obj::isArray($ids) && Arr::onlyNumericValues($ids)) { |
| 140 | 140 | $id = $ids; |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | if ($model->send() && $model->validate()) { |
| 169 | 169 | $model->make(); |
| 170 | 170 | App::$Session->getFlashBag()->add('success', __('Comments or answers are successful deleted!')); |
| 171 | - App::$Response->redirect('comments/' . ($type === 'answer' ? 'answerlist' : 'index')); |
|
| 171 | + App::$Response->redirect('comments/'.($type === 'answer' ? 'answerlist' : 'index')); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | // render view |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | public function actionPublish($type, $id = 0) |
| 188 | 188 | { |
| 189 | 189 | // check if it multiple accept ids |
| 190 | - if ($id === 0 || (int)$id < 1) { |
|
| 190 | + if ($id === 0 || (int) $id < 1) { |
|
| 191 | 191 | $ids = App::$Request->query->get('selected'); |
| 192 | 192 | if (Obj::isArray($ids) && Arr::onlyNumericValues($ids)) { |
| 193 | 193 | $id = $ids; |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | if ($model->send()) { |
| 222 | 222 | $model->make(); |
| 223 | 223 | App::$Session->getFlashBag()->add('success', __('Comments or answers are successful published')); |
| 224 | - App::$Response->redirect('comments/' . ($type === 'answer' ? 'answerlist' : 'index')); |
|
| 224 | + App::$Response->redirect('comments/'.($type === 'answer' ? 'answerlist' : 'index')); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | return App::$View->render('publish', [ |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | public function actionAnswerlist() |
| 237 | 237 | { |
| 238 | 238 | // set current page and offset |
| 239 | - $page = (int)App::$Request->query->get('page'); |
|
| 239 | + $page = (int) App::$Request->query->get('page'); |
|
| 240 | 240 | $offset = $page * self::ITEM_PER_PAGE; |
| 241 | 241 | |
| 242 | 242 | // initialize ar answers model |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | namespace Apps\Controller\Front; |
| 4 | 4 | |
| 5 | 5 | use Apps\ActiveRecord\ContentCategory; |
| 6 | -use Apps\ActiveRecord\Content as ContentEntity; |
|
| 6 | +use Apps\ActiveRecord\Content as ContentRecord; |
|
| 7 | 7 | use Apps\Model\Front\Content\EntityContentSearch; |
| 8 | 8 | use Extend\Core\Arch\FrontAppController; |
| 9 | 9 | use Ffcms\Core\App; |
@@ -19,7 +19,6 @@ discard block |
||
| 19 | 19 | use Suin\RSSWriter\Item; |
| 20 | 20 | use Ffcms\Core\Helper\Type\Arr; |
| 21 | 21 | use Apps\Model\Front\Content\FormNarrowContentUpdate; |
| 22 | -use Apps\ActiveRecord\Content as ContentRecord; |
|
| 23 | 22 | |
| 24 | 23 | /** |
| 25 | 24 | * Class Content. Controller of content app - content and categories. |
@@ -54,9 +54,9 @@ discard block |
||
| 54 | 54 | { |
| 55 | 55 | $path = App::$Request->getPathWithoutControllerAction(); |
| 56 | 56 | $configs = $this->getConfigs(); |
| 57 | - $page = (int)App::$Request->query->get('page', 0); |
|
| 58 | - $sort = (string)App::$Request->query->get('sort', 'newest'); |
|
| 59 | - $itemCount = (int)$configs['itemPerCategory']; |
|
| 57 | + $page = (int) App::$Request->query->get('page', 0); |
|
| 58 | + $sort = (string) App::$Request->query->get('sort', 'newest'); |
|
| 59 | + $itemCount = (int) $configs['itemPerCategory']; |
|
| 60 | 60 | |
| 61 | 61 | // build special model with content list and category list information |
| 62 | 62 | $model = new EntityCategoryList($path, $configs, $page, $sort); |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | $model = new EntityContentRead($categoryRecord, $contentRecord->first()); |
| 137 | 137 | $search = null; |
| 138 | 138 | // check if similar search is enabled for item category |
| 139 | - if ((int)$model->getCategory()->getProperty('showSimilar') === 1 && $trash === false) { |
|
| 139 | + if ((int) $model->getCategory()->getProperty('showSimilar') === 1 && $trash === false) { |
|
| 140 | 140 | $search = new EntityContentSearch($model->title, $model->id); |
| 141 | 141 | } |
| 142 | 142 | |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | { |
| 167 | 167 | $configs = $this->getConfigs(); |
| 168 | 168 | // check if tags is enabled |
| 169 | - if ((int)$configs['keywordsAsTags'] !== 1) { |
|
| 169 | + if ((int) $configs['keywordsAsTags'] !== 1) { |
|
| 170 | 170 | throw new NotFoundException(__('Tag system is disabled')); |
| 171 | 171 | } |
| 172 | 172 | |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | // get equal rows order by creation date |
| 182 | - $records = ContentEntity::where('meta_keywords', 'like', '%' . $tagName . '%')->orderBy('created_at', 'DESC')->take(self::TAG_PER_PAGE); |
|
| 182 | + $records = ContentEntity::where('meta_keywords', 'like', '%'.$tagName.'%')->orderBy('created_at', 'DESC')->take(self::TAG_PER_PAGE); |
|
| 183 | 183 | // check if result is not empty |
| 184 | 184 | if ($records->count() < 1) { |
| 185 | 185 | throw new NotFoundException(__('Nothing founded')); |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | $this->layout = null; |
| 214 | 214 | |
| 215 | 215 | // check if rss display allowed for this category |
| 216 | - if ((int)$model->category['configs']['showRss'] !== 1) { |
|
| 216 | + if ((int) $model->category['configs']['showRss'] !== 1) { |
|
| 217 | 217 | throw new ForbiddenException(__('Rss feed is disabled for this category')); |
| 218 | 218 | } |
| 219 | 219 | |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | // set channel data |
| 225 | 225 | $channel->title($model->category['title']) |
| 226 | 226 | ->description($model->category['description']) |
| 227 | - ->url(App::$Alias->baseUrl . '/content/list/' . $model->category['path']) |
|
| 227 | + ->url(App::$Alias->baseUrl.'/content/list/'.$model->category['path']) |
|
| 228 | 228 | ->appendTo($feed); |
| 229 | 229 | |
| 230 | 230 | // add content data |
@@ -234,10 +234,10 @@ discard block |
||
| 234 | 234 | // add title, short text, url |
| 235 | 235 | $item->title($row['title']) |
| 236 | 236 | ->description($row['text']) |
| 237 | - ->url(App::$Alias->baseUrl . $row['uri']); |
|
| 237 | + ->url(App::$Alias->baseUrl.$row['uri']); |
|
| 238 | 238 | // add poster |
| 239 | 239 | if ($row['thumb'] !== null) { |
| 240 | - $item->enclosure(App::$Alias->scriptUrl . $row['thumb'], $row['thumbSize'], 'image/jpeg'); |
|
| 240 | + $item->enclosure(App::$Alias->scriptUrl.$row['thumb'], $row['thumbSize'], 'image/jpeg'); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | // append response to channel |
@@ -264,12 +264,12 @@ discard block |
||
| 264 | 264 | |
| 265 | 265 | // check if user add enabled |
| 266 | 266 | $configs = $this->getConfigs(); |
| 267 | - if (!(bool)$configs['userAdd']) { |
|
| 267 | + if (!(bool) $configs['userAdd']) { |
|
| 268 | 268 | throw new NotFoundException(__('User add is disabled')); |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | // prepare query |
| 272 | - $page = (int)App::$Request->query->get('page', 0); |
|
| 272 | + $page = (int) App::$Request->query->get('page', 0); |
|
| 273 | 273 | $offset = $page * 10; |
| 274 | 274 | $query = ContentRecord::where('author_id', '=', App::$User->identity()->getId()); |
| 275 | 275 | |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | |
| 310 | 310 | // check if user add enabled |
| 311 | 311 | $configs = $this->getConfigs(); |
| 312 | - if (!(bool)$configs['userAdd']) { |
|
| 312 | + if (!(bool) $configs['userAdd']) { |
|
| 313 | 313 | throw new NotFoundException(__('User add is disabled')); |
| 314 | 314 | } |
| 315 | 315 | |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | $new = $record->id === null; |
| 319 | 319 | |
| 320 | 320 | // reject edit published items and items from other authors |
| 321 | - if (($new === false && (int)$record->author_id !== App::$User->identity()->getId()) || (int)$record->display === 1) { |
|
| 321 | + if (($new === false && (int) $record->author_id !== App::$User->identity()->getId()) || (int) $record->display === 1) { |
|
| 322 | 322 | throw new ForbiddenException(__('You have no permissions to edit this content')); |
| 323 | 323 | } |
| 324 | 324 | |
@@ -1,7 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | use Ffcms\Core\Helper\Date; |
| 4 | -use Ffcms\Core\Helper\HTML\Form; |
|
| 5 | 4 | use Ffcms\Core\Helper\HTML\Table; |
| 6 | 5 | use Ffcms\Core\Helper\Serialize; |
| 7 | 6 | use Ffcms\Core\Helper\Url; |
@@ -29,10 +29,10 @@ |
||
| 29 | 29 | } |
| 30 | 30 | $items = []; |
| 31 | 31 | foreach ($records as $record) { |
| 32 | - $moderate = (int)$record->display === 0; |
|
| 32 | + $moderate = (int) $record->display === 0; |
|
| 33 | 33 | $title = Serialize::getDecodeLocale($record->title); |
| 34 | 34 | if ($moderate) { |
| 35 | - $title = Url::link(['content/update', $record->id], $title) . ' <i class="fa fa-pencil"></i>'; |
|
| 35 | + $title = Url::link(['content/update', $record->id], $title).' <i class="fa fa-pencil"></i>'; |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | $items[] = [ |
@@ -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 | $userObject = $this->_record->getUser(); |
| 58 | 58 | if ($userObject !== null) { |
| 59 | 59 | $userName = $userObject->getProfile()->getNickname(); |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | 'text' => $this->_record->message, |
| 72 | 72 | 'date' => Date::convertToDatetime($this->_record->created_at, Date::FORMAT_TO_HOUR), |
| 73 | 73 | 'pathway' => $this->_record->pathway, |
| 74 | - 'moderate' => (int)$this->_record->moderate, |
|
| 74 | + 'moderate' => (int) $this->_record->moderate, |
|
| 75 | 75 | 'user' => [ |
| 76 | 76 | 'id' => $this->_record->user_id, |
| 77 | 77 | 'name' => $userName, |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | - * Set default values from database record |
|
| 48 | - */ |
|
| 47 | + * Set default values from database record |
|
| 48 | + */ |
|
| 49 | 49 | public function before() |
| 50 | 50 | { |
| 51 | 51 | // set data from db record |
@@ -85,9 +85,9 @@ discard block |
||
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
| 88 | - * Form labels |
|
| 89 | - * @return array |
|
| 90 | - */ |
|
| 88 | + * Form labels |
|
| 89 | + * @return array |
|
| 90 | + */ |
|
| 91 | 91 | public function labels() |
| 92 | 92 | { |
| 93 | 93 | return [ |
@@ -100,9 +100,9 @@ discard block |
||
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
| 103 | - * Content update form validation rules |
|
| 104 | - * @return array |
|
| 105 | - */ |
|
| 103 | + * Content update form validation rules |
|
| 104 | + * @return array |
|
| 105 | + */ |
|
| 106 | 106 | public function rules() |
| 107 | 107 | { |
| 108 | 108 | $r = [ |
@@ -57,13 +57,13 @@ discard block |
||
| 57 | 57 | // set current user id |
| 58 | 58 | $this->authorId = App::$User->identity()->getId(); |
| 59 | 59 | // set true if it is a new content item |
| 60 | - if ($this->_record->id === null || (int)$this->_record->id < 1) { |
|
| 60 | + if ($this->_record->id === null || (int) $this->_record->id < 1) { |
|
| 61 | 61 | $this->_new = true; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | // set random path slug if not defined |
| 65 | 65 | if ($this->path === null || Str::likeEmpty($this->path)) { |
| 66 | - $randPath = date('d-m-Y') . '-' . Str::randomLatin(mt_rand(8,12)); |
|
| 66 | + $randPath = date('d-m-Y').'-'.Str::randomLatin(mt_rand(8, 12)); |
|
| 67 | 67 | $this->path = Str::lowerCase($randPath); |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -107,21 +107,21 @@ discard block |
||
| 107 | 107 | { |
| 108 | 108 | $r = [ |
| 109 | 109 | [['path', 'categoryId'], 'required'], |
| 110 | - ['title.' . App::$Request->getLanguage(), 'required'], |
|
| 111 | - ['text.' . App::$Request->getLanguage(), 'required', null, true, true], |
|
| 110 | + ['title.'.App::$Request->getLanguage(), 'required'], |
|
| 111 | + ['text.'.App::$Request->getLanguage(), 'required', null, true, true], |
|
| 112 | 112 | ['text', 'used', null, true, true], |
| 113 | 113 | ['path', 'direct_match', '/^[a-zA-Z0-9\-]+$/'], |
| 114 | 114 | ['categoryId', 'in', $this->categoryIds()], |
| 115 | 115 | ['path', 'Apps\Model\Front\Content\FormNarrowContentUpdate::validatePath'], |
| 116 | 116 | ['poster', 'used'], |
| 117 | 117 | ['poster', 'isFile', ['jpg', 'png', 'gif', 'jpeg']], |
| 118 | - ['poster', 'sizeFile', (int)$this->_configs['gallerySize'] * 1024] // in bytes |
|
| 118 | + ['poster', 'sizeFile', (int) $this->_configs['gallerySize'] * 1024] // in bytes |
|
| 119 | 119 | ]; |
| 120 | 120 | |
| 121 | 121 | foreach (App::$Properties->get('languages') as $lang) { |
| 122 | - $r[] = ['title.' . $lang, 'length_max', 120, null, true, true]; |
|
| 123 | - $r[] = ['keywords.' . $lang, 'length_max', 150]; |
|
| 124 | - $r[] = ['description.' . $lang, 'length_max', 250]; |
|
| 122 | + $r[] = ['title.'.$lang, 'length_max', 120, null, true, true]; |
|
| 123 | + $r[] = ['keywords.'.$lang, 'length_max', 150]; |
|
| 124 | + $r[] = ['description.'.$lang, 'length_max', 250]; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | return $r; |
@@ -136,9 +136,9 @@ discard block |
||
| 136 | 136 | $this->_record->title = Serialize::encode(App::$Security->strip_tags($this->title)); |
| 137 | 137 | $this->_record->text = Serialize::encode(App::$Security->secureHtml($this->text)); |
| 138 | 138 | $this->_record->path = $this->path; |
| 139 | - $this->_record->category_id = (int)$this->categoryId; |
|
| 139 | + $this->_record->category_id = (int) $this->categoryId; |
|
| 140 | 140 | $this->_record->display = 0; // set to premoderation |
| 141 | - $this->_record->author_id = (int)$this->authorId; |
|
| 141 | + $this->_record->author_id = (int) $this->authorId; |
|
| 142 | 142 | if ($this->_new === true) { |
| 143 | 143 | $this->_record->comment_hash = $this->generateCommentHash(); |
| 144 | 144 | } |
@@ -148,8 +148,8 @@ discard block |
||
| 148 | 148 | // work with poster data |
| 149 | 149 | if ($this->poster !== null) { |
| 150 | 150 | // lets move poster from tmp to gallery |
| 151 | - $originDir = '/upload/gallery/' . $this->_record->id . '/orig/'; |
|
| 152 | - $thumbDir = '/upload/gallery/' . $this->_record->id . '/thumb/'; |
|
| 151 | + $originDir = '/upload/gallery/'.$this->_record->id.'/orig/'; |
|
| 152 | + $thumbDir = '/upload/gallery/'.$this->_record->id.'/thumb/'; |
|
| 153 | 153 | if (!Directory::exist($originDir)) { |
| 154 | 154 | Directory::create($originDir); |
| 155 | 155 | } |
@@ -157,17 +157,17 @@ discard block |
||
| 157 | 157 | Directory::create($thumbDir); |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - $fileName = App::$Security->simpleHash($this->poster->getClientOriginalName() . $this->poster->getSize()); |
|
| 161 | - $newFullName = $fileName . '.' . $this->poster->guessExtension(); |
|
| 160 | + $fileName = App::$Security->simpleHash($this->poster->getClientOriginalName().$this->poster->getSize()); |
|
| 161 | + $newFullName = $fileName.'.'.$this->poster->guessExtension(); |
|
| 162 | 162 | // move poster to upload gallery directory |
| 163 | 163 | $this->poster->move(Normalize::diskFullPath($originDir), $newFullName); |
| 164 | 164 | // initialize image resizer |
| 165 | 165 | $thumb = new Image(); |
| 166 | - $thumb->setCacheDir(root . '/Private/Cache/images'); |
|
| 166 | + $thumb->setCacheDir(root.'/Private/Cache/images'); |
|
| 167 | 167 | |
| 168 | 168 | // open original file, resize it and save |
| 169 | - $thumbSaveName = Normalize::diskFullPath($thumbDir) . '/' . $fileName . '.jpg'; |
|
| 170 | - $thumb->open(Normalize::diskFullPath($originDir) . DIRECTORY_SEPARATOR . $newFullName) |
|
| 169 | + $thumbSaveName = Normalize::diskFullPath($thumbDir).'/'.$fileName.'.jpg'; |
|
| 170 | + $thumb->open(Normalize::diskFullPath($originDir).DIRECTORY_SEPARATOR.$newFullName) |
|
| 171 | 171 | ->cropResize($this->_configs['galleryResize']) |
| 172 | 172 | ->save($thumbSaveName, 'jpg', 90); |
| 173 | 173 | $thumb = null; |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | $data = ContentCategory::getSortedCategories(); |
| 188 | 188 | $response = []; |
| 189 | 189 | foreach ($data as $key=>$val) { |
| 190 | - $response[] = (string)$key; |
|
| 190 | + $response[] = (string) $key; |
|
| 191 | 191 | } |
| 192 | 192 | return $response; |
| 193 | 193 | } |