/**
  * @param \TYPO3\CMS\Extbase\Mvc\Request $request
  * @return string $text
  */
 public static function plainText($request)
 {
     define(NL, "\n");
     $text = 'Kontaktdaten:' . NL;
     if ($request->hasArgument('companyName')) {
         $text .= 'Firma: ' . $request->getArgument('companyName') . NL;
     }
     if ($request->hasArgument('firstName')) {
         $firstName = $request->getArgument('firstName') . ' ';
     } else {
         $firstName = '';
     }
     if ($request->hasArgument('lastName')) {
         $text .= 'Ansprechpartner: ' . $firstName . $request->getArgument('lastName') . NL . NL;
     }
     if ($request->hasArgument('address')) {
         $text .= $request->getArgument('address') . NL;
     }
     if ($request->hasArgument('zip')) {
         $text .= $request->getArgument('zip') . ' ';
     }
     if ($request->hasArgument('city')) {
         $text .= $request->getArgument('city') . NL;
     }
     if ($request->hasArgument('country')) {
         $text .= $request->getArgument('country') . NL . NL;
     }
     if ($request->hasArgument('email')) {
         $text .= 'E-Mail: ' . $request->getArgument('email') . NL;
     }
     if ($request->hasArgument('phone')) {
         $text .= 'Phone: ' . $request->getArgument('phone') . NL;
     }
     return $text;
 }
 /**
  * Maps arguments delivered by the request object to the local controller arguments.
  *
  * @throws Exception\RequiredArgumentMissingException
  * @return void
  */
 protected function mapRequestArgumentsToControllerArguments()
 {
     if ($this->configurationManager->isFeatureEnabled('rewrittenPropertyMapper')) {
         foreach ($this->arguments as $argument) {
             $argumentName = $argument->getName();
             if ($this->request->hasArgument($argumentName)) {
                 $argument->setValue($this->request->getArgument($argumentName));
             } elseif ($argument->isRequired()) {
                 throw new \TYPO3\CMS\Extbase\Mvc\Controller\Exception\RequiredArgumentMissingException('Required argument "' . $argumentName . '" is not set for ' . $this->request->getControllerObjectName() . '->' . $this->request->getControllerActionName() . '.', 1298012500);
             }
         }
     } else {
         // @deprecated since Extbase 1.4, will be removed two versions after Extbase 6.1
         $optionalPropertyNames = array();
         $allPropertyNames = $this->arguments->getArgumentNames();
         foreach ($allPropertyNames as $propertyName) {
             if ($this->arguments[$propertyName]->isRequired() === FALSE) {
                 $optionalPropertyNames[] = $propertyName;
             }
         }
         /** @var $validator ArgumentsValidator */
         $validator = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ArgumentsValidator');
         $this->deprecatedPropertyMapper->mapAndValidate($allPropertyNames, $this->request->getArguments(), $this->arguments, $optionalPropertyNames, $validator);
         $this->argumentsMappingResults = $this->deprecatedPropertyMapper->getMappingResults();
     }
 }
 /**
  * @return int|false
  * @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException
  */
 protected function getReservationIdFromRequest()
 {
     $reservationId = false;
     $argument = $this->request->getArgument('reservation');
     if (is_string($argument)) {
         $reservationId = (int) $argument;
     }
     if ($argument instanceof Reservation) {
         $reservationId = $argument->getUid();
     }
     if (is_array($argument) && isset($argument['__identity'])) {
         $reservationId = (int) $argument['__identity'];
         return $reservationId;
     }
     return $reservationId;
 }
 /**
  * Add support for variable argument lists using a wildcard property name '*'.
  * This is required for a file multiupload, as you can't guess how many files
  * will be uploaded when rendering the form (and generating the
  * trustedPropertiesToken) on the server.
  *
  * You can use it like this:
  * If you write a formfield viewhelper, you have to register all the properties
  * that should be mapped when processing the input on the server. To allow
  * the mapping of some properties of all submitted elements, insert a wildcard
  * in the path at the position where new keys will appear. This class will
  * enable the mapping of all arguments that are assigned to this path.
  *
  * So, if you have this line in your viewhelper:
  *		$this->registerFieldNameForFormTokenGeneration('my_plugin[my_object][object_storage_property][*][foo]');
  * and request arguments like this:
  *		array( 'my_object' => array( 'object_storage_property' => array(
  *			0 => array( 'foo' => 13 ),
  *			1 => array( 'foo' => 42 ),
  *			2 => array( 'foo' => false )
  *		)))
  * the PropertyMapper won't complain about missing permissions to "map
  * attribute my_object.object_storage_property.0".
  *
  * This is different from simply using $propertyMappingConfiguration->allowAllProperties()
  * because:
  * - You don't have to post that line into each of your controllers
  * - You can control which sub-properties to map
  * - You don't override assigned settings for specific keys: if there is a
  *   configuration for my_object.object_storage_property.42, it won't be
  *   changed to the wildcard value.
  *
  * @param \TYPO3\CMS\Extbase\Mvc\Request $request
  * @param \TYPO3\CMS\Extbase\Mvc\Controller\Arguments $controllerArguments
  * @return void
  */
 public function initializePropertyMappingConfigurationFromRequest(\TYPO3\CMS\Extbase\Mvc\Request $request, \TYPO3\CMS\Extbase\Mvc\Controller\Arguments $controllerArguments)
 {
     $trustedPropertiesToken = $request->getInternalArgument('__trustedProperties');
     if (!is_string($trustedPropertiesToken)) {
         return;
     }
     $serializedTrustedProperties = $this->hashService->validateAndStripHmac($trustedPropertiesToken);
     $trustedProperties = unserialize($serializedTrustedProperties);
     foreach ($trustedProperties as $propertyName => $propertyConfiguration) {
         if (!$controllerArguments->hasArgument($propertyName)) {
             continue;
         }
         $propertyMappingConfiguration = $controllerArguments->getArgument($propertyName)->getPropertyMappingConfiguration();
         //
         // Extended from parent class - begin
         //
         if (is_array($propertyConfiguration)) {
             foreach (HelhumArrayUtility::getPathsToKey($propertyConfiguration, '*') as $path) {
                 $configurationTemplate = ExtbaseArrayUtility::getValueByPath($propertyConfiguration, $path . '.*');
                 $propertyConfiguration = ExtbaseArrayUtility::unsetValueByPath($propertyConfiguration, $path . '.*');
                 if ($request->hasArgument($propertyName) && is_array($request->getArgument($propertyName))) {
                     $rawArgument = ExtbaseArrayUtility::getValueByPath($request->getArgument($propertyName), $path);
                     $subPropertyConfiguration = ExtbaseArrayUtility::getValueByPath($propertyConfiguration, $path);
                     foreach ($rawArgument as $index => $_) {
                         if (!is_int($index) || array_key_exists($index, $subPropertyConfiguration)) {
                             continue;
                         }
                         $propertyConfiguration = ExtbaseArrayUtility::setValueByPath($propertyConfiguration, $path . '.' . $index, $configurationTemplate);
                     }
                 }
             }
         }
         //
         // Extended from parent class - end
         //
         $this->modifyPropertyMappingConfiguration($propertyConfiguration, $propertyMappingConfiguration);
     }
 }
Example #5
0
 /**
  * Get Cart/Product From Request
  *
  * @param array $pluginSettings TypoScript Plugin Settings
  * @param Request $request Request
  * @param \Extcode\Cart\Domain\Model\Cart\TaxClass[] $taxClasses Tax Class Array
  *
  * @return \Extcode\Cart\Domain\Model\Cart\Product[]
  */
 public function getProductsFromRequest(array $pluginSettings, Request $request, array $taxClasses)
 {
     if (!$this->pluginSettings) {
         $this->pluginSettings = $pluginSettings;
     }
     if (!$this->taxClasses) {
         $this->taxClasses = $taxClasses;
     }
     $multiple = 1;
     if ($this->pluginSettings['multiple']) {
         $argumentName = $this->pluginSettings['multiple'];
         if ($request->hasArgument($argumentName)) {
             $multiple = intval($request->getArgument($argumentName));
         }
     }
     $products = [];
     $preCartProductSets = [];
     if ($multiple == 1) {
         $preCartProductSets[1] = $this->parserUtility->getPreCartProductSet($pluginSettings, $request);
     } else {
         // TODO: iterate over request
     }
     foreach ($preCartProductSets as $preCartProductSetKey => $preCartProductSetValue) {
         if ($preCartProductSetValue['contentId']) {
             $products[$preCartProductSetKey] = $this->getCartProductFromCE($preCartProductSetValue);
         } elseif ($preCartProductSetValue['productId']) {
             $products[$preCartProductSetKey] = $this->getCartProductFromDatabase($preCartProductSetValue);
         }
     }
     return $products;
 }
Example #6
0
 /**
  * @param array $pluginSettings
  * @param Request $request Request
  *
  * @return array
  */
 public function getPreCartProductSet(array $pluginSettings, Request $request)
 {
     if (!$this->pluginSettings) {
         $this->pluginSettings = $pluginSettings;
     }
     $productValueSet = [];
     if ($request->hasArgument('productId')) {
         $productValueSet['productId'] = intval($request->getArgument('productId'));
     }
     if ($request->hasArgument('tableId')) {
         $productValueSet['tableId'] = intval($request->getArgument('tableId'));
     }
     if ($request->hasArgument('repositoryId')) {
         $productValueSet['repositoryId'] = intval($request->getArgument('repositoryId'));
     }
     if ($request->hasArgument('contentId')) {
         $productValueSet['contentId'] = intval($request->getArgument('contentId'));
     }
     if ($request->hasArgument('quantity')) {
         $quantity = intval($request->getArgument('quantity'));
         $productValueSet['quantity'] = $quantity ? $quantity : 1;
     }
     if ($request->hasArgument('feVariants')) {
         $requestFeVariants = $request->getArgument('feVariants');
         if (is_array($requestFeVariants)) {
             foreach ($requestFeVariants as $requestFeVariantKey => $requestFeVariantValue) {
                 $productValueSet['feVariants'][$requestFeVariantKey] = $requestFeVariantValue;
             }
         }
     }
     if ($request->hasArgument('beVariants')) {
         $requestVariants = $request->getArgument('beVariants');
         if (is_array($requestVariants)) {
             foreach ($requestVariants as $requestVariantKey => $requestVariantValue) {
                 $productValueSet['beVariants'][$requestVariantKey] = intval($requestVariantValue);
             }
         }
     }
     return $productValueSet;
 }
 /**
  * Render
  *
  * @return string
  */
 public function render()
 {
     return $this->request->getArgument($this->arguments['key']);
 }
Example #8
0
 /**
  * Checks honeypot fields
  *
  * @param Request $request The request to be checked
  *
  * @return boolean
  */
 protected function checkHoneyPotFields(Request $request)
 {
     if (!$request->hasArgument('author') || strlen($request->getArgument('author')) > 0) {
         return FALSE;
     }
     if (!$request->hasArgument('link') || strlen($request->getArgument('link')) > 0) {
         return FALSE;
     }
     if (!$request->hasArgument('text') || strlen($request->getArgument('text')) > 0) {
         return FALSE;
     }
     if (!$request->hasArgument('timestamp') || $request->getArgument('timestamp') !== '1368283172') {
         return FALSE;
     }
     return TRUE;
 }