diff --git a/Classes/Controller/FormController.php b/Classes/Controller/FormController.php index 8e2ade0e..794eed4f 100644 --- a/Classes/Controller/FormController.php +++ b/Classes/Controller/FormController.php @@ -105,8 +105,6 @@ *Documentation:End */ /** Documentation:Start:GeneralOptions/Index.rst. - * - *.. include:: /Includes.rst.txt * *.. _general-options: * @@ -114,11 +112,32 @@ *General Options *=============== * + * *All forms are build via TypoScript as predefined forms. * + * + *.. toctree:: + * :maxdepth: 2 + * :hidden: + * + * Settings + * PredefinedForm + * Step + * + *Documentation:End + */ +/** Documentation:Start:GeneralOptions/Settings.rst. + * + *.. include:: /Includes.rst.txt + * + *.. _settings: + * + *======== *Settings *======== * + *All forms are build via TypoScript as predefined forms. + * *.. list-table:: * :align: left * :width: 100% @@ -197,7 +216,7 @@ * :stub-columns: 0 * * * - **predefinedForm** - * - See `Predefined Forms `__ + * - See :ref:`Predefined-Form` * * - * - * * - *Mandatory* @@ -273,296 +292,6 @@ * * - *Data Type* * - MailModel * - *Predefined Forms - *================ - * - *.. _predefined-forms-label: - * - *.. list-table:: - * :align: left - * :width: 100% - * :widths: 20 80 - * :header-rows: 0 - * :stub-columns: 0 - * - * * - **TypoScript Path** - * - plugin.tx_formhandler_form.settings.predefinedForms.FormName - * - *.. code-block:: typoscript - * - * Example Code: - * - * plugin.tx_formhandler_form.settings.predefinedForms.devExample { - * formId = DevExampleForm - * formName = Dev Example Form - * formValuesPrefix = DevExampleForm - * langFileDefault = locallang_example_form.xlf - * templateForm = DevExample/Default - * templateMailHtml = DevExample/MailHtml - * templateMailText = DevExample/MailText - * - * debuggers { - * } - * - * steps { - * 1 { - * templateForm = DevExampleForm/DevExampleHTMLStep1 - * validators { - * DefaultValidator { - * model = DefaultValidatorModel - * config { - * messageLimit = 1 - * messageLimits { - * 1.customer.email = 2 - * } - * fields { - * customer.fields { - * firstname.errorChecks { - * required { - * model = RequiredModel - * } - * maxLength { - * model = MaxLengthModel - * maxLength = 20 - * } - * } - * lastname.errorChecks { - * required { - * model = RequiredModel - * } - * maxLength { - * model = MaxLengthModel - * maxLength = 20 - * } - * } - * streetAddress.errorChecks { - * required { - * model = RequiredModel - * } - * } - * postalCode.errorChecks { - * required { - * model = RequiredModel - * } - * } - * city.errorChecks { - * required { - * model = RequiredModel - * } - * maxLength { - * model = MaxLengthModel - * maxLength = 70 - * } - * } - * country.errorChecks { - * required { - * model = RequiredModel - * } - * } - * telephone.errorChecks { - * required { - * model = RequiredModel - * } - * maxLength { - * model = MaxLengthModel - * maxLength = 20 - * } - * } - * email.errorChecks { - * required { - * model = RequiredModel - * } - * maxLength { - * model = MaxLengthModel - * maxLength = 50 - * } - * email { - * model = EmailModel - * } - * } - * } - * } - * } - * } - * } - * } - * } - * - * finishers { - * Mail { - * model = MailFinisherModel - * } - * Redirect { - * model = RedirectFinisherModel - * config { - * returns = true - * correctRedirectUrl = false - * additionalParams { - * postal_code = 1.customer.postalCode - * queryParam2 = valueIfNotFoundAsFieldName - * } - * } - * } - * } - * } - * - ***Properties** - * - *.. list-table:: - * :align: left - * :width: 100% - * :widths: 20 80 - * :header-rows: 0 - * :stub-columns: 0 - * - * * - **formId** - * - Value of the id attribute of the form tag. - * * - - * - - * * - *Mandatory* - * - True - * * - *Data Type* - * - String - * - *.. list-table:: - * :align: left - * :width: 100% - * :widths: 20 80 - * :header-rows: 0 - * :stub-columns: 0 - * - * * - **formName** - * - Value of the name shown in the dropdown list. - * * - - * - - * * - *Mandatory* - * - True - * * - *Data Type* - * - String - * - *.. list-table:: - * :align: left - * :width: 100% - * :widths: 20 80 - * :header-rows: 0 - * :stub-columns: 0 - * - * * - **formValuesPrefix** - * - Prefix of form fields. Use this if you use a prefix for your forms to avoid conflicts with other plugins. Settings this option you will be able to use only the fieldname in all markers and do not need to add prefix. - * * - - * - - * * - *Mandatory* - * - False - * * - *Data Type* - * - String - * * - *Default* - * - tx_formhandler_form - * * - *Note* - * - It is highly recommended to use this setting! - * - *.. list-table:: - * :align: left - * :width: 100% - * :widths: 20 80 - * :header-rows: 0 - * :stub-columns: 0 - * - * * - **langFileDefault** - * - Path to default language file, can be altered as parameter by the form fields. - * * - - * - - * * - *Mandatory* - * - False - * * - *Data Type* - * - String - * - *.. list-table:: - * :align: left - * :width: 100% - * :widths: 20 80 - * :header-rows: 0 - * :stub-columns: 0 - * - * * - **debuggers** - * - A list of :ref:`Debuggers` for the predefined forms. - * * - - * - - * * - *Mandatory* - * - False - * * - *Data Type* - * - Array`> - * - *.. list-table:: - * :align: left - * :width: 100% - * :widths: 20 80 - * :header-rows: 0 - * :stub-columns: 0 - * - * * - **steps** - * - You can split a form into as many steps as you like and add as many :ref:`Validators` as you like to each step, but even if the form has just one step it must be defined to add :ref:`Validators`. - * * - - * - - * * - *Mandatory* - * - True (Only if a form has needs :ref:`Validators`, otherwise not.) - * * - *Data Type* - * - Array`__> - * * - *Note* - * - The key Integer in Array`__> starts at 1 for first step. - * - *.. list-table:: - * :align: left - * :width: 100% - * :widths: 20 80 - * :header-rows: 0 - * :stub-columns: 0 - * - * * - **finishers** - * - A list of :ref:`Finishers` for the predefined forms. - * * - - * - - * * - *Mandatory* - * - False - * * - *Data Type* - * - Array`> - * - *Step - *==== - * - *.. _step-label: - * - *.. list-table:: - * :align: left - * :width: 100% - * :widths: 20 80 - * :header-rows: 0 - * :stub-columns: 0 - * - * * - **templateForm** - * - The template for a given step. - * * - - * - - * * - *Mandatory* - * - False - * * - *Data Type* - * - String - * - *.. list-table:: - * :align: left - * :width: 100% - * :widths: 20 80 - * :header-rows: 0 - * :stub-columns: 0 - * - * * - **validators** - * - A list of :ref:`Validators` for a given step. - * * - - * - - * * - *Mandatory* - * - False - * * - *Data Type* - * - Array`> - * *Documentation:End */ class FormController extends ActionController { @@ -672,11 +401,12 @@ public function formAction(): ResponseInterface { } } - $this->formConfig->processDebugLog(); + $debugOutput = $this->formConfig->processDebugLog(); // Prepare output $this->view->assignMultiple( [ + 'debugOutput' => $debugOutput, 'fieldsRequired' => $this->fieldsRequired, 'fieldsErrors' => $this->formConfig->fieldsErrors, 'fieldSets' => $this->formConfig->fieldSets, @@ -800,7 +530,7 @@ private function formStepIsLast(): bool { private function formSubmitted(): bool { if (is_array($this->parsedBody[FormhandlerExtensionConfig::EXTENSION_KEY] ?? false)) { - return boolval($this->parsedBody[FormhandlerExtensionConfig::EXTENSION_KEY]['submitted'] ?? false); + return filter_var($this->parsedBody[FormhandlerExtensionConfig::EXTENSION_KEY]['submitted'] ?? false, FILTER_VALIDATE_BOOLEAN); } return false; diff --git a/Classes/Debugger/AbstractDebugger.php b/Classes/Debugger/AbstractDebugger.php index ff3d5f45..d0aa1503 100644 --- a/Classes/Debugger/AbstractDebugger.php +++ b/Classes/Debugger/AbstractDebugger.php @@ -5,7 +5,6 @@ namespace Typoheads\Formhandler\Debugger; use TYPO3\CMS\Core\SingletonInterface; -use Typoheads\Formhandler\Definitions\Severity; use Typoheads\Formhandler\Domain\Model\Config\Debugger\AbstractDebuggerModel; use Typoheads\Formhandler\Domain\Model\Config\FormModel; @@ -25,9 +24,9 @@ public function init( } /** - * @param array|object|string}>> $debugLog + * @param array|object|string}>> $debugLog */ abstract public function processDebugLog( array $debugLog, - ): void; + ): ?string; } diff --git a/Classes/Debugger/PrintToScreenDebugger.php b/Classes/Debugger/PrintToScreenDebugger.php new file mode 100644 index 00000000..33aa0b92 --- /dev/null +++ b/Classes/Debugger/PrintToScreenDebugger.php @@ -0,0 +1,58 @@ +debuggerConfig instanceof PrintToScreenDebuggerModel) { + return null; + } + if (!$this->debuggerConfig->active || 'html' != $this->formConfig->responseType) { + return null; + } + + $debugOutput = ''; + + foreach ($debugLog as $section => $logData) { + $debugOutput .= str_replace('|', $section, $this->debuggerConfig->sectionHeaderWrap); + $sectionContent = ''; + foreach ($logData as $messageData) { + $message = str_replace("\n", '
', $messageData['message']); + $message = str_replace('|', $message, $this->debuggerConfig->severityWrap[$messageData['severity']]); + + $sectionContent .= str_replace('|', $message, $this->debuggerConfig->messageWrap); + + if ($messageData['data']) { + $sectionContent .= trim(DebuggerUtility::var_dump($messageData['data'], '', $this->debuggerConfig->maxDepth, false, false, true)); + $sectionContent .= '
'; + } + } + $debugOutput .= str_replace('|', $sectionContent, $this->debuggerConfig->sectionWrap); + } + + return $debugOutput; + } +} diff --git a/Classes/Debugger/VarDumpDebugger.php b/Classes/Debugger/VarDumpDebugger.php index 4e1de165..98627808 100644 --- a/Classes/Debugger/VarDumpDebugger.php +++ b/Classes/Debugger/VarDumpDebugger.php @@ -10,12 +10,12 @@ class VarDumpDebugger extends AbstractDebugger { public function processDebugLog( array $debugLog, - ): void { + ): ?string { if (!$this->debuggerConfig instanceof VarDumpDebuggerModel) { - return; + return null; } if (!$this->debuggerConfig->active || 'html' != $this->formConfig->responseType) { - return; + return null; } DebuggerUtility::var_dump( @@ -28,5 +28,7 @@ public function processDebugLog( $this->debuggerConfig->blacklistedClassNames, $this->debuggerConfig->blacklistedPropertyNames, ); + + return null; } } diff --git a/Classes/Definitions/Severity.php b/Classes/Definitions/Severity.php index 68062612..68575d70 100644 --- a/Classes/Definitions/Severity.php +++ b/Classes/Definitions/Severity.php @@ -4,10 +4,10 @@ namespace Typoheads\Formhandler\Definitions; -enum Severity: int { - case Error = 3; +class Severity { + public const Error = 3; - case Info = 1; + public const Info = 1; - case Warning = 2; + public const Warning = 2; } diff --git a/Classes/Domain/Model/Config/Debugger/AbstractDebuggerModel.php b/Classes/Domain/Model/Config/Debugger/AbstractDebuggerModel.php index 87e7f962..bcb527f6 100644 --- a/Classes/Domain/Model/Config/Debugger/AbstractDebuggerModel.php +++ b/Classes/Domain/Model/Config/Debugger/AbstractDebuggerModel.php @@ -26,26 +26,17 @@ * * - **TypoScript Path** * - plugin.tx_formhandler_form.settings.predefinedForms.FormName * - *.. code-block:: typoscript - * - * Example Code: - * - * plugin.tx_formhandler_form.settings.predefinedForms.devExample { - * debuggers { - * VarDumpDebugger { - * model = VarDumpDebuggerModel - * config { - * active = true - * maxDepth = 20 - * } - * } - * } - * } + *:ref:`PrintToScreenDebugger` + * Will print out the debug messages to screen. + * + *:ref:`VarDumpDebugger` + * Will print out the debug messages to screen as VarDump. * *.. toctree:: * :maxdepth: 2 * :hidden: * + * PrintToScreenDebugger * VarDumpDebugger * *Documentation:End diff --git a/Classes/Domain/Model/Config/Debugger/PrintToScreenDebuggerModel.php b/Classes/Domain/Model/Config/Debugger/PrintToScreenDebuggerModel.php new file mode 100644 index 00000000..101741a7 --- /dev/null +++ b/Classes/Domain/Model/Config/Debugger/PrintToScreenDebuggerModel.php @@ -0,0 +1,216 @@ +| + * 2 = | + * 3 = | + * } + * } + * } + * } + * } + * + * + ***Properties** + * + *.. list-table:: + * :align: left + * :width: 100% + * :widths: 20 80 + * :header-rows: 0 + * :stub-columns: 0 + * + * * - **active** + * - Status of the debugger + * * - + * - + * * - *Mandatory* + * - False + * * - *Data Type* + * - Boolean + * * - *Default* + * - False + * + *.. list-table:: + * :align: left + * :width: 100% + * :widths: 20 80 + * :header-rows: 0 + * :stub-columns: 0 + * + * * - **maxDepth** + * - Sets the max recursion depth of the dump. De- or increase the number according to your needs and memory limit. + * * - + * - + * * - *Mandatory* + * - False + * * - *Data Type* + * - Integer + * * - *Default* + * - 8 + * + *.. list-table:: + * :align: left + * :width: 100% + * :widths: 20 80 + * :header-rows: 0 + * :stub-columns: 0 + * + * * - **messageWrap** + * - Wrap for a single debug message + * * - + * - + * * - *Mandatory* + * - False + * * - *Data Type* + * - String + * * - *Default* + * -
|
+ * + *.. list-table:: + * :align: left + * :width: 100% + * :widths: 20 80 + * :header-rows: 0 + * :stub-columns: 0 + * + * * - **sectionHeaderWrap** + * - Wrap for a section header + * * - + * - + * * - *Mandatory* + * - False + * * - *Data Type* + * - String + * * - *Default* + * -

|

+ * + *.. list-table:: + * :align: left + * :width: 100% + * :widths: 20 80 + * :header-rows: 0 + * :stub-columns: 0 + * + * * - **sectionWrap** + * - Wrap for a section (e.g. all log messages of a component are wrapped in a section) + * * - + * - + * * - *Mandatory* + * - False + * * - *Data Type* + * - String + * * - *Default* + * -
|
+ * + *.. list-table:: + * :align: left + * :width: 100% + * :widths: 20 80 + * :header-rows: 0 + * :stub-columns: 0 + * + * * - **blacklistedPropertyNames** + * - Use this to configure different appearance of different log severity levels. + * * - + * - + * * - *Mandatory* + * - False + * * - *Data Type* + * - Array + * * - *Default* + * - | severityWrap { + * | 1 = | + * | 2 = | + * | 3 = | + * | } + * * - *Note* + * - The key Integer in Array is the severity level (1-3). + * + *Documentation:End + */ +class PrintToScreenDebuggerModel extends AbstractDebuggerModel { + public readonly bool $active; + + public readonly int $maxDepth; + + public readonly string $messageWrap; + + public readonly string $sectionHeaderWrap; + + public readonly string $sectionWrap; + + /** @var array */ + public readonly array $severityWrap; + + /** + * @param array $config + */ + public function __construct(array $config) { + $this->active = filter_var($config['active'] ?? false, FILTER_VALIDATE_BOOLEAN); + + $this->maxDepth = intval($config['maxDepth'] ?? 8); + + $this->messageWrap = strval($config['messageWrap'] ?? '
|
'); + $this->sectionHeaderWrap = strval($config['sectionHeaderWrap'] ?? '

|

'); + $this->sectionWrap = strval($config['sectionWrap'] ?? '
|
'); + + $SeverityInfoDefault = '|'; + $SeverityWarningDefault = '|'; + $SeverityErrorDefault = '|'; + + if (isset($config['severityWrap']) && is_array($config['severityWrap'])) { + $severityWrap[Severity::Info] = $config['severityWrap'][Severity::Info] ?? $SeverityInfoDefault; + $severityWrap[Severity::Warning] = $config['severityWrap'][Severity::Info] ?? $SeverityWarningDefault; + $severityWrap[Severity::Error] = $config['severityWrap'][Severity::Info] ?? $SeverityErrorDefault; + + $this->severityWrap = $severityWrap; + } else { + $severityWrap[Severity::Info] = $SeverityInfoDefault; + $severityWrap[Severity::Warning] = $SeverityWarningDefault; + $severityWrap[Severity::Error] = $SeverityErrorDefault; + $this->severityWrap = $severityWrap; + } + } + + public function class(): string { + return PrintToScreenDebugger::class; + } +} diff --git a/Classes/Domain/Model/Config/Debugger/VarDumpDebuggerModel.php b/Classes/Domain/Model/Config/Debugger/VarDumpDebuggerModel.php index 2822b00c..0cb5bbf5 100644 --- a/Classes/Domain/Model/Config/Debugger/VarDumpDebuggerModel.php +++ b/Classes/Domain/Model/Config/Debugger/VarDumpDebuggerModel.php @@ -26,6 +26,23 @@ * * - **TypoScript Path** * - plugin.tx_formhandler_form.settings.predefinedForms.[x].debuggers.VarDumpDebugger * + *.. code-block:: typoscript + * + * Example Code: + * + * plugin.tx_formhandler_form.settings.predefinedForms.devExample { + * debuggers { + * VarDumpDebugger { + * model = VarDumpDebuggerModel + * config { + * active = true + * maxDepth = 20 + * } + * } + * } + * } + * + * ***Properties** * *.. list-table:: @@ -197,8 +214,8 @@ class VarDumpDebuggerModel extends AbstractDebuggerModel { * @param array $config */ public function __construct(array $config) { - $this->active = boolval($config['active'] ?? false); - $this->ansiColors = boolval($config['ansiColors'] ?? true); + $this->active = filter_var($config['active'] ?? false, FILTER_VALIDATE_BOOLEAN); + $this->ansiColors = filter_var($config['ansiColors'] ?? true, FILTER_VALIDATE_BOOLEAN); if (isset($config['blacklistedClassNames']) && is_array($config['blacklistedClassNames'])) { $this->blacklistedClassNames = $config['blacklistedClassNames']; @@ -213,8 +230,8 @@ public function __construct(array $config) { } $this->maxDepth = intval($config['maxDepth'] ?? 8); - $this->plainText = boolval($config['plainText'] ?? false); - $this->return = boolval($config['return'] ?? false); + $this->plainText = filter_var($config['plainText'], FILTER_VALIDATE_BOOLEAN); + $this->return = filter_var($config['return'], FILTER_VALIDATE_BOOLEAN); if (isset($config['title'])) { $this->title = strval($config['title']); diff --git a/Classes/Domain/Model/Config/Finisher/MailFinisherModel.php b/Classes/Domain/Model/Config/Finisher/MailFinisherModel.php index 84ee32c9..7bf92be7 100644 --- a/Classes/Domain/Model/Config/Finisher/MailFinisherModel.php +++ b/Classes/Domain/Model/Config/Finisher/MailFinisherModel.php @@ -24,7 +24,7 @@ class MailFinisherModel extends AbstractFinisherModel { * @param array $settings */ public function __construct(array $settings) { - $this->returns = boolval($settings['returns'] ?? false); + $this->returns = filter_var($settings['returns'] ?? false, FILTER_VALIDATE_BOOLEAN); } public function class(): string { diff --git a/Classes/Domain/Model/Config/Finisher/RedirectFinisherModel.php b/Classes/Domain/Model/Config/Finisher/RedirectFinisherModel.php index 4eef6749..c4469cff 100644 --- a/Classes/Domain/Model/Config/Finisher/RedirectFinisherModel.php +++ b/Classes/Domain/Model/Config/Finisher/RedirectFinisherModel.php @@ -135,7 +135,7 @@ class RedirectFinisherModel extends AbstractFinisherModel { * @param array $settings */ public function __construct(array $settings) { - $this->returns = boolval($settings['returns'] ?? false); + $this->returns = filter_var($settings['returns'] ?? false, FILTER_VALIDATE_BOOLEAN); $additionalParams = []; if (is_array($settings['additionalParams'] ?? false)) { foreach ($settings['additionalParams'] as $queryParam => $valueOrFieldName) { @@ -144,7 +144,7 @@ public function __construct(array $settings) { } $this->additionalParams = $additionalParams; - $this->correctRedirectUrl = boolval($settings['correctRedirectUrl'] ?? false); + $this->correctRedirectUrl = filter_var($settings['correctRedirectUrl'] ?? false, FILTER_VALIDATE_BOOLEAN); $this->headerStatusCode = intval($settings['headerStatusCode'] ?? 303); } diff --git a/Classes/Domain/Model/Config/FormModel.php b/Classes/Domain/Model/Config/FormModel.php index b8d7f67b..59702683 100644 --- a/Classes/Domain/Model/Config/FormModel.php +++ b/Classes/Domain/Model/Config/FormModel.php @@ -18,6 +18,266 @@ use Typoheads\Formhandler\Session\AbstractSession; use Typoheads\Formhandler\Utility\Utility; +/** Documentation:Start:GeneralOptions/PredefinedForm.rst. + * + *.. _predefined-form: + * + *=============== + *Predefined Form + *=============== + * + * Predefine form settings and make them selectable in plugin record. + * + *.. list-table:: + * :align: left + * :width: 100% + * :widths: 20 80 + * :header-rows: 0 + * :stub-columns: 0 + * + * * - **TypoScript Path** + * - plugin.tx_formhandler_form.settings.predefinedForms.FormName + * + *.. code-block:: typoscript + * + * Example Code: + * + * plugin.tx_formhandler_form.settings.predefinedForms.devExample { + * formId = DevExampleForm + * formName = Dev Example Form + * formValuesPrefix = DevExampleForm + * langFileDefault = locallang_example_form.xlf + * templateForm = DevExample/Default + * templateMailHtml = DevExample/MailHtml + * templateMailText = DevExample/MailText + * + * debuggers { + * } + * + * steps { + * 1 { + * templateForm = DevExampleForm/DevExampleHTMLStep1 + * validators { + * DefaultValidator { + * model = DefaultValidatorModel + * config { + * messageLimit = 1 + * messageLimits { + * 1.customer.email = 2 + * } + * fields { + * customer.fields { + * firstname.errorChecks { + * required { + * model = RequiredModel + * } + * maxLength { + * model = MaxLengthModel + * maxLength = 20 + * } + * } + * lastname.errorChecks { + * required { + * model = RequiredModel + * } + * maxLength { + * model = MaxLengthModel + * maxLength = 20 + * } + * } + * streetAddress.errorChecks { + * required { + * model = RequiredModel + * } + * } + * postalCode.errorChecks { + * required { + * model = RequiredModel + * } + * } + * city.errorChecks { + * required { + * model = RequiredModel + * } + * maxLength { + * model = MaxLengthModel + * maxLength = 70 + * } + * } + * country.errorChecks { + * required { + * model = RequiredModel + * } + * } + * telephone.errorChecks { + * required { + * model = RequiredModel + * } + * maxLength { + * model = MaxLengthModel + * maxLength = 20 + * } + * } + * email.errorChecks { + * required { + * model = RequiredModel + * } + * maxLength { + * model = MaxLengthModel + * maxLength = 50 + * } + * email { + * model = EmailModel + * } + * } + * } + * } + * } + * } + * } + * } + * } + * + * finishers { + * Mail { + * model = MailFinisherModel + * } + * Redirect { + * model = RedirectFinisherModel + * config { + * returns = true + * correctRedirectUrl = false + * additionalParams { + * postal_code = 1.customer.postalCode + * queryParam2 = valueIfNotFoundAsFieldName + * } + * } + * } + * } + * } + * + ***Properties** + * + *.. list-table:: + * :align: left + * :width: 100% + * :widths: 20 80 + * :header-rows: 0 + * :stub-columns: 0 + * + * * - **formId** + * - Value of the id attribute of the form tag. + * * - + * - + * * - *Mandatory* + * - True + * * - *Data Type* + * - String + * + *.. list-table:: + * :align: left + * :width: 100% + * :widths: 20 80 + * :header-rows: 0 + * :stub-columns: 0 + * + * * - **formName** + * - Value of the name shown in the dropdown list. + * * - + * - + * * - *Mandatory* + * - True + * * - *Data Type* + * - String + * + *.. list-table:: + * :align: left + * :width: 100% + * :widths: 20 80 + * :header-rows: 0 + * :stub-columns: 0 + * + * * - **formValuesPrefix** + * - Prefix of form fields. Use this if you use a prefix for your forms to avoid conflicts with other plugins. Settings this option you will be able to use only the fieldname in all markers and do not need to add prefix. + * * - + * - + * * - *Mandatory* + * - False + * * - *Data Type* + * - String + * * - *Default* + * - tx_formhandler_form + * * - *Note* + * - It is highly recommended to use this setting! + * + *.. list-table:: + * :align: left + * :width: 100% + * :widths: 20 80 + * :header-rows: 0 + * :stub-columns: 0 + * + * * - **langFileDefault** + * - Path to default language file, can be altered as parameter by the form fields. + * * - + * - + * * - *Mandatory* + * - False + * * - *Data Type* + * - String + * + *.. list-table:: + * :align: left + * :width: 100% + * :widths: 20 80 + * :header-rows: 0 + * :stub-columns: 0 + * + * * - **debuggers** + * - A list of :ref:`Debuggers` for the predefined forms. + * * - + * - + * * - *Mandatory* + * - False + * * - *Data Type* + * - Array`> + * + *.. list-table:: + * :align: left + * :width: 100% + * :widths: 20 80 + * :header-rows: 0 + * :stub-columns: 0 + * + * * - **steps** + * - You can split a form into as many steps as you like and add as many :ref:`Validators` as you like to each step, but even if the form has just one step it must be defined to add :ref:`Validators`. + * * - + * - + * * - *Mandatory* + * - True (Only if a form has needs :ref:`Validators`, otherwise not.) + * * - *Data Type* + * - Array + * * - *Note* + * - The key Integer in Array starts at 1 for first step. + * + *.. list-table:: + * :align: left + * :width: 100% + * :widths: 20 80 + * :header-rows: 0 + * :stub-columns: 0 + * + * * - **finishers** + * - A list of :ref:`Finishers` for the predefined forms. + * * - + * - + * * - *Mandatory* + * - False + * * - *Data Type* + * - Array`> + * + *Documentation:End + */ class FormModel { public MailModel $admin; @@ -89,7 +349,7 @@ class FormModel { /** @var AbstractDebugger[] */ private array $debuggers = []; - /** @var array|object|string}>> */ + /** @var array|object|string}>> */ private array $debugLog = []; /** @@ -214,10 +474,10 @@ public function __construct(array $settings) { * * @param string $key The message or key in language file (locallang_debug.xlf) * @param array $printfArgs if the message contains placeholders for usage with printf, pass the replacement values in this array - * @param Severity $severity The severity of the message. Valid values are Severity::Info, Severity::Warning and Severity::Error + * @param int $severity The severity of the message. Valid values are Severity::Info, Severity::Warning and Severity::Error * @param array|bool|float|int|object|string $data Additional debug data (e.g. the array of GET/POST values) */ - public function debugMessage(string $key, array $printfArgs = [], Severity $severity = Severity::Info, array|bool|float|int|object|string $data = []): void { + public function debugMessage(string $key, array $printfArgs = [], int $severity = Severity::Info, array|bool|float|int|object|string $data = []): void { if (empty($this->debuggers)) { return; } @@ -246,9 +506,16 @@ public function debugMessage(string $key, array $printfArgs = [], Severity $seve $this->debugLog[$section][] = ['message' => $message, 'severity' => $severity, 'data' => $data]; } - public function processDebugLog(): void { + public function processDebugLog(): ?string { + $debugOutput = null; + foreach ($this->debuggers as $debugger) { - $debugger->processDebugLog($this->debugLog); + $debuggerOutput = $debugger->processDebugLog($this->debugLog); + if (null !== $debuggerOutput) { + $debugOutput .= $debuggerOutput; + } } + + return $debugOutput; } } diff --git a/Classes/Domain/Model/Config/Interceptor/AbstractInterceptorModel.php b/Classes/Domain/Model/Config/Interceptor/AbstractInterceptorModel.php index 0a5d1094..9c057c24 100644 --- a/Classes/Domain/Model/Config/Interceptor/AbstractInterceptorModel.php +++ b/Classes/Domain/Model/Config/Interceptor/AbstractInterceptorModel.php @@ -6,6 +6,93 @@ use Typoheads\Formhandler\Interceptor\AbstractInterceptor; +/** Documentation:Start:TocTree:Interceptors/Index.rst. + * + *.. _interceptors: + * + *============ + *Interceptors + *============ + * + *You can enter as many Interceptors as you like. Each entry requires a model name of the Interceptor. Optionally you can enter specific configuration for the Interceptor in the config section. + * + *.. list-table:: + * :align: left + * :width: 100% + * :widths: 20 80 + * :header-rows: 0 + * :stub-columns: 0 + * + * * - **TypoScript Path** + * - plugin.tx_formhandler_form.settings.predefinedForms.[x].(init/save)Interceptors + * + *:ref:`InitInterceptors` + * The init interceptors are called before every time the form is displayed or the :ref:`Validators` are called. + * + *:ref:`SaveInterceptors` + * The save interceptors are called after all steps are validated and before the :ref:`Loggers` and :ref:`Finishers` are called. + * + *.. toctree:: + * :maxdepth: 2 + * :hidden: + * + * InitInterceptors + * SaveInterceptors + * + *Documentation:End + */ +/** Documentation:Start:Interceptors/InitInterceptors.rst. + * + *.. _initinterceptors: + * + *================ + *InitInterceptors + *================ + * + *The init interceptors are called before every time the form is displayed. + * + *.. list-table:: + * :align: left + * :width: 100% + * :widths: 20 80 + * :header-rows: 0 + * :stub-columns: 0 + * + * * - **TypoScript Path** + * - plugin.tx_formhandler_form.settings.predefinedForms.[x].initInterceptors + * + *.. toctree:: + * :maxdepth: 2 + * :hidden: + * + *Documentation:End + */ +/** Documentation:Start:Interceptors/SaveInterceptors.rst. + * + *.. _saveinterceptors: + * + *================ + *SaveInterceptors + *================ + * + *The save interceptors are called after all steps are validated and before the loggers and finishers are called. + * + *.. list-table:: + * :align: left + * :width: 100% + * :widths: 20 80 + * :header-rows: 0 + * :stub-columns: 0 + * + * * - **TypoScript Path** + * - plugin.tx_formhandler_form.settings.predefinedForms.[x].saveInterceptors + * + *.. toctree:: + * :maxdepth: 2 + * :hidden: + * + *Documentation:End + */ abstract class AbstractInterceptorModel { /** * @param array $settings diff --git a/Classes/Domain/Model/Config/Logger/AbstractLoggerModel.php b/Classes/Domain/Model/Config/Logger/AbstractLoggerModel.php index f35844c1..607248ef 100644 --- a/Classes/Domain/Model/Config/Logger/AbstractLoggerModel.php +++ b/Classes/Domain/Model/Config/Logger/AbstractLoggerModel.php @@ -6,6 +6,39 @@ use Typoheads\Formhandler\Logger\AbstractLogger; +/** Documentation:Start:TocTree:Loggers/Index.rst. + * + *.. _loggers: + * + *======= + *Loggers + *======= + * + *Loggers take care of logging every form submission. + * + *Logger\DB gets called by Formhandler automatically as its log data is used by various :ref:`Finishers` and Generators and the Backend Module. + * + *.. list-table:: + * :align: left + * :width: 100% + * :widths: 20 80 + * :header-rows: 0 + * :stub-columns: 0 + * + * * - **TypoScript Path** + * - plugin.tx_formhandler_form.settings.predefinedForms.[x].loggers + * + *:ref:`DatabaseLogger` + * Will log into tx_formhandler_log. The logs can be accessed via the Formhandler backend module. + * + *.. toctree:: + * :maxdepth: 2 + * :hidden: + * + * DatabaseLogger + * + *Documentation:End + */ abstract class AbstractLoggerModel { /** * @param array $settings diff --git a/Classes/Domain/Model/Config/Logger/DatabaseLoggerModel.php b/Classes/Domain/Model/Config/Logger/DatabaseLoggerModel.php index 02dc0f52..683b88fb 100644 --- a/Classes/Domain/Model/Config/Logger/DatabaseLoggerModel.php +++ b/Classes/Domain/Model/Config/Logger/DatabaseLoggerModel.php @@ -6,6 +6,32 @@ use Typoheads\Formhandler\Logger\DatabaseLogger; +/** Documentation:Start:Loggers/DatabaseLogger.rst. + * + *.. _databaselogger: + * + *============== + *DatabaseLogger + *============== + * + *Will log into tx_formhandler_log. The logs can be accessed via the Formhandler backend module. + * + *.. list-table:: + * :align: left + * :width: 100% + * :widths: 20 80 + * :header-rows: 0 + * :stub-columns: 0 + * + * * - **TypoScript Path** + * - plugin.tx_formhandler_form.settings.predefinedForms.[x].loggers + * + *.. toctree:: + * :maxdepth: 2 + * :hidden: + * + *Documentation:End + */ class DatabaseLoggerModel extends AbstractLoggerModel { /** * @param array $settings diff --git a/Classes/Domain/Model/Config/StepModel.php b/Classes/Domain/Model/Config/StepModel.php index 8a964964..649a051b 100644 --- a/Classes/Domain/Model/Config/StepModel.php +++ b/Classes/Domain/Model/Config/StepModel.php @@ -8,6 +8,48 @@ use Typoheads\Formhandler\Domain\Model\Config\Validator\AbstractValidatorModel; use Typoheads\Formhandler\Utility\Utility; +/** Documentation:Start:GeneralOptions/Step.rst. + * + *.. _step: + * + *==== + *Step + *==== + * + *.. list-table:: + * :align: left + * :width: 100% + * :widths: 20 80 + * :header-rows: 0 + * :stub-columns: 0 + * + * * - **templateForm** + * - The template for a given step. + * * - + * - + * * - *Mandatory* + * - False + * * - *Data Type* + * - String + * + *.. list-table:: + * :align: left + * :width: 100% + * :widths: 20 80 + * :header-rows: 0 + * :stub-columns: 0 + * + * * - **validators** + * - A list of :ref:`Validators` for a given step. + * * - + * - + * * - *Mandatory* + * - False + * * - *Data Type* + * - Array`> + * + *Documentation:End + */ class StepModel { /** @var AbstractValidatorModel[] */ public readonly array $validators; diff --git a/Classes/Domain/Model/Config/Validator/Field/FieldModel.php b/Classes/Domain/Model/Config/Validator/Field/FieldModel.php index acb7b6e5..00d84fad 100644 --- a/Classes/Domain/Model/Config/Validator/Field/FieldModel.php +++ b/Classes/Domain/Model/Config/Validator/Field/FieldModel.php @@ -36,7 +36,7 @@ public function __construct( } $this->fields = $fields; - $this->fieldArray = boolval($settings['fieldArray'] ?? false); + $this->fieldArray = filter_var($settings['fieldArray'] ?? false, FILTER_VALIDATE_BOOLEAN); if (!isset($settings['errorChecks']) || !is_array($settings['errorChecks'])) { $this->errorChecks = []; diff --git a/Configuration/TypoScript/Example/HTML/DevExample.typoscript b/Configuration/TypoScript/Example/HTML/DevExample.typoscript index ecc07a08..8511d8e4 100644 --- a/Configuration/TypoScript/Example/HTML/DevExample.typoscript +++ b/Configuration/TypoScript/Example/HTML/DevExample.typoscript @@ -44,10 +44,9 @@ plugin.tx_formhandler_form.settings.predefinedForms.devExample { debuggers { VarDumpDebugger { - model = VarDumpDebuggerModel + model = PrintToScreenDebuggerModel config { active = true - maxDepth = 20 } } } diff --git a/Documentation/.buildinfo b/Documentation/.buildinfo index 94e170a2..642d9d83 100644 --- a/Documentation/.buildinfo +++ b/Documentation/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: 6c360dd9f21dbde8e9ab6cf4d704120f +config: 5d530a48f2ea346aa6c6b929e2c0d8cb tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/Documentation/.doctrees/Debuggers/Index.doctree b/Documentation/.doctrees/Debuggers/Index.doctree index 9495716a..ef4160d2 100644 Binary files a/Documentation/.doctrees/Debuggers/Index.doctree and b/Documentation/.doctrees/Debuggers/Index.doctree differ diff --git a/Documentation/.doctrees/Debuggers/PrintToScreenDebugger.doctree b/Documentation/.doctrees/Debuggers/PrintToScreenDebugger.doctree new file mode 100644 index 00000000..74316aa8 Binary files /dev/null and b/Documentation/.doctrees/Debuggers/PrintToScreenDebugger.doctree differ diff --git a/Documentation/.doctrees/Debuggers/VarDumpDebugger.doctree b/Documentation/.doctrees/Debuggers/VarDumpDebugger.doctree index f7a93bec..14eb00d1 100644 Binary files a/Documentation/.doctrees/Debuggers/VarDumpDebugger.doctree and b/Documentation/.doctrees/Debuggers/VarDumpDebugger.doctree differ diff --git a/Documentation/.doctrees/GeneralOptions/Index.doctree b/Documentation/.doctrees/GeneralOptions/Index.doctree index 43fd3de9..1c04c91e 100644 Binary files a/Documentation/.doctrees/GeneralOptions/Index.doctree and b/Documentation/.doctrees/GeneralOptions/Index.doctree differ diff --git a/Documentation/.doctrees/GeneralOptions/PredefinedForm.doctree b/Documentation/.doctrees/GeneralOptions/PredefinedForm.doctree new file mode 100644 index 00000000..9e85e1ae Binary files /dev/null and b/Documentation/.doctrees/GeneralOptions/PredefinedForm.doctree differ diff --git a/Documentation/.doctrees/GeneralOptions/Settings.doctree b/Documentation/.doctrees/GeneralOptions/Settings.doctree new file mode 100644 index 00000000..6cd8b7a8 Binary files /dev/null and b/Documentation/.doctrees/GeneralOptions/Settings.doctree differ diff --git a/Documentation/.doctrees/GeneralOptions/Step.doctree b/Documentation/.doctrees/GeneralOptions/Step.doctree new file mode 100644 index 00000000..a27b8fbc Binary files /dev/null and b/Documentation/.doctrees/GeneralOptions/Step.doctree differ diff --git a/Documentation/.doctrees/Index.doctree b/Documentation/.doctrees/Index.doctree index 2304971d..3c9fb65b 100644 Binary files a/Documentation/.doctrees/Index.doctree and b/Documentation/.doctrees/Index.doctree differ diff --git a/Documentation/.doctrees/Interceptors/Index.doctree b/Documentation/.doctrees/Interceptors/Index.doctree new file mode 100644 index 00000000..c39b3559 Binary files /dev/null and b/Documentation/.doctrees/Interceptors/Index.doctree differ diff --git a/Documentation/.doctrees/Interceptors/InitInterceptors.doctree b/Documentation/.doctrees/Interceptors/InitInterceptors.doctree new file mode 100644 index 00000000..4246ef53 Binary files /dev/null and b/Documentation/.doctrees/Interceptors/InitInterceptors.doctree differ diff --git a/Documentation/.doctrees/Interceptors/SaveInterceptors.doctree b/Documentation/.doctrees/Interceptors/SaveInterceptors.doctree new file mode 100644 index 00000000..a1b0a4f0 Binary files /dev/null and b/Documentation/.doctrees/Interceptors/SaveInterceptors.doctree differ diff --git a/Documentation/.doctrees/Loggers/DatabaseLogger.doctree b/Documentation/.doctrees/Loggers/DatabaseLogger.doctree new file mode 100644 index 00000000..ab3616b9 Binary files /dev/null and b/Documentation/.doctrees/Loggers/DatabaseLogger.doctree differ diff --git a/Documentation/.doctrees/Loggers/Index.doctree b/Documentation/.doctrees/Loggers/Index.doctree new file mode 100644 index 00000000..e9fbc8cb Binary files /dev/null and b/Documentation/.doctrees/Loggers/Index.doctree differ diff --git a/Documentation/.doctrees/environment.pickle b/Documentation/.doctrees/environment.pickle index 542182f5..af4a8da2 100644 Binary files a/Documentation/.doctrees/environment.pickle and b/Documentation/.doctrees/environment.pickle differ diff --git a/Documentation/Debuggers/Index.html b/Documentation/Debuggers/Index.html index ba63a47f..41fe9483 100644 --- a/Documentation/Debuggers/Index.html +++ b/Documentation/Debuggers/Index.html @@ -12,14 +12,16 @@ + + - - + + @@ -33,17 +35,27 @@ Formhandler +
+
+ + + +
+