/**
  * @param string $func
  * @param string $filename
  */
 public function render($func = 'type', $filename = null)
 {
     if (!$filename) {
         return;
     }
     switch ($func) {
         case 'suffix':
             return $this->fileHelper->suffix($filename);
         case 'type':
             return $this->fileHelper->filetype($filename);
         case 'basename':
             return basename($filename);
         case 'filesize':
             if (!file_exists($filename)) {
                 return 0;
             }
             return filesize($filename);
         case 'exists':
             return $this->fileHelper->exists($filename);
     }
 }
 /**
  * action showForm
  *
  * @return void
  */
 public function validateFormAction()
 {
     $gpVars = $this->_GP;
     $type = $this->settings['tablename'];
     $settings = $this->settings[$type];
     $extName = $settings['extension'];
     $tmplPath = $settings['templatePath'];
     $uploads = array();
     // Validierung des Formulars
     // z.B. ... validation.personinfo.email = required,email
     $errorData = array();
     if ($ref = $settings['validation']) {
         foreach ($ref as $field => $types) {
             $types = $this->anyHelper->trimExplode(',', $types);
             foreach ($types as $type) {
                 $isMedia = $settings['media'][$field];
                 $checkfield = $isMedia ? $field . '_upload' : $field;
                 $fieldValue = $gpVars[$checkfield];
                 $altFieldValue = $gpVars[$field];
                 if ($isMedia && is_array($fieldValue) && isset($fieldValue['name'])) {
                     $fieldValue = $fieldValue['name'];
                 }
                 if (!$fieldValue && $altFieldValue) {
                     $fieldValue = $altFieldValue;
                 }
                 $validator = '\\Nng\\Nnfesubmit\\Validation\\' . ucfirst($type) . 'Validator';
                 if (class_exists($validator)) {
                     // Eigener Validator?
                     $checker = $this->objectManager->create($validator);
                     if ($errors = $checker->validate($fieldValue, $checkfield, $gpVars)->getErrors()) {
                         $errorData[$field][$type] = 1;
                         $errorData[$checkfield][$type] = 1;
                     }
                 } else {
                     // Typo3 interner Validator
                     $validator = '\\TYPO3\\CMS\\Extbase\\Validation\\Validator\\' . ucfirst($type) . 'Validator';
                     $checker = $this->objectManager->create($validator);
                     if ($errors = $checker->validate($fieldValue)->getErrors()) {
                         $errorData[$field][$type] = 1;
                         $errorData[$checkfield][$type] = 1;
                     }
                 }
             }
         }
     }
     // Spezieller Validator enthalten?
     $mapperName = '\\Nng\\Nnfesubmit\\Mapper\\' . \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($extName) . 'Mapper';
     if (class_exists($mapperName)) {
         $mapper = $this->objectManager->create($mapperName);
         \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($errorData, $mapper->validate($gpVars, $settings));
     }
     // Dateien hochgeladen?
     if ($files = $_FILES['tx_nnfesubmit_nnfesubmit']) {
         foreach ($files['name'] as $k => $file) {
             if ($files['size'][$k] > $this->settings['maxUploadFileSize'] * 1000) {
                 $errorData[$k]['filesize'] = 1;
             } else {
                 if (!$this->fileHelper->isForbidden($file) && !$errorData[$k]) {
                     $file = \TYPO3\CMS\Core\Utility\File\BasicFileUtility::cleanFileName(trim($file));
                     $unique_filename = $this->basicFileFunctions->getUniqueName($file, 'uploads/tx_nnfesubmit/');
                     if (\TYPO3\CMS\Core\Utility\GeneralUtility::upload_copy_move($files['tmp_name'][$k], $unique_filename)) {
                         $kn = $k;
                         if (substr($kn, -7) == '_upload') {
                             $kn = substr($kn, 0, -7);
                         }
                         $uploads[$kn] = basename($unique_filename);
                     }
                 } else {
                     if ($file) {
                         $errorData[$k]['invalid_filetype'] = 1;
                     }
                 }
             }
         }
     }
     $gpVars = array_merge($gpVars, $uploads);
     foreach ($gpVars as $k => $v) {
         $gpVars[$k] = $this->anyHelper->cleanTexteditorInput($v);
     }
     $this->view->assign('gp', $gpVars);
     $this->view->assign('errors', $errorData);
     $this->insertViewVariablesFromMapper($extName);
     $this->_GP = $gpVars;
     if ($errorData) {
         $this->view->setTemplatePathAndFilename($tmplPath . 'Form.html');
     } else {
         if ($settings['showConfirmationForm']) {
             $this->showConfirmationFormAction();
         } else {
             $this->finalizeAction();
         }
     }
 }