You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
engelsystem/includes/view/EventConfig_view.php

163 lines
5.7 KiB
PHTML

<?php
/**
* Shows basic event infos and countdowns.
8 years ago
*
* @param array $event_config The event configuration
* @return string
*/
8 years ago
function EventConfig_countdown_page($event_config)
{
if (empty($event_config)) {
8 years ago
return div('col-md-12 text-center', [
heading(sprintf(__('Welcome to the %s!'), '<span class="icon-icon_angel"></span> ENGELSYSTEM'), 2)
8 years ago
]);
8 years ago
}
8 years ago
8 years ago
$elements = [];
8 years ago
if (!is_null($event_config['event_name'])) {
8 years ago
$elements[] = div('col-sm-12 text-center', [
8 years ago
heading(sprintf(
__('Welcome to the %s!'),
8 years ago
$event_config['event_name'] . ' <span class="icon-icon_angel"></span> ENGELSYSTEM'
), 2)
]);
8 years ago
}
8 years ago
if (!is_null($event_config['buildup_start_date']) && time() < $event_config['buildup_start_date']) {
8 years ago
$elements[] = div('col-sm-3 text-center hidden-xs', [
heading(__('Buildup starts'), 4),
8 years ago
'<span class="moment-countdown text-big" data-timestamp="' . $event_config['buildup_start_date'] . '">%c</span>',
'<small>' . date(__('Y-m-d'), $event_config['buildup_start_date']) . '</small>'
8 years ago
]);
8 years ago
}
8 years ago
if (!is_null($event_config['event_start_date']) && time() < $event_config['event_start_date']) {
8 years ago
$elements[] = div('col-sm-3 text-center hidden-xs', [
heading(__('Event starts'), 4),
8 years ago
'<span class="moment-countdown text-big" data-timestamp="' . $event_config['event_start_date'] . '">%c</span>',
'<small>' . date(__('Y-m-d'), $event_config['event_start_date']) . '</small>'
8 years ago
]);
8 years ago
}
8 years ago
if (!is_null($event_config['event_end_date']) && time() < $event_config['event_end_date']) {
8 years ago
$elements[] = div('col-sm-3 text-center hidden-xs', [
heading(__('Event ends'), 4),
8 years ago
'<span class="moment-countdown text-big" data-timestamp="' . $event_config['event_end_date'] . '">%c</span>',
'<small>' . date(__('Y-m-d'), $event_config['event_end_date']) . '</small>'
8 years ago
]);
8 years ago
}
8 years ago
if (!is_null($event_config['teardown_end_date']) && time() < $event_config['teardown_end_date']) {
8 years ago
$elements[] = div('col-sm-3 text-center hidden-xs', [
heading(__('Teardown ends'), 4),
8 years ago
'<span class="moment-countdown text-big" data-timestamp="' . $event_config['teardown_end_date'] . '">%c</span>',
'<small>' . date(__('Y-m-d'), $event_config['teardown_end_date']) . '</small>'
8 years ago
]);
8 years ago
}
8 years ago
return join('', $elements);
}
/**
* Converts event name and start+end date into a line of text.
*
* @param array $event_config
* @return string
*/
8 years ago
function EventConfig_info($event_config)
{
if (empty($event_config)) {
return '';
8 years ago
}
8 years ago
// Event name, start+end date are set
if (
!is_null($event_config['event_name'])
&& !is_null($event_config['event_start_date'])
&& !is_null($event_config['event_end_date'])
) {
8 years ago
return sprintf(
__('%s, from %s to %s'),
8 years ago
$event_config['event_name'],
date(__('Y-m-d'), $event_config['event_start_date']),
date(__('Y-m-d'), $event_config['event_end_date'])
8 years ago
);
}
// Event name, start date are set
if (!is_null($event_config['event_name']) && !is_null($event_config['event_start_date'])) {
8 years ago
return sprintf(
__('%s, starting %s'), $event_config['event_name'],
date(__('Y-m-d'), $event_config['event_start_date'])
8 years ago
);
}
// Event start+end date are set
if (!is_null($event_config['event_start_date']) && !is_null($event_config['event_end_date'])) {
8 years ago
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'])
8 years ago
);
}
// Only event name is set
if (!is_null($event_config['event_name'])) {
8 years ago
return sprintf($event_config['event_name']);
}
return '';
}
/**
* 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
*/
8 years ago
function EventConfig_edit_view(
$event_name,
$event_welcome_msg,
$buildup_start_date,
$event_start_date,
$event_end_date,
$teardown_end_date
) {
8 years ago
return page_with_title(event_config_title(), [
8 years ago
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.')
)
8 years ago
]),
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)
8 years ago
]),
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)
8 years ago
])
]),
div('row', [
div('col-md-6', [
form_submit('submit', __('Save'))
8 years ago
])
])
])
]);
}