phpffcms /
ffcms
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | use Ffcms\Core\Helper\Date; |
||
| 3 | use Ffcms\Core\Helper\HTML\Table; |
||
| 4 | use Ffcms\Core\Helper\Text; |
||
| 5 | use Ffcms\Core\Helper\Type\Str; |
||
| 6 | use Ffcms\Core\Helper\Url; |
||
| 7 | |||
| 8 | /** @var \Apps\ActiveRecord\CommentPost $records */ |
||
| 9 | /** @var \Ffcms\Core\Helper\HTML\SimplePagination $pagination */ |
||
| 10 | |||
| 11 | $this->title = __('Comments list'); |
||
| 12 | $this->breadcrumbs = [ |
||
| 13 | Url::to('main/index') => __('Main'), |
||
| 14 | Url::to('widget/index') => __('Widgets'), |
||
| 15 | __('Comments') |
||
| 16 | ]; |
||
| 17 | |||
| 18 | ?> |
||
| 19 | |||
| 20 | <?= $this->render('comments/_tabs') ?> |
||
| 21 | |||
| 22 | <h1><?= __('Comments list') ?></h1> |
||
| 23 | <hr /> |
||
| 24 | |||
| 25 | <?php |
||
| 26 | View Code Duplication | if ($records === null || $records->count() < 1) { |
|
|
0 ignored issues
–
show
|
|||
| 27 | echo '<p class="alert alert-warning">' . __('Comments is not founded') . '</p>'; |
||
| 28 | return; |
||
| 29 | } |
||
| 30 | $items = []; |
||
| 31 | foreach ($records as $item) { |
||
| 32 | $message = Text::cut(\App::$Security->strip_tags($item->message), 0, 75); |
||
| 33 | $userArr = []; |
||
| 34 | if ((int)$item->user_id > 0 && \App::$User->isExist($item->user_id)) { |
||
| 35 | $userName = \App::$User->identity($item->user_id)->getProfile()->getNickname(); |
||
| 36 | $userArr = ['text' => Url::link(['user/update', $item->user_id], $userName), 'html' => true]; |
||
| 37 | } |
||
| 38 | |||
| 39 | $items[] = [ |
||
| 40 | 1 => ['text' => $item->id], |
||
| 41 | 2 => ['text' => Url::link(['comments/list', $item->id], $message), 'html' => true], |
||
| 42 | 3 => ['text' => $item->getAnswerCount()], |
||
| 43 | 4 => $userArr, |
||
| 44 | 5 => ['text' => '<a href="' . App::$Alias->scriptUrl . $item->pathway . '" target="_blank">' . Str::sub($item->pathway, 0, 20) . '...</a>', 'html' => true], |
||
| 45 | 6 => ['text' => Date::convertToDatetime($item->created_at, Date::FORMAT_TO_HOUR)], |
||
| 46 | 7 => ['text' => Url::link(['comments/list', $item->id], '<i class="fa fa-list fa-lg"></i>') . |
||
| 47 | ' ' . Url::link(['comments/delete', 'comment', $item->id], '<i class="fa fa-trash-o fa-lg"></i>'), |
||
| 48 | 'html' => true, 'property' => ['class' => 'text-center']], |
||
| 49 | 'property' => ['class' => 'checkbox-row'] |
||
| 50 | ]; |
||
| 51 | } |
||
| 52 | |||
| 53 | ?> |
||
| 54 | |||
| 55 | <div class="table-responsive"> |
||
| 56 | <?= Table::display([ |
||
| 57 | 'table' => ['class' => 'table table-bordered table-hover'], |
||
| 58 | 'thead' => [ |
||
| 59 | 'titles' => [ |
||
| 60 | ['text' => '#'], |
||
| 61 | ['text' => __('Comment')], |
||
| 62 | ['text' => __('Answers')], |
||
| 63 | ['text' => __('Author')], |
||
| 64 | ['text' => __('Page')], |
||
| 65 | ['text' => __('Date')], |
||
| 66 | ['text' => __('Actions')], |
||
| 67 | ] |
||
| 68 | ], |
||
| 69 | 'tbody' => [ |
||
| 70 | 'items' => $items |
||
| 71 | ], |
||
| 72 | 'selectableBox' => [ |
||
| 73 | 'attachOrder' => 1, |
||
| 74 | 'form' => ['method' => 'GET', 'class' => 'form-horizontal', 'action' => Url::to('comments/delete', 'comments')], |
||
| 75 | 'input' => ['type' => 'checkbox', 'name' => 'selectRemove[]', 'class' => 'massSelectId'], |
||
| 76 | 'button' => ['type' => 'submit', 'class' => 'btn btn-danger', 'value' => __('Delete selected')] |
||
| 77 | ] |
||
| 78 | ]); ?> |
||
| 79 | </div> |
||
| 80 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.