aboutsummaryrefslogtreecommitdiff
path: root/app/views/resources/resource/_standard_properties_display_part.php
blob: ada4f80e08504fb320e7ef38e09ee10152fff06c (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?
/**
 * Template documentation:
 * This template expects the $properties parameter to be present.
 * That parameter must contain ResourceProperty objects.
 */
?>
<? if ($property_groups): ?>
    <? foreach ($property_groups as $name => $properties): ?>
        <? $properties = array_filter($properties, function ($p) {
            return !empty($p->state);
        }); ?>
        <? if (!count($properties)) continue; ?>
        <section class="contentbox">
            <header>
                <h1>
                    <? if ($name): ?>
                        <?= htmlReady($name) ?>
                    <? else: ?>
                        <?= _('Weitere Eigenschaften') ?>
                    <? endif ?>
                </h1>
            </header>

            <table class="default">
                <tbody>
                    <? foreach ($properties as $property): ?>
                        <tr>
                            <td>
                                <?= htmlReady(
                                    $property->display_name
                                        ?: $property->name
                                ) ?>
                            </td>
                            <td>
                                <? if ($property->definition->type == 'bool'): ?>
                                    <? if ($property->state): ?>
                                        <?= _('ja') ?>
                                    <? else: ?>
                                        <?= _('nein') ?>
                                    <? endif ?>
                                <? elseif ($property->definition->type == 'user'): ?>
                                    <?
                                    $user = User::findByUsername($property->state);
                                    if (!$user) {
                                        //Find by ID:
                                        $user = User::find($property->state);
                                    }
                                    ?>
                                    <? if ($user instanceof User): ?>
                                        <a href="<?= $controller->link_for(
                                            'profile',
                                            ['username' => $user->username]
                                        ) ?>" target="_blank">
                                            <?= htmlReady($user->getFullName()) ?>
                                        </a>
                                        <a href="<?= $controller->link_for(
                                            'messages/write',
                                            ['rec_uname' => $user->username]
                                        ) ?>" data-dialog>
                                            <?= Icon::create('mail')->asImg(
                                                ['class' => 'text-bottom']
                                            ) ?>
                                        </a>
                                    <? else: ?>
                                        <?= htmlReady($property->state) ?>
                                    <? endif ?>
                                <? elseif ($property->definition->type == 'url'): ?>
                                    <a href="<?= htmlReady($property->state) ?>"
                                       target="_blank">
                                        <?= htmlReady($property->state) ?>
                                        <?= Icon::create('link-extern')->asImg(
                                            ['class' => 'text-bottom']
                                        ) ?>
                                    </a>
                                <? else: ?>
                                    <?= htmlReady($property->state) ?>
                                <? endif ?>
                            </td>
                        </tr>
                    <? endforeach ?>
                </tbody>
            </table>
        </section>
    <? endforeach ?>
<? endif ?>