Clean up obsolete survey editor and DCA code

This commit is contained in:
Jürgen Mummert
2026-06-07 22:16:37 +02:00
parent 497b4f962d
commit b7bcdd8372
10 changed files with 6 additions and 95 deletions
+1 -7
View File
@@ -5,8 +5,6 @@ declare(strict_types=1);
use Contao\DC_Table;
use Mummert\SurveyBundle\EventListener\SurveyDcaListener;
$guardCallback = [SurveyDcaListener::class, 'guardConditionSave'];
$GLOBALS['TL_DCA']['tl_survey_condition'] = [
'config' => [
'dataContainer' => DC_Table::class,
@@ -16,7 +14,6 @@ $GLOBALS['TL_DCA']['tl_survey_condition'] = [
[SurveyDcaListener::class, 'touchSurveyConditionParent'],
],
'ondelete_callback' => [
[SurveyDcaListener::class, 'guardConditionDelete'],
[SurveyDcaListener::class, 'touchSurveyConditionParent'],
],
'sql' => [
@@ -32,7 +29,7 @@ $GLOBALS['TL_DCA']['tl_survey_condition'] = [
'sorting' => [
'mode' => 4,
'fields' => ['id'],
'headerFields' => ['title', 'alias', 'published', 'isLocked'],
'headerFields' => ['title', 'alias', 'published'],
'panelLayout' => 'sort,search,limit',
],
'label' => [
@@ -71,14 +68,12 @@ $GLOBALS['TL_DCA']['tl_survey_condition'] = [
'inputType' => 'select',
'options_callback' => [SurveyDcaListener::class, 'getQuestionOptions'],
'eval' => ['mandatory' => true, 'includeBlankOption' => true, 'chosen' => true, 'tl_class' => 'w50'],
'save_callback' => [$guardCallback],
'sql' => 'int(10) unsigned NOT NULL default 0',
],
'answerValue' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_condition']['answerValue'],
'inputType' => 'text',
'eval' => ['mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'],
'save_callback' => [$guardCallback],
'sql' => "varchar(255) NOT NULL default ''",
],
'targetQuestion' => [
@@ -86,7 +81,6 @@ $GLOBALS['TL_DCA']['tl_survey_condition'] = [
'inputType' => 'select',
'options_callback' => [SurveyDcaListener::class, 'getQuestionOptions'],
'eval' => ['mandatory' => true, 'includeBlankOption' => true, 'chosen' => true, 'tl_class' => 'clr'],
'save_callback' => [$guardCallback],
'sql' => 'int(10) unsigned NOT NULL default 0',
],
],
+1 -26
View File
@@ -5,8 +5,6 @@ declare(strict_types=1);
use Contao\DC_Table;
use Mummert\SurveyBundle\EventListener\SurveyDcaListener;
$guardCallback = [SurveyDcaListener::class, 'guardContentSave'];
$GLOBALS['TL_DCA']['tl_survey_content'] = [
'config' => [
'dataContainer' => DC_Table::class,
@@ -19,7 +17,6 @@ $GLOBALS['TL_DCA']['tl_survey_content'] = [
[SurveyDcaListener::class, 'resolveSurveyContentPalette'],
],
'ondelete_callback' => [
[SurveyDcaListener::class, 'guardContentDelete'],
[SurveyDcaListener::class, 'touchSurveyContentParent'],
],
'sql' => [
@@ -35,7 +32,7 @@ $GLOBALS['TL_DCA']['tl_survey_content'] = [
'sorting' => [
'mode' => 4,
'fields' => ['sorting'],
'headerFields' => ['title', 'alias', 'published', 'isLocked'],
'headerFields' => ['title', 'alias', 'published'],
'child_record_class' => 'survey-question-record',
'panelLayout' => 'sort,search,limit',
],
@@ -83,21 +80,18 @@ $GLOBALS['TL_DCA']['tl_survey_content'] = [
'options' => ['yes_no_maybe', 'text', 'range', 'choice'],
'reference' => &$GLOBALS['TL_LANG']['tl_survey_content']['types'],
'eval' => ['mandatory' => true, 'includeBlankOption' => true, 'submitOnChange' => true, 'chosen' => true, 'tl_class' => 'w50'],
'save_callback' => [$guardCallback],
'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'],
'save_callback' => [$guardCallback],
'sql' => "varchar(255) NOT NULL default ''",
],
'description' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['description'],
'inputType' => 'textarea',
'eval' => ['tl_class' => 'clr'],
'save_callback' => [$guardCallback],
'sql' => 'text NULL',
],
'mandatory' => [
@@ -105,7 +99,6 @@ $GLOBALS['TL_DCA']['tl_survey_content'] = [
'inputType' => 'checkbox',
'default' => '1',
'eval' => ['tl_class' => 'w50 m12'],
'save_callback' => [$guardCallback],
'sql' => "char(1) NOT NULL default ''",
],
'published' => [
@@ -113,14 +106,12 @@ $GLOBALS['TL_DCA']['tl_survey_content'] = [
'inputType' => 'checkbox',
'default' => '1',
'eval' => ['tl_class' => 'w50 m12'],
'save_callback' => [$guardCallback],
'sql' => "char(1) NOT NULL default ''",
],
'allowMaybe' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['allowMaybe'],
'inputType' => 'checkbox',
'eval' => ['tl_class' => 'w50 m12 clr'],
'save_callback' => [$guardCallback],
'sql' => "char(1) NOT NULL default ''",
],
'jumpOnYes' => [
@@ -128,7 +119,6 @@ $GLOBALS['TL_DCA']['tl_survey_content'] = [
'inputType' => 'select',
'options_callback' => [SurveyDcaListener::class, 'getQuestionOptionsForContent'],
'eval' => ['includeBlankOption' => true, 'chosen' => true, 'tl_class' => 'w50 clr'],
'save_callback' => [$guardCallback],
'sql' => 'int(10) unsigned NOT NULL default 0',
],
'jumpOnNo' => [
@@ -136,105 +126,90 @@ $GLOBALS['TL_DCA']['tl_survey_content'] = [
'inputType' => 'select',
'options_callback' => [SurveyDcaListener::class, 'getQuestionOptionsForContent'],
'eval' => ['includeBlankOption' => true, 'chosen' => true, 'tl_class' => 'w50'],
'save_callback' => [$guardCallback],
'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'],
'save_callback' => [$guardCallback],
'sql' => "char(1) NOT NULL default ''",
],
'answerOption1' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['answerOption1'],
'inputType' => 'text',
'eval' => ['maxlength' => 255, 'tl_class' => 'w50 clr'],
'save_callback' => [$guardCallback],
'sql' => "varchar(255) NOT NULL default ''",
],
'answerOption2' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['answerOption2'],
'inputType' => 'text',
'eval' => ['maxlength' => 255, 'tl_class' => 'w50'],
'save_callback' => [$guardCallback],
'sql' => "varchar(255) NOT NULL default ''",
],
'answerOption3' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['answerOption3'],
'inputType' => 'text',
'eval' => ['maxlength' => 255, 'tl_class' => 'w50 clr'],
'save_callback' => [$guardCallback],
'sql' => "varchar(255) NOT NULL default ''",
],
'answerOption4' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['answerOption4'],
'inputType' => 'text',
'eval' => ['maxlength' => 255, 'tl_class' => 'w50'],
'save_callback' => [$guardCallback],
'sql' => "varchar(255) NOT NULL default ''",
],
'answerOption5' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['answerOption5'],
'inputType' => 'text',
'eval' => ['maxlength' => 255, 'tl_class' => 'w50 clr'],
'save_callback' => [$guardCallback],
'sql' => "varchar(255) NOT NULL default ''",
],
'answerOption6' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['answerOption6'],
'inputType' => 'text',
'eval' => ['maxlength' => 255, 'tl_class' => 'w50'],
'save_callback' => [$guardCallback],
'sql' => "varchar(255) NOT NULL default ''",
],
'answerOption7' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['answerOption7'],
'inputType' => 'text',
'eval' => ['maxlength' => 255, 'tl_class' => 'w50 clr'],
'save_callback' => [$guardCallback],
'sql' => "varchar(255) NOT NULL default ''",
],
'answerOption8' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['answerOption8'],
'inputType' => 'text',
'eval' => ['maxlength' => 255, 'tl_class' => 'w50'],
'save_callback' => [$guardCallback],
'sql' => "varchar(255) NOT NULL default ''",
],
'answerOption9' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['answerOption9'],
'inputType' => 'text',
'eval' => ['maxlength' => 255, 'tl_class' => 'w50 clr'],
'save_callback' => [$guardCallback],
'sql' => "varchar(255) NOT NULL default ''",
],
'answerOption10' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['answerOption10'],
'inputType' => 'text',
'eval' => ['maxlength' => 255, 'tl_class' => 'w50'],
'save_callback' => [$guardCallback],
'sql' => "varchar(255) NOT NULL default ''",
],
'rangeMin' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_content']['rangeMin'],
'inputType' => 'text',
'eval' => ['rgxp' => 'digit', 'tl_class' => 'w50'],
'save_callback' => [$guardCallback],
'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' => [$guardCallback],
'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' => [$guardCallback],
'sql' => 'int(10) unsigned NOT NULL default 1',
],
],
+1 -1
View File
@@ -28,7 +28,7 @@ $GLOBALS['TL_DCA']['tl_survey_editor'] = [
'sorting' => [
'mode' => 4,
'fields' => ['member'],
'headerFields' => ['title', 'alias', 'isLocked'],
'headerFields' => ['title', 'alias'],
'panelLayout' => 'sort,search,limit',
],
'label' => [
@@ -56,7 +56,6 @@
<div class="survey-card survey-editor-meta-card">
{{ form_start(surveyForm, {action: metadataFormActionUrl, attr: {class: 'survey-form-grid', id: surveyMetaFormId, 'data-survey-dirty-form': '1'}}) }}
<input type="hidden" name="REQUEST_TOKEN" value="{{ contao.request_token }}">
<input type="hidden" name="{{ surveyForm.published.vars.full_name }}" value="0">
{{ form_widget(surveyForm._token) }}
{{ form_errors(surveyForm) }}
<label class="survey-label">{{ 'survey.edit.label_survey_title'|trans }}{{ form_widget(surveyForm.title) }}{{ form_errors(surveyForm.title) }}</label>
@@ -76,7 +76,7 @@ final class MemberSurveyEditController extends AbstractFrontendModuleController
$surveyForm = $this->formFactory->createNamed('survey_meta', SurveyEditorType::class, $survey instanceof SurveyModel ? SurveyEditorData::fromModel($survey) : new SurveyEditorData());
$surveyForm->handleRequest($request);
if ($surveyForm->isSubmitted() && $surveyForm->isValid()) {
if ($surveyForm->isSubmitted() && $surveyForm->isValid() && (!$survey instanceof SurveyModel || '1' !== (string) $survey->published)) {
try {
if ($survey instanceof SurveyModel) {
$this->surveyEditorService->updateSurvey($survey, $memberId, $surveyForm->getData());
@@ -92,6 +92,8 @@ final class MemberSurveyEditController extends AbstractFrontendModuleController
} catch (\Throwable $exception) {
$this->addFlash('error', $exception->getMessage());
}
} elseif ($surveyForm->isSubmitted() && $survey instanceof SurveyModel && '1' === (string) $survey->published) {
$this->addFlash('error', 'Die Metadaten können nach der Veröffentlichung im Frontend nicht mehr geändert werden.');
}
if (!$survey instanceof SurveyModel) {
-23
View File
@@ -242,16 +242,6 @@ final class SurveyDcaListener
return $surveyId > 0 ? $this->surveyEditorRepository->findMemberIdsBySurvey($surveyId) : [];
}
public function guardContentSave(mixed $value, DataContainer $dataContainer): mixed
{
return $value;
}
public function guardConditionSave(mixed $value, DataContainer $dataContainer): mixed
{
return $value;
}
public function guardEditorSave(mixed $value, DataContainer $dataContainer): mixed
{
$surveyId = $this->resolveSurveyId('tl_survey_editor', $dataContainer);
@@ -389,10 +379,6 @@ final class SurveyDcaListener
$this->surveyRepository->refreshListMetadata($surveyId);
}
public function guardContentDelete(DataContainer $dataContainer): void
{
}
public function touchSurveyContentParent(DataContainer $dataContainer): void
{
$surveyId = $this->resolveSurveyId('tl_survey_content', $dataContainer);
@@ -402,10 +388,6 @@ final class SurveyDcaListener
}
}
public function guardConditionDelete(DataContainer $dataContainer): void
{
}
public function touchSurveyConditionParent(DataContainer $dataContainer): void
{
$surveyId = $this->resolveSurveyId('tl_survey_condition', $dataContainer);
@@ -424,11 +406,6 @@ final class SurveyDcaListener
}
}
public function guardSurveyStructureSave(mixed $value, DataContainer $dataContainer): mixed
{
return $value;
}
public function resolveSurveyContentPalette(string $palette, DataContainer $dataContainer): string
{
$type = (string) ($dataContainer->activeRecord->type ?? '');
-3
View File
@@ -10,14 +10,12 @@ final class SurveyEditorData
{
public string $title = '';
public string $description = '';
public bool $published = false;
public static function fromModel(SurveyModel $survey): self
{
$data = new self();
$data->title = (string) $survey->title;
$data->description = (string) $survey->description;
$data->published = '1' === (string) $survey->published;
return $data;
}
@@ -30,7 +28,6 @@ final class SurveyEditorData
return [
'title' => $this->title,
'description' => $this->description,
'published' => $this->published,
];
}
}
-5
View File
@@ -6,7 +6,6 @@ namespace Mummert\SurveyBundle\Form;
use Mummert\SurveyBundle\Form\Model\SurveyEditorData;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
@@ -29,10 +28,6 @@ final class SurveyEditorType extends AbstractType
'empty_data' => '',
'attr' => ['rows' => 5],
])
->add('published', CheckboxType::class, [
'label' => 'Veröffentlicht',
'required' => false,
])
;
}
-14
View File
@@ -24,34 +24,20 @@ survey:
login_required: "Dieses Frontendmodul ist für eingeloggte Mitglieder gedacht. Nutzen Sie den normalen Contao-Mitgliederlogin auf einer geschützten Seite."
entry_not_allowed: "Diese Seite kann nicht direkt geöffnet werden. Bitte wechseln Sie über die Umfragen-Liste in den Bearbeitungsmodus."
create_title: "Neue Umfrage erstellen"
create_text: "Die Umfrage wird nach dem Anlegen automatisch dem eingeloggten Mitglied zugewiesen."
label_title: "Titel"
label_survey_title: "Titel der Umfrage"
label_description: "Beschreibung"
publish_directly: "Direkt veröffentlichen"
create_submit: "Umfrage erstellen"
back_to_list: "Zur Liste"
public_view_open: "Öffentliche Ansicht öffnen"
copy_public_link: "Öffentlichen Link kopieren"
copy_public_link_success: "Link kopiert"
public_link: "Öffentlicher Link"
no_public_page: "Noch keine öffentliche Seite hinterlegt."
status: "Status"
editors: "Bearbeitende"
editors_count: "%count% Mitglied(er)"
published: "veröffentlicht"
draft: "Entwurf"
locked: "gesperrt"
structure_locked: "Die Fragen dieser Umfrage sind gesperrt, weil die Umfrage veröffentlicht wurde oder bereits erste Teilnahmen vorliegen. Die Metadaten können weiter gepflegt werden."
published_readonly: "Diese Umfrage ist veröffentlicht. Die Bearbeitung im Frontend ist deshalb deaktiviert. Änderungen sind weiterhin im Backend möglich."
metadata: "Umfrage-Metadaten"
publish_survey: "Umfrage veröffentlichen"
publish_help: "Umfrage veröffentlichen. Danach sind keine Änderungen mehr möglich."
publish_confirm: "Sind Sie wirklich sicher? Nachdem die Umfrage veröffentlicht wurde sind keine Änderungen mehr möglich!"
deactivate_survey: "Umfrage vorübergehend deaktivieren"
activate_survey: "Umfrage wieder aktivieren"
deactivate_help: "Die veröffentlichte Umfrage wird vorübergehend offline genommen. Fragen bleiben weiter gesperrt."
activate_help: "Die veröffentlichte Umfrage wird wieder öffentlich erreichbar gemacht. Fragen bleiben weiter gesperrt."
save: "Speichern"
save_metadata: "Metadaten speichern"
save_this_question: "Diese Frage speichern"
-14
View File
@@ -24,34 +24,20 @@ survey:
login_required: "This frontend module is intended for logged-in members. Please use the regular Contao member login on a protected page."
entry_not_allowed: "This page cannot be opened directly. Please switch to edit mode via the survey list."
create_title: "Create new survey"
create_text: "The survey will automatically be assigned to the logged-in member after creation."
label_title: "Title"
label_survey_title: "Survey title"
label_description: "Description"
publish_directly: "Publish immediately"
create_submit: "Create survey"
back_to_list: "Back to list"
public_view_open: "Open public view"
copy_public_link: "Copy public link"
copy_public_link_success: "Link copied"
public_link: "Public link"
no_public_page: "No public page configured yet."
status: "Status"
editors: "Editors"
editors_count: "%count% member(s)"
published: "published"
draft: "draft"
locked: "locked"
structure_locked: "The questions of this survey are locked because the survey was published or first participations already exist. The metadata can still be maintained."
published_readonly: "This survey is published. Frontend editing is therefore disabled. Changes are still possible in the backend."
metadata: "Survey metadata"
publish_survey: "Publish survey"
publish_help: "Publish survey. No further changes will be possible afterwards."
publish_confirm: "Are you really sure? After the survey has been published, no further changes will be possible!"
deactivate_survey: "Temporarily deactivate survey"
activate_survey: "Reactivate survey"
deactivate_help: "The published survey is temporarily taken offline. Questions remain locked."
activate_help: "The published survey is made publicly reachable again. Questions remain locked."
save: "Save"
save_metadata: "Save metadata"
save_this_question: "Save this question"