/**
  * Set the options for this object
  *
  * @param array $parameters Configuration array
  * @return void
  */
 protected function setOptions(array $parameters)
 {
     if (is_array($parameters)) {
         $keys = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($parameters);
         foreach ($keys as $key) {
             $class = $parameters[$key];
             if ((int) $key && strpos($key, '.') === false) {
                 if (isset($parameters[$key . '.']) && $class === 'OPTION') {
                     $childElementArguments = $parameters[$key . '.'];
                     if (isset($childElementArguments['selected'])) {
                         $childElementArguments['attributes']['selected'] = $childElementArguments['selected'];
                         unset($childElementArguments['selected']);
                     }
                     if (isset($childElementArguments['value'])) {
                         $childElementArguments['attributes']['value'] = $childElementArguments['value'];
                         unset($childElementArguments['value']);
                     }
                     if (isset($childElementArguments['data']) && !isset($childElementArguments['text'])) {
                         // preserve backward compatibility by rewriting data to text
                         $childElementArguments['text'] = $childElementArguments['data'];
                     }
                     $this->configuration['options'][] = $childElementArguments;
                 }
             }
         }
     }
 }
Example #2
0
 /**
  * The main method called by the controller
  *
  * Iterates over the configured post processors and calls them with their
  * own settings
  *
  * @return string HTML messages from the called processors
  */
 public function process()
 {
     $html = '';
     if (is_array($this->postProcessorTypoScript)) {
         $keys = TemplateService::sortedKeyList($this->postProcessorTypoScript);
         foreach ($keys as $key) {
             if (!(int) $key || strpos($key, '.') !== false) {
                 continue;
             }
             $className = false;
             $processorName = $this->postProcessorTypoScript[$key];
             $processorArguments = array();
             if (isset($this->postProcessorTypoScript[$key . '.'])) {
                 $processorArguments = $this->postProcessorTypoScript[$key . '.'];
             }
             if (class_exists($processorName, true)) {
                 $className = $processorName;
             } else {
                 $classNameExpanded = 'TYPO3\\CMS\\Form\\PostProcess\\' . ucfirst(strtolower($processorName)) . 'PostProcessor';
                 if (class_exists($classNameExpanded, true)) {
                     $className = $classNameExpanded;
                 }
             }
             if ($className !== false) {
                 $processor = $this->objectManager->get($className, $this->form, $processorArguments);
                 if ($processor instanceof PostProcessorInterface) {
                     $processor->setControllerContext($this->controllerContext);
                     $html .= $processor->process();
                 }
             }
         }
     }
     return $html;
 }
 /**
  * @test
  * @expectedException \RuntimeException
  */
 public function updateRootlineDataWithInvalidNewRootlineThrowsException()
 {
     $originalRootline = array(0 => array('uid' => 2, 'title' => 'originalTitle'), 1 => array('uid' => 3, 'title' => 'originalTitle2'));
     $newInvalidRootline = array(0 => array('uid' => 1, 'title' => 'newTitle'), 1 => array('uid' => 2, 'title' => 'newTitle2'));
     $this->templateServiceMock->_set('rootLine', $originalRootline);
     $this->templateServiceMock->updateRootlineData($newInvalidRootline);
 }
 /**
  * Checks if getData() works with type "path"
  *
  * @test
  */
 public function getDataWithTypePath()
 {
     $filenameIn = uniqid('someValue');
     $filenameOut = uniqid('someValue');
     $this->template->expects($this->atLeastOnce())->method('getFileName')->with($filenameIn)->will($this->returnValue($filenameOut));
     $this->assertEquals($filenameOut, $this->cObj->getData('path:' . $filenameIn));
 }
 /**
  * Checks if getData() works with type "path"
  *
  * @test
  */
 public function getDataWithTypePath()
 {
     $filenameIn = $this->getUniqueId('someValue');
     $filenameOut = $this->getUniqueId('someValue');
     $this->templateServiceMock->expects($this->atLeastOnce())->method('getFileName')->with($filenameIn)->will($this->returnValue($filenameOut));
     $this->assertEquals($filenameOut, $this->subject->getData('path:' . $filenameIn));
 }
Example #6
0
 /**
  * Generates a frameset based on input configuration in a TypoScript array.
  *
  * @param array $setup The TypoScript properties of the PAGE object property "frameSet.". See link.
  * @return string A <frameset> tag.
  * @see TSpagegen::renderContentWithHeader()
  * @todo Define visibility
  */
 public function make($setup)
 {
     $content = '';
     if (is_array($setup)) {
         $sKeyArray = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($setup);
         foreach ($sKeyArray as $theKey) {
             $theValue = $setup[$theKey];
             if ((int) $theKey && ($conf = $setup[$theKey . '.'])) {
                 switch ($theValue) {
                     case 'FRAME':
                         $typeNum = (int) $GLOBALS['TSFE']->tmpl->setup[$conf['obj'] . '.']['typeNum'];
                         if (!$conf['src'] && !$typeNum) {
                             $typeNum = -1;
                         }
                         $content .= '<frame' . $this->frameParams($conf, $typeNum) . ' />' . LF;
                         break;
                     case 'FRAMESET':
                         $frameset = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\FramesetRenderer');
                         $content .= $frameset->make($conf) . LF;
                         break;
                 }
             }
         }
         return '<frameset' . $this->framesetParams($setup) . '>' . LF . $content . '</frameset>';
     }
 }
 /**
  * @test
  */
 public function getImgResourceHookGetsCalled()
 {
     $this->template->expects($this->atLeastOnce())->method('getFileName')->with('typo3/clear.gif')->will($this->returnValue('typo3/clear.gif'));
     $className = uniqid('tx_coretest');
     $getImgResourceHookMock = $this->getMock('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectGetImageResourceHookInterface', array('getImgResourcePostProcess'), array(), $className);
     $getImgResourceHookMock->expects($this->once())->method('getImgResourcePostProcess')->will($this->returnCallback(array($this, 'isGetImgResourceHookCalledCallback')));
     $getImgResourceHookObjects = array($getImgResourceHookMock);
     $this->cObj->_setRef('getImgResourceHookObjects', $getImgResourceHookObjects);
     $this->cObj->IMAGE($this->typoScriptImage);
 }
Example #8
0
 /**
  * Set the various properties for the element
  *
  * For this element this is the prefix, suffix and middleName if they will
  * be shown in the form
  *
  * @param array $parameters Configuration array
  * @return void
  */
 protected function setVarious(array $parameters)
 {
     if (is_array($parameters)) {
         $keys = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($parameters);
         foreach ($keys as $key) {
             $class = $parameters[$key];
             if ((int) $key && strpos($key, '.') === FALSE) {
                 if (isset($parameters[$key . '.'])) {
                     $childElementArguments = $parameters[$key . '.'];
                     if (in_array($childElementArguments['name'], array('prefix', 'suffix', 'middleName'))) {
                         $this->configuration['various'][$childElementArguments['name']] = TRUE;
                     }
                 }
             }
         }
     }
 }
 /**
  * Rendering of a "numerical array" of Form objects from TypoScript
  * Creates new object for each element found
  *
  * @param AbstractJsonElement $parentElement Parent model object
  * @param array $typoscript Configuration array
  * @return void
  */
 protected function getChildElementsByIntegerKey(AbstractJsonElement $parentElement, array $typoscript)
 {
     if (is_array($typoscript)) {
         $keys = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($typoscript);
         foreach ($keys as $key) {
             $class = $typoscript[$key];
             if ((int) $key && strpos($key, '.') === FALSE) {
                 if (isset($typoscript[$key . '.'])) {
                     $elementArguments = $typoscript[$key . '.'];
                 } else {
                     $elementArguments = array();
                 }
                 $this->setElementType($parentElement, $class, $elementArguments);
             }
         }
     }
 }
 /**
  * Rendering of a "numerical array" of Form objects from TypoScript
  * Creates new object for each element found
  *
  * @param \TYPO3\CMS\Form\Domain\Model\Json\AbstractJsonElement $parentElement Parent model object
  * @param array $arguments Configuration array
  * @return void
  */
 protected function getChildElementsByIntegerKey(\TYPO3\CMS\Form\Domain\Model\Json\AbstractJsonElement $parentElement, array $typoscript)
 {
     if (is_array($typoscript)) {
         $keys = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($typoscript);
         foreach ($keys as $key) {
             $class = $typoscript[$key];
             if (intval($key) && !strstr($key, '.')) {
                 if (isset($typoscript[$key . '.'])) {
                     $elementArguments = $typoscript[$key . '.'];
                 } else {
                     $elementArguments = array();
                 }
                 $this->setElementType($parentElement, $class, $elementArguments);
             }
         }
     }
 }
 /**
  * Check for the availability of processors, defined in TypoScript, and use them for data processing
  *
  * @param ContentObjectRenderer $cObject
  * @param array $configuration Configuration array
  * @param array $variables the variables to be processed
  * @return array the processed data and variables as key/value store
  * @throws \UnexpectedValueException If a processor class does not exist
  */
 public function process(ContentObjectRenderer $cObject, array $configuration, array $variables)
 {
     if (!empty($configuration['dataProcessing.']) && is_array($configuration['dataProcessing.'])) {
         $processors = $configuration['dataProcessing.'];
         $processorKeys = TemplateService::sortedKeyList($processors);
         foreach ($processorKeys as $key) {
             $className = $processors[$key];
             if (!class_exists($className)) {
                 throw new \UnexpectedValueException('Processor class name "' . $className . '" does not exist!', 1427455378);
             }
             if (!in_array(DataProcessorInterface::class, class_implements($className), true)) {
                 throw new \UnexpectedValueException('Processor with class name "' . $className . '" ' . 'must implement interface "' . DataProcessorInterface::class . '"', 1427455377);
             }
             $processorConfiguration = isset($processors[$key . '.']) ? $processors[$key . '.'] : array();
             $variables = GeneralUtility::makeInstance($className)->process($cObject, $configuration, $processorConfiguration, $variables);
         }
     }
     return $variables;
 }
 /**
  * Set the options for this object
  *
  * @param array $parameters Configuration array
  * @return void
  */
 protected function setOptions(array $parameters)
 {
     if (is_array($parameters)) {
         $keys = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($parameters);
         foreach ($keys as $key) {
             $class = $parameters[$key];
             if (intval($key) && !strstr($key, '.')) {
                 if (isset($parameters[$key . '.']) && $class === 'OPTION') {
                     $childElementArguments = $parameters[$key . '.'];
                     if (isset($childElementArguments['selected'])) {
                         $childElementArguments['attributes']['selected'] = $childElementArguments['selected'];
                         unset($childElementArguments['selected']);
                     }
                     $this->configuration['options'][] = $childElementArguments;
                 }
             }
         }
     }
 }
 /**
  * Set the options for this object
  *
  * @param array $parameters Configuration array
  * @return void
  */
 protected function setOptions(array $parameters)
 {
     if (is_array($parameters)) {
         $keys = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($parameters);
         foreach ($keys as $key) {
             $class = $parameters[$key];
             if ((int) $key && strpos($key, '.') === FALSE) {
                 if (isset($parameters[$key . '.']) && $class === 'RADIO') {
                     $childElementArguments = $parameters[$key . '.'];
                     if (isset($childElementArguments['checked'])) {
                         $childElementArguments['attributes']['selected'] = 'selected';
                         unset($childElementArguments['checked']);
                     }
                     if (isset($childElementArguments['label.'])) {
                         $childElementArguments['data'] = $childElementArguments['label.']['value'];
                         unset($childElementArguments['label.']);
                     }
                     $this->configuration['options'][] = $childElementArguments;
                 }
             }
         }
     }
 }
 /**
  * Build validation rules from typoscript.
  * The old breakOnError property are no longer supported
  *
  * @param array $rawArgument
  * @return void
  */
 public function buildRules(array $rawArgument = array())
 {
     $userConfiguredFormTyposcript = $this->configuration->getTypoScript();
     $rulesTyposcript = isset($userConfiguredFormTyposcript['rules.']) ? $userConfiguredFormTyposcript['rules.'] : null;
     $this->rules[$this->configuration->getPrefix()] = array();
     if (is_array($rulesTyposcript)) {
         $keys = TemplateService::sortedKeyList($rulesTyposcript);
         foreach ($keys as $key) {
             $ruleName = $rulesTyposcript[$key];
             $validatorClassName = $this->typoScriptRepository->getRegisteredClassName($ruleName, 'registeredValidators');
             if ($validatorClassName === null) {
                 throw new \RuntimeException('Class "' . $validatorClassName . '" not registered via typoscript.');
             }
             if ((int) $key && strpos($key, '.') === false) {
                 $ruleArguments = $rulesTyposcript[$key . '.'];
                 $fieldName = $this->formUtility->sanitizeNameAttribute($ruleArguments['element']);
                 // remove unsupported validator options
                 $validatorOptions = $ruleArguments;
                 $validatorOptions['errorMessage'] = array($ruleArguments['error.'], $ruleArguments['error']);
                 $keysToRemove = array_flip(array('breakOnError', 'message', 'message.', 'error', 'error.', 'showMessage'));
                 $validatorOptions = array_diff_key($validatorOptions, $keysToRemove);
                 // Instantiate the validator to check if all required options are assigned
                 // and to use the validator message rendering function to pre-render the mandatory message
                 /** @var AbstractValidator $validator */
                 $validator = $this->objectManager->get($validatorClassName, $validatorOptions);
                 if ($validator instanceof AbstractValidator) {
                     $validator->setRawArgument($rawArgument);
                     $validator->setFormUtility($this->formUtility);
                     if ((int) $ruleArguments['showMessage'] === 1) {
                         $mandatoryMessage = $validator->renderMessage($ruleArguments['message.'], $ruleArguments['message']);
                     } else {
                         $mandatoryMessage = NULL;
                     }
                     $this->rules[$this->configuration->getPrefix()][$fieldName][] = array('validator' => $validator, 'validatorName' => $validatorClassName, 'validatorOptions' => $validatorOptions, 'mandatoryMessage' => $mandatoryMessage);
                 } else {
                     throw new \RuntimeException('Class "' . $validatorClassName . '" could not be loaded.');
                 }
             }
         }
     }
 }
 /**
  * orderedStdWrap
  * Calls stdWrap for each entry in the provided array
  *
  * @param string $content Input value undergoing processing in this function.
  * @param array $conf stdWrap properties for orderedStdWrap.
  * @return string The processed input value
  */
 public function stdWrap_orderedStdWrap($content = '', $conf = array())
 {
     $sortedKeysArray = TemplateService::sortedKeyList($conf['orderedStdWrap.'], true);
     foreach ($sortedKeysArray as $key) {
         $content = $this->stdWrap($content, $conf['orderedStdWrap.'][$key . '.']);
     }
     return $content;
 }
Example #16
0
 /**
  * Handles the incoming form data
  *
  * @param Element $element
  * @param array $userConfiguredElementTypoScript
  * @return array
  */
 protected function handleIncomingValues(Element $element, array $userConfiguredElementTypoScript)
 {
     if (!$this->getIncomingData()) {
         return;
     }
     $elementName = $element->getName();
     if ($element->getHtmlAttribute('value') !== null) {
         $modelValue = $element->getHtmlAttribute('value');
     } else {
         $modelValue = $element->getAdditionalArgument('value');
     }
     if ($this->getIncomingData()->getIncomingField($elementName) !== null) {
         /* filter values and set it back to incoming fields */
         /* remove xss every time */
         $userConfiguredElementTypoScript['filters.'][-1] = 'removexss';
         $keys = TemplateService::sortedKeyList($userConfiguredElementTypoScript['filters.']);
         foreach ($keys as $key) {
             $class = $userConfiguredElementTypoScript['filters.'][$key];
             if ((int) $key && strpos($key, '.') === false) {
                 $filterArguments = $userConfiguredElementTypoScript['filters.'][$key . '.'];
                 $filterClassName = $this->typoScriptRepository->getRegisteredClassName((string) $class, 'registeredFilters');
                 if ($filterClassName !== null) {
                     // toDo: handel array values
                     if (is_string($this->getIncomingData()->getIncomingField($elementName))) {
                         if (is_null($filterArguments)) {
                             $filter = $this->objectManager->get($filterClassName);
                         } else {
                             $filter = $this->objectManager->get($filterClassName, $filterArguments);
                         }
                         if ($filter) {
                             $value = $filter->filter($this->getIncomingData()->getIncomingField($elementName));
                             $this->getIncomingData()->setIncomingField($elementName, $value);
                         } else {
                             throw new \RuntimeException('Class "' . $filterClassName . '" could not be loaded.');
                         }
                     }
                 } else {
                     throw new \RuntimeException('Class "' . $filterClassName . '" not registered via TypoScript.');
                 }
             }
         }
         if ($element->getHtmlAttribute('value') !== null) {
             $element->setHtmlAttribute('value', $this->getIncomingData()->getIncomingField($elementName));
         } else {
             $element->setAdditionalArgument('value', $this->getIncomingData()->getIncomingField($elementName));
         }
     }
     $this->signalSlotDispatcher->dispatch(__CLASS__, 'txFormHandleIncomingValues', array($element, $this->getIncomingData(), $modelValue, $this));
 }
 /**
  * Determines to include custom or pagegen.php script
  * returns script-filename if a TypoScript (config) script is defined and should be include instead of pagegen.php
  *
  * @return string The relative filepath of "config.pageGenScript" if found and allowed
  * @todo Define visibility
  */
 public function generatePage_whichScript()
 {
     if (!$this->TYPO3_CONF_VARS['FE']['noPHPscriptInclude'] && $this->config['config']['pageGenScript']) {
         return $this->tmpl->getFileName($this->config['config']['pageGenScript']);
     }
 }
Example #18
0
 /**
  * Wrapper method for \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList
  * (makes unit testing possible)
  *
  * @return array
  * @deprecated in TYPO3 CMS 7, does not trigger deprecation log in 6.2
  */
 public function sortTypoScriptKeyList()
 {
     return \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($this->typoScript);
 }
Example #19
0
 /**
  * The actual rendering of the image file.
  * Basically sets the dimensions, the background color, the traverses the array of GIFBUILDER objects and finally setting the transparent color if defined.
  * Creates a GDlib resource in $this->im and works on that
  * Called by gifBuild()
  *
  * @return void
  * @access private
  * @see gifBuild()
  */
 public function make()
 {
     // Get trivial data
     $XY = $this->XY;
     // Reset internal properties
     $this->saveAlphaLayer = false;
     // Gif-start
     $this->im = imagecreatetruecolor($XY[0], $XY[1]);
     $this->w = $XY[0];
     $this->h = $XY[1];
     // Transparent layer as background if set and requirements are met
     if (!empty($this->setup['backColor']) && $this->setup['backColor'] === 'transparent' && $this->png_truecolor && !$this->setup['reduceColors'] && (empty($this->setup['format']) || $this->setup['format'] === 'png')) {
         // Set transparency properties
         imagesavealpha($this->im, true);
         // Fill with a transparent background
         $transparentColor = imagecolorallocatealpha($this->im, 0, 0, 0, 127);
         imagefill($this->im, 0, 0, $transparentColor);
         // Set internal properties to keep the transparency over the rendering process
         $this->saveAlphaLayer = true;
         // Force PNG in case no format is set
         $this->setup['format'] = 'png';
         $BGcols = array();
     } else {
         // Fill the background with the given color
         $BGcols = $this->convertColor($this->setup['backColor']);
         $Bcolor = ImageColorAllocate($this->im, $BGcols[0], $BGcols[1], $BGcols[2]);
         ImageFilledRectangle($this->im, 0, 0, $XY[0], $XY[1], $Bcolor);
     }
     // Traverse the GIFBUILDER objects an render each one:
     if (is_array($this->setup)) {
         $sKeyArray = TemplateService::sortedKeyList($this->setup);
         foreach ($sKeyArray as $theKey) {
             $theValue = $this->setup[$theKey];
             if ((int) $theKey && ($conf = $this->setup[$theKey . '.'])) {
                 // apply stdWrap to all properties, except for TEXT objects
                 // all properties of the TEXT sub-object have already been stdWrap-ped
                 // before in ->checkTextObj()
                 if ($theValue !== 'TEXT') {
                     $isStdWrapped = array();
                     foreach ($conf as $key => $value) {
                         $parameter = rtrim($key, '.');
                         if (!$isStdWrapped[$parameter] && isset($conf[$parameter . '.'])) {
                             $conf[$parameter] = $this->cObj->stdWrap($conf[$parameter], $conf[$parameter . '.']);
                             $isStdWrapped[$parameter] = 1;
                         }
                     }
                 }
                 switch ($theValue) {
                     case 'IMAGE':
                         if ($conf['mask']) {
                             $this->maskImageOntoImage($this->im, $conf, $this->workArea);
                         } else {
                             $this->copyImageOntoImage($this->im, $conf, $this->workArea);
                         }
                         break;
                     case 'TEXT':
                         if (!$conf['hide']) {
                             if (is_array($conf['shadow.'])) {
                                 $isStdWrapped = array();
                                 foreach ($conf['shadow.'] as $key => $value) {
                                     $parameter = rtrim($key, '.');
                                     if (!$isStdWrapped[$parameter] && isset($conf[$parameter . '.'])) {
                                         $conf['shadow.'][$parameter] = $this->cObj->stdWrap($conf[$parameter], $conf[$parameter . '.']);
                                         $isStdWrapped[$parameter] = 1;
                                     }
                                 }
                                 $this->makeShadow($this->im, $conf['shadow.'], $this->workArea, $conf);
                             }
                             if (is_array($conf['emboss.'])) {
                                 $isStdWrapped = array();
                                 foreach ($conf['emboss.'] as $key => $value) {
                                     $parameter = rtrim($key, '.');
                                     if (!$isStdWrapped[$parameter] && isset($conf[$parameter . '.'])) {
                                         $conf['emboss.'][$parameter] = $this->cObj->stdWrap($conf[$parameter], $conf[$parameter . '.']);
                                         $isStdWrapped[$parameter] = 1;
                                     }
                                 }
                                 $this->makeEmboss($this->im, $conf['emboss.'], $this->workArea, $conf);
                             }
                             if (is_array($conf['outline.'])) {
                                 $isStdWrapped = array();
                                 foreach ($conf['outline.'] as $key => $value) {
                                     $parameter = rtrim($key, '.');
                                     if (!$isStdWrapped[$parameter] && isset($conf[$parameter . '.'])) {
                                         $conf['outline.'][$parameter] = $this->cObj->stdWrap($conf[$parameter], $conf[$parameter . '.']);
                                         $isStdWrapped[$parameter] = 1;
                                     }
                                 }
                                 $this->makeOutline($this->im, $conf['outline.'], $this->workArea, $conf);
                             }
                             $conf['imgMap'] = 1;
                             $this->makeText($this->im, $conf, $this->workArea);
                         }
                         break;
                     case 'OUTLINE':
                         if ($this->setup[$conf['textObjNum']] == 'TEXT' && ($txtConf = $this->checkTextObj($this->setup[$conf['textObjNum'] . '.']))) {
                             $this->makeOutline($this->im, $conf, $this->workArea, $txtConf);
                         }
                         break;
                     case 'EMBOSS':
                         if ($this->setup[$conf['textObjNum']] == 'TEXT' && ($txtConf = $this->checkTextObj($this->setup[$conf['textObjNum'] . '.']))) {
                             $this->makeEmboss($this->im, $conf, $this->workArea, $txtConf);
                         }
                         break;
                     case 'SHADOW':
                         if ($this->setup[$conf['textObjNum']] == 'TEXT' && ($txtConf = $this->checkTextObj($this->setup[$conf['textObjNum'] . '.']))) {
                             $this->makeShadow($this->im, $conf, $this->workArea, $txtConf);
                         }
                         break;
                     case 'BOX':
                         $this->makeBox($this->im, $conf, $this->workArea);
                         break;
                     case 'EFFECT':
                         $this->makeEffect($this->im, $conf);
                         break;
                     case 'ADJUST':
                         $this->adjust($this->im, $conf);
                         break;
                     case 'CROP':
                         $this->crop($this->im, $conf);
                         break;
                     case 'SCALE':
                         $this->scale($this->im, $conf);
                         break;
                     case 'WORKAREA':
                         if ($conf['set']) {
                             // this sets the workArea
                             $this->setWorkArea($conf['set']);
                         }
                         if (isset($conf['clear'])) {
                             // This sets the current to the default;
                             $this->workArea = $this->defaultWorkArea;
                         }
                         break;
                     case 'ELLIPSE':
                         $this->makeEllipse($this->im, $conf, $this->workArea);
                         break;
                 }
             }
         }
     }
     // Preserve alpha transparency
     if (!$this->saveAlphaLayer) {
         if ($this->setup['transparentBackground']) {
             // Auto transparent background is set
             $Bcolor = ImageColorClosest($this->im, $BGcols[0], $BGcols[1], $BGcols[2]);
             imagecolortransparent($this->im, $Bcolor);
         } elseif (is_array($this->setup['transparentColor_array'])) {
             // Multiple transparent colors are set. This is done via the trick that all transparent colors get
             // converted to one color and then this one gets set as transparent as png/gif can just have one
             // transparent color.
             $Tcolor = $this->unifyColors($this->im, $this->setup['transparentColor_array'], (int) $this->setup['transparentColor.']['closest']);
             if ($Tcolor >= 0) {
                 imagecolortransparent($this->im, $Tcolor);
             }
         }
     }
 }
 /**
  * Set the validation rules
  *
  * Makes the validation object and adds rules to it
  *
  * @param array $typoscript TypoScript
  * @return \TYPO3\CMS\Form\Utility\ValidatorUtility The validation object
  */
 public function setRules(array $typoscript)
 {
     $rulesTyposcript = isset($typoscript['rules.']) ? $typoscript['rules.'] : NULL;
     /** @var $rulesClass \TYPO3\CMS\Form\Utility\ValidatorUtility */
     $rulesClass = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Form\\Utility\\ValidatorUtility', $rulesTyposcript);
     // singleton
     if (is_array($rulesTyposcript)) {
         $keys = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($rulesTyposcript);
         foreach ($keys as $key) {
             $class = $rulesTyposcript[$key];
             if (intval($key) && !strstr($key, '.')) {
                 $elementArguments = $rulesTyposcript[$key . '.'];
                 $rule = $rulesClass->createRule($class, $elementArguments);
                 $rule->setFieldName($elementArguments['element']);
                 $breakOnError = isset($elementArguments['breakOnError']) ? $elementArguments['breakOnError'] : FALSE;
                 $rulesClass->addRule($rule, $elementArguments['element'], $breakOnError);
             }
         }
     }
     return $rulesClass;
 }
 /**
  * Will traverse input array with configuration per-item and create corresponding GIF files for the menu.
  * The data of the files are stored in $this->result
  *
  * @param array $conf Array with configuration for each item.
  * @return void
  * @access private
  * @see generate()
  * @todo Define visibility
  */
 public function makeImageMap($conf)
 {
     if (!is_array($conf)) {
         $conf = array();
     }
     if (is_array($this->mconf['main.'])) {
         $gifCreator = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Imaging\\GifBuilder');
         $gifCreator->init();
         $itemsConf = $conf;
         $conf = $this->mconf['main.'];
         if (is_array($conf)) {
             $gifObjCount = 0;
             $sKeyArray = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($conf);
             $gifObjCount = (int) end($sKeyArray);
             $lastOriginal = $gifObjCount;
             // Now we add graphical objects to the gifbuilder-setup
             $waArr = array();
             foreach ($itemsConf as $key => $val) {
                 if (is_array($val)) {
                     $gifObjCount++;
                     $waArr[$key]['free'] = $gifObjCount;
                     $sKeyArray = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($val);
                     foreach ($sKeyArray as $theKey) {
                         $theValue = $val[$theKey];
                         if ((int) $theKey && ($theValArr = $val[$theKey . '.'])) {
                             $cObjData = $this->menuArr[$key] ?: array();
                             $gifObjCount++;
                             if ($theValue == 'TEXT') {
                                 $waArr[$key]['textNum'] = $gifObjCount;
                                 $gifCreator->data = $cObjData;
                                 $theValArr = $gifCreator->checkTextObj($theValArr);
                                 // if this is not done it seems that imageMaps will be rendered wrong!!
                                 unset($theValArr['text.']);
                                 // check links
                                 $LD = $this->menuTypoLink($this->menuArr[$key], $this->mconf['target'], '', '', array(), '', $this->mconf['forceTypeValue']);
                                 // If access restricted pages should be shown in menus, change the link of such pages to link to a redirection page:
                                 $this->changeLinksForAccessRestrictedPages($LD, $this->menuArr[$key], $this->mconf['target'], $this->mconf['forceTypeValue']);
                                 // Overriding URL / Target if set to do so:
                                 if ($this->menuArr[$key]['_OVERRIDE_HREF']) {
                                     $LD['totalURL'] = $this->menuArr[$key]['_OVERRIDE_HREF'];
                                     if ($this->menuArr[$key]['_OVERRIDE_TARGET']) {
                                         $LD['target'] = $this->menuArr[$key]['_OVERRIDE_TARGET'];
                                     }
                                 }
                                 // Setting target/url for Image Map:
                                 if ($theValArr['imgMap.']['url'] == '') {
                                     $theValArr['imgMap.']['url'] = $LD['totalURL'];
                                 }
                                 if ($theValArr['imgMap.']['target'] == '') {
                                     $theValArr['imgMap.']['target'] = $LD['target'];
                                 }
                                 if (is_array($theValArr['imgMap.']['altText.'])) {
                                     $cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
                                     $cObj->start($cObjData, 'pages');
                                     if (isset($theValArr['imgMap.']['altText.'])) {
                                         $theValArr['imgMap.']['altText'] = $cObj->stdWrap($theValArr['imgMap.']['altText'], $theValArr['imgMap.']['altText.']);
                                     }
                                     unset($theValArr['imgMap.']['altText.']);
                                 }
                                 if (is_array($theValArr['imgMap.']['titleText.'])) {
                                     $cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
                                     $cObj->start($cObjData, 'pages');
                                     if (isset($theValArr['imgMap.']['titleText.'])) {
                                         $theValArr['imgMap.']['titleText'] = $cObj->stdWrap($theValArr['imgMap.']['titleText'], $theValArr['imgMap.']['titleText.']);
                                     }
                                     unset($theValArr['imgMap.']['titleText.']);
                                 }
                             }
                             // This code goes one level in if the object is an image. If 'file' and/or 'mask' appears to be GIFBUILDER-objects, they are both searched for TEXT objects, and if a textobj is found, it's checked with the currently loaded record!!
                             if ($theValue == 'IMAGE') {
                                 if ($theValArr['file'] == 'GIFBUILDER') {
                                     $temp_sKeyArray = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($theValArr['file.']);
                                     foreach ($temp_sKeyArray as $temp_theKey) {
                                         if ($theValArr['mask.'][$temp_theKey] == 'TEXT') {
                                             $gifCreator->data = $this->menuArr[$key] ?: array();
                                             $theValArr['mask.'][$temp_theKey . '.'] = $gifCreator->checkTextObj($theValArr['mask.'][$temp_theKey . '.']);
                                             // If this is not done it seems that imageMaps will be rendered wrong!!
                                             unset($theValArr['mask.'][$temp_theKey . '.']['text.']);
                                         }
                                     }
                                 }
                                 if ($theValArr['mask'] == 'GIFBUILDER') {
                                     $temp_sKeyArray = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($theValArr['mask.']);
                                     foreach ($temp_sKeyArray as $temp_theKey) {
                                         if ($theValArr['mask.'][$temp_theKey] == 'TEXT') {
                                             $gifCreator->data = $this->menuArr[$key] ?: array();
                                             $theValArr['mask.'][$temp_theKey . '.'] = $gifCreator->checkTextObj($theValArr['mask.'][$temp_theKey . '.']);
                                             // if this is not done it seems that imageMaps will be rendered wrong!!
                                             unset($theValArr['mask.'][$temp_theKey . '.']['text.']);
                                         }
                                     }
                                 }
                             }
                             // Checks if disabled is set...
                             $setObjFlag = 1;
                             if ($theValArr['if.']) {
                                 /** @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $cObj */
                                 $cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
                                 $cObj->start($cObjData, 'pages');
                                 if (!empty($theValArr['if.']) && !$cObj->checkIf($theValArr['if.'])) {
                                     $setObjFlag = 0;
                                 }
                                 unset($theValArr['if.']);
                             }
                             // Set the object!
                             if ($setObjFlag) {
                                 $conf[$gifObjCount] = $theValue;
                                 $conf[$gifObjCount . '.'] = $theValArr;
                             }
                         }
                     }
                 }
             }
             $gifCreator->start($conf, $GLOBALS['TSFE']->page);
             // calculations
             foreach ($waArr as $key => $val) {
                 if ($dConf[$key] = $itemsConf[$key]['distrib']) {
                     $textBB = $gifCreator->objBB[$val['textNum']];
                     $dConf[$key] = str_replace(array('textX', 'textY'), array($textBB[0], $textBB[1]), $dConf[$key]);
                     $dConf[$key] = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $gifCreator->calcOffset($dConf[$key]));
                 }
             }
             $workArea = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $gifCreator->calcOffset($this->mconf['dWorkArea']));
             foreach ($waArr as $key => $val) {
                 $index = $val['free'];
                 $gifCreator->setup[$index] = 'WORKAREA';
                 $workArea[2] = $dConf[$key][2] ?: $dConf[$key][0];
                 $workArea[3] = $dConf[$key][3] ?: $dConf[$key][1];
                 $gifCreator->setup[$index . '.']['set'] = implode(',', $workArea);
                 $workArea[0] += $dConf[$key][0];
                 $workArea[1] += $dConf[$key][1];
             }
             if ($this->mconf['debugRenumberedObject']) {
                 echo '<h3>Renumbered GIFBUILDER object:</h3>';
                 debug($gifCreator->setup);
             }
             $gifCreator->createTempSubDir('menu/');
             $gifFileName = $gifCreator->fileName('menu/');
             // Gets the ImageMap from the cache...
             $imgHash = md5($gifFileName);
             $imgMap = $this->sys_page->getHash($imgHash);
             // File exists
             if ($imgMap && file_exists($gifFileName)) {
                 $info = @getimagesize($gifFileName);
                 $w = $info[0];
                 $h = $info[1];
             } else {
                 // file is generated
                 $gifCreator->make();
                 $w = $gifCreator->w;
                 $h = $gifCreator->h;
                 $gifCreator->output($gifFileName);
                 $gifCreator->destroy();
                 $imgMap = $gifCreator->map;
                 $this->sys_page->storeHash($imgHash, $imgMap, 'MENUIMAGEMAP');
             }
             $imgMap .= $this->mconf['imgMapExtras'];
             $gifFileName = \TYPO3\CMS\Core\Utility\GeneralUtility::png_to_gif_by_imagemagick($gifFileName);
             $this->result = array('output_file' => $gifFileName, 'output_w' => $w, 'output_h' => $h, 'imgMap' => $imgMap);
         }
     }
 }
 /**
  * Includes a comma-separated list of library files by PHP function include_once.
  *
  * @param array $libraries The libraries to be included.
  * @return void
  * @todo deprecate this method
  */
 public function includeLibraries(array $libraries)
 {
     $timeTracker = $this->getTimeTracker();
     $timeTracker->push('Include libraries');
     $timeTracker->setTSlogMessage('Files for inclusion: "' . implode(', ', $libraries) . '"');
     foreach ($libraries as $library) {
         $file = $this->tmpl->getFileName($library);
         if ($file) {
             include_once './' . $file;
         } else {
             $timeTracker->setTSlogMessage('Include file "' . $file . '" did not exist!', 2);
         }
     }
     $timeTracker->pull();
 }
 /**
  * @test
  * @dataProvider splitConfDataProvider
  * @see https://docs.typo3.org/typo3cms/TyposcriptReference/ObjectsAndProperties/Index.html#objects-optionsplit
  */
 public function splitConfArraytest($configuration, $splitCount, $expected)
 {
     $actual = $this->templateService->splitConfArray($configuration, $splitCount);
     $this->assertSame($expected, $actual);
 }
 /**
  * Splitting a string for ImageTTFBBox up into an array where each part has its own configuration options.
  *
  * @param string $string UTF-8 string
  * @param array $splitRendering Split-rendering configuration from GIFBUILDER TEXT object.
  * @param int $fontSize Current fontsize
  * @param string $fontFile Current font file
  * @return array Array with input string splitted according to configuration
  */
 public function splitString($string, $splitRendering, $fontSize, $fontFile)
 {
     // Initialize by setting the whole string and default configuration as the first entry.
     $result = array();
     $result[] = array('str' => $string, 'fontSize' => $fontSize, 'fontFile' => $fontFile);
     // Traverse the split-rendering configuration:
     // Splitting will create more entries in $result with individual configurations.
     if (is_array($splitRendering)) {
         $sKeyArray = TemplateService::sortedKeyList($splitRendering);
         // Traverse configured options:
         foreach ($sKeyArray as $key) {
             $cfg = $splitRendering[$key . '.'];
             // Process each type of split rendering keyword:
             switch ((string) $splitRendering[$key]) {
                 case 'highlightWord':
                     if ((string) $cfg['value'] !== '') {
                         $newResult = array();
                         // Traverse the current parts of the result array:
                         foreach ($result as $part) {
                             // Explode the string value by the word value to highlight:
                             $explodedParts = explode($cfg['value'], $part['str']);
                             foreach ($explodedParts as $c => $expValue) {
                                 if ((string) $expValue !== '') {
                                     $newResult[] = array_merge($part, array('str' => $expValue));
                                 }
                                 if ($c + 1 < count($explodedParts)) {
                                     $newResult[] = array('str' => $cfg['value'], 'fontSize' => $cfg['fontSize'] ? $cfg['fontSize'] : $part['fontSize'], 'fontFile' => $cfg['fontFile'] ? $cfg['fontFile'] : $part['fontFile'], 'color' => $cfg['color'], 'xSpaceBefore' => $cfg['xSpaceBefore'], 'xSpaceAfter' => $cfg['xSpaceAfter'], 'ySpaceBefore' => $cfg['ySpaceBefore'], 'ySpaceAfter' => $cfg['ySpaceAfter']);
                                 }
                             }
                         }
                         // Set the new result as result array:
                         if (!empty($newResult)) {
                             $result = $newResult;
                         }
                     }
                     break;
                 case 'charRange':
                     if ((string) $cfg['value'] !== '') {
                         // Initialize range:
                         $ranges = GeneralUtility::trimExplode(',', $cfg['value'], true);
                         foreach ($ranges as $i => $rangeDef) {
                             $ranges[$i] = GeneralUtility::intExplode('-', $ranges[$i]);
                             if (!isset($ranges[$i][1])) {
                                 $ranges[$i][1] = $ranges[$i][0];
                             }
                         }
                         $newResult = array();
                         // Traverse the current parts of the result array:
                         foreach ($result as $part) {
                             // Initialize:
                             $currentState = -1;
                             $bankAccum = '';
                             // Explode the string value by the word value to highlight:
                             $utf8Chars = $this->csConvObj->utf8_to_numberarray($part['str'], true, true);
                             foreach ($utf8Chars as $utfChar) {
                                 // Find number and evaluate position:
                                 $uNumber = (int) $this->csConvObj->utf8CharToUnumber($utfChar);
                                 $inRange = 0;
                                 foreach ($ranges as $rangeDef) {
                                     if ($uNumber >= $rangeDef[0] && (!$rangeDef[1] || $uNumber <= $rangeDef[1])) {
                                         $inRange = 1;
                                         break;
                                     }
                                 }
                                 if ($currentState == -1) {
                                     $currentState = $inRange;
                                 }
                                 // Initialize first char
                                 // Switch bank:
                                 if ($inRange != $currentState && $uNumber !== 9 && $uNumber !== 10 && $uNumber !== 13 && $uNumber !== 32) {
                                     // Set result:
                                     if ($bankAccum !== '') {
                                         $newResult[] = array('str' => $bankAccum, 'fontSize' => $currentState && $cfg['fontSize'] ? $cfg['fontSize'] : $part['fontSize'], 'fontFile' => $currentState && $cfg['fontFile'] ? $cfg['fontFile'] : $part['fontFile'], 'color' => $currentState ? $cfg['color'] : '', 'xSpaceBefore' => $currentState ? $cfg['xSpaceBefore'] : '', 'xSpaceAfter' => $currentState ? $cfg['xSpaceAfter'] : '', 'ySpaceBefore' => $currentState ? $cfg['ySpaceBefore'] : '', 'ySpaceAfter' => $currentState ? $cfg['ySpaceAfter'] : '');
                                     }
                                     // Initialize new settings:
                                     $currentState = $inRange;
                                     $bankAccum = '';
                                 }
                                 // Add char to bank:
                                 $bankAccum .= $utfChar;
                             }
                             // Set result for FINAL part:
                             if ($bankAccum !== '') {
                                 $newResult[] = array('str' => $bankAccum, 'fontSize' => $currentState && $cfg['fontSize'] ? $cfg['fontSize'] : $part['fontSize'], 'fontFile' => $currentState && $cfg['fontFile'] ? $cfg['fontFile'] : $part['fontFile'], 'color' => $currentState ? $cfg['color'] : '', 'xSpaceBefore' => $currentState ? $cfg['xSpaceBefore'] : '', 'xSpaceAfter' => $currentState ? $cfg['xSpaceAfter'] : '', 'ySpaceBefore' => $currentState ? $cfg['ySpaceBefore'] : '', 'ySpaceAfter' => $currentState ? $cfg['ySpaceAfter'] : '');
                             }
                         }
                         // Set the new result as result array:
                         if (!empty($newResult)) {
                             $result = $newResult;
                         }
                     }
                     break;
             }
         }
     }
     return $result;
 }
 /**
  * @test
  */
 public function getFileNameReturnsNullWithInvalidFileName()
 {
     $this->assertNull($this->templateService->getFileName('  '));
     $this->assertNull($this->templateService->getFileName('something/../else'));
 }
 /**
  * Rendering the cObject, FORM
  *
  * Note on $formData:
  * In the optional $formData array each entry represents a line in the ordinary setup.
  * In those entries each entry (0,1,2...) represents a space normally divided by the '|' line.
  *
  * $formData [] = array('Name:', 'name=input, 25 ', 'Default value....');
  * $formData [] = array('Email:', 'email=input, 25 ', 'Default value for email....');
  *
  * - corresponds to the $conf['data'] value being :
  * Name:|name=input, 25 |Default value....||Email:|email=input, 25 |Default value for email....
  *
  * If $formData is an array the value of $conf['data'] is ignored.
  *
  * @param array $conf Array of TypoScript properties
  * @param array $formData Alternative formdata overriding whatever comes from TypoScript
  * @return string Output
  */
 public function render($conf = array(), $formData = '')
 {
     $content = '';
     if (is_array($formData)) {
         $dataArray = $formData;
     } else {
         $data = isset($conf['data.']) ? $this->cObj->stdWrap($conf['data'], $conf['data.']) : $conf['data'];
         // Clearing dataArr
         $dataArray = array();
         // Getting the original config
         if (trim($data)) {
             $data = str_replace(LF, '||', $data);
             $dataArray = explode('||', $data);
         }
         // Adding the new dataArray config form:
         if (is_array($conf['dataArray.'])) {
             // dataArray is supplied
             $sortedKeyArray = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($conf['dataArray.'], true);
             foreach ($sortedKeyArray as $theKey) {
                 $singleKeyArray = $conf['dataArray.'][$theKey . '.'];
                 if (is_array($singleKeyArray)) {
                     $temp = array();
                     $label = isset($singleKeyArray['label.']) ? $this->cObj->stdWrap($singleKeyArray['label'], $singleKeyArray['label.']) : $singleKeyArray['label'];
                     list($temp[0]) = explode('|', $label);
                     $type = isset($singleKeyArray['type.']) ? $this->cObj->stdWrap($singleKeyArray['type'], $singleKeyArray['type.']) : $singleKeyArray['type'];
                     list($temp[1]) = explode('|', $type);
                     $required = isset($singleKeyArray['required.']) ? $this->cObj->stdWrap($singleKeyArray['required'], $singleKeyArray['required.']) : $singleKeyArray['required'];
                     if ($required) {
                         $temp[1] = '*' . $temp[1];
                     }
                     $singleValue = isset($singleKeyArray['value.']) ? $this->cObj->stdWrap($singleKeyArray['value'], $singleKeyArray['value.']) : $singleKeyArray['value'];
                     list($temp[2]) = explode('|', $singleValue);
                     // If value array is set, then implode those values.
                     if (is_array($singleKeyArray['valueArray.'])) {
                         $temp_accumulated = array();
                         foreach ($singleKeyArray['valueArray.'] as $singleKey => $singleKey_valueArray) {
                             if (is_array($singleKey_valueArray) && (int) $singleKey . '.' === (string) $singleKey) {
                                 $temp_valueArray = array();
                                 $valueArrayLabel = isset($singleKey_valueArray['label.']) ? $this->cObj->stdWrap($singleKey_valueArray['label'], $singleKey_valueArray['label.']) : $singleKey_valueArray['label'];
                                 list($temp_valueArray[0]) = explode('=', $valueArrayLabel);
                                 $selected = isset($singleKey_valueArray['selected.']) ? $this->cObj->stdWrap($singleKey_valueArray['selected'], $singleKey_valueArray['selected.']) : $singleKey_valueArray['selected'];
                                 if ($selected) {
                                     $temp_valueArray[0] = '*' . $temp_valueArray[0];
                                 }
                                 $singleKeyValue = isset($singleKey_valueArray['value.']) ? $this->cObj->stdWrap($singleKey_valueArray['value'], $singleKey_valueArray['value.']) : $singleKey_valueArray['value'];
                                 list($temp_valueArray[1]) = explode(',', $singleKeyValue);
                             }
                             $temp_accumulated[] = implode('=', $temp_valueArray);
                         }
                         $temp[2] = implode(',', $temp_accumulated);
                     }
                     $specialEval = isset($singleKeyArray['specialEval.']) ? $this->cObj->stdWrap($singleKeyArray['specialEval'], $singleKeyArray['specialEval.']) : $singleKeyArray['specialEval'];
                     list($temp[3]) = explode('|', $specialEval);
                     // Adding the form entry to the dataArray
                     $dataArray[] = implode('|', $temp);
                 }
             }
         }
     }
     $attachmentCounter = '';
     $hiddenfields = '';
     $fieldlist = array();
     $propertyOverride = array();
     $fieldname_hashArray = array();
     $counter = 0;
     $xhtmlStrict = GeneralUtility::inList('xhtml_strict,xhtml_11,xhtml_2', $GLOBALS['TSFE']->xhtmlDoctype);
     // Formname
     $formName = isset($conf['formName.']) ? $this->cObj->stdWrap($conf['formName'], $conf['formName.']) : $conf['formName'];
     $formName = $this->cleanFormName($formName);
     $formName = $GLOBALS['TSFE']->getUniqueId($formName);
     $fieldPrefix = isset($conf['fieldPrefix.']) ? $this->cObj->stdWrap($conf['fieldPrefix'], $conf['fieldPrefix.']) : $conf['fieldPrefix'];
     if (isset($conf['fieldPrefix']) || isset($conf['fieldPrefix.'])) {
         if ($fieldPrefix) {
             $prefix = $this->cleanFormName($fieldPrefix);
         } else {
             $prefix = '';
         }
     } else {
         $prefix = $formName;
     }
     foreach ($dataArray as $dataValue) {
         $counter++;
         $confData = array();
         if (is_array($formData)) {
             $parts = $dataValue;
             // TRUE...
             $dataValue = 1;
         } else {
             $dataValue = trim($dataValue);
             $parts = explode('|', $dataValue);
         }
         if ($dataValue && strcspn($dataValue, '#/')) {
             // label:
             $confData['label'] = GeneralUtility::removeXSS(trim($parts[0]));
             // field:
             $fParts = explode(',', $parts[1]);
             $fParts[0] = trim($fParts[0]);
             if ($fParts[0][0] === '*') {
                 $confData['required'] = 1;
                 $fParts[0] = substr($fParts[0], 1);
             }
             $typeParts = explode('=', $fParts[0]);
             $confData['type'] = trim(strtolower(end($typeParts)));
             if (count($typeParts) === 1) {
                 $confData['fieldname'] = $this->cleanFormName($parts[0]);
                 if (strtolower(preg_replace('/[^[:alnum:]]/', '', $confData['fieldname'])) == 'email') {
                     $confData['fieldname'] = 'email';
                 }
                 // Duplicate fieldnames resolved
                 if (isset($fieldname_hashArray[md5($confData['fieldname'])])) {
                     $confData['fieldname'] .= '_' . $counter;
                 }
                 $fieldname_hashArray[md5($confData['fieldname'])] = $confData['fieldname'];
                 // Attachment names...
                 if ($confData['type'] == 'file') {
                     $confData['fieldname'] = 'attachment' . $attachmentCounter;
                     $attachmentCounter = (int) $attachmentCounter + 1;
                 }
             } else {
                 $confData['fieldname'] = str_replace(' ', '_', trim($typeParts[0]));
             }
             $confData['fieldname'] = htmlspecialchars($confData['fieldname']);
             $fieldCode = '';
             $wrapFieldName = isset($conf['wrapFieldName']) ? $this->cObj->stdWrap($conf['wrapFieldName'], $conf['wrapFieldName.']) : $conf['wrapFieldName'];
             if ($wrapFieldName) {
                 $confData['fieldname'] = $this->cObj->wrap($confData['fieldname'], $wrapFieldName);
             }
             // Set field name as current:
             $this->cObj->setCurrentVal($confData['fieldname']);
             // Additional parameters
             if (trim($confData['type'])) {
                 if (isset($conf['params.'][$confData['type']])) {
                     $addParams = isset($conf['params.'][$confData['type'] . '.']) ? trim($this->cObj->stdWrap($conf['params.'][$confData['type']], $conf['params.'][$confData['type'] . '.'])) : trim($conf['params.'][$confData['type']]);
                 } else {
                     $addParams = isset($conf['params.']) ? trim($this->cObj->stdWrap($conf['params'], $conf['params.'])) : trim($conf['params']);
                 }
                 if ((string) $addParams !== '') {
                     $addParams = ' ' . $addParams;
                 }
             } else {
                 $addParams = '';
             }
             $dontMd5FieldNames = isset($conf['dontMd5FieldNames.']) ? $this->cObj->stdWrap($conf['dontMd5FieldNames'], $conf['dontMd5FieldNames.']) : $conf['dontMd5FieldNames'];
             if ($dontMd5FieldNames) {
                 $fName = $confData['fieldname'];
             } else {
                 $fName = md5($confData['fieldname']);
             }
             // Accessibility: Set id = fieldname attribute:
             $accessibility = isset($conf['accessibility.']) ? $this->cObj->stdWrap($conf['accessibility'], $conf['accessibility.']) : $conf['accessibility'];
             if ($accessibility || $xhtmlStrict) {
                 $elementIdAttribute = ' id="' . $prefix . $fName . '"';
             } else {
                 $elementIdAttribute = '';
             }
             // Create form field based on configuration/type:
             switch ($confData['type']) {
                 case 'textarea':
                     $cols = trim($fParts[1]) ? (int) $fParts[1] : 20;
                     $compensateFieldWidth = isset($conf['compensateFieldWidth.']) ? $this->cObj->stdWrap($conf['compensateFieldWidth'], $conf['compensateFieldWidth.']) : $conf['compensateFieldWidth'];
                     $compWidth = doubleval($compensateFieldWidth ? $compensateFieldWidth : $GLOBALS['TSFE']->compensateFieldWidth);
                     $compWidth = $compWidth ? $compWidth : 1;
                     $cols = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($cols * $compWidth, 1, 120);
                     $rows = trim($fParts[2]) ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($fParts[2], 1, 30) : 5;
                     $wrap = trim($fParts[3]);
                     $noWrapAttr = isset($conf['noWrapAttr.']) ? $this->cObj->stdWrap($conf['noWrapAttr'], $conf['noWrapAttr.']) : $conf['noWrapAttr'];
                     if ($noWrapAttr || $wrap === 'disabled') {
                         $wrap = '';
                     } else {
                         $wrap = $wrap ? ' wrap="' . $wrap . '"' : ' wrap="virtual"';
                     }
                     $noValueInsert = isset($conf['noValueInsert.']) ? $this->cObj->stdWrap($conf['noValueInsert'], $conf['noValueInsert.']) : $conf['noValueInsert'];
                     $default = $this->getFieldDefaultValue($noValueInsert, $confData['fieldname'], str_replace('\\n', LF, trim($parts[2])));
                     $fieldCode = sprintf('<textarea name="%s"%s cols="%s" rows="%s"%s%s>%s</textarea>', $confData['fieldname'], $elementIdAttribute, $cols, $rows, $wrap, $addParams, htmlspecialchars($default));
                     break;
                 case 'input':
                 case 'password':
                     $size = trim($fParts[1]) ? (int) $fParts[1] : 20;
                     $compensateFieldWidth = isset($conf['compensateFieldWidth.']) ? $this->cObj->stdWrap($conf['compensateFieldWidth'], $conf['compensateFieldWidth.']) : $conf['compensateFieldWidth'];
                     $compWidth = doubleval($compensateFieldWidth ? $compensateFieldWidth : $GLOBALS['TSFE']->compensateFieldWidth);
                     $compWidth = $compWidth ? $compWidth : 1;
                     $size = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($size * $compWidth, 1, 120);
                     $noValueInsert = isset($conf['noValueInsert.']) ? $this->cObj->stdWrap($conf['noValueInsert'], $conf['noValueInsert.']) : $conf['noValueInsert'];
                     $default = $this->getFieldDefaultValue($noValueInsert, $confData['fieldname'], trim($parts[2]));
                     if ($confData['type'] == 'password') {
                         $default = '';
                     }
                     $max = trim($fParts[2]) ? ' maxlength="' . \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($fParts[2], 1, 1000) . '"' : '';
                     $theType = $confData['type'] == 'input' ? 'text' : 'password';
                     $fieldCode = sprintf('<input type="%s" name="%s"%s size="%s"%s value="%s"%s />', $theType, $confData['fieldname'], $elementIdAttribute, $size, $max, htmlspecialchars($default), $addParams);
                     break;
                 case 'file':
                     $size = trim($fParts[1]) ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($fParts[1], 1, 60) : 20;
                     $fieldCode = sprintf('<input type="file" name="%s"%s size="%s"%s />', $confData['fieldname'], $elementIdAttribute, $size, $addParams);
                     break;
                 case 'check':
                     // alternative default value:
                     $noValueInsert = isset($conf['noValueInsert.']) ? $this->cObj->stdWrap($conf['noValueInsert'], $conf['noValueInsert.']) : $conf['noValueInsert'];
                     $default = $this->getFieldDefaultValue($noValueInsert, $confData['fieldname'], trim($parts[2]));
                     $checked = $default ? ' checked="checked"' : '';
                     $fieldCode = sprintf('<input type="checkbox" value="%s" name="%s"%s%s%s />', 1, $confData['fieldname'], $elementIdAttribute, $checked, $addParams);
                     break;
                 case 'select':
                     $option = '';
                     $valueParts = explode(',', $parts[2]);
                     // size
                     if (strtolower(trim($fParts[1])) == 'auto') {
                         $fParts[1] = count($valueParts);
                     }
                     // Auto size set here. Max 20
                     $size = trim($fParts[1]) ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($fParts[1], 1, 20) : 1;
                     // multiple
                     $multiple = strtolower(trim($fParts[2])) == 'm' ? ' multiple="multiple"' : '';
                     // Where the items will be
                     $items = array();
                     //RTF
                     $defaults = array();
                     $pCount = count($valueParts);
                     for ($a = 0; $a < $pCount; $a++) {
                         $valueParts[$a] = trim($valueParts[$a]);
                         // Finding default value
                         if ($valueParts[$a][0] === '*') {
                             $sel = 'selected';
                             $valueParts[$a] = substr($valueParts[$a], 1);
                         } else {
                             $sel = '';
                         }
                         // Get value/label
                         $subParts = explode('=', $valueParts[$a]);
                         // Sets the value
                         $subParts[1] = isset($subParts[1]) ? trim($subParts[1]) : trim($subParts[0]);
                         // Adds the value/label pair to the items-array
                         $items[] = $subParts;
                         if ($sel) {
                             $defaults[] = $subParts[1];
                         }
                     }
                     // alternative default value:
                     $noValueInsert = isset($conf['noValueInsert.']) ? $this->cObj->stdWrap($conf['noValueInsert'], $conf['noValueInsert.']) : $conf['noValueInsert'];
                     $default = $this->getFieldDefaultValue($noValueInsert, $confData['fieldname'], $defaults);
                     if (!is_array($default)) {
                         $defaults = array();
                         $defaults[] = $default;
                     } else {
                         $defaults = $default;
                     }
                     // Create the select-box:
                     $iCount = count($items);
                     for ($a = 0; $a < $iCount; $a++) {
                         $option .= '<option value="' . $items[$a][1] . '"' . (in_array($items[$a][1], $defaults) ? ' selected="selected"' : '') . '>' . trim($items[$a][0]) . '</option>';
                     }
                     if ($multiple) {
                         // The fieldname must be prepended '[]' if multiple select. And the reason why it's prepended is, because the required-field list later must also have [] prepended.
                         $confData['fieldname'] .= '[]';
                     }
                     $fieldCode = sprintf('<select name="%s"%s size="%s"%s%s>%s</select>', $confData['fieldname'], $elementIdAttribute, $size, $multiple, $addParams, $option);
                     //RTF
                     break;
                 case 'radio':
                     $option = '';
                     $valueParts = explode(',', $parts[2]);
                     // Where the items will be
                     $items = array();
                     $default = '';
                     $pCount = count($valueParts);
                     for ($a = 0; $a < $pCount; $a++) {
                         $valueParts[$a] = trim($valueParts[$a]);
                         if ($valueParts[$a][0] === '*') {
                             $sel = 'checked';
                             $valueParts[$a] = substr($valueParts[$a], 1);
                         } else {
                             $sel = '';
                         }
                         // Get value/label
                         $subParts = explode('=', $valueParts[$a]);
                         // Sets the value
                         $subParts[1] = isset($subParts[1]) ? trim($subParts[1]) : trim($subParts[0]);
                         // Adds the value/label pair to the items-array
                         $items[] = $subParts;
                         if ($sel) {
                             $default = $subParts[1];
                         }
                     }
                     // alternative default value:
                     $noValueInsert = isset($conf['noValueInsert.']) ? $this->cObj->stdWrap($conf['noValueInsert'], $conf['noValueInsert.']) : $conf['noValueInsert'];
                     $default = $this->getFieldDefaultValue($noValueInsert, $confData['fieldname'], $default);
                     // Create the select-box:
                     $iCount = count($items);
                     for ($a = 0; $a < $iCount; $a++) {
                         $optionParts = '';
                         $radioId = $prefix . $fName . $this->cleanFormName($items[$a][0]);
                         if ($accessibility) {
                             $radioLabelIdAttribute = ' id="' . $radioId . '"';
                         } else {
                             $radioLabelIdAttribute = '';
                         }
                         $optionParts .= '<input type="radio" name="' . $confData['fieldname'] . '"' . $radioLabelIdAttribute . ' value="' . $items[$a][1] . '"' . ((string) $items[$a][1] === (string) $default ? ' checked="checked"' : '') . $addParams . ' />';
                         if ($accessibility) {
                             $label = isset($conf['radioWrap.']) ? $this->cObj->stdWrap(trim($items[$a][0]), $conf['radioWrap.']) : trim($items[$a][0]);
                             $optionParts .= '<label for="' . $radioId . '">' . $label . '</label>';
                         } else {
                             $optionParts .= isset($conf['radioWrap.']) ? $this->cObj->stdWrap(trim($items[$a][0]), $conf['radioWrap.']) : trim($items[$a][0]);
                         }
                         $option .= isset($conf['radioInputWrap.']) ? $this->cObj->stdWrap($optionParts, $conf['radioInputWrap.']) : $optionParts;
                     }
                     if ($accessibility) {
                         $accessibilityWrap = isset($conf['radioWrap.']['accessibilityWrap.']) ? $this->cObj->stdWrap($conf['radioWrap.']['accessibilityWrap'], $conf['radioWrap.']['accessibilityWrap.']) : $conf['radioWrap.']['accessibilityWrap'];
                         if ($accessibilityWrap) {
                             $search = array('###RADIO_FIELD_ID###', '###RADIO_GROUP_LABEL###');
                             $replace = array($elementIdAttribute, $confData['label']);
                             $accessibilityWrap = str_replace($search, $replace, $accessibilityWrap);
                             $option = $this->cObj->wrap($option, $accessibilityWrap);
                         }
                     }
                     $fieldCode = $option;
                     break;
                 case 'hidden':
                     $value = trim($parts[2]);
                     // If this form includes an auto responder message, include a HMAC checksum field
                     // in order to verify potential abuse of this feature.
                     if ($value !== '') {
                         if (GeneralUtility::inList($confData['fieldname'], 'auto_respond_msg')) {
                             $hmacChecksum = GeneralUtility::hmac($value, 'content_form');
                             $hiddenfields .= sprintf('<input type="hidden" name="auto_respond_checksum" id="%sauto_respond_checksum" value="%s" />', $prefix, $hmacChecksum);
                         }
                         if (GeneralUtility::inList('recipient_copy,recipient', $confData['fieldname']) && $GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail']) {
                             break;
                         }
                         if (GeneralUtility::inList('recipient_copy,recipient', $confData['fieldname'])) {
                             $value = \TYPO3\CMS\Compatibility6\Utility\FormUtility::codeString($value);
                         }
                     }
                     $hiddenfields .= sprintf('<input type="hidden" name="%s"%s value="%s" />', $confData['fieldname'], $elementIdAttribute, htmlspecialchars($value));
                     break;
                 case 'property':
                     if (GeneralUtility::inList('type,locationData,goodMess,badMess,emailMess', $confData['fieldname'])) {
                         $value = trim($parts[2]);
                         $propertyOverride[$confData['fieldname']] = $value;
                         $conf[$confData['fieldname']] = $value;
                     }
                     break;
                 case 'submit':
                     $value = trim($parts[2]);
                     if ($conf['image.']) {
                         $this->cObj->data[$this->cObj->currentValKey] = $value;
                         $image = $this->cObj->cObjGetSingle('IMG_RESOURCE', $conf['image.']);
                         $params = $conf['image.']['params'] ? ' ' . $conf['image.']['params'] : '';
                         $params .= $this->cObj->getAltParam($conf['image.'], false);
                         $params .= $addParams;
                     } else {
                         $image = '';
                     }
                     if ($image) {
                         $fieldCode = sprintf('<input type="image" name="%s"%s src="%s"%s />', $confData['fieldname'], $elementIdAttribute, $image, $params);
                     } else {
                         $fieldCode = sprintf('<input type="submit" name="%s"%s value="%s"%s />', $confData['fieldname'], $elementIdAttribute, htmlspecialchars($value, ENT_COMPAT, 'UTF-8', false), $addParams);
                     }
                     break;
                 case 'reset':
                     $value = trim($parts[2]);
                     $fieldCode = sprintf('<input type="reset" name="%s"%s value="%s"%s />', $confData['fieldname'], $elementIdAttribute, htmlspecialchars($value, ENT_COMPAT, 'UTF-8', false), $addParams);
                     break;
                 case 'label':
                     $fieldCode = nl2br(htmlspecialchars(trim($parts[2])));
                     break;
                 default:
                     $confData['type'] = 'comment';
                     $fieldCode = trim($parts[2]) . '&nbsp;';
             }
             if ($fieldCode) {
                 // Checking for special evaluation modes:
                 if (trim($parts[3]) !== '' && GeneralUtility::inList('textarea,input,password', $confData['type'])) {
                     $modeParameters = GeneralUtility::trimExplode(':', $parts[3]);
                 } else {
                     $modeParameters = array();
                 }
                 // Adding evaluation based on settings:
                 switch ((string) $modeParameters[0]) {
                     case 'EREG':
                         $fieldlist[] = '_EREG';
                         $fieldlist[] = $modeParameters[1];
                         $fieldlist[] = $modeParameters[2];
                         $fieldlist[] = $confData['fieldname'];
                         $fieldlist[] = $confData['label'];
                         // Setting this so "required" layout is used.
                         $confData['required'] = 1;
                         break;
                     case 'EMAIL':
                         $fieldlist[] = '_EMAIL';
                         $fieldlist[] = $confData['fieldname'];
                         $fieldlist[] = $confData['label'];
                         // Setting this so "required" layout is used.
                         $confData['required'] = 1;
                         break;
                     default:
                         if ($confData['required']) {
                             $fieldlist[] = $confData['fieldname'];
                             $fieldlist[] = $confData['label'];
                         }
                 }
                 // Field:
                 $fieldLabel = $confData['label'];
                 if ($accessibility && trim($fieldLabel) && !preg_match('/^(label|hidden|comment)$/', $confData['type'])) {
                     $fieldLabel = '<label for="' . $prefix . $fName . '">' . $fieldLabel . '</label>';
                 }
                 // Getting template code:
                 if (isset($conf['fieldWrap.'])) {
                     $fieldCode = $this->cObj->stdWrap($fieldCode, $conf['fieldWrap.']);
                 }
                 $labelCode = isset($conf['labelWrap.']) ? $this->cObj->stdWrap($fieldLabel, $conf['labelWrap.']) : $fieldLabel;
                 $commentCode = isset($conf['commentWrap.']) ? $this->cObj->stdWrap($confData['label'], $conf['commentWrap.']) : $confData['label'];
                 $result = $conf['layout'];
                 $req = isset($conf['REQ.']) ? $this->cObj->stdWrap($conf['REQ'], $conf['REQ.']) : $conf['REQ'];
                 if ($req && $confData['required']) {
                     if (isset($conf['REQ.']['fieldWrap.'])) {
                         $fieldCode = $this->cObj->stdWrap($fieldCode, $conf['REQ.']['fieldWrap.']);
                     }
                     if (isset($conf['REQ.']['labelWrap.'])) {
                         $labelCode = $this->cObj->stdWrap($fieldLabel, $conf['REQ.']['labelWrap.']);
                     }
                     $reqLayout = isset($conf['REQ.']['layout.']) ? $this->cObj->stdWrap($conf['REQ.']['layout'], $conf['REQ.']['layout.']) : $conf['REQ.']['layout'];
                     if ($reqLayout) {
                         $result = $reqLayout;
                     }
                 }
                 if ($confData['type'] == 'comment') {
                     $commentLayout = isset($conf['COMMENT.']['layout.']) ? $this->cObj->stdWrap($conf['COMMENT.']['layout'], $conf['COMMENT.']['layout.']) : $conf['COMMENT.']['layout'];
                     if ($commentLayout) {
                         $result = $commentLayout;
                     }
                 }
                 if ($confData['type'] == 'check') {
                     $checkLayout = isset($conf['CHECK.']['layout.']) ? $this->cObj->stdWrap($conf['CHECK.']['layout'], $conf['CHECK.']['layout.']) : $conf['CHECK.']['layout'];
                     if ($checkLayout) {
                         $result = $checkLayout;
                     }
                 }
                 if ($confData['type'] == 'radio') {
                     $radioLayout = isset($conf['RADIO.']['layout.']) ? $this->cObj->stdWrap($conf['RADIO.']['layout'], $conf['RADIO.']['layout.']) : $conf['RADIO.']['layout'];
                     if ($radioLayout) {
                         $result = $radioLayout;
                     }
                 }
                 if ($confData['type'] == 'label') {
                     $labelLayout = isset($conf['LABEL.']['layout.']) ? $this->cObj->stdWrap($conf['LABEL.']['layout'], $conf['LABEL.']['layout.']) : $conf['LABEL.']['layout'];
                     if ($labelLayout) {
                         $result = $labelLayout;
                     }
                 }
                 //RTF
                 $content .= str_replace(array('###FIELD###', '###LABEL###', '###COMMENT###'), array($fieldCode, $labelCode, $commentCode), $result);
             }
         }
     }
     if (isset($conf['stdWrap.'])) {
         $content = $this->cObj->stdWrap($content, $conf['stdWrap.']);
     }
     // Redirect (external: where to go afterwards. internal: where to submit to)
     $theRedirect = isset($conf['redirect.']) ? $this->cObj->stdWrap($conf['redirect'], $conf['redirect.']) : $conf['redirect'];
     // redirect should be set to the page to redirect to after an external script has been used. If internal scripts is used, and if no 'type' is set that dictates otherwise, redirect is used as the url to jump to as long as it's an integer (page)
     $target = isset($conf['target.']) ? $this->cObj->stdWrap($conf['target'], $conf['target.']) : $conf['target'];
     // redirect should be set to the page to redirect to after an external script has been used. If internal scripts is used, and if no 'type' is set that dictates otherwise, redirect is used as the url to jump to as long as it's an integer (page)
     $noCache = isset($conf['no_cache.']) ? $this->cObj->stdWrap($conf['no_cache'], $conf['no_cache.']) : $conf['no_cache'];
     // redirect should be set to the page to redirect to after an external script has been used. If internal scripts is used, and if no 'type' is set that dictates otherwise, redirect is used as the url to jump to as long as it's an integer (page)
     $page = $GLOBALS['TSFE']->page;
     // Internal: Just submit to current page
     if (!$theRedirect) {
         $LD = $GLOBALS['TSFE']->tmpl->linkData($page, $target, $noCache, 'index.php', '', $this->cObj->getClosestMPvalueForPage($page['uid']));
     } elseif (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($theRedirect)) {
         // Internal: Submit to page with ID $theRedirect
         $page = $GLOBALS['TSFE']->sys_page->getPage_noCheck($theRedirect);
         $LD = $GLOBALS['TSFE']->tmpl->linkData($page, $target, $noCache, 'index.php', '', $this->cObj->getClosestMPvalueForPage($page['uid']));
     } else {
         // External URL, redirect-hidden field is rendered!
         $LD = $GLOBALS['TSFE']->tmpl->linkData($page, $target, $noCache, '', '', $this->cObj->getClosestMPvalueForPage($page['uid']));
         $LD['totalURL'] = $theRedirect;
         $hiddenfields .= '<input type="hidden" name="redirect" value="' . htmlspecialchars($LD['totalURL']) . '" />';
     }
     // Formtype (where to submit to!):
     if ($propertyOverride['type']) {
         $formtype = $propertyOverride['type'];
     } else {
         $formtype = isset($conf['type.']) ? $this->cObj->stdWrap($conf['type'], $conf['type.']) : $conf['type'];
     }
     // Submit to a specific page
     if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($formtype)) {
         $page = $GLOBALS['TSFE']->sys_page->getPage_noCheck($formtype);
         $LD_A = $GLOBALS['TSFE']->tmpl->linkData($page, $target, $noCache, '', '', $this->cObj->getClosestMPvalueForPage($page['uid']));
         $action = $LD_A['totalURL'];
     } elseif ($formtype) {
         // Submit to external script
         $LD_A = $LD;
         $action = $formtype;
     } elseif (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($theRedirect)) {
         $LD_A = $LD;
         $action = $LD_A['totalURL'];
     } else {
         // Submit to "nothing" - which is current page
         $LD_A = $GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page, $target, $noCache, '', '', $this->cObj->getClosestMPvalueForPage($page['uid']));
         $action = $LD_A['totalURL'];
     }
     // Recipient:
     $theEmail = isset($conf['recipient.']) ? $this->cObj->stdWrap($conf['recipient'], $conf['recipient.']) : $conf['recipient'];
     if ($theEmail && !$GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail']) {
         $theEmail = \TYPO3\CMS\Compatibility6\Utility\FormUtility::codeString($theEmail);
         $hiddenfields .= '<input type="hidden" name="recipient" value="' . htmlspecialchars($theEmail) . '" />';
     }
     // location data:
     $location = isset($conf['locationData.']) ? $this->cObj->stdWrap($conf['locationData'], $conf['locationData.']) : $conf['locationData'];
     if ($location) {
         if ($location == 'HTTP_POST_VARS' && isset($_POST['locationData'])) {
             $locationData = GeneralUtility::_POST('locationData');
         } else {
             // locationData is [the page id]:[tablename]:[uid of record]. Indicates on which page the record (from tablename with uid) is shown. Used to check access.
             if (isset($this->data['_LOCALIZED_UID'])) {
                 $locationData = $GLOBALS['TSFE']->id . ':' . str_replace($this->data['uid'], $this->data['_LOCALIZED_UID'], $this->cObj->currentRecord);
             } else {
                 $locationData = $GLOBALS['TSFE']->id . ':' . $this->cObj->currentRecord;
             }
         }
         $hiddenfields .= '<input type="hidden" name="locationData" value="' . htmlspecialchars($locationData) . '" />';
     }
     // Hidden fields:
     if (is_array($conf['hiddenFields.'])) {
         foreach ($conf['hiddenFields.'] as $hF_key => $hF_conf) {
             if (substr($hF_key, -1) != '.') {
                 $hF_value = $this->cObj->cObjGetSingle($hF_conf, $conf['hiddenFields.'][$hF_key . '.'], 'hiddenfields');
                 if ((string) $hF_value !== '' && GeneralUtility::inList('recipient_copy,recipient', $hF_key)) {
                     if ($GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail']) {
                         continue;
                     }
                     $hF_value = \TYPO3\CMS\Compatibility6\Utility\FormUtility::codeString($hF_value);
                 }
                 $hiddenfields .= '<input type="hidden" name="' . $hF_key . '" value="' . htmlspecialchars($hF_value) . '" />';
             }
         }
     }
     // Wrap all hidden fields in a div tag (see http://forge.typo3.org/issues/14491)
     $hiddenfields = isset($conf['hiddenFields.']['stdWrap.']) ? $this->cObj->stdWrap($hiddenfields, $conf['hiddenFields.']['stdWrap.']) : '<div style="display:none;">' . $hiddenfields . '</div>';
     if ($conf['REQ']) {
         $goodMess = isset($conf['goodMess.']) ? $this->cObj->stdWrap($conf['goodMess'], $conf['goodMess.']) : $conf['goodMess'];
         $badMess = isset($conf['badMess.']) ? $this->cObj->stdWrap($conf['badMess'], $conf['badMess.']) : $conf['badMess'];
         $emailMess = isset($conf['emailMess.']) ? $this->cObj->stdWrap($conf['emailMess'], $conf['emailMess.']) : $conf['emailMess'];
         $validateForm = ' onsubmit="return validateForm(' . GeneralUtility::quoteJSvalue($formName) . ',' . GeneralUtility::quoteJSvalue(implode(',', $fieldlist)) . ',' . GeneralUtility::quoteJSvalue($goodMess) . ',' . GeneralUtility::quoteJSvalue($badMess) . ',' . GeneralUtility::quoteJSvalue($emailMess) . ')"';
         $GLOBALS['TSFE']->additionalHeaderData['JSFormValidate'] = '<script type="text/javascript" src="' . GeneralUtility::createVersionNumberedFilename($GLOBALS['TSFE']->absRefPrefix . 'typo3/sysext/compatibility6/Resources/Public/JavaScript/jsfunc.validateform.js') . '"></script>';
     } else {
         $validateForm = '';
     }
     // Create form tag:
     $theTarget = $theRedirect ? $LD['target'] : $LD_A['target'];
     $method = isset($conf['method.']) ? $this->cObj->stdWrap($conf['method'], $conf['method.']) : $conf['method'];
     $content = array('<form' . ' action="' . htmlspecialchars($action) . '"' . ' id="' . $formName . '"' . ($xhtmlStrict ? '' : ' name="' . $formName . '"') . ' enctype="multipart/form-data"' . ' method="' . ($method ? $method : 'post') . '"' . ($theTarget ? ' target="' . $theTarget . '"' : '') . $validateForm . '>', $hiddenfields . $content, '</form>');
     $arrayReturnMode = isset($conf['arrayReturnMode.']) ? $this->cObj->stdWrap($conf['arrayReturnMode'], $conf['arrayReturnMode.']) : $conf['arrayReturnMode'];
     if ($arrayReturnMode) {
         $content['validateForm'] = $validateForm;
         $content['formname'] = $formName;
         return $content;
     } else {
         return implode('', $content);
     }
 }
 /**
  * orderedStdWrap
  * Calls stdWrap for each entry in the provided array
  *
  * @param string $content Input value undergoing processing in this function.
  * @param array $conf stdWrap properties for orderedStdWrap.
  * @return string The processed input value
  */
 public function stdWrap_orderedStdWrap($content = '', $conf = array())
 {
     $sortedKeysArray = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($conf['orderedStdWrap.'], TRUE);
     foreach ($sortedKeysArray as $key) {
         $content = $this->stdWrap($content, $conf['orderedStdWrap.'][$key . '.']);
     }
     return $content;
 }
 /**
  * Generating the per-menu-item configuration arrays based on the settings for item states (NO, RO, ACT, CUR etc) set in ->mconf (config for the current menu object)
  * Basically it will produce an individual array for each menu item based on the item states. BUT in addition the "optionSplit" syntax for the values is ALSO evaluated here so that all property-values are "option-splitted" and the output will thus be resolved.
  * Is called from the "generate" functions in the extension classes. The function is processor intensive due to the option split feature in particular. But since the generate function is not always called (since the ->result array may be cached, see makeMenu) it doesn't hurt so badly.
  *
  * @param integer $splitCount Number of menu items in the menu
  * @return array An array with two keys: array($NOconf,$ROconf) - where $NOconf contains the resolved configuration for each item when NOT rolled-over and $ROconf contains the ditto for the mouseover state (if any)
  * @access private
  * @todo Define visibility
  */
 public function procesItemStates($splitCount)
 {
     // Prepare normal settings
     if (!is_array($this->mconf['NO.']) && $this->mconf['NO']) {
         // Setting a blank array if NO=1 and there are no properties.
         $this->mconf['NO.'] = array();
     }
     $NOconf = $this->tmpl->splitConfArray($this->mconf['NO.'], $splitCount);
     // Prepare rollOver settings, overriding normal settings
     $ROconf = array();
     if ($this->mconf['RO']) {
         $ROconf = $this->tmpl->splitConfArray($this->mconf['RO.'], $splitCount);
     }
     // Prepare IFSUB settings, overriding normal settings
     // IFSUB is TRUE if there exist submenu items to the current item
     if ($this->mconf['IFSUB']) {
         // Flag: If $IFSUB is generated
         $IFSUBinit = 0;
         foreach ($NOconf as $key => $val) {
             if ($this->isItemState('IFSUB', $key)) {
                 // if this is the first IFSUB element, we must generate IFSUB.
                 if (!$IFSUBinit) {
                     $IFSUBconf = $this->tmpl->splitConfArray($this->mconf['IFSUB.'], $splitCount);
                     if ($this->mconf['IFSUBRO']) {
                         $IFSUBROconf = $this->tmpl->splitConfArray($this->mconf['IFSUBRO.'], $splitCount);
                     }
                     $IFSUBinit = 1;
                 }
                 // Substitute normal with ifsub
                 $NOconf[$key] = $IFSUBconf[$key];
                 // If rollOver on normal, we must apply a state for rollOver on the active
                 if ($ROconf) {
                     // If RollOver on active then apply this
                     $ROconf[$key] = $IFSUBROconf[$key] ?: $IFSUBconf[$key];
                 }
             }
         }
     }
     // Prepare active settings, overriding normal settings
     if ($this->mconf['ACT']) {
         // Flag: If $ACT is generated
         $ACTinit = 0;
         // Find active
         foreach ($NOconf as $key => $val) {
             if ($this->isItemState('ACT', $key)) {
                 // If this is the first 'active', we must generate ACT.
                 if (!$ACTinit) {
                     $ACTconf = $this->tmpl->splitConfArray($this->mconf['ACT.'], $splitCount);
                     // Prepare active rollOver settings, overriding normal active settings
                     if ($this->mconf['ACTRO']) {
                         $ACTROconf = $this->tmpl->splitConfArray($this->mconf['ACTRO.'], $splitCount);
                     }
                     $ACTinit = 1;
                 }
                 // Substitute normal with active
                 $NOconf[$key] = $ACTconf[$key];
                 // If rollOver on normal, we must apply a state for rollOver on the active
                 if ($ROconf) {
                     // If RollOver on active then apply this
                     $ROconf[$key] = $ACTROconf[$key] ?: $ACTconf[$key];
                 }
             }
         }
     }
     // Prepare ACT (active)/IFSUB settings, overriding normal settings
     // ACTIFSUB is TRUE if there exist submenu items to the current item and the current item is active
     if ($this->mconf['ACTIFSUB']) {
         // Flag: If $ACTIFSUB is generated
         $ACTIFSUBinit = 0;
         // Find active
         foreach ($NOconf as $key => $val) {
             if ($this->isItemState('ACTIFSUB', $key)) {
                 // If this is the first 'active', we must generate ACTIFSUB.
                 if (!$ACTIFSUBinit) {
                     $ACTIFSUBconf = $this->tmpl->splitConfArray($this->mconf['ACTIFSUB.'], $splitCount);
                     // Prepare active rollOver settings, overriding normal active settings
                     if ($this->mconf['ACTIFSUBRO']) {
                         $ACTIFSUBROconf = $this->tmpl->splitConfArray($this->mconf['ACTIFSUBRO.'], $splitCount);
                     }
                     $ACTIFSUBinit = 1;
                 }
                 // Substitute normal with active
                 $NOconf[$key] = $ACTIFSUBconf[$key];
                 // If rollOver on normal, we must apply a state for rollOver on the active
                 if ($ROconf) {
                     // If RollOver on active then apply this
                     $ROconf[$key] = $ACTIFSUBROconf[$key] ?: $ACTIFSUBconf[$key];
                 }
             }
         }
     }
     // Prepare CUR (current) settings, overriding normal settings
     // CUR is TRUE if the current page equals the item here!
     if ($this->mconf['CUR']) {
         // Flag: If $CUR is generated
         $CURinit = 0;
         foreach ($NOconf as $key => $val) {
             if ($this->isItemState('CUR', $key)) {
                 // if this is the first 'current', we must generate CUR. Basically this control is just inherited
                 // from the other implementations as current would only exist one time and thats it
                 // (unless you use special-features of HMENU)
                 if (!$CURinit) {
                     $CURconf = $this->tmpl->splitConfArray($this->mconf['CUR.'], $splitCount);
                     if ($this->mconf['CURRO']) {
                         $CURROconf = $this->tmpl->splitConfArray($this->mconf['CURRO.'], $splitCount);
                     }
                     $CURinit = 1;
                 }
                 // Substitute normal with current
                 $NOconf[$key] = $CURconf[$key];
                 // If rollOver on normal, we must apply a state for rollOver on the active
                 if ($ROconf) {
                     // If RollOver on active then apply this
                     $ROconf[$key] = $CURROconf[$key] ?: $CURconf[$key];
                 }
             }
         }
     }
     // Prepare CUR (current)/IFSUB settings, overriding normal settings
     // CURIFSUB is TRUE if there exist submenu items to the current item and the current page equals the item here!
     if ($this->mconf['CURIFSUB']) {
         // Flag: If $CURIFSUB is generated
         $CURIFSUBinit = 0;
         foreach ($NOconf as $key => $val) {
             if ($this->isItemState('CURIFSUB', $key)) {
                 // If this is the first 'current', we must generate CURIFSUB.
                 if (!$CURIFSUBinit) {
                     $CURIFSUBconf = $this->tmpl->splitConfArray($this->mconf['CURIFSUB.'], $splitCount);
                     // Prepare current rollOver settings, overriding normal current settings
                     if ($this->mconf['CURIFSUBRO']) {
                         $CURIFSUBROconf = $this->tmpl->splitConfArray($this->mconf['CURIFSUBRO.'], $splitCount);
                     }
                     $CURIFSUBinit = 1;
                 }
                 // Substitute normal with active
                 $NOconf[$key] = $CURIFSUBconf[$key];
                 // If rollOver on normal, we must apply a state for rollOver on the current
                 if ($ROconf) {
                     // If RollOver on current then apply this
                     $ROconf[$key] = $CURIFSUBROconf[$key] ?: $CURIFSUBconf[$key];
                 }
             }
         }
     }
     // Prepare active settings, overriding normal settings
     if ($this->mconf['USR']) {
         // Flag: If $USR is generated
         $USRinit = 0;
         // Find active
         foreach ($NOconf as $key => $val) {
             if ($this->isItemState('USR', $key)) {
                 // if this is the first active, we must generate USR.
                 if (!$USRinit) {
                     $USRconf = $this->tmpl->splitConfArray($this->mconf['USR.'], $splitCount);
                     // Prepare active rollOver settings, overriding normal active settings
                     if ($this->mconf['USRRO']) {
                         $USRROconf = $this->tmpl->splitConfArray($this->mconf['USRRO.'], $splitCount);
                     }
                     $USRinit = 1;
                 }
                 // Substitute normal with active
                 $NOconf[$key] = $USRconf[$key];
                 // If rollOver on normal, we must apply a state for rollOver on the active
                 if ($ROconf) {
                     // If RollOver on active then apply this
                     $ROconf[$key] = $USRROconf[$key] ?: $USRconf[$key];
                 }
             }
         }
     }
     // Prepare spacer settings, overriding normal settings
     if ($this->mconf['SPC']) {
         // Flag: If $SPC is generated
         $SPCinit = 0;
         // Find spacers
         foreach ($NOconf as $key => $val) {
             if ($this->isItemState('SPC', $key)) {
                 // If this is the first spacer, we must generate SPC.
                 if (!$SPCinit) {
                     $SPCconf = $this->tmpl->splitConfArray($this->mconf['SPC.'], $splitCount);
                     $SPCinit = 1;
                 }
                 // Substitute normal with spacer
                 $NOconf[$key] = $SPCconf[$key];
             }
         }
     }
     // Prepare Userdefined settings
     if ($this->mconf['USERDEF1']) {
         // Flag: If $USERDEF1 is generated
         $USERDEF1init = 0;
         // Find active
         foreach ($NOconf as $key => $val) {
             if ($this->isItemState('USERDEF1', $key)) {
                 // If this is the first active, we must generate USERDEF1.
                 if (!$USERDEF1init) {
                     $USERDEF1conf = $this->tmpl->splitConfArray($this->mconf['USERDEF1.'], $splitCount);
                     // Prepare active rollOver settings, overriding normal active settings
                     if ($this->mconf['USERDEF1RO']) {
                         $USERDEF1ROconf = $this->tmpl->splitConfArray($this->mconf['USERDEF1RO.'], $splitCount);
                     }
                     $USERDEF1init = 1;
                 }
                 // Substitute normal with active
                 $NOconf[$key] = $USERDEF1conf[$key];
                 // If rollOver on normal, we must apply a state for rollOver on the active
                 if ($ROconf) {
                     // If RollOver on active then apply this
                     $ROconf[$key] = $USERDEF1ROconf[$key] ?: $USERDEF1conf[$key];
                 }
             }
         }
     }
     // Prepare Userdefined settings
     if ($this->mconf['USERDEF2']) {
         // Flag: If $USERDEF2 is generated
         $USERDEF2init = 0;
         // Find active
         foreach ($NOconf as $key => $val) {
             if ($this->isItemState('USERDEF2', $key)) {
                 // If this is the first active, we must generate USERDEF2.
                 if (!$USERDEF2init) {
                     $USERDEF2conf = $this->tmpl->splitConfArray($this->mconf['USERDEF2.'], $splitCount);
                     // Prepare active rollOver settings, overriding normal active settings
                     if ($this->mconf['USERDEF2RO']) {
                         $USERDEF2ROconf = $this->tmpl->splitConfArray($this->mconf['USERDEF2RO.'], $splitCount);
                     }
                     $USERDEF2init = 1;
                 }
                 // Substitute normal with active
                 $NOconf[$key] = $USERDEF2conf[$key];
                 // If rollOver on normal, we must apply a state for rollOver on the active
                 if ($ROconf) {
                     // If RollOver on active then apply this
                     $ROconf[$key] = $USERDEF2ROconf[$key] ?: $USERDEF2conf[$key];
                 }
             }
         }
     }
     return array($NOconf, $ROconf);
 }
 /**
  * Check for the availability of processors, defined in TypoScript, and use them for data processing
  *
  * @param array $configuration Configuration array
  * @param array $variables the variables to be processed
  * @return array the processed data and variables as key/value store
  * @throws \UnexpectedValueException
  */
 protected function processData(array $configuration, array $variables)
 {
     if (!empty($configuration['dataProcessing.']) && is_array($configuration['dataProcessing.'])) {
         $processors = $configuration['dataProcessing.'];
         $processorKeys = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($processors);
         foreach ($processorKeys as $key) {
             $className = $processors[$key];
             $processor = GeneralUtility::makeInstance($className);
             if (!$processor instanceof DataProcessorInterface) {
                 throw new \UnexpectedValueException('$processor with class name "' . $className . '" ' . 'must implement interface "' . DataProcessorInterface::class . '"', 1427455377);
             }
             $processorConfiguration = isset($processors[$key . '.']) ? $processors[$key . '.'] : array();
             $variables = $processor->process($this->cObj, $configuration, $processorConfiguration, $variables);
         }
     }
     return $variables;
 }