Files
survey-bundle/contao/dca/tl_survey_content.php
T
Claude Fable 5 833a8964cf Add topic sections, ordered inserts, rich-text descriptions and grouped results (Ausbaustufe 3)
- section content type with structure service, reader context and grouped results/PDF/Excel
- new questions append at the end (backend oncreate) and per-section add buttons
- rich-text descriptions: Quill 2 (frontend), reduced TinyMCE (backend), server-side whitelist sanitizer
- externalize inline assets, bundle Chart.js locally, harden debug access, validate range bounds

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-22 07:57:40 +02:00

232 lines
10 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
declare(strict_types=1);
use Contao\DC_Table;
use Mummert\SurveyBundle\EventListener\SurveyDcaListener;
$GLOBALS['TL_DCA']['tl_survey_content'] = [
'config' => [
'dataContainer' => DC_Table::class,
'ptable' => 'tl_survey',
'enableVersioning' => true,
'onsubmit_callback' => [
[SurveyDcaListener::class, 'touchSurveyContentParent'],
],
'oncreate_callback' => [
// "Neu" im Listenkopf fügt in Contao oben ein Fragen sollen immer ans Ende.
[SurveyDcaListener::class, 'placeNewContentAtEnd'],
],
'onpalette_callback' => [
[SurveyDcaListener::class, 'resolveSurveyContentPalette'],
],
'ondelete_callback' => [
[SurveyDcaListener::class, 'touchSurveyContentParent'],
],
'sql' => [
'keys' => [
'id' => 'primary',
'pid' => 'index',
'sorting' => 'index',
'published' => 'index',
],
],
],
'list' => [
'sorting' => [
'mode' => 4,
'fields' => ['sorting'],
'headerFields' => ['title', 'published'],
'child_record_class' => 'survey-question-record',
'panelLayout' => 'sort,search,limit',
],
'label' => [
'fields' => ['question', 'type'],
'label_callback' => [SurveyDcaListener::class, 'renderSurveyContentLabel'],
],
'operations' => [
'edit' => [
'href' => 'act=edit',
'icon' => 'edit.svg',
'primary' => true,
],
'cut' => [
'href' => 'act=paste&amp;mode=cut',
'method' => 'POST',
'icon' => 'mover.svg',
'attributes' => 'data-action="contao--scroll-offset#store"',
],
'copy' => [
'href' => 'act=copy',
'icon' => 'copy.svg',
],
'delete' => [
'href' => 'act=delete',
'icon' => 'delete.svg',
'attributes' => 'onclick="if(!confirm(\'Eintrag wirklich löschen?\'))return false;Backend.getScrollOffset()"',
],
'show' => [
'href' => 'act=show',
'icon' => 'show.svg',
],
],
],
'palettes' => [
'default' => '{question_legend},type,question,description;{settings_legend},mandatory,published',
'yes_no_maybe' => '{question_legend},type,question,description;{settings_legend},mandatory,published,allowMaybe,jumpOnYes,jumpOnNo',
'text' => '{question_legend},type,question,description;{settings_legend},mandatory,published',
'range' => '{question_legend},type,question,description;{settings_legend},mandatory,published,rangeMin,rangeMax,rangeStep',
'choice' => '{question_legend},type,question,description;{settings_legend},mandatory,published,allowMultiple,answerOption1,answerOption2,answerOption3,answerOption4,answerOption5,answerOption6,answerOption7,answerOption8,answerOption9,answerOption10',
// Themenbereich: reine Gliederungszeile, kein Antwortfeld, kein Aktiv-/Pflicht-Flag.
'section' => '{question_legend},type,question',
],
'fields' => [
'id' => ['sql' => 'int(10) unsigned NOT NULL auto_increment'],
'tstamp' => ['sql' => 'int(10) unsigned NOT NULL default 0'],
'pid' => ['sql' => 'int(10) unsigned NOT NULL default 0'],
'sorting' => [
'sql' => 'int(10) unsigned NOT NULL default 0',
],
'type' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['type'],
'inputType' => 'select',
'options' => ['yes_no_maybe', 'text', 'range', 'choice', 'section'],
'reference' => &$GLOBALS['TL_LANG']['tl_survey_content']['types'],
'eval' => ['mandatory' => true, 'includeBlankOption' => true, 'submitOnChange' => true, 'chosen' => true, 'tl_class' => 'w50'],
'sql' => "varchar(32) NOT NULL default ''",
],
'question' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['question'],
'inputType' => 'text',
'eval' => ['mandatory' => true, 'maxlength' => 255, 'tl_class' => 'clr'],
'sql' => "varchar(255) NOT NULL default ''",
],
'description' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['description'],
'inputType' => 'textarea',
'eval' => ['rte' => 'tinyMCE_survey', 'tl_class' => 'clr'],
'save_callback' => [[SurveyDcaListener::class, 'sanitizeRichText']],
'sql' => 'text NULL',
],
'mandatory' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['mandatory'],
'inputType' => 'checkbox',
'default' => '1',
'eval' => ['tl_class' => 'w50 m12'],
'sql' => "char(1) NOT NULL default ''",
],
'published' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['published'],
'inputType' => 'checkbox',
'default' => '1',
'eval' => ['tl_class' => 'w50 m12'],
'sql' => "char(1) NOT NULL default ''",
],
'allowMaybe' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['allowMaybe'],
'inputType' => 'checkbox',
'eval' => ['tl_class' => 'w50 m12 clr'],
'sql' => "char(1) NOT NULL default ''",
],
'jumpOnYes' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['jumpOnYes'],
'inputType' => 'select',
'options_callback' => [SurveyDcaListener::class, 'getQuestionOptionsForContent'],
'eval' => ['includeBlankOption' => true, 'chosen' => true, 'tl_class' => 'w50 clr'],
'sql' => 'int(10) unsigned NOT NULL default 0',
],
'jumpOnNo' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['jumpOnNo'],
'inputType' => 'select',
'options_callback' => [SurveyDcaListener::class, 'getQuestionOptionsForContent'],
'eval' => ['includeBlankOption' => true, 'chosen' => true, 'tl_class' => 'w50'],
'sql' => 'int(10) unsigned NOT NULL default 0',
],
'allowMultiple' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['allowMultiple'],
'inputType' => 'checkbox',
'eval' => ['tl_class' => 'w50 m12 clr'],
'sql' => "char(1) NOT NULL default ''",
],
'answerOption1' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['answerOption1'],
'inputType' => 'text',
'eval' => ['maxlength' => 255, 'tl_class' => 'w50 clr'],
'sql' => "varchar(255) NOT NULL default ''",
],
'answerOption2' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['answerOption2'],
'inputType' => 'text',
'eval' => ['maxlength' => 255, 'tl_class' => 'w50'],
'sql' => "varchar(255) NOT NULL default ''",
],
'answerOption3' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['answerOption3'],
'inputType' => 'text',
'eval' => ['maxlength' => 255, 'tl_class' => 'w50 clr'],
'sql' => "varchar(255) NOT NULL default ''",
],
'answerOption4' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['answerOption4'],
'inputType' => 'text',
'eval' => ['maxlength' => 255, 'tl_class' => 'w50'],
'sql' => "varchar(255) NOT NULL default ''",
],
'answerOption5' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['answerOption5'],
'inputType' => 'text',
'eval' => ['maxlength' => 255, 'tl_class' => 'w50 clr'],
'sql' => "varchar(255) NOT NULL default ''",
],
'answerOption6' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['answerOption6'],
'inputType' => 'text',
'eval' => ['maxlength' => 255, 'tl_class' => 'w50'],
'sql' => "varchar(255) NOT NULL default ''",
],
'answerOption7' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['answerOption7'],
'inputType' => 'text',
'eval' => ['maxlength' => 255, 'tl_class' => 'w50 clr'],
'sql' => "varchar(255) NOT NULL default ''",
],
'answerOption8' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['answerOption8'],
'inputType' => 'text',
'eval' => ['maxlength' => 255, 'tl_class' => 'w50'],
'sql' => "varchar(255) NOT NULL default ''",
],
'answerOption9' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['answerOption9'],
'inputType' => 'text',
'eval' => ['maxlength' => 255, 'tl_class' => 'w50 clr'],
'sql' => "varchar(255) NOT NULL default ''",
],
'answerOption10' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['answerOption10'],
'inputType' => 'text',
'eval' => ['maxlength' => 255, 'tl_class' => 'w50'],
'sql' => "varchar(255) NOT NULL default ''",
],
'rangeMin' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['rangeMin'],
'inputType' => 'text',
'eval' => ['rgxp' => 'digit', 'tl_class' => 'w50'],
'sql' => 'int(10) NOT NULL default 0',
],
'rangeMax' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['rangeMax'],
'inputType' => 'text',
'eval' => ['rgxp' => 'digit', 'tl_class' => 'w50'],
'save_callback' => [[SurveyDcaListener::class, 'validateRangeMax']],
'sql' => 'int(10) NOT NULL default 10',
],
'rangeStep' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['rangeStep'],
'inputType' => 'text',
'eval' => ['rgxp' => 'digit', 'tl_class' => 'w50'],
'save_callback' => [[SurveyDcaListener::class, 'validateRangeStep']],
'sql' => 'int(10) unsigned NOT NULL default 1',
],
],
];