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\CommentAnswer[]|\Illuminate\Support\Collection $records */ |
||
10 | /** @var array $pagination */ |
||
11 | |||
12 | $this->layout('_layouts/default', [ |
||
13 | 'title' => __('Answers list'), |
||
14 | 'breadcrumbs' => [ |
||
15 | Url::to('main/index') => __('Main'), |
||
16 | Url::to('widget/index') => __('Widgets'), |
||
17 | Url::to('comments/index') => __('Comments'), |
||
18 | __('Answers') |
||
19 | ] |
||
20 | ]); |
||
21 | ?> |
||
22 | |||
23 | <?php $this->start('body') ?> |
||
24 | |||
25 | <?= $this->insert('comments/_tabs') ?> |
||
26 | |||
27 | <h1><?= __('Answers list') ?></h1> |
||
28 | <?php |
||
29 | if (!$records || $records->count() < 1) { |
||
30 | echo $this->bootstrap()->alert('warning', __('Answers 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' => __('Answer')], |
||
40 | ['text' => __('Author')], |
||
41 | ['text' => __('Date')], |
||
42 | ['text' => __('Actions')] |
||
43 | ]); |
||
44 | |||
45 | foreach ($records as $item) { |
||
46 | /** @var \Apps\ActiveRecord\CommentAnswer $item */ |
||
47 | $message = Text::cut(\App::$Security->strip_tags($item->message), 0, 75); |
||
48 | $moderate = (bool)$item->moderate; |
||
49 | if ($moderate) { |
||
50 | $moderateIsFound = true; |
||
51 | } |
||
52 | |||
53 | $btngrp = $this->bootstrap()->btngroup(['class' => 'btn-group btn-group-sm']); |
||
54 | if ($moderate) { |
||
55 | $btngrp->add('<i class="fa fa-eye-slash" style="color: #aa2222;"></i>', ['comments/display', ['answer', $item->id]], ['class' => 'btn btn-light', 'data-toggle' => 'tooltip', 'title' => __('Answer is hidden'), 'html' => true]); |
||
56 | } else { |
||
57 | $btngrp->add('<i class="fa fa-eye" style="color: #1a8007"></i>', ['comments/display', ['answer', $item->id]], ['class' => 'btn btn-light', 'data-toggle' => 'tooltip', 'title' => __('Answer is public'), 'html' => true]); |
||
58 | } |
||
59 | $btngrp->add('<i class="fa fa-list"></i>', ['comments/read', [$item->post->id]], ['class' => 'btn btn-primary', 'html' => true]) |
||
60 | ->add('<i class="fa fa-trash-o"></i>', ['comments/delete', ['answer', $item->id]], ['class' => 'btn btn-danger', 'html' => true]); |
||
61 | |||
62 | $table->row([ |
||
63 | ['text' => $item->id], |
||
64 | ['text' => '<div>' . Url::a(['comments/read', [$item->comment_id]], $message) . '</div><small class="text-muted">→' . Text::snippet(\App::$Security->strip_tags($item->post->message), 50) . '</small>' , 'html' => true], |
||
65 | ['text' => Simplify::parseUserLink((int)$item->user_id, $item->guest_name, 'user/update'), 'html' => true], |
||
66 | ['text' => Date::convertToDatetime($item->created_at, Date::FORMAT_TO_HOUR)], |
||
67 | ['text' => $btngrp->display(), 'html' => true |
||
68 | ] |
||
69 | ]); |
||
70 | } |
||
71 | |||
72 | $table->selectize(0, 'selected'); |
||
73 | ?> |
||
74 | |||
75 | <div class="table-responsive"> |
||
76 | <?= $table->display() ?> |
||
77 | </div> |
||
78 | |||
79 | <?= $this->javascript()->submitSelectizeTable('input[name="selected[]"]', 'selected', __('Delete selected'), ['comments/delete', ['answer']], ['class' => 'btn btn-danger']) ?> |
||
80 | <?php if ($moderateIsFound) { |
||
81 | echo $this->javascript()->submitSelectizeTable('input[name="selected[]"]', 'selected', __('Publish'), ['comments/publish', ['answer']], ['class' => 'btn btn-warning']); |
||
82 | } ?> |
||
83 | |||
84 | <?= $this->bootstrap()->pagination($pagination['url'], ['class' => 'pagination justify-content-center']) |
||
85 | ->size($pagination['total'], $pagination['page'], $pagination['step']) |
||
86 | ->display(); ?> |
||
87 | |||
88 | <?php $this->stop() ?> |
||
89 |
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: