1 | <?php |
||
2 | |||
3 | use Ffcms\Core\Helper\Date; |
||
4 | use Ffcms\Core\Helper\Type\Str; |
||
5 | use Ffcms\Templex\Url\Url; |
||
0 ignored issues
–
show
|
|||
6 | |||
7 | /** @var $id string */ |
||
8 | /** @var string|null $add */ |
||
9 | /** @var \Ffcms\Templex\Template\Template $this */ |
||
10 | /** @var \Apps\ActiveRecord\Profile[]|\Illuminate\Support\Collection $records */ |
||
11 | /** @var array $pagination */ |
||
12 | /** @var bool $ratingOn */ |
||
13 | |||
14 | $title = __('User list'); |
||
15 | if ($id === 'all') { |
||
16 | $title .= ': ' . __('All'); |
||
17 | } elseif ($id === 'rating') { |
||
18 | $title .= ': ' . __('Rating'); |
||
19 | } elseif ($id === 'city') { |
||
20 | $title .= ': ' . __('City') . ' ' . $this->e(urldecode($add)); |
||
21 | } elseif ($id === 'hobby') { |
||
22 | $title .= ': ' . __('Hobby') . ' ' . $this->e(urldecode($add)); |
||
23 | } |
||
24 | |||
25 | $this->layout('_layouts/default', [ |
||
26 | 'title' => $title, |
||
27 | 'breadcrumbs' => [ |
||
28 | Url::to('main/index') => __('Home'), |
||
29 | $title |
||
30 | ] |
||
31 | ]); |
||
32 | |||
33 | ?> |
||
34 | |||
35 | <?php $this->start('body') ?> |
||
36 | |||
37 | <?php $this->insert('profile/menus/index', ['rating' => $ratingOn]) ?> |
||
38 | |||
39 | <?php |
||
40 | if (!$records || $records->count() < 1) { |
||
41 | echo $this->bootstrap()->alert('danger', __('Users are not founded!')); |
||
42 | $this->stop(); |
||
43 | return; |
||
44 | } |
||
45 | ?> |
||
46 | |||
47 | <?php foreach ($records as $profile) :?> |
||
48 | <div class="row pt-1"> |
||
49 | <div class="col-md-2"> |
||
50 | <div class="text-center"><img src="<?= $profile->getAvatarUrl('small') ?>" class="img-fluid img-circle img-thumbnail"/></div> |
||
51 | </div> |
||
52 | <div class="col-md-8"> |
||
53 | <h3> |
||
54 | <?= Url::a( |
||
55 | ['profile/show', [$profile->user_id]], |
||
56 | (Str::likeEmpty($profile->nick) ? __('No name') . '(id' . $profile->user_id . ')' : $profile->nick), |
||
57 | ['style' => 'color: ' . $profile->user->role->color] |
||
58 | ) ?> |
||
59 | </h3> |
||
60 | <p><?= __('Registered') ?>: <?= Date::convertToDatetime($profile->created_at, Date::FORMAT_TO_DAY) ?></p> |
||
61 | <?php if (\App::$User->identity() !== null && $profile->user_id !== \App::$User->identity()->getId()): ?> |
||
62 | <?= Url::a(['profile/messages', null, ['newdialog' => $profile->user_id]], '<i class="fa fa-envelope"></i> ' . __('New message'), ['class' => 'btn btn-info', 'html' => true]) ?> |
||
63 | <?php endif; ?> |
||
64 | </div> |
||
65 | <div class="col-md-2"> |
||
66 | <div class="h3 float-right"> |
||
67 | <?php |
||
68 | $markLabel = 'badge-light'; |
||
69 | if ($profile->rating > 0) { |
||
70 | $markLabel = 'badge-success'; |
||
71 | } elseif ($profile->rating < 0) { |
||
72 | $markLabel = 'badge-danger'; |
||
73 | } |
||
74 | ?> |
||
75 | <span class="badge <?= $markLabel ?>"> |
||
76 | <?= $profile->rating > 0 ? '+' : null ?><?= $profile->rating ?> |
||
77 | </span> |
||
78 | </div> |
||
79 | </div> |
||
80 | </div> |
||
81 | <hr/> |
||
82 | <?php endforeach; ?> |
||
83 | |||
84 | <?= $this->bootstrap()->pagination(['profile/index', [$id]], ['class' => 'pagination justify-content-center']) |
||
85 | ->size($pagination['total'], $pagination['page'], $pagination['step']) |
||
86 | ->display(); ?> |
||
87 | |||
88 | <?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: