Skip to content

Commit

Permalink
Allow loading of recipients from current page
Browse files Browse the repository at this point in the history
  • Loading branch information
akiessling committed Apr 29, 2024
1 parent 75adad7 commit 1fabde0
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ class SelectableRecipientOptions extends \TYPO3\CMS\Form\Domain\Model\FormElemen
*/
public function setProperty(string $key, $value)
{

if ($key === 'pageUid') {
$value = (int) $value;
// use uid of current page if pageUid is not set
if ($value === 0) $value = $GLOBALS['TSFE']->id;
if ($value === 0) {
$pageArguments = $GLOBALS['TYPO3_REQUEST']->getAttribute('routing');
$value = $pageArguments->getPageId();
}
$this->setProperty('options', $this->getOptions($value));
// automatic cache clearing with data handler, if anything in that page changes
if ($GLOBALS['TSFE'] instanceof \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController) {
Expand Down
10 changes: 1 addition & 9 deletions Classes/Domain/Repository/RecipientRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,11 @@
*/
class RecipientRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
{
/**
* @var array
* @phpstan-ignore-next-line
*/
protected $defaultOrderings = [
'sorting' => QueryInterface::ORDER_ASCENDING
];

/**
* @param $pid
* @return array
*/
public function findInPid($pid)
public function findInPid(int $pid): array
{
$query = $this->createQuery();
$query->getQuerySettings()->setStoragePageIds([$pid]);
Expand Down
10 changes: 2 additions & 8 deletions Configuration/Yaml/FormSetup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,16 @@ prototypes:
identifier: 'pageUid'
templateName: 'Inspector-Typo3WinBrowserEditor'
label: 'formEditor.elements.FormDynamicRecipient.pageUid.label'
fieldExplanationText: 'formEditor.elements.FormDynamicRecipient.pageUid.fieldExplanationText'
buttonLabel: 'formEditor.elements.FormDynamicRecipient.pageUid.buttonLabel'
browsableType: pages
iconIdentifier: apps-pagetree-page-default
# very important setting -> defines the written form definition
propertyPath: 'properties.pageUid'
propertyValidatorsMode: 'OR'
propertyValidators:
10: 'Integer'
10: 'IntegerOrEmpty'
20: 'FormElementIdentifierWithinCurlyBracesExclusive'
400:
identifier: 'assignedVariable'
templateName: 'Inspector-TextEditor'
label: 'formEditor.elements.FormDynamicRecipient.assignedVariable.label'
propertyPath: 'properties.assignedVariable'
propertyValidators:
10: 'NotEmpty'

formEditor:
translationFiles:
Expand Down
33 changes: 18 additions & 15 deletions Resources/Private/Language/Database.xlf
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.0" xmlns:t3="http://typo3.org/schemas/xliff">
<file t3:id="1471786343" source-language="en" datatype="plaintext" original="messages" date="2016-08-21T20:15:32Z" product-name="form">
<header/>
<body>
<trans-unit id="formEditor.elements.FormDynamicRecipient.pageUid.label" xml:space="preserve">
<source>Page containing dynamic values</source>
</trans-unit>
<trans-unit id="formEditor.elements.FormDynamicRecipient.pageUid.buttonLabel" xml:space="preserve">
<source>Pages</source>
</trans-unit>
<trans-unit id="formEditor.elements.FormDynamicRecipient.assignedVariable.label" xml:space="preserve">
<source>Variable to fill with the selected option</source>
</trans-unit>
</body>
</file>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="EXT:form_dynamic_recipient/Resources/Private/Language/Database.xlf" date="2024-04-29T14:07:59Z" product-name="form_dynamic_recipient">
<header/>
<body>
<trans-unit id="formEditor.elements.FormDynamicRecipient.pageUid.label" resname="formEditor.elements.FormDynamicRecipient.pageUid.label">
<source>Page containing dynamic values</source>
</trans-unit>
<trans-unit id="formEditor.elements.FormDynamicRecipient.pageUid.fieldExplanationText" resname="formEditor.elements.FormDynamicRecipient.pageUid.fieldExplanationText">
<source>Leave blank to load recipients from the page where the plugin is inserted</source>
</trans-unit>
<trans-unit id="formEditor.elements.FormDynamicRecipient.pageUid.buttonLabel" resname="formEditor.elements.FormDynamicRecipient.pageUid.buttonLabel">
<source>Page</source>
</trans-unit>
<trans-unit id="formEditor.elements.FormDynamicRecipient.assignedVariable.label" resname="formEditor.elements.FormDynamicRecipient.assignedVariable.label">
<source>Variable to fill with the selected option</source>
</trans-unit>
</body>
</file>
</xliff>
24 changes: 24 additions & 0 deletions Resources/Private/Language/de.Database.xlf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" target-language="de" datatype="plaintext" original="EXT:form_dynamic_recipient/Resources/Private/Language/Database.xlf" date="2024-04-29T14:07:59Z" product-name="form_dynamic_recipient">
<header/>
<body>
<trans-unit id="formEditor.elements.FormDynamicRecipient.pageUid.label" resname="formEditor.elements.FormDynamicRecipient.pageUid.label">
<source>Page containing dynamic values</source>
<target>Seite mit Empfänger-Datensätzen</target>
</trans-unit>
<trans-unit id="formEditor.elements.FormDynamicRecipient.pageUid.fieldExplanationText" resname="formEditor.elements.FormDynamicRecipient.pageUid.fieldExplanationText">
<source>Leave blank to load recipients from the page where the plugin is inserted</source>
<target>Leer lassen, um die Datensätze von der aktuellen Seite mit dem Formular-Plugin zu laden</target>
</trans-unit>
<trans-unit id="formEditor.elements.FormDynamicRecipient.pageUid.buttonLabel" resname="formEditor.elements.FormDynamicRecipient.pageUid.buttonLabel">
<source>Page</source>
<target>Seite</target>
</trans-unit>
<trans-unit id="formEditor.elements.FormDynamicRecipient.assignedVariable.label" resname="formEditor.elements.FormDynamicRecipient.assignedVariable.label">
<source>Variable to fill with the selected option</source>
<target>Gewählte Option in diese Variable laden</target>
</trans-unit>
</body>
</file>
</xliff>

0 comments on commit 1fabde0

Please sign in to comment.