aboutsummaryrefslogtreecommitdiff
path: root/templates/dates/seminar_html.php
blob: c59b5cea69259b697b46b2a57fea0e9bf0fbaece (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
if (!$dates['regular']['turnus_data'] && empty($dates['irregular'])) {
    if ($dates['ort'] && $show_room) {
        echo htmlReady($dates['ort']);
    } else {
        echo _('Die Zeiten der Veranstaltung stehen nicht fest.');
    }
} else {
    if (!isset($link)) {
        $link = true;
    }
    if (!isset($show_room)) {
        // show rooms only if there is more than one
        $show_room = count($dates['rooms']) > 1;
    }

    $output = [];

    if (is_array($dates['regular']['turnus_data'])) {
        foreach ($dates['regular']['turnus_data'] as $cycle) {
            $first_date = sprintf(
                _('ab %s'),
                strftime('%x', $cycle['first_date']['date'])
            );
            $cycle_output = $cycle['tostring'] . ' (' . $first_date . ')';
            if ($cycle['desc']) {
                $cycle_output .= ', <em>' . htmlReady($cycle['desc']) . '</em>';
            }

            if ($show_room) {
                $cycle_output .= $this->render_partial('dates/_seminar_rooms', [
                    'assigned' => $cycle['assigned_rooms'],
                    'freetext' => $cycle['freetext_rooms'],
                    'link' => $link
                ]);
            }

            $output[] = $cycle_output;
        }
    }

    echo implode('<br>', $output);
    echo $output ? '<br>' : '';

    $freetext_rooms = [];

    if (is_array($dates['irregular'])) {
        foreach ($dates['irregular'] as $date) {
            $irregular[] = $date;
            $irregular_strings[] = $date['tostring'];
            if ($date['resource_id']) {
                $irregular_rooms[$date['resource_id']]++;
            } elseif ($date['raum']) {
                $freetext_rooms['(' . htmlReady($date['raum']) . ')']++;
            }
        }
        unset($irregular_rooms['']);

        if (is_array($irregular) && sizeof($irregular)) {
            $dates = shrink_dates($irregular);

            echo _("Termine am");
            if (is_array($dates)) {
                if (count($dates) > 10) {
                    echo implode(', ', array_slice($dates, 0, 10));

                    echo '<span class="more-dates-infos" style="display: none">';
                    echo ', ';
                    echo implode(', ', array_slice($dates, 10));
                    echo '</span>';
                    echo '<span class="more-dates-digits"> ...</span>';
                    echo '<a class="more-dates" style="cursor: pointer; margin-left: 3px"
                 title="' . _('Blenden Sie die restlichen Termine ein') . '">(' ._('mehr'). ')</a>';
                } else {
                    $string = implode(', ', $dates);
                    if (mb_strlen($string) > 222) {
                        echo mb_substr($string,0, 128);
                        echo '<span class="more-dates-infos" style="display: none">';
                        echo mb_substr($string, -1, 1) != ','? ', ' : ' ';
                        echo mb_substr($string, 128);
                        echo '</span>';
                        echo '<span class="more-dates-digits"> ...</span>';
                        echo '<a class="more-dates" style="cursor: pointer; margin-left: 3px"
                            title="' . _('Blenden Sie die restlichen Termine ein') . '">(' ._('mehr'). ')</a>';
                    } else {
                        echo $string;
                    }
                }
            }

            if ($show_room) {
                echo $this->render_partial('dates/_seminar_rooms', array(
                    'assigned'   => $irregular_rooms,
                    'freetext'   => $freetext_rooms,
                    'link'       => $link,
                    'prefix'     => count($dates) > 10 ? '<br>' : ', ',
                    'hide_empty' => true,
                ));
            }
        }
    }

    if ($link_to_dates) {
        echo '<br>';
        printf(
            _('Details zu allen Terminen im %sAblaufplan%s'),
            '<a href="' . URLHelper::getLink('seminar_main.php', array('auswahl' => $seminar_id, 'redirect_to' => 'dispatch.php/course/dates')) . '">',
            '</a>'
        );
    }
}