aboutsummaryrefslogtreecommitdiff
path: root/templates/shared/action-menu-single.php
blob: 05c74962b2563f9ef32a827805a268946fc03025 (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
<?php
/**
 * @var array<array{
 *     type: string,
 *     label: string,
 *     link?: string,
 *     name?: string,
 *     object?: MultiPersonSearch,
 *     icon: Icon,
 *     attributes: array
 * }> $actions
 */
?>
<? foreach ($actions as $action): ?>
    <? if ($action['type'] === 'link'): ?>
        <a href="<?= htmlReady($action['link']) ?>" <?= arrayToHtmlAttributes($action['attributes'] + ['title' => $action['label']]) ?>>
            <? if ($action['icon']): ?>
                <?= $action['icon']->asImg(false) ?>
            <? else: ?>
                <?= htmlReady($action['label']) ?>
            <? endif ?>
        </a>
    <? elseif ($action['type'] === 'button'): ?>
        <? if ($action['icon']): ?>
            <?= $action['icon']->asInput(false, $action['attributes'] + ['name' => $action['name'], 'title' => $action['label']]) ?>
        <? else: ?>
            <button name="<?= htmlReady($action['name']) ?>" <?= arrayToHtmlAttributes($action['attributes']) ?>>
                <?= htmlReady($action['label']) ?>
            </button>
        <? endif ?>
    <? elseif ($action['type'] === 'multi-person-search'): ?>
        <?= $action['object']->render(false) ?>
    <? endif ?>
<? endforeach ?>