1 | <?php |
||
2 | |||
3 | use Ffcms\Templex\Url\Url; |
||
0 ignored issues
–
show
|
|||
4 | |||
5 | /** @var \Ffcms\Templex\Template\Template $this */ |
||
6 | /** @var Apps\ActiveRecord\ProfileField $records */ |
||
7 | |||
8 | $this->layout('_layouts/default', [ |
||
9 | 'title' => __('Profile fields'), |
||
10 | 'breadcrumbs' => [ |
||
11 | Url::to('main/index') => __('Main'), |
||
12 | Url::to('application/index') => __('Applications'), |
||
13 | Url::to('profile/index') => __('Profile list'), |
||
14 | __('Profile fields') |
||
15 | ] |
||
16 | ]); |
||
17 | ?> |
||
18 | |||
19 | <?php $this->start('body') ?> |
||
20 | |||
21 | <?= $this->insert('profile/_tabs') ?> |
||
22 | <h1><?= __('Additional profile fields') ?></h1> |
||
23 | <div class="row"> |
||
24 | <div class="col-md-12"> |
||
25 | <?= Url::a(['profile/fieldupdate'], __('Add field'), ['class' => 'btn btn-primary', 'html' => true]) ?> |
||
26 | </div> |
||
27 | </div> |
||
28 | |||
29 | <?php if ($records->count() < 1) { |
||
30 | echo $this->bootstrap()->alert('warning', __('No additional fields is add yet!')); |
||
31 | $this->stop(); |
||
32 | return; |
||
33 | } ?> |
||
34 | |||
35 | <?php |
||
36 | $table = $this->table(['class' => 'table table-striped']) |
||
37 | ->head([ |
||
38 | ['text' => '#'], |
||
39 | ['text' => __('Title')], |
||
40 | ['text' => __('Type')], |
||
41 | ['text' => __('Rule')], |
||
42 | ['text' => __('Actions'), 'properties' => ['class' => 'text-center']] |
||
43 | ]); |
||
44 | |||
45 | foreach ($records as $row) { |
||
46 | $labelClass = 'badge '; |
||
47 | $labelClass .= ($row->type === 'link' ? 'badge-primary' : 'badge-secondary'); |
||
48 | |||
49 | $table->row([ |
||
50 | ['text' => $row->id], |
||
51 | ['text' => $row->getLocaled('name')], |
||
52 | ['text' => '<span class="' . $labelClass . '">' . $row->type . '</span>', 'html' => true], |
||
53 | ['text' => '<code>' . ($row->reg_cond == 0 ? '!' : null) . 'preg_match("' . $row->reg_exp . '", input)' . '</code>', 'html' => true], |
||
54 | ['text' => $this->bootstrap()->btngroup(['class' => 'btn-group btn-group-sm']) |
||
55 | ->add('<i class="fa fa-pencil"></i>', ['profile/fieldupdate', [$row->id]], ['class' => 'btn btn-primary', 'html' => true]) |
||
56 | ->add('<i class="fa fa-trash-o"></i>', ['profile/fielddelete', [$row->id]], ['class' => 'btn btn-danger', 'html' => true]) |
||
57 | ->display(), |
||
58 | 'html' => true, |
||
59 | 'properties' => ['class' => 'text-center'] |
||
60 | ] |
||
61 | ]); |
||
62 | } |
||
63 | ?> |
||
64 | |||
65 | <div class="table-responsive"> |
||
66 | <?= $table->display(); ?> |
||
67 | </div> |
||
68 | |||
69 | <?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: