aboutsummaryrefslogtreecommitdiff
path: root/templates/shared/action-menu-single.php
blob: dbe38c1453167cf4acce41a4df7f1b376802fc58 (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
<?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['disabled']): ?>
        <label class="undecorated action-menu-item-disabled" aria-disabled="true" <?= arrayToHtmlAttributes($action['attributes'] + ['title' => $action['label']]) ?>>
        <? if ($action['icon']): ?>
            <?= $action['icon']->asImg(['class' => 'action-menu-item-icon']) ?>
        <? else: ?>
            <?= htmlReady($action['label']) ?>
        <? endif ?>
        </label>
    <? elseif ($action['type'] === 'link'): ?>
        <a href="<?= htmlReady($action['link']) ?>" <?= arrayToHtmlAttributes($action['attributes'] + ['title' => $action['label']]) ?>>
            <? if ($action['icon']): ?>
                <?= $action['icon']->asImg(['class' => 'action-menu-item-icon']) ?>
            <? else: ?>
                <?= htmlReady($action['label']) ?>
            <? endif ?>
        </a>
    <? elseif ($action['type'] === 'button'): ?>
        <? if ($action['icon']): ?>
            <?= $action['icon']->asInput($action['attributes'] + [
                'class' => 'action-menu-item-icon',
                '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) ?>
    <? elseif ($action['type'] === 'separator'): ?>
        <span class="quiet">|</span>
    <? endif ?>
<? endforeach ?>