1 | <?php |
||
2 | |||
3 | use Ffcms\Templex\Url\Url; |
||
0 ignored issues
–
show
|
|||
4 | |||
5 | /** @var \Ffcms\Templex\Template\Template $this */ |
||
6 | /** @var \Apps\Model\Admin\Main\CollectionSearchResults $model */ |
||
7 | |||
8 | $query = $this->e($model->getQuery()); |
||
9 | |||
10 | $this->layout('_layouts/default', [ |
||
11 | 'title' => __('Search: %query%', ['query' => $query]), |
||
12 | 'breadcrumbs' => [ |
||
13 | Url::to('main/index') => __('Main'), |
||
14 | __('Search') |
||
15 | ], |
||
16 | 'query' => $query |
||
17 | ]); |
||
18 | |||
19 | ?> |
||
20 | |||
21 | <?php $this->start('body') ?> |
||
22 | |||
23 | <h1><?= __('Search: %query%', ['query' => $query]) ?></h1> |
||
24 | <div class="row"> |
||
25 | <div class="col"> |
||
26 | <form class="form-inline" method="get" action="<?= Url::link(['main/search']) ?>"> |
||
27 | <input type="text" class="form-control col" name="search" placeholder="<?= __('Enter search query') ?>" value="<?= $query ?>"> |
||
28 | <input type="submit" name="submit" value="<?= __('Search') ?>" class="btn btn-secondary" /> |
||
29 | </form> |
||
30 | </div> |
||
31 | </div> |
||
32 | |||
33 | <?php |
||
34 | $result = $model->getRelevanceBasedResult(); |
||
35 | if (!$result || count($result) < 1) { |
||
36 | echo $this->bootstrap()->alert('warning', __('Nothing found')); |
||
37 | $this->stop(); |
||
38 | return; |
||
39 | } |
||
40 | ?> |
||
41 | <?php foreach ($result as $item): ?> |
||
42 | <?php /** @var \Apps\Model\Admin\Main\AbstractSearchItem $item */ ?> |
||
43 | <div class="row mt-2"> |
||
44 | <div class="col-md-12"> |
||
45 | <div class="search-result"> |
||
46 | <div class="h4"> |
||
47 | <a href="<?= $item->getUrl() ?>"> |
||
48 | <?= $model->highlightText($item->getTitle(), 'span', ['class' => 'search-highlight']) ?> |
||
49 | </a> |
||
50 | <span class="badge badge-secondary"><?= $item->getMarker() ?></span> |
||
51 | <small class="float-right text-secondary"><?= $item->getDate() ?></small> |
||
52 | </div> |
||
53 | <p class="text-muted"><?= $model->highlightText($item->getSnippet(), 'span', ['class' => 'search-highlight']) ?>...</p> |
||
54 | </div> |
||
55 | </div> |
||
56 | </div> |
||
57 | <hr class="mt-0 pt-0" /> |
||
58 | <?php endforeach; ?> |
||
59 | |||
60 | |||
61 | <?php $this->stop() ?> |
||
62 |
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: