1 | <?php |
||
2 | |||
3 | use Ffcms\Core\Helper\Date; |
||
4 | use Ffcms\Templex\Url\Url; |
||
0 ignored issues
–
show
|
|||
5 | |||
6 | /** @var \Apps\ActiveRecord\User[]|\Illuminate\Support\Collection $records */ |
||
7 | /** @var array $pagination */ |
||
8 | /** @var \Ffcms\Templex\Template\Template $this */ |
||
9 | /** @var string $search */ |
||
10 | |||
11 | $this->layout('_layouts/default', [ |
||
12 | 'title' => __('User list'), |
||
13 | 'breadcrumbs' => [ |
||
14 | Url::to('main/index') => __('Main'), |
||
15 | Url::to('application/index') => __('Applications'), |
||
16 | __('User list') |
||
17 | ] |
||
18 | ]); |
||
19 | ?> |
||
20 | |||
21 | <?php $this->start('body') ?> |
||
22 | <?= $this->insert('user/_tabs') ?> |
||
23 | <h1><?= __('User list') ?></h1> |
||
24 | <div class="row"> |
||
25 | <div class="col-md-8"> |
||
26 | <?= Url::a(['user/update'], __('Add user'), ['class' => 'btn btn-primary']) ?> |
||
27 | </div> |
||
28 | <div class="col-md-4"> |
||
29 | <form accept-charset="UTF-8" method="get"> |
||
30 | <div class="input-group"> |
||
31 | <input type="text" name="search" id="search" value="<?= $this->e($search) ?>" placeholder="login, email ..." class="form-control mr-sm-1"> |
||
32 | <span class="input-group-btn"> |
||
33 | <input type="submit" name="dosearch" value="<?= __('Search') ?>" class="btn btn-primary"> |
||
34 | </span> |
||
35 | </div> |
||
36 | </form> |
||
37 | </div> |
||
38 | </div> |
||
39 | |||
40 | <?php if ($records->count() < 1) { |
||
41 | echo $this->bootstrap()->alert('warning', __('No users found')); |
||
42 | $this->stop(); |
||
43 | return; |
||
44 | } ?> |
||
45 | |||
46 | <?php |
||
47 | $table = $this->table(['class' => 'table table-striped']) |
||
48 | ->head([ |
||
49 | ['text' => '#'], |
||
50 | ['text' => __('Email')], |
||
51 | ['text' => __('Login')], |
||
52 | ['text' => __('Role')], |
||
53 | ['text' => __('Register date')], |
||
54 | ['text' => __('Actions'), 'properties' => ['class' => 'text-center']] |
||
55 | ]); |
||
56 | |||
57 | foreach ($records as $user) { |
||
58 | $roleHtml = $user->role->color ? '<span class="badge badge-light" style="color: ' . $user->role->color . '">' . $user->role->name . '</span>' : $user->role->name; |
||
59 | |||
60 | $btngrp = $this->bootstrap()->btngroup(['class' => 'btn-group btn-group-sm'], 4) |
||
61 | ->add('<i class="fa fa-pencil"></i>', ['user/update', [$user->id]], ['class' => 'btn btn-primary', 'html' => true]) |
||
62 | ->add('<i class="fa fa-eraser"></i>', ['user/clear', [$user->id]], ['class' => 'btn btn-warning', 'html' => true]) |
||
63 | ->add('<i class="fa fa-trash-o"></i>', ['user/delete', [$user->id]], ['class' => 'btn btn-danger', 'html' => true]); |
||
64 | |||
65 | // user not approved - show approve button |
||
66 | if ($user->approve_token) { |
||
67 | $btngrp->add('<i class="fa fa-check"></i>', ['user/approve', [$user->id]], ['class' => 'btn btn-success', 'html' => true]); |
||
68 | } |
||
69 | |||
70 | $table->row([ |
||
71 | ['text' => $user->id], |
||
72 | ['text' => $user->email], |
||
73 | ['text' => $user->login], |
||
74 | ['text' => $roleHtml, 'html' => true], |
||
75 | ['text' => Date::convertToDatetime($user->created_at, Date::FORMAT_TO_DAY)], |
||
76 | ['text' => $btngrp->display(), |
||
77 | 'properties' => ['class' => 'text-center'], 'html' => true], |
||
78 | 'properties' => ['class' => 'checkbox-row' . ($user->approve_token !== null ? ' bg-warning' : null)] |
||
79 | |||
80 | ]); |
||
81 | } |
||
82 | $table->selectize(0, 'selected'); |
||
83 | ?> |
||
84 | |||
85 | <div class="table-responsive"> |
||
86 | <?= $table->display(); ?> |
||
87 | </div> |
||
88 | |||
89 | <?= $this->javascript()->submitSelectizeTable('input[name="selected[]"]', 'selected', __('Delete selected'), ['user/delete'], ['class' => 'btn btn-danger']) ?> |
||
90 | |||
91 | <?= $this->bootstrap()->pagination($pagination['url'], ['class' => 'pagination justify-content-center']) |
||
92 | ->size($pagination['total'], $pagination['page'], $pagination['step']) |
||
93 | ->display(); ?> |
||
94 | |||
95 | <?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: