Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 102 additions & 6 deletions Classes/Domain/Factory/SuggestFormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,43 @@ public function build(
'elementDescription',
$this->getLocalizedLabel($settings['suggest']['fields']['title']['description'])
);
/** @var NotEmptyValidator $titleValidator */
$titleValidator = $this->validatorResolver->createValidator(NotEmptyValidator::class);
$titleField->addValidator($titleValidator);
$titleStringLengthValidatorOptions = ['minimum' => $settings['suggest']['fields']['title']['validation']['min'] ?? 1];
if ($settings['suggest']['fields']['title']['validation']['max'] ?? false) {
$titleStringLengthValidatorOptions['maximum'] = (int)$settings['suggest']['fields']['title']['validation']['max'];
}
/** @var StringLengthValidator $titleStringLengthValidator */
$titleStringLengthValidator = $this->validatorResolver->createValidator(StringLengthValidator::class, $titleStringLengthValidatorOptions);
$titleField->addValidator($titleStringLengthValidator);
if ($titleStringLengthValidatorOptions['minimum'] > 0) {
/** @var NotEmptyValidator $titleNotEmptyValidator */
$titleNotEmptyValidator = $this->validatorResolver->createValidator(NotEmptyValidator::class);
$titleField->addValidator($titleNotEmptyValidator);
}

if ((bool)($settings['suggest']['fields']['subtitle']['enable'] ?? false) === true) {
/** @var GenericFormElement $subtitleField */
$subtitleField = $sessionInformation->createElement('subtitle', 'Text');
$subtitleField->setLabel($this->getLocalizedLabel($settings['suggest']['fields']['subtitle']['label']));
$subtitleField->setProperty(
'elementDescription',
$this->getLocalizedLabel($settings['suggest']['fields']['subtitle']['description'])
);
$subtitleStringLengthValidatorOptions = ['minimum' => $settings['suggest']['fields']['subtitle']['validation']['min'] ?? 1];
if ($settings['suggest']['fields']['subtitle']['validation']['max'] ?? false) {
$subtitleStringLengthValidatorOptions['maximum'] = (int)$settings['suggest']['fields']['subtitle']['validation']['max'];
}
/** @var StringLengthValidator $subtitleStringLengthValidator */
$subtitleStringLengthValidator = $this->validatorResolver->createValidator(
StringLengthValidator::class,
$subtitleStringLengthValidatorOptions
);
$subtitleField->addValidator($subtitleStringLengthValidator);
if ($subtitleStringLengthValidatorOptions['minimum'] > 0) {
/** @var NotEmptyValidator $subtitleNotEmptyValidator */
$subtitleNotEmptyValidator = $this->validatorResolver->createValidator(NotEmptyValidator::class);
$subtitleField->addValidator($subtitleNotEmptyValidator);
}
}

/** @var GenericFormElement $descriptionField */
$descriptionField = $sessionInformation->createElement('description', 'Textarea');
Expand All @@ -208,6 +242,31 @@ public function build(
);
$descriptionField->addValidator($stringLengthValidator);

if ((bool)($settings['suggest']['fields']['tag_suggestion']['enable'] ?? false) === true) {
/** @var GenericFormElement $tagSuggestionField */
$tagSuggestionField = $sessionInformation->createElement('tag_suggestion', 'Text');
$tagSuggestionField->setLabel($this->getLocalizedLabel($settings['suggest']['fields']['tag_suggestion']['label']));
$tagSuggestionField->setProperty(
'elementDescription',
$this->getLocalizedLabel($settings['suggest']['fields']['tag_suggestion']['description'])
);
$tagSuggestionStringLengthValidatorOptions = ['minimum' => $settings['suggest']['fields']['tag_suggestion']['validation']['min'] ?? 1];
if ($settings['suggest']['fields']['tag_suggestion']['validation']['max'] ?? false) {
$tagSuggestionStringLengthValidatorOptions['maximum'] = (int)$settings['suggest']['fields']['tag_suggestion']['validation']['max'];
}
/** @var StringLengthValidator $tagSuggestionStringLengthValidator */
$tagSuggestionStringLengthValidator = $this->validatorResolver->createValidator(
StringLengthValidator::class,
$tagSuggestionStringLengthValidatorOptions
);
$tagSuggestionField->addValidator($tagSuggestionStringLengthValidator);
if ($tagSuggestionStringLengthValidatorOptions['minimum'] > 0) {
/** @var NotEmptyValidator $tagSuggestionNotEmptyValidator */
$tagSuggestionNotEmptyValidator = $this->validatorResolver->createValidator(NotEmptyValidator::class);
$tagSuggestionField->addValidator($tagSuggestionNotEmptyValidator);
}
}

if ((bool)($settings['suggest']['fields']['length']['enable'] ?? false) === true) {
/** @var GenericFormElement $lengthField */
$lengthField = $sessionInformation->createElement('estimatedlength', 'SingleSelect');
Expand Down Expand Up @@ -287,15 +346,38 @@ public function build(
]);
}

$message = $settings['suggest']['confirmation']['message'] ??
'LLL:EXT:sessionplaner/Resources/Private/Language/locallang.xlf:form.suggest.confirmation';
$confirmationMessage = LocalizationUtility::translate($message) ?? '';

if ($this->sendingSenderNotificationAllowed($settings)) {
$form->createFinisher('EmailToSender', [
'subject' => $settings['suggest']['senderNotification']['subject'],
'recipients' => [
'{email}' => '{fullname}',
],
'senderAddress' => $settings['suggest']['senderNotification']['senderAddress'],
'senderName' => $settings['suggest']['senderNotification']['senderName'],
'format' => 'html',
'headline' => $settings['suggest']['senderNotification']['subject'],
'variables' => [
'title' => $settings['suggest']['senderNotification']['subject'],
'message' => $confirmationMessage,
],
'templateName' => 'EmailToSender',
'templateRootPaths' => [
100 => 'EXT:sessionplaner/Resources/Private/Templates/Email/'
],
]);
}

if (($settings['suggest']['confirmation']['pageUid'] ?? '') !== '') {
$form->createFinisher('Redirect', [
'pageUid' => (int)$settings['suggest']['confirmation']['pageUid'],
]);
} else {
$message = $settings['suggest']['confirmation']['message'] ??
'LLL:EXT:sessionplaner/Resources/Private/Language/locallang.xlf:form.suggest.confirmation';
$form->createFinisher('Confirmation', [
'message' => LocalizationUtility::translate($message) ?? '',
'message' => $confirmationMessage,
]);
}

Expand All @@ -321,6 +403,20 @@ protected function sendingNotificationAllowed(array $settings): bool
&& $settings['suggest']['notification']['senderName'] !== '';
}

protected function sendingSenderNotificationAllowed(array $settings): bool
{
return isset(
$settings['suggest']['senderNotification']['enable'],
$settings['suggest']['senderNotification']['subject'],
$settings['suggest']['senderNotification']['senderAddress'],
$settings['suggest']['senderNotification']['senderName']
)
&& (bool)$settings['suggest']['senderNotification']['enable'] === true
&& $settings['suggest']['senderNotification']['subject'] !== ''
&& $settings['suggest']['senderNotification']['senderAddress'] !== ''
&& $settings['suggest']['senderNotification']['senderName'] !== '';
}

protected function getLocalizedLabel(string $label): string
{
if (strncmp($label, 'LLL:', 4) === 0) {
Expand Down
2 changes: 2 additions & 0 deletions Classes/Domain/Finisher/SuggestFormFinisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ protected function executeInternal()
}

$session->setTopic((string)($data['title'] ?? ''));
$session->setTopicAddition((string)($data['subtitle'] ?? ''));
$session->setDescription((string)($data['description'] ?? ''));
$session->setTagSuggestion((string)($data['tag_suggestion'] ?? ''));

if (isset($data['type']) && $data['type'] !== '') {
$session->setType((int)$data['type']);
Expand Down
24 changes: 24 additions & 0 deletions Classes/Domain/Model/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ class Session extends AbstractSlugEntity
*/
protected string $topic = '';

protected string $topicAddition = '';

protected string $pathSegment = '';

protected string $description = '';

protected string $tagSuggestion = '';

protected string $speaker = '';

protected string $twitter = '';
Expand Down Expand Up @@ -146,6 +150,16 @@ public function getTopic(): string
return $this->topic;
}

public function setTopicAddition(string $topicAddition): void
{
$this->topicAddition = $topicAddition;
}

public function getTopicAddition(): string
{
return $this->topicAddition;
}

public function setPathSegment(string $pathSegment): void
{
$this->pathSegment = $pathSegment;
Expand All @@ -166,6 +180,16 @@ public function getDescription(): string
return $this->description;
}

public function setTagSuggestion(string $tagSuggestion): void
{
$this->tagSuggestion = $tagSuggestion;
}

public function getTagSuggestion(): string
{
return $this->tagSuggestion;
}

public function addSpeaker(Speaker $speaker): void
{
$this->speakers->attach($speaker);
Expand Down
24 changes: 24 additions & 0 deletions Configuration/TCA/tx_sessionplaner_domain_model_session.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@
'max' => 256,
],
],
'topic_addition' => [
'exclude' => false,
'label' => $languageFile . 'tx_sessionplaner_domain_model_session-topic_addition',
'config' => [
'type' => 'input',
'size' => 40,
'eval' => 'trim',
'required' => false,
'max' => 256,
],
],
'path_segment' => [
'exclude' => false,
'label' => $languageFile . 'tx_sessionplaner_domain_model_session-path_segment',
Expand Down Expand Up @@ -156,6 +167,17 @@
'richtextConfiguration' => 'default',
],
],
'tag_suggestion' => [
'exclude' => false,
'label' => $languageFile . 'tx_sessionplaner_domain_model_session-tag_suggestion',
'config' => [
'type' => 'input',
'size' => 40,
'eval' => 'trim',
'required' => false,
'max' => 256,
],
],
'documents' => [
'exclude' => false,
'label' => $languageFile . 'tx_sessionplaner_domain_model_session-download',
Expand Down Expand Up @@ -341,6 +363,7 @@
--div--;General,
--palette--;' . $languageFile . 'tx_sessionplaner_domain_model_session.palettes.options;options,
topic,
topic_addition,
path_segment,
description,
--palette--;' . $languageFile
Expand All @@ -356,6 +379,7 @@
day,
room,
slot,
tag_suggestion,
tags,
',
],
Expand Down
11 changes: 11 additions & 0 deletions Configuration/TypoScript/constants.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# customsubcategory=110_SPPERSISTENCE=Persistence
# customsubcategory=120_SPSETTINGS=Settings
# customsubcategory=130_SPSUGGESTMAIL=Suggest Notifications
# customsubcategory=135_SPSUGGESTSENDERMAIL=Suggest Notifications to Sender
# customsubcategory=140_SPSUGGESTCONFIRMATION=Suggest Confirmation

plugin.tx_sessionplaner {
Expand Down Expand Up @@ -48,6 +49,16 @@ plugin.tx_sessionplaner {
# cat=plugin.sessionplaner/130_SPSUGGESTMAIL/blindCarbonCopyAddress; type=string; label=Blind Carbon Copy Address
blindCarbonCopyAddress =
}
senderNotification {
# cat=plugin.sessionplaner/135_SPSUGGESTSENDERMAIL/enable; type=boolean; label=Enable
enable = 0
# cat=plugin.sessionplaner/135_SPSUGGESTSENDERMAIL/subject; type=string; label=Subject
subject = Thank you for your suggestion
# cat=plugin.sessionplaner/135_SPSUGGESTSENDERMAIL/senderAddress; type=string; label=Sender Address
senderAddress =
# cat=plugin.sessionplaner/135_SPSUGGESTSENDERMAIL/senderName; type=string; label=Sender Name
senderName =
}
confirmation {
# cat=plugin.sessionplaner/140_SPSUGGESTCONFIRMATION/message; type=string; label=Confirmation Message
message = LLL:EXT:sessionplaner/Resources/Private/Language/locallang.xlf:form.suggest.confirmation
Expand Down
28 changes: 28 additions & 0 deletions Configuration/TypoScript/setup.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,28 @@ plugin.tx_sessionplaner {
title {
label = LLL:EXT:sessionplaner/Resources/Private/Language/locallang.xlf:form.title
description = LLL:EXT:sessionplaner/Resources/Private/Language/locallang.xlf:form.title.description
validation {
min = 1
max = 255
}
}
subtitle {
enable = 0
label = LLL:EXT:sessionplaner/Resources/Private/Language/locallang.xlf:form.subtitle
description = LLL:EXT:sessionplaner/Resources/Private/Language/locallang.xlf:form.subtitle.description
validation {
min = 0
max = 255
}
}
tag_suggestion {
enable = 0
label = LLL:EXT:sessionplaner/Resources/Private/Language/locallang.xlf:form.tag_suggestion
description = LLL:EXT:sessionplaner/Resources/Private/Language/locallang.xlf:form.tag_suggestion.description
validation {
min = 0
max = 255
}
}
description {
label = LLL:EXT:sessionplaner/Resources/Private/Language/locallang.xlf:form.description
Expand Down Expand Up @@ -105,6 +127,12 @@ plugin.tx_sessionplaner {
carbonCopyAddress = {$plugin.tx_sessionplaner.settings.suggest.notification.carbonCopyAddress}
blindCarbonCopyAddress = {$plugin.tx_sessionplaner.settings.suggest.notification.blindCarbonCopyAddress}
}
senderNotification {
enable = {$plugin.tx_sessionplaner.settings.suggest.senderNotification.enable}
subject = {$plugin.tx_sessionplaner.settings.suggest.senderNotification.subject}
senderAddress = {$plugin.tx_sessionplaner.settings.suggest.senderNotification.senderAddress}
senderName = {$plugin.tx_sessionplaner.settings.suggest.senderNotification.senderName}
}
confirmation {
message = {$plugin.tx_sessionplaner.settings.suggest.confirmation.message}
pageUid = {$plugin.tx_sessionplaner.settings.suggest.confirmation.pageUid}
Expand Down
12 changes: 12 additions & 0 deletions Resources/Private/Language/locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,24 @@
<trans-unit id="form.title.description">
<source>A descriptive title for your submission</source>
</trans-unit>
<trans-unit id="form.subtitle">
<source>Subtitle</source>
</trans-unit>
<trans-unit id="form.subtitle.description">
<source>A descriptive subtitle for your submission</source>
</trans-unit>
<trans-unit id="form.description">
<source>Description</source>
</trans-unit>
<trans-unit id="form.description.description">
<source>A description of your submission</source>
</trans-unit>
<trans-unit id="form.tag_suggestion">
<source>Tag Suggestion</source>
</trans-unit>
<trans-unit id="form.tag_suggestion.description">
<source>A descriptive tag you would add to your submission</source>
</trans-unit>
<trans-unit id="form.type">
<source>Type</source>
</trans-unit>
Expand Down
6 changes: 6 additions & 0 deletions Resources/Private/Language/locallang_tca.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,15 @@
<trans-unit id="tx_sessionplaner_domain_model_session-donotlink" xml:space="preserve">
<source>Do not link</source>
</trans-unit>
<trans-unit id="tx_sessionplaner_domain_model_session-tag_suggestion" xml:space="preserve">
<source>Tag Suggestion</source>
</trans-unit>
<trans-unit id="tx_sessionplaner_domain_model_session-topic" xml:space="preserve">
<source>Topic</source>
</trans-unit>
<trans-unit id="tx_sessionplaner_domain_model_session-topic_addition" xml:space="preserve">
<source>Topic Addition</source>
</trans-unit>
<trans-unit id="tx_sessionplaner_domain_model_session-path_segment" xml:space="preserve">
<source>Path Segment</source>
</trans-unit>
Expand Down
Loading