engelsystem/includes/view/EventConfig_view.php

129 lines
4.8 KiB
PHP
Raw Normal View History

<?php
2016-09-29 09:25:06 +02:00
/**
* Shows basic event infos and countdowns.
* @param EventConfig $event_config The event configuration
*/
function EventConfig_countdown_page($event_config) {
if ($event_config == null) {
2016-11-18 15:36:02 +01:00
return div('col-md-12 text-center', [
heading(sprintf(_("Welcome to the %s!"), '<span class="icon-icon_angel"></span> ENGELSYSTEM'), 2)
]);
2016-09-29 09:25:06 +02:00
}
$elements = [];
if ($event_config['event_name'] != null) {
2016-11-18 15:36:02 +01:00
$elements[] = div('col-md-12 text-center', [
heading(sprintf(_("Welcome to the %s!"), $event_config['event_name'] . ' <span class="icon-icon_angel"></span> ENGELSYSTEM'), 2)
]);
2016-09-29 09:25:06 +02:00
}
2016-11-18 15:36:02 +01:00
if ($event_config['buildup_start_date'] != null) {
$elements[] = div('col-md-3 text-center', [
heading(_("Buildup starts"), 3),
'<h2 class="moment-countdown" data-timestamp="' . $event_config['buildup_start_date'] . '">%c</h2>',
'<small>' . date(_("Y-m-d"), $event_config['buildup_start_date']) . '</small>'
]);
2016-09-29 09:25:06 +02:00
}
2016-11-18 15:36:02 +01:00
if ($event_config['event_start_date'] != null) {
$elements[] = div('col-md-3 text-center', [
heading(_("Event starts"), 3),
'<h2 class="moment-countdown" data-timestamp="' . $event_config['event_start_date'] . '">%c</h2>',
'<small>' . date(_("Y-m-d"), $event_config['event_start_date']) . '</small>'
]);
2016-09-29 09:25:06 +02:00
}
2016-11-18 15:36:02 +01:00
if ($event_config['event_end_date'] != null) {
$elements[] = div('col-md-3 text-center', [
heading(_("Event ends"), 3),
'<h2 class="moment-countdown" data-timestamp="' . $event_config['event_end_date'] . '">%c</h2>',
'<small>' . date(_("Y-m-d"), $event_config['event_end_date']) . '</small>'
]);
2016-09-29 09:25:06 +02:00
}
2016-11-18 15:36:02 +01:00
if ($event_config['teardown_end_date'] != null) {
$elements[] = div('col-md-3 text-center', [
heading(_("Teardown ends"), 3),
'<h2 class="moment-countdown" data-timestamp="' . $event_config['teardown_end_date'] . '">%c</h2>',
'<small>' . date(_("Y-m-d"), $event_config['teardown_end_date']) . '</small>'
]);
2016-09-29 09:25:06 +02:00
}
return join("", $elements);
}
2016-09-28 11:46:40 +02:00
/**
* Converts event name and start+end date into a line of text.
*/
2016-09-29 09:25:06 +02:00
function EventConfig_info($event_config) {
if ($event_config == null) {
return "";
2016-09-28 11:46:40 +02:00
}
// Event name, start+end date are set
if ($event_config['event_name'] != null && $event_config['event_start_date'] != null && $event_config['event_end_date'] != null) {
2016-11-15 17:54:59 +01:00
return sprintf(_("%s, from %s to %s"), $event_config['event_name'], date(_("Y-m-d"), $event_config['event_start_date']), date(_("Y-m-d"), $event_config['event_end_date']));
2016-09-28 11:46:40 +02:00
}
// Event name, start date are set
if ($event_config['event_name'] != null && $event_config['event_start_date'] != null) {
return sprintf(_("%s, starting %s"), $event_config['event_name'], date(_("Y-m-d"), $event_config['event_start_date']));
2016-09-28 11:46:40 +02:00
}
// Event start+end date are set
if ($event_config['event_start_date'] != null && $event_config['event_end_date'] != null) {
2016-11-15 17:54:59 +01:00
return sprintf(_("Event from %s to %s"), date(_("Y-m-d"), $event_config['event_start_date']), date(_("Y-m-d"), $event_config['event_end_date']));
2016-09-28 11:46:40 +02:00
}
// Only event name is set
if ($event_config['event_name'] != null) {
return sprintf($event_config['event_name']);
}
return "";
}
/**
* Render edit page for event config.
2016-09-28 11:46:40 +02:00
*
* @param string $event_name
* The event name
* @param string $event_welcome_msg
* The welcome message
* @param date $buildup_start_date
* @param date $event_start_date
* @param date $event_end_date
* @param date $teardown_end_date
*/
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."))
]),
2016-09-27 18:08:55 +02:00
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)
]),
2016-09-27 18:08:55 +02:00
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"))
])
])
])
]);
}
?>