Files
ks-nossenerland-bundle/contao/dca/tl_calendar_events.php
T
2026-04-01 12:02:50 +02:00

233 lines
7.9 KiB
PHP

<?php
$dca = &$GLOBALS['TL_DCA']['tl_calendar_events'];
use Contao\CoreBundle\DataContainer\PaletteManipulator;
use Mummert\KsNossenerlandBundle\DataContainer\CalendarEvents;
use Mummert\KsNossenerlandBundle\Model\ExternalLocationModel;
$dca['fields']['featured']['filter'] = false;
$dca['fields']['recurring']['filter'] = false;
$dca['fields']['published']['filter'] = false;
$dca['fields']['startTime']['filter'] = false;
$fields = [
'featured', 'addTime', 'addImage', 'overwriteMeta', 'fullsize', 'recurring', 'addEnclosure', 'target',
'published', 'socialImage', 'pid', 'tstamp', 'startTime', 'endTime', 'startDate',
'endDate', 'pageTitle', 'robots', 'description', 'canonicalLink', 'location', 'address', 'singleSRC',
'alt', 'imageTitle', 'size', 'imageUrl', 'caption', 'floating', 'repeatEach', 'repeatEnd', 'recurrences', 'enclosure',
'source', 'linkText', 'jumpTo', 'articleId', 'url', 'cssClass', 'start', 'stop', 'languageMain', 'catalog_ort',
'catalog_kontakt', 'godi_options', 'catalog_pfarrbereiche', 'styleManager', 'export',
'external_location', 'evlkscalendar', 'evlks_access'
];
foreach ($fields as $field) {
$dca['fields'][$field]['search'] = false;
}
$dca['list']['sorting']['child_record_callback'] = [
'Mummert\KsNossenerlandBundle\DataContainer\CalendarEvents',
'listEvents'
];
// Subpalettes
$dca['palettes']['__selector__'][] = 'export';
$dca['subpalettes']['export'] = 'external_location';
/**
* Felder
*/
$dca['fields']['catalog_ort'] = [
'label' => &$GLOBALS['TL_LANG']['tl_calendar_events']['catalog_ort'],
'exclude' => false,
'filter' => true,
'inputType' => 'select',
'options_callback' => [CalendarEvents::class, 'getCtlgOrteOptions'],
'eval' => [
'mandatory' => true,
'includeBlankOption' => true,
'blankOptionLabel' => '-', // Explizites leeres Label für HTML5-Validierung
'tl_class' => 'w50',
],
'sql' => "int(10) unsigned NOT NULL default '0'", // Falls nötig, hier default '0' entfernen
];
$dca['fields']['catalog_kontakt'] = [
'label' => &$GLOBALS['TL_LANG']['tl_calendar_events']['catalog_kontakt'],
'exclude' => false,
'filter' => true,
'inputType' => 'select',
'options_callback' => [CalendarEvents::class, 'getCtlgKontaktOptions'],
'eval' => [
'mandatory' => false,
'includeBlankOption' => true,
'multiple' => true,
'chosen' => true,
'csv' => ',',
'tl_class' => 'w50',
],
'sql' => "text NULL",
];
$dca['fields']['catalog_pfarrbereiche'] = [
'label' => &$GLOBALS['TL_LANG']['tl_calendar_events']['catalog_pfarrbereiche'],
'exclude' => true,
'inputType' => 'select',
'options_callback' => [CalendarEvents::class, 'getCtlgPfarrbereicheOptions'],
'eval' => [
'mandatory' => false,
'includeBlankOption' => true,
'multiple' => true,
'chosen' => true,
'csv' => ',',
'tl_class' => 'w50',
],
'sql' => "text NULL", // Speichert die Werte als kommaseparierte Liste
];
$dca['fields']['godi_options'] = [
'label' => &$GLOBALS['TL_LANG']['tl_calendar_events']['godi_options'],
'exclude' => false,
'inputType' => 'checkboxWizard',
'options' => [
1 => 'Abendmahl',
2 => 'Kindergottesdienst',
3 => 'Kirchenkaffee',
4 => 'Taufe',
],
'eval' => [
'mandatory' => false,
'multiple' => true,
'csv' => ',',
'tl_class' => 'clr',
],
'sql' => "text NULL",
];
$dca['fields']['subtitle'] = [
'label' => &$GLOBALS['TL_LANG']['tl_calendar_events']['subtitle'],
'exclude' => false,
'search' => false,
'sorting' => false,
'filter' => false,
'inputType' => 'text',
'eval' => ['maxlength' => 255, 'tl_class' => 'w50'],
'sql' => "varchar(255) DEFAULT NULL",
];
$dca['fields']['contributors'] = [
'label' => &$GLOBALS['TL_LANG']['tl_calendar_events']['contributors'],
'exclude' => false,
'search' => false,
'sorting' => false,
'filter' => false,
'inputType' => 'text',
'eval' => ['maxlength' => 255, 'tl_class' => 'w50'],
'sql' => "varchar(255) DEFAULT NULL",
];
$dca['fields']['evlkscalendar'] = [
'label' => &$GLOBALS['TL_LANG']['tl_calendar_events']['evlkscalendar'],
'inputType' => 'checkbox',
'eval' => ['tl_class' => 'w50'],
'sql' => "char(1) NOT NULL default ''",
];
$dca['fields']['export'] = [
'label' => &$GLOBALS['TL_LANG']['tl_calendar_events']['export'],
'inputType' => 'checkbox',
'eval' => ['submitOnChange' => true],
'sql' => "char(1) NOT NULL default ''",
];
$dca['fields']['evlks_access'] = [
'label' => &$GLOBALS['TL_LANG']['tl_calendar_events']['evlks_access'],
'exclude' => true,
'inputType' => 'select',
'options' => [
1 => 'Veranstaltung in Gebaerdensprache bzw. Gebaerdendolmetscher ist anwesend',
2 => 'Predigt / Liturgie der Veranstaltung liegt in schriftlicher Form vor',
3 => 'Veranstaltung findet in Leichter Sprache statt',
4 => 'Gebaerdensprachdolmetscher kann bei Bedarf bestellt werden',
5 => 'Abholung oder Fahrdienst kann bei Bedarf organisiert werden',
6 => 'Induktive Hoeranlage',
7 => 'FM-Anlage (drahtlose Funkanlage)',
8 => 'Punktschrift / Grossdruck auf Anfrage',
9 => 'Begleitservice auf Anfrage',
],
'eval' => [
'multiple' => true,
'chosen' => true,
'csv' => ',',
'includeBlankOption' => true,
'tl_class' => 'w50 clr',
],
'sql' => "text NULL",
];
$dca['fields']['external_location'] = [
'label' => &$GLOBALS['TL_LANG']['tl_calendar_events']['external_location'],
'inputType' => 'select',
'options_callback' => function () {
try {
$locations = ExternalLocationModel::findAllLocations();
if (empty($locations)) {
return ['debug' => "Keine Einträge in der Tabelle 'tl_location' gefunden."];
}
$options = [];
foreach ($locations as $location) {
$options[$location['id']] = $location['title'];
}
return $options;
} catch (\Exception $e) {
return ['debug' => "Fehler: " . $e->getMessage()];
}
},
'eval' => [
'mandatory' => true,
'includeBlankOption' => true,
'tl_class' => 'w50',
],
'sql' => "int(10) unsigned NOT NULL default '0'",
];
PaletteManipulator::create()
->addLegend('godioptions_legend', 'details_legend', PaletteManipulator::POSITION_AFTER)
->addLegend('nossenerland_legend', 'details_legend', PaletteManipulator::POSITION_AFTER)
->addField('godi_options', 'godioptions_legend', PaletteManipulator::POSITION_APPEND)
->addField('subtitle', 'title_legend', PaletteManipulator::POSITION_APPEND)
->addField('evlkscalendar', 'nossenerland_legend', PaletteManipulator::POSITION_APPEND)
->addField('export', 'nossenerland_legend', PaletteManipulator::POSITION_APPEND)
->addField('evlks_access', 'nossenerland_legend', PaletteManipulator::POSITION_APPEND)
->addField('contributors', 'address')
->addField('catalog_kontakt', 'address')
->addField('catalog_pfarrbereiche', 'address')
->addField('catalog_ort', 'address')
->applyToPalette('default', 'tl_calendar_events');
PaletteManipulator::create()
->removeField('location')
->removeField('address')
->removeField('location_name')
->removeField('location_str')
->removeField('location_ort')
->applyToPalette('default', 'tl_calendar_events');
$GLOBALS['TL_DCA']['tl_calendar_events']['config']['onsubmit_callback'][] = [
'Mummert\KsNossenerlandBundle\EventListener\CalendarAliasListener',
'onSubmitCallback'
];