aboutsummaryrefslogtreecommitdiff
path: root/templates/shared/contentgroup-table.php
blob: 69e9245018ead05dcd548b181c5e9036e37f41f9 (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
<?php
$table_rows = 0;
$table_cols = 0;
$max_rows   = 0;
$max_cols   = 0;
if ($rows > 1) {
    $max_rows = $rows;
} else {
    $max_cols = $columns;
}
?>

<? // class "action-menu" will be set from API ?>
<nav <?= arrayToHtmlAttributes($attributes) ?>>
    <a class="action-menu-icon" title="<?= htmlReady($label) ?>"
       aria-expanded="false" aria-label="<?= htmlReady($aria_label) ?>">
        <?= $image ?>
    </a>
    <div class="action-menu-content">
        <div class="action-menu-title">
            <?= htmlReady($label) ?>
        </div>

        <table class="action-menu-table">
            <tr>
            <? foreach ($actions as $action): ?>
                <td>
                <? if ($action['type'] === 'link'): ?>
                    <a href="<?= $action['link'] ?>" <?= arrayToHtmlAttributes($action['attributes']) ?>>
                    <? if ($action['icon']): ?>
                        <?= $action['icon'] ?>
                    <? else: ?>
                        <span class="action-menu-no-icon"></span>
                    <? endif; ?>
                        <br>
                        <div class="navtitle"><?= htmlReady($action['label']) ?></div>
                    </a>
                <? elseif ($action['type'] === 'button'): ?>
                    <label>
                    <? if ($action['icon']): ?>
                        <?= $action['icon']->asInput(['name' => $action['name']]) ?>
                    <? else: ?>
                        <span class="action-menu-no-icon"></span>
                        <button type="submit" name="<?= htmlReady($action['name']) ?>" style="display: none;"></button>
                    <? endif; ?>
                        <?= htmlReady($action['label']) ?>
                    </label>
                <? elseif ($action['type'] === 'multi-person-search'): ?>
                    <?= $action['object']->render() ?>
                <? endif; ?>
                </td>
            <?php
                $table_cols += 1;
                if ($table_cols >= $max_cols) {
                    $table_rows += 1;
                    $table_cols = 0;
                    echo '</tr><tr>'; // Open next row
                }
            ?>
            <? endforeach; ?>
            </tr>
        </table>
    </div>
</nav>