summaryrefslogtreecommitdiff
path: root/includes/view/EventConfig_view.php
blob: 730593b1abffcfb510bfc46e4ebb8362de5101c2 (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
112
113
114
115
<?php

use Carbon\Carbon;
use Illuminate\Support\Str;

/**
 * Shows basic event infos and countdowns.
 *
 * @return string
 */
function EventConfig_countdown_page()
{
    $config = config();
    $name = $config->get('name', '');
    /** @var Carbon $buildup */
    $buildup = $config->get('buildup_start');
    /** @var Carbon $start */
    $start = $config->get('event_start');
    /** @var Carbon $end */
    $end = $config->get('event_end');
    /** @var Carbon $teardown */
    $teardown = $config->get('teardown_end');
    $elements = [];

    $elements[] = div('col-sm-12 text-center', [
        heading(sprintf(
            __('Welcome to the %s!'),
            $name . ' <span class="icon-icon_angel"></span> ' . Str::upper(config('app_name'))
        ), 2)
    ]);

    if (!empty($buildup) && $buildup->greaterThan(new Carbon())) {
        $elements[] = div('col-sm-3 text-center hidden-xs', [
            heading(__('Buildup starts'), 4),
            '<span class="moment-countdown text-big" data-timestamp="' . $buildup->getTimestamp() . '">%c</span>',
            '<small>' . $buildup->format(__('Y-m-d')) . '</small>'
        ]);
    }

    if (!empty($start) && $start->greaterThan(new Carbon())) {
        $elements[] = div('col-sm-3 text-center hidden-xs', [
            heading(__('Event starts'), 4),
            '<span class="moment-countdown text-big" data-timestamp="' . $start->getTimestamp() . '">%c</span>',
            '<small>' . $start->format(__('Y-m-d')) . '</small>'
        ]);
    }

    if (!empty($end) && $end->greaterThan(new Carbon())) {
        $elements[] = div('col-sm-3 text-center hidden-xs', [
            heading(__('Event ends'), 4),
            '<span class="moment-countdown text-big" data-timestamp="' . $end->getTimestamp() . '">%c</span>',
            '<small>' . $end->format(__('Y-m-d')) . '</small>'
        ]);
    }

    if (!empty($teardown) && $teardown->greaterThan(new Carbon())) {
        $elements[] = div('col-sm-3 text-center hidden-xs', [
            heading(__('Teardown ends'), 4),
            '<span class="moment-countdown text-big" data-timestamp="' . $teardown->getTimestamp() . '">%c</span>',
            '<small>' . $teardown->format(__('Y-m-d')) . '</small>'
        ]);
    }

    return join('', $elements);
}

/**
 * Render edit page for event config.
 *
 * @param string $event_name         The event name
 * @param string $event_welcome_msg  The welcome message
 * @param int    $buildup_start_date unix time stamp
 * @param int    $event_start_date   unix time stamp
 * @param int    $event_end_date     unix time stamp
 * @param int    $teardown_end_date  unix time stamp
 * @return string
 */
function EventConfig_edit_view(
    $event_name,
    $event_welcome_msg,
    $buildup_start_date,
    $event_start_date,
    $event_end_date,
    $teardown_end_date
) {
    return page_with_title(event_config_title(), [
        msg(),
        form([
            div('row', [
                div('col-md-6', [
                    form_text('event_name', __('Event Name'), $event_name),
                    form_info('', __('Event Name is shown on the start page.')),
                    form_textarea('event_welcome_msg', __('Event Welcome Message'), $event_welcome_msg),
                    form_info(
                        '',
                        __('Welcome message is shown after successful registration. You can use markdown.')
                    )
                ]),
                div('col-md-3 col-xs-6', [
                    form_date('buildup_start_date', __('Buildup date'), $buildup_start_date),
                    form_date('event_start_date', __('Event start date'), $event_start_date)
                ]),
                div('col-md-3 col-xs-6', [
                    form_date('teardown_end_date', __('Teardown end date'), $teardown_end_date),
                    form_date('event_end_date', __('Event end date'), $event_end_date)
                ])
            ]),
            div('row', [
                div('col-md-6', [
                    form_submit('submit', __('Save'))
                ])
            ])
        ])
    ]);
}