diff options
| author | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2025-10-13 18:19:16 +0200 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2025-10-13 18:19:16 +0200 |
| commit | 94c1ca0a6db6f4aee91ec13858419dda1062858d (patch) | |
| tree | 39f960409bcbe4aff9cdb0b14208677eb8f2abe1 /templates | |
| parent | 4770dc276787edb1350d89d4ed77c194d33e1b25 (diff) | |
fix search widget (and add php doc), fixes #5923
Closes #5923
Merge request studip/studip!4539
Diffstat (limited to 'templates')
| -rw-r--r-- | templates/sidebar/search-widget.php | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/templates/sidebar/search-widget.php b/templates/sidebar/search-widget.php index 784b646..d150055 100644 --- a/templates/sidebar/search-widget.php +++ b/templates/sidebar/search-widget.php @@ -1,11 +1,28 @@ +<?php +/** + * @var string $url + * @var string $method + * @var array $url_params + * @var array $needles + * @var array $filters + * @var array $quick_search + * @var string $reset_link + * @var string $onsubmit + * @var string $onclear + * @var bool $has_data + */ +?> +<?php + $id ??= 'form-' . md5(uniqid()); +?> <form action="<?= URLHelper::getLink($url) ?>" method="<?= $method ?>" - <? $id = $id ?? 'form-'.md5(uniqid()) ?> <? printf('id="%s"', htmlReady($id)) ?> - <?= $onsubmit ? 'onsubmit="'.htmlReady($onsubmit).'"' : '' ?> - class="sidebar-search"> + <?= $onsubmit ? 'onsubmit="' . htmlReady($onsubmit) . '"' : '' ?> + class="sidebar-search" +> <? foreach ($url_params as $key => $value): ?> - <?=addHiddenFields($key,$value)?> + <?= addHiddenFields($key, $value) ?> <? endforeach; ?> <ul class="needles"> <? foreach ($needles as $needle): ?> @@ -23,22 +40,7 @@ value="<?= htmlReady($needle['value']) ?>" <? if ($needle['placeholder']) printf('placeholder="%s"', htmlReady($needle['label'])); ?> <?= arrayToHtmlAttributes($needle['attributes']) ?>> - <? endif; ?> - <? if ($reset_link): ?> - <? if ($onsubmit) : ?> - <?= Icon::create('decline')->asInput([ - 'title' => _('Suche zurücksetzen'), - 'class' => 'reset-search', - 'onclick' => "window.document.getElementById('needle-".$hash."').value = '';" - ], without_label: true) ?> - <? else : ?> - <a class="reset-search" href="<?= $reset_link ?>" tabindex="0" role="button" - <?= $onsubmit ? 'onclick="'."window.document.getElementById('needle-".$hash."').value = ''; window.document.getElementById('".$id."').submit(); return false; ".'"' : '' ?> - title="<?= _('Suche zurücksetzen') ?>"> - <?= Icon::create('decline') ?> - </a> - <? endif ?> - <? endif; ?> + <? endif; ?> <button type="submit" class="submit-search<?= $reset_link ? ' is-executed' : '' ?>" title="<?= _('Suche ausführen') ?>"> <?= Icon::create('search') ?> @@ -75,11 +77,11 @@ <? endif; ?> <? if (!empty($quick_search)): ?> <script> -(function ($) { +(() => { <? foreach ($quick_search as $needle): ?> STUDIP.QuickSearch.autocomplete('needle-<?= md5($url . '|' . $needle['name']) ?>', '<?= $url ?>'); <? endforeach; ?> -}(jQuery)); +})(); </script> <? endif; ?> </form> |
