aboutsummaryrefslogtreecommitdiff
path: root/app/views/files_dashboard/search.php
blob: ec738d4e20bc1bde967bb131236db232776c1ec4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<? $filter = $query->getFilter() ?>
<form class="default files-search-search" novalidate="novalidate">
    <label>
        <input type="hidden"
               name="filter[category]"
               value="<?= $filter->getCategory() ?: '' ?>">

        <input type="hidden"
               name="filter[semester]"
               value="<?= $filter->getSemester() ? $filter->getSemester()->id : '' ?>">

        <?= $this->render_partial('files_dashboard/_input-group-search', ['query' => $query->getQuery()]) ?>
    </label>
</form>

<? if ($query->hasError()) : ?>
    <?= MessageBox::error($query->getError()) ?>
<? endif ?>

<? if (isset($result)) : ?>

    <? $resultPage = $result->getResultPage() ?>

    <? if (count($resultPage) || $query->getOffset()) : ?>
        <? $counter = $query->getOffset() ?>
        <div class="table-scrollbox-horizontal">
            <table class="default flat files-search-results">
                <caption>
                    <?= $this->render_partial('files_dashboard/_search_active_filters') ?>

                    <? if ($result->hasMore()) : ?>
                        <span><?= _('Suchergebnisse') ?></span>
                    <? else : ?>
                        <span><?= sprintf('Suchergebnis: %d Treffer', $result->getTotal()) ?></span>
                    <? endif ?>
                </caption>

                <thead>
                    <tr>
                        <th><?= _('Typ') ?></th>
                        <th><?= _('Name') ?></th>
                        <th><?= _('Beschreibung') ?></th>
                        <th><?= _('Ort') ?></th>
                        <th><?= _('Autor/-in') ?></th>
                        <th><?= _('Datum') ?></th>
                        <th><?= _('Aktionen') ?></th>
                    </tr>
                </thead>

                <tbody>
                    <? foreach ($resultPage as $searchResult) : ?>
                        <?= $this->render_partial(
                            'files_dashboard/_search_tr.php',
                            ['counter' => $counter++, 'searchResult' => $searchResult,]
                        ) ?>
                    <? endforeach ?>
                </tbody>

                <tfoot>
                    <tr>
                        <td colspan="7">
                            <? if ($result->hasMore()) : ?>
                                <?= \Studip\LinkButton::create(
                                    _('Weitere Ergebnisse suchen'),
                                    \URLHelper::getUrl(
                                        'dispatch.php/files_dashboard/search',
                                        [
                                            'q' => $query->getQuery(),
                                            'filter' => $filter->toArray(),
                                            'page' => $query->getPage() + 1
                                        ]
                                    ),
                                    ['class' => 'files-search-more']
                                ) ?>

                            <? else :  ?>
                                <div><?= sprintf('%d Treffer', $result->getTotal()) ?></div>
                            <? endif ?>
                        </td>
                    </tr>
                </tfoot>

            </table>
        </div>
    <? else : ?>
        <?= $this->render_partial('files_dashboard/_search_active_filters') ?>

        <?= MessageBox::info(_('Leider keine Treffer.')) ?>
        </div>
    <? endif ?>
<? endif ?>