diff --git a/Classes/Controller/JoblistController.php b/Classes/Controller/JoblistController.php index 09652a84f53ced0142486b5361e619850d6b013c..4bbd2975912679a0ef5143e24458bf490b5fcfdf 100644 --- a/Classes/Controller/JoblistController.php +++ b/Classes/Controller/JoblistController.php @@ -107,11 +107,13 @@ class JoblistController extends ActionController { /** * Renders the application form with an optional job * - * @param JobApplication|NULL $applyData - * @param string|NULL $error - * @param string|NULL $folderName + * @param JobApplication $applyData + * @param string $error + * @param string $folderName + * @param int $uid + * @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException */ - public function applyFormAction(JobApplication $applyData = NULL, $error = NULL, $folderName = NULL) { + public function applyFormAction(JobApplication $applyData = NULL, $error = NULL, $folderName = NULL, $uid = NULL) { if ($error !== NULL && $error !== '') { $this->view->assign('internalError', $error); } @@ -121,11 +123,10 @@ class JoblistController extends ActionController { } $this->view->assign('folderName', $folderName); - $jobId = $this->request->getArguments()['uid']; $jobData = NULL; - if (!empty($jobId)) { + if (!$uid !== NULL) { /** @var Job $jobData */ - $jobData = $this->jobRepository->findByUid($jobId); + $jobData = $this->jobRepository->findByUid($uid); $this->view->assign('job', $jobData); } @@ -195,7 +196,7 @@ class JoblistController extends ActionController { $resourceFactory = $this->objectManager->get(ResourceFactory::class); $newName = date('Ymd-His') . '_' . $applicationData->getFirstName(); $storage = $resourceFactory->getStorageObject(1); - $applicationFilePath = str_replace('/', '', $storage->getConfiguration()['basePath']) . $folderName . + $applicationFilePath = PATH_site . $storage->getConfiguration()['basePath'] . 'JobApplication/' . $folderName . '/' . $newName . '.csv'; $this->writeApplicationFile($applicationData, $applicationFilePath); } @@ -244,14 +245,13 @@ class JoblistController extends ActionController { $mailService->sendEmail(); - // redirect to the given page id from the flexform - $redirectPageId = (int) $this->configurationManager->getConfiguration( - ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK - )['settings']['redirectPage']; + $redirectPageUid = (int) $this->settings['redirectPage']; + if ($redirectPageUid) { + $url = $this->configurationManager->getContentObject()->getTypoLink_URL($redirectPageUid); + $this->redirectToUri($url); + } - $uriBuilder = $this->uriBuilder; - $uri = $uriBuilder->reset()->setTargetPageUid($redirectPageId)->build(); - $this->redirectToUri($uri); + $this->redirect('applyForm'); } catch (\Exception $exception) { $this->forward('applyForm', NULL, NULL, ['applyData' => $applyData, 'error' => $exception->getMessage()]); diff --git a/Classes/Domain/Model/JobApplication.php b/Classes/Domain/Model/JobApplication.php index 8518046014b5ce896129e93600d3b72fc8dbeea5..a4a624bd945c2ea634e1b47a65d6b51b0f1bbb52 100644 --- a/Classes/Domain/Model/JobApplication.php +++ b/Classes/Domain/Model/JobApplication.php @@ -37,7 +37,6 @@ class JobApplication extends AbstractEntity { * An internal id for external purposes * * @var string $jobId - * @validate NotEmpty */ protected $jobId = ''; @@ -45,7 +44,7 @@ class JobApplication extends AbstractEntity { * @var string $gender * @validate NotEmpty */ - protected $gender = ''; + protected $gender = 0; /** * @var string $firstName diff --git a/Configuration/TypoScript/Common/setup.txt b/Configuration/TypoScript/Common/setup.txt new file mode 100644 index 0000000000000000000000000000000000000000..dbe4f43461b2e4fdea8b52eec443e6c4a94afd58 --- /dev/null +++ b/Configuration/TypoScript/Common/setup.txt @@ -0,0 +1,11 @@ +config.tx_extbase { + persistence { + classes { + SGalinski\SgJobs\Domain\Model\JobApplication { + mapping { + tableName = tx_sgjobs_domain_model_job_application + } + } + } + } +} diff --git a/Resources/Private/Templates/Joblist/ApplyForm.html b/Resources/Private/Templates/Joblist/ApplyForm.html index 098f06f549af8d07722713d4fe997e1b9862ba67..a92f9324ecf8ebfd92a9bc01def28fe3cc57e6d2 100644 --- a/Resources/Private/Templates/Joblist/ApplyForm.html +++ b/Resources/Private/Templates/Joblist/ApplyForm.html @@ -4,7 +4,25 @@ <f:section name="main"> <f:form action="apply" controller="Joblist" method="post" name="applyData" object="{applyData}" enctype="multipart/form-data"> - <f:form.hidden name="folderName" value="{folderName}" /> + <input type="hidden" name="tx_sgjobs_jobapplication[folderName]" value="{folderName}" /> + + <f:comment><!-- To output all validation errors + <f:form.validationResults> + <f:if condition="{validationResults.flattenedErrors}"> + <ul class="errors"> + <f:for each="{validationResults.flattenedErrors}" as="errors" key="propertyPath"> + <li>{propertyPath} + <ul> + <f:for each="{errors}" as="error"> + <li>{error.code}: {error}</li> + </f:for> + </ul> + </li> + </f:for> + </ul> + </f:if> + </f:form.validationResults> + --></f:comment> <f:if condition="{internalError}"> <div class="errormessage"> @@ -14,7 +32,8 @@ <f:if condition="{job}"> <p> - <f:form.hidden value="{applyData.jobId}" property="jobId" /> + <input type="hidden" name="tx_sgjobs_jobapplication[applyData][jobId]" value="{job.jobId}" /> + <input type="hidden" name="tx_sgjobs_jobapplication[applyData][jobTitle]" value="{job.title}" /> <label for="apply-title"><f:translate key="frontend.apply.title" /></label> <span id="apply-title">{job.title}</span> </p> diff --git a/Resources/Private/Templates/SgMail/ApplicationMail/template.html b/Resources/Private/Templates/SgMail/ApplicationMail/template.html index bfdad9ec42e859278f5627bf05e1f385da3c20f9..e11335978be091d4b3f9295db44f13d556ae1d8c 100644 --- a/Resources/Private/Templates/SgMail/ApplicationMail/template.html +++ b/Resources/Private/Templates/SgMail/ApplicationMail/template.html @@ -20,4 +20,4 @@ Mobil: {application.mobile} E-Mail Adresse: {application.email} -Nachricht: {application.message} \ No newline at end of file +Nachricht: {application.message} diff --git a/ext_localconf.php b/ext_localconf.php index b2b1f99c24eba8248d50c4a4182558775aa05770..adc9537d9c2a56700dd3f350478a3aa2e408599b 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -1,5 +1,11 @@ <?php +$extPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('sg_jobs'); + +// common typoscript configuration +$tsPath = $extPath . 'Configuration/TypoScript/Common/'; +\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScriptSetup(file_get_contents($tsPath . 'setup.txt')); + // Configure frontend plugins \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( 'SGalinski.sg_jobs', @@ -34,7 +40,6 @@ ); if (TYPO3_MODE === 'BE') { - $extPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('sg_jobs'); $tsPath = $extPath . 'Configuration/TypoScript/Backend/'; \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScriptConstants(