1 | <?php |
||
2 | |||
3 | /** @var \Ffcms\Templex\Template\Template $this */ |
||
4 | /** @var array $categories */ |
||
5 | |||
6 | use Ffcms\Core\Helper\Type\Str; |
||
7 | use Ffcms\Templex\Url\Url; |
||
0 ignored issues
–
show
|
|||
8 | |||
9 | $this->layout('_layouts/default', [ |
||
10 | 'title' => __('Category list'), |
||
11 | 'breadcrumbs' => [ |
||
12 | Url::to('main/index') => __('Main'), |
||
13 | Url::to('application/index') => __('Applications'), |
||
14 | Url::to('content/index') => __('Contents'), |
||
15 | __('Categories') |
||
16 | ] |
||
17 | ]); |
||
18 | |||
19 | ?> |
||
20 | |||
21 | <?php $this->start('body') ?> |
||
22 | |||
23 | <?= $this->insert('content/_tabs') ?> |
||
24 | |||
25 | <h1><?= __('Category list') ?></h1> |
||
26 | <div class="row"> |
||
27 | <div class="col-md-12"> |
||
28 | <?= Url::a(['content/categoryupdate'], '<i class="fa fa-plus"></i> ' . __('Add category'), ['class' => 'btn btn-primary', 'html' => true]) ?> |
||
29 | </div> |
||
30 | </div> |
||
31 | <div class="table-responsive"> |
||
32 | <table class="table table-striped table-hover"> |
||
33 | <thead> |
||
34 | <tr> |
||
35 | <th class="col-md-10"><?= __('Category') ?></th> |
||
36 | <th class="col-md-2 text-center"><?= __('Actions') ?></th> |
||
37 | </tr> |
||
38 | </thead> |
||
39 | <tbody> |
||
40 | <?php |
||
41 | foreach ($categories as $path => $row): |
||
42 | $offset = 2; |
||
43 | $nesting = 0; |
||
44 | if ($row->path === '') { |
||
45 | --$offset; |
||
46 | } else { |
||
47 | $nesting = Str::entryCount($row->path, '/'); |
||
48 | $offset += $nesting; |
||
49 | |||
50 | } |
||
51 | if ($offset > 8) { |
||
52 | $offset = 8; |
||
53 | } |
||
54 | $set = 12 - $offset; |
||
55 | ?> |
||
56 | <tr> |
||
57 | <td> |
||
58 | <div class="row"> |
||
59 | <div class="d-none d-md-block col-md-<?= $offset ?> col-xs-<?= $offset+2 ?> " style="border-bottom: 2px solid #8a8a8a;height: 1px;padding-top: 10px;"></div> |
||
60 | <div class="col-md-<?= $set ?> col-xs-<?= $set-2 ?>"> |
||
61 | <?= $row->getLocaled('title') ?> |
||
62 | <sup>id: <?= $row->id ?></sup> |
||
63 | <a href="<?= \App::$Alias->scriptUrl . '/content/list/' . $row->path ?>" target="_blank" class="badge badge-secondary">/<?= $row->path ?></a> |
||
64 | </div> |
||
65 | </div> |
||
66 | </td> |
||
67 | <td class="text-center"> |
||
68 | <?php $btn = $this->bootstrap()->btngroup(['class' => 'btn-group btn-group-sm', 'dropdown' => ['class' => 'btn-group btn-group-sm'], 'role' => 'group'], 4) |
||
69 | ->add('<i class="fa fa-eye"></i>', [\App::$Alias->scriptUrl . '/content/list/' . $row->path], ['html' => true, 'target' => '_blank']) |
||
70 | ->add('<i class="fa fa-plus"></i>', ['content/categoryupdate', null, ['parent' => $row->id]], ['class' => 'btn btn-success', 'data-toggle' => 'tooltip', 'title' => __('Add subcategory'), 'html' => true]) |
||
71 | ->add('<i class="fa fa-cog"></i>', ['content/categoryupdate', [$row->id]], ['class' => 'btn btn-primary', 'data-toggle' => 'tooltip', 'title' => __('Category configurations'), 'html' => true]); |
||
72 | if ($row->id > 1) { |
||
73 | $btn = $btn->add('<i class="fa fa-trash-o"></i>', ['content/categorydelete', [$row->id]], ['class' => 'btn btn-danger', 'data-toggle' => 'tooltip', 'title' => __('Delete category'), 'html' => true]); |
||
74 | } |
||
75 | echo $btn->display(); |
||
76 | ?> |
||
77 | </td> |
||
78 | </tr> |
||
79 | <?php endforeach ?> |
||
80 | </tbody> |
||
81 | </table> |
||
82 | </div> |
||
83 | |||
84 | <?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: