1 | <?php |
||||
2 | |||||
3 | use Ffcms\Core\Helper\Date; |
||||
4 | use Ffcms\Core\Helper\Simplify; |
||||
5 | use Ffcms\Core\Helper\Text; |
||||
6 | use Ffcms\Templex\Url\Url; |
||||
0 ignored issues
–
show
|
|||||
7 | |||||
8 | /** @var \Ffcms\Templex\Template\Template $this */ |
||||
9 | /** @var \Apps\ActiveRecord\CommentPost[]|\Illuminate\Support\Collection $records */ |
||||
10 | /** @var array $pagination */ |
||||
11 | |||||
12 | $this->layout('_layouts/default', [ |
||||
13 | 'title' => __('Comments list'), |
||||
14 | 'breadcrumbs' => [ |
||||
15 | Url::to('main/index') => __('Main'), |
||||
16 | Url::to('widget/index') => __('Widgets'), |
||||
17 | __('Comments') |
||||
18 | ] |
||||
19 | ]); |
||||
20 | ?> |
||||
21 | |||||
22 | <?php $this->start('body') ?> |
||||
23 | |||||
24 | <?= $this->insert('comments/_tabs'); ?> |
||||
25 | |||||
26 | <h1><?= __('Comments list') ?></h1> |
||||
27 | |||||
28 | <?php |
||||
29 | if (!$records || $records->count() < 1) { |
||||
30 | echo $this->bootstrap()->alert('warning', __('Comments is not founded')); |
||||
31 | $this->stop(); |
||||
32 | return; |
||||
33 | } |
||||
34 | $items = []; |
||||
35 | $moderateIsFound = false; |
||||
36 | $table = $this->table(['class' => 'table table-striped']) |
||||
37 | ->head([ |
||||
38 | ['text' => '#'], |
||||
39 | ['text' => __('Comment')], |
||||
40 | ['text' => __('Answers')], |
||||
41 | ['text' => __('Author')], |
||||
42 | ['text' => __('Page')], |
||||
43 | ['text' => __('Date')], |
||||
44 | ['text' => __('Actions')], |
||||
45 | ]); |
||||
46 | |||||
47 | foreach ($records as $item) { |
||||
48 | $message = Text::cut(\App::$Security->strip_tags($item->message), 0, 75); |
||||
0 ignored issues
–
show
It seems like
App::Security->strip_tags($item->message) can also be of type array and null ; however, parameter $text of Ffcms\Core\Helper\Text::cut() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
49 | |||||
50 | $moderate = (bool)$item->moderate; |
||||
51 | // if even one moderate item is found - change global flag to true |
||||
52 | if ($moderate) { |
||||
53 | $moderateIsFound = true; |
||||
54 | } |
||||
55 | |||||
56 | $btngrp = $this->bootstrap()->btngroup(['class' => 'btn-group btn-group-sm']); |
||||
57 | |||||
58 | if ($moderate) { |
||||
59 | $btngrp->add('<i class="fa fa-eye-slash" style="color: #aa2222;"></i>', ['comments/display', ['comment', $item->id]], ['class' => 'btn btn-light', 'data-toggle' => 'tooltip', 'title' => __('Comment is hidden'), 'html' => true]); |
||||
60 | } else { |
||||
61 | $btngrp->add('<i class="fa fa-eye" style="color: #1a8007"></i>', ['comments/display', ['comment', $item->id]], ['class' => 'btn btn-light', 'data-toggle' => 'tooltip', 'title' => __('Comment is public'), 'html' => true]); |
||||
62 | } |
||||
63 | |||||
64 | $btngrp->add('<i class="fa fa-list"></i>', ['comments/read', [$item->id]], ['class' => 'btn btn-primary', 'html' => true]) |
||||
65 | ->add('<i class="fa fa-trash-o"></i>', ['comments/delete', ['comment', $item->id]], ['class' => 'btn btn-danger', 'html' => true]); |
||||
66 | |||||
67 | $table->row([ |
||||
68 | ['text' => $item->id], |
||||
69 | ['text' => Url::a(['comments/read', [$item->id]], $message), 'html' => true], |
||||
70 | ['text' => '<span class="badge badge-light">' . $item->getAnswerCount() . '</span>', 'html' => true], |
||||
71 | ['text' => Simplify::parseUserLink((int)$item->user_id, $item->guest_name, 'user/update'), 'html' => true], |
||||
72 | ['text' => '<a href="'.Url::stringUrl($item->app_name . '/comments/' . $item->app_relation_id).'" target="_blank">' . $item->app_name . '/' . $item->app_relation_id . '</a>', 'html' => true], |
||||
73 | ['text' => Date::convertToDatetime($item->created_at, Date::FORMAT_TO_HOUR)], |
||||
74 | ['text' => $btngrp->display(), 'html' => true |
||||
75 | ], |
||||
76 | 'properties' => ['class' => 'checbox-row'] |
||||
77 | ]); |
||||
78 | } |
||||
79 | |||||
80 | $table->selectize(0, 'selected'); |
||||
81 | ?> |
||||
82 | |||||
83 | <div class="table-responsive"> |
||||
84 | <?= $table->display() ?> |
||||
85 | </div> |
||||
86 | |||||
87 | <?= $this->javascript()->submitSelectizeTable('input[name="selected[]"]', 'selected', __('Delete selected'), ['comments/delete', ['comment']], ['class' => 'btn btn-danger']) ?> |
||||
88 | <?php if ($moderateIsFound) { |
||||
89 | echo $this->javascript()->submitSelectizeTable('input[name="selected[]"]', 'selected', __('Publish'), ['comments/publish', ['comment']], ['class' => 'btn btn-warning']); |
||||
90 | } ?> |
||||
91 | |||||
92 | <?= $this->bootstrap()->pagination($pagination['url'], ['class' => 'pagination justify-content-center']) |
||||
93 | ->size($pagination['total'], $pagination['page'], $pagination['step']) |
||||
94 | ->display(); ?> |
||||
95 | |||||
96 | |||||
97 | <?php $this->stop() ?> |
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: