1<?php /* @var \dokuwiki\plugin\bez\meta\Tpl $tpl */ ?>
2<form action="<?php echo $tpl->url('types') ?>" method="POST">
3<table>
4<tr>
5	<th>Name</th>
6	<th colspan="3">Count</th>
7</tr>
8<?php foreach ($tpl->get('labels') as $label): ?>
9<tr>
10	<?php if (  in_array($tpl->param('action'), array('edit', 'update')) &&
11                $tpl->param('id') == $label->id): ?>
12            <td>
13                <input type="hidden" name="id" value="<?php echo $label->id ?>" />
14                <input name="name" value="<?php echo $tpl->value('name') ?>" />
15            </td>
16            <td colspan="2">
17                <button name="action" value="update"><?php echo $tpl->getLang('save') ?></button>
18                <a href="<?php echo $tpl->url('types') ?>">
19                    <?php echo $tpl->getLang('cancel') ?>
20                </a>
21            </td>
22	<?php else: ?>
23        <td><?php echo $label->name ?></td>
24        <td <?php if ($label->count > 0) echo 'colspan="2"'; ?>>
25            <a href="<?php echo $tpl->url('types', 'action', 'edit', 'id', $label->id) ?>">
26                <?php echo $tpl->getLang('edit') ?>
27            </a>
28        </td>
29        <?php if ($label->count == 0): ?>
30            <td>
31            <a onclick="return confirm('<?php echo $tpl->getLang('js')['remove_confirm'] ?>')"
32                href="<?php echo $tpl->url('types', 'action', 'remove', 'id', $label->id) ?>">
33                <?php echo $tpl->getLang('delete') ?>
34            </a>
35            </td>
36        <?php endif ?>
37    <?php endif ?>
38
39        <td>
40        <a href="<?php echo $tpl->url('threads', 'label_id', $label->id) ?>">
41            <?php echo $label->count ?>
42        </a>
43    </td>
44</tr>
45<?php endforeach ?>
46<?php if (  $tpl->param('action') !== 'edit' &&
47            $tpl->param('action') !== 'update'): ?>
48<tr>
49	<td><input name="name" value="<?php echo $tpl->value('name') ?>" /></td>
50	<td colspan="3">
51        <button name="action" value="add"><?php echo $tpl->getLang('save') ?></button>
52    </td>
53</tr>
54<?php endif ?>
55</table>
56</form>
57