<?php namespace SGalinski\SgJobs\Controller\Ajax; /*************************************************************** * Copyright notice * * (c) sgalinski Internet Services (https://www.sgalinski.de) * * All rights reserved * * This script is part of the TYPO3 project. The TYPO3 project is * free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * The GNU General Public License can be found at * http://www.gnu.org/copyleft/gpl.html. * * This script is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ use SGalinski\SgAjax\Controller\Ajax\AbstractAjaxController; use SGalinski\SgJobs\Domain\Repository\JobRepository; use SGalinski\SgJobs\Service\BackendService; use SGalinski\SgJobs\Service\FrontendFilterService; use TYPO3\CMS\Core\Resource\ResourceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; /** * Ajax Controller */ class JoblistController extends AbstractAjaxController { /** * @var \SGalinski\SgJobs\Domain\Repository\CompanyRepository * @inject */ private $companyRepository; /** * Show all job offers and options to manage them * * @return void * @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException * @throws \InvalidArgumentException */ public function filterAction() { $siteRootId = BackendService::getRootUidByPageUid($GLOBALS['TSFE']->id); $filters = [ 'country' => $_POST['parameters']['country'], 'location' => $_POST['parameters']['location'], 'company' => $_POST['parameters']['company'], 'area' => $_POST['parameters']['area'], 'function' => $_POST['parameters']['function'], ]; // get all correct filter options, based on the selection $this->view->assign('cities', FrontendFilterService::getLocations($filters, $siteRootId)); $this->view->assign('companies', FrontendFilterService::getCompanies($filters, $siteRootId)); $this->view->assign('areas', FrontendFilterService::getAreas($filters, $siteRootId)); $this->view->assign('functions', FrontendFilterService::getFunctions($filters, $siteRootId)); $this->view->assign('countries', $this->companyRepository->getAllCountries($siteRootId)); // set all filtered jobs $this->view->assign('jobs', FrontendFilterService::getJobs($filters,$siteRootId)); // set default selected values $this->view->assign('selectedCountry', $filters['country']); $this->view->assign('selectedCompany', $filters['company']); $this->view->assign('selectedLocation', $filters['location']); $this->view->assign('selectedArea', $filters['area']); $this->view->assign('selectedFunction', $filters['function']); } /** * Delete an uploaded file from temp storage * * @return void */ public function deleteTempFileAction() { $file = $_POST['file']; $type = $_POST['type']; $resourceFactory = GeneralUtility::makeInstance( ResourceFactory::class ); $storage = $resourceFactory->getStorageObject(1); $fileObject = $storage->getFile('/Applications/temp/' . $GLOBALS['TSFE']->fe_user->id . '/' . $type . '/' . $file); $storage->deleteFile($fileObject); } }