/**
  * Load the property value to be used for validation.
  *
  * In case the object is a doctrine proxy, we need to load the real instance first.
  *
  * @param \TYPO3\CMS\Form\Domain\Model\ValidationElement $validationElement
  * @param string $propertyName
  * @return mixed
  */
 protected function getPropertyValue(\TYPO3\CMS\Form\Domain\Model\ValidationElement $validationElement, $propertyName)
 {
     /**
      * If a confirmation page is set and a fileupload was done before
      * there is no incoming data if the process action is called.
      * The data is only in the session at this time.
      * This results in a negative validation (if a validation is set).
      * Therefore, look first in the session.
      */
     if ($this->sessionUtility->getSessionData($propertyName)) {
         $propertyValue = $this->sessionUtility->getSessionData($propertyName);
     } else {
         $propertyValue = $validationElement->getIncomingField($propertyName);
     }
     return $propertyValue;
 }
 /**
  * Loop through all elements of the session and attach the file
  * if its a uploaded file
  *
  * @return void
  */
 protected function addAttachmentsFromSession()
 {
     $sessionData = $this->sessionUtility->getSessionData();
     if (is_array($sessionData)) {
         foreach ($sessionData as $fieldName => $values) {
             if (is_array($values)) {
                 foreach ($values as $file) {
                     if (isset($file['tempFilename'])) {
                         if (is_file($file['tempFilename']) && GeneralUtility::isAllowedAbsPath($file['tempFilename'])) {
                             $this->mailMessage->attach(\Swift_Attachment::fromPath($file['tempFilename'])->setFilename($file['name']));
                         }
                     }
                 }
             }
         }
     }
 }
Example #3
0
 /**
  * Set the htmlAttributes and the additionalAttributes
  * Remap htmlAttributes to additionalAttributes if needed
  *
  * @param ElementBuilder $elementBuilder
  * @param Element $element
  * @return void
  */
 protected function setAttributes(ElementBuilder $elementBuilder, Element $element)
 {
     $htmlAttributes = $this->typoScriptRepository->getModelDefinedHtmlAttributes($element->getElementType());
     $elementBuilder->setHtmlAttributes($htmlAttributes);
     $elementBuilder->setHtmlAttributeWildcards();
     $elementBuilder->overlayUserdefinedHtmlAttributeValues();
     $elementBuilder->setNameAndId();
     $elementBuilder->overlayFixedHtmlAttributeValues();
     // remove all NULL values
     $htmlAttributes = array_filter($elementBuilder->getHtmlAttributes());
     $elementBuilder->setHtmlAttributes($htmlAttributes);
     $elementBuilder->moveHtmlAttributesToAdditionalArguments();
     $elementBuilder->setViewHelperDefaulArgumentsToAdditionalArguments();
     $elementBuilder->moveAllOtherUserdefinedPropertiesToAdditionalArguments();
     $htmlAttributes = $elementBuilder->getHtmlAttributes();
     $userConfiguredElementTypoScript = $elementBuilder->getUserConfiguredElementTypoScript();
     $additionalArguments = $elementBuilder->getAdditionalArguments();
     $element->setHtmlAttributes($htmlAttributes);
     $additionalArguments = $this->typoScriptService->convertTypoScriptArrayToPlainArray($additionalArguments);
     $additionalArguments['prefix'] = $this->configuration->getPrefix();
     $element->setAdditionalArguments($additionalArguments);
     $this->handleIncomingValues($element, $userConfiguredElementTypoScript);
     if ($element->getElementType() === 'FORM' && $this->getControllerAction() === 'show') {
         if (empty($element->getHtmlAttribute('action'))) {
             if ($element->getAdditionalArgument('confirmation') && (int) $element->getAdditionalArgument('confirmation') === 1) {
                 $element->setAdditionalArgument('action', 'confirmation');
             } else {
                 $element->setAdditionalArgument('action', 'process');
             }
         } else {
             $element->setAdditionalArgument('pageUid', $element->getHtmlAttribute('action'));
             $element->setAdditionalArgument('action', null);
         }
     }
     // needed if confirmation page is enabled
     if ($this->sessionUtility->getSessionData($element->getName()) && $element->getAdditionalArgument('uploadedFiles') === null) {
         $element->setAdditionalArgument('uploadedFiles', $this->sessionUtility->getSessionData($element->getName()));
     }
 }
 /**
  * Skip the processing of foreign forms.
  * If there is more than one form on a page
  * we have to be sure that only the submitted form will be
  * processed. On data submission, the extbase action "confirmation" or
  * "process" is called. The detection which form is submitted
  * is done by the form prefix. All forms which do not have any
  * submitted data are skipped and forwarded to the show action.
  *
  * @return void
  */
 protected function skipForeignFormProcessing()
 {
     if (!$this->request->hasArgument($this->configuration->getPrefix()) && !$this->sessionUtility->getSessionData()) {
         $this->forward('show');
     }
 }