Skip to content
Snippets Groups Projects
Commit c58ee806 authored by Kevin von Spiczak's avatar Kevin von Spiczak
Browse files

[TASK] merge origin/master

parents bf329c12 c12be331
No related branches found
No related tags found
1 merge request!27[FEATURE] save filters in session
Showing
with 825 additions and 348 deletions
......@@ -87,76 +87,70 @@ class BackendController extends ActionController {
* @return void
*/
public function indexAction(array $filters = []): void {
try {
$pageUid = (int) GeneralUtility::_GP('id');
/** @var BackendUserAuthentication $backendUser */
$backendUser = $GLOBALS['BE_USER'];
if ($filters === []) {
$filters = $backendUser->getModuleData('tools_beuser/index.php/web_SgJobsBackend_filters', 'ses') ?: [];
} else {
$backendUser->pushModuleData('tools_beuser/index.php/web_SgJobsBackend_filters', $filters);
}
// create docheader + buttons
$pageInfo = BackendUtility::readPageAccess($pageUid, $GLOBALS['BE_USER']->getPagePermsClause(1));
if ($pageInfo === FALSE) {
$pageInfo = ['uid' => $pageUid];
}
$this->docHeaderComponent = GeneralUtility::makeInstance(DocHeaderComponent::class);
$this->docHeaderComponent->setMetaInformation($pageInfo);
BackendService::makeButtons($this->docHeaderComponent, $this->request);
$this->view->assign('docHeader', $this->docHeaderComponent->docHeaderContent());
// get all jobs
/** @var ObjectStorage $jobs */
$jobs = $this->jobRepository->findBackendJobs($pageUid, $filters);
$totalJobCount = \count($jobs);
$this->view->assign('pages', BackendService::getPagesWithJobRecords());
$this->view->assign('pageUid', $pageUid);
$sortingData = [];
if ($GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['sg_jobs']['allowManualSorting'] && count($filters) <= 0) {
/**
*
* Somehow the pId is changed so data gets lost.
*
*
* $previousUid = 0;
* $sortingData = [];
* foreach ($jobs as $job) {
* if ($previousUid) {
* $sortingData['prev'][$job->getUid()] = $previousUid;
* $sortingData['next'][$previousUid] = $job->getUid();
* }
* $previousUid = $job->getUid();
* }
*/
$this->view->assign('manualSortingDestroysEverything', TRUE);
}
$this->view->assign('sortingData', $sortingData);
// get all Locations
/** @noinspection PhpUndefinedMethodInspection */
/** @var QueryResultInterface $companies */
$companies = $this->companyRepository->findByPid($pageUid);
$this->view->assign('locationOptions', $companies);
if ($totalJobCount || $companies->count()) {
$this->view->assign('jobs', $jobs);
$this->view->assign('filters', $filters);
} else {
$this->view->assign('noRecords', 1);
$this->view->assign('isAdmin', $GLOBALS['BE_USER']->isAdmin());
$this->addFlashMessage(
LocalizationUtility::translate('backend.notice.noRecords', 'SgJobs'), '', FlashMessage::INFO
);
}
} catch (\Exception $exception) {
// check for NULL value in view and render an error message
$this->view->assign('docHeader', NULL);
$pageUid = (int) GeneralUtility::_GP('id');
/** @var BackendUserAuthentication $backendUser */
$backendUser = $GLOBALS['BE_USER'];
if ($filters === []) {
$filters = $backendUser->getModuleData('tools_beuser/index.php/web_SgJobsBackend_filters', 'ses') ?: [];
} else {
$backendUser->pushModuleData('tools_beuser/index.php/web_SgJobsBackend_filters', $filters);
}
// create docheader + buttons
$pageInfo = BackendUtility::readPageAccess($pageUid, $GLOBALS['BE_USER']->getPagePermsClause(1));
if ($pageInfo === FALSE) {
$pageInfo = ['uid' => $pageUid];
}
$this->docHeaderComponent = GeneralUtility::makeInstance(DocHeaderComponent::class);
$this->docHeaderComponent->setMetaInformation($pageInfo);
BackendService::makeButtons($this->docHeaderComponent, $this->request);
$this->view->assign('docHeader', $this->docHeaderComponent->docHeaderContent());
$this->view->assign('pageUid', $pageUid);
$this->view->assign('pages', BackendService::getPagesWithJobRecords());
$sortingData = [];
if ($GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['sg_jobs']['allowManualSorting'] && count($filters) <= 0) {
/**
* Somehow the pId is changed so data gets lost.
*
*
* $previousUid = 0;
* $sortingData = [];
* foreach ($jobs as $job) {
* if ($previousUid) {
* $sortingData['prev'][$job->getUid()] = $previousUid;
* $sortingData['next'][$previousUid] = $job->getUid();
* }
* $previousUid = $job->getUid();
* }
*/
$this->view->assign('manualSortingDestroysEverything', TRUE);
}
$this->view->assign('sortingData', $sortingData);
/** @var ObjectStorage $jobs */
$jobs = $this->jobRepository->findBackendJobs($pageUid, $filters);
$totalJobCount = \count($jobs);
// get all Locations
/** @noinspection PhpUndefinedMethodInspection */
/** @var QueryResultInterface $companies */
$companies = $this->companyRepository->findByPid($pageUid);
$this->view->assign('locationOptions', $companies);
$this->view->assign('isAdmin', $GLOBALS['BE_USER']->isAdmin());
$this->view->assign('filters', $filters);
$this->view->assign('jobs', $jobs);
if (!$totalJobCount && $pageUid) {
// clear previously set filters again,
// without this, the user would be stuck without filters and just the flash message
$backendUser->pushModuleData('tools_beuser/index.php/web_SgJobsBackend_filters', []);
$this->addFlashMessage(
LocalizationUtility::translate('backend.notice.noRecords', 'SgJobs'), '', FlashMessage::INFO
);
}
}
}
......@@ -37,7 +37,14 @@ class JobTeaserController extends ActionController {
/**
* @var JobRepository
*/
private $jobRepository;
protected $jobRepository;
/**
* @param JobRepository $jobRepository
*/
public function injectJobRepository(JobRepository $jobRepository) {
$this->jobRepository = $jobRepository;
}
/**
* Get marked offers and display them
......@@ -47,7 +54,7 @@ class JobTeaserController extends ActionController {
*/
public function indexAction(): void {
$allowedLocations = [];
if (!empty($this->settings['locations'])) {
if ($this->settings['locations'] !== '') {
$allowedLocations = GeneralUtility::trimExplode(',', $this->settings['locations']);
}
$totalAmountOfOffers = $this->jobRepository->countAll($allowedLocations);
......@@ -58,14 +65,7 @@ class JobTeaserController extends ActionController {
$featuredOffers = $this->jobRepository->findByFeaturedOffer($allowedLocations);
$this->view->assign('totalAmountOfOffers', $totalAmountOfOffers);
$this->view->assign('filteredLocations', !empty($allowedLocations));
$this->view->assign('filteredLocations', (bool) count($allowedLocations));
$this->view->assign('featuredOffers', $featuredOffers);
}
/**
* @param JobRepository $jobRepository
*/
public function injectJobRepository(JobRepository $jobRepository) {
$this->jobRepository = $jobRepository;
}
}
......@@ -36,15 +36,20 @@ use SGalinski\SgJobs\Domain\Repository\JobApplicationRepository;
use SGalinski\SgJobs\Domain\Repository\JobRepository;
use SGalinski\SgJobs\Property\TypeConverter\UploadedFileReferenceConverter;
use SGalinski\SgMail\Service\MailTemplateService;
use SGalinski\SgSeo\Service\HeadTagService;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Http\ImmediateResponseException;
use TYPO3\CMS\Core\Resource\ResourceFactory;
use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
use TYPO3\CMS\Frontend\Controller\ErrorController;
use TYPO3\CMS\Frontend\Page\PageAccessFailureReasons;
/**
* The joblist plugin controller
......@@ -123,15 +128,31 @@ class JoblistController extends ActionController {
$this->jobRepository = $jobRepository;
}
/**
* Initialize the indexAction to set the currentPageBrowserPage parameter
*
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentNameException
*/
public function initializeIndexAction() {
$currentPageBrowserPage = (int) GeneralUtility::_GP('tx_sgjobs_pagebrowser')['currentPage'];
if ($currentPageBrowserPage > 0) {
$this->request->setArgument('currentPageBrowserPage', $currentPageBrowserPage);
}
}
/**
* Show all job offers and options to manage them
*
* @param array $filters
* @param int $jobId
* @param int $currentPageBrowserPage
* @return void
* @throws \InvalidArgumentException
* @throws \TYPO3\CMS\Core\Context\Exception\AspectNotFoundException
* @throws \TYPO3\CMS\Core\Error\Http\PageNotFoundException
* @throws ImmediateResponseException
* @throws \TYPO3\CMS\Core\Package\Exception
*/
public function indexAction(array $filters = [], $jobId = NULL): void {
public function indexAction(array $filters = [], int $jobId = NULL, int $currentPageBrowserPage = 0): void {
if ($filters) {
$this->view->assign('selectedCountry', $filters['filterCountry']);
$this->view->assign('selectedCompany', $filters['filterCompany']);
......@@ -157,17 +178,27 @@ class JoblistController extends ActionController {
throw new \InvalidArgumentException('Given Job Id is invalid!');
}
$GLOBALS['TSFE']->page['titlebyextension'] = $job->getTitle();
$GLOBALS['TSFE']->page['description'] = \strip_tags(\substr($job->getDescription(), 0, 200));
$GLOBALS['TSFE']->page['extensionArgumentsForCanonicalAndHrefLang'] =
'&tx_sgjobs_jobapplication[jobId]=' . $jobId;
if (version_compare(ExtensionManagementUtility::getExtensionVersion('sg_seo'), '5.0.0', '>=')) {
$headTagService = GeneralUtility::makeInstance(
HeadTagService::class,
TRUE,
$job->getTitle(),
$job->getDescription(),
'&tx_sgjobs_jobapplication[jobId]=' . $jobId
);
$headTagService->execute();
} else {
$GLOBALS['TSFE']->page['titlebyextension'] = $job->getTitle();
$GLOBALS['TSFE']->page['description'] = \strip_tags(\substr($job->getDescription(), 0, 200));
$GLOBALS['TSFE']->page['extensionArgumentsForCanonicalAndHrefLang'] =
'&tx_sgjobs_jobapplication[jobId]=' . $jobId;
}
$jobs = [$job];
$numberOfPages = 1;
} else {
// pagination logic
$offset = 0;
$currentPageBrowserPage = (int) GeneralUtility::_GP('tx_sgjobs_pagebrowser')['currentPage'];
if ($currentPageBrowserPage && $jobLimit) {
$offset = $currentPageBrowserPage * $jobLimit;
}
......@@ -192,7 +223,17 @@ class JoblistController extends ActionController {
// get all jobs for the current page
$allJobs = $this->jobRepository->findJobsByFilter($filters)->toArray();
$numberOfPages = ($jobLimit <= 0 ? 0 : \ceil(\count($allJobs) / $jobLimit));
$numberOfPages = (int) ($jobLimit <= 0 ? 0 : \ceil(\count($allJobs) / $jobLimit));
if ($numberOfPages !== 0 && $currentPageBrowserPage >= $numberOfPages) {
/** @var ErrorController $errorController */
$errorController = GeneralUtility::makeInstance(ErrorController::class);
$response = $errorController->pageNotFoundAction(
$GLOBALS['TYPO3_REQUEST'],
'The requested page does not exist',
['code' => PageAccessFailureReasons::PAGE_NOT_FOUND]
);
throw new ImmediateResponseException($response);
}
}
$this->view->assign('jobs', $jobs);
......@@ -203,16 +244,15 @@ class JoblistController extends ActionController {
/**
* Renders the application form with an optional job
*
* @param JobApplication $applyData
* @param JobApplication|null $applyData
* @param string $error
* @param int $jobId
* @throws \TYPO3\CMS\Core\Context\Exception\AspectNotFoundException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentNameException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException
* @throws \TYPO3\CMS\Core\Context\Exception\AspectNotFoundException
*/
public function applyFormAction(JobApplication $applyData = NULL, $error = NULL, $jobId = NULL): void {
if ($error !== NULL && $error !== '') {
public function applyFormAction(JobApplication $applyData = NULL, string $error = '', int $jobId = NULL): void {
if ($error !== '') {
$this->view->assign('internalError', $error);
$this->request->setArgument('error', NULL);
}
......@@ -244,10 +284,21 @@ class JoblistController extends ActionController {
/** @var Job $job */
$job = $this->jobRepository->findByUid($jobId);
if ($job) {
$GLOBALS['TSFE']->page['titlebyextension'] = $job->getTitle();
$GLOBALS['TSFE']->page['description'] = \strip_tags(\substr($job->getDescription(), 0, 200));
$GLOBALS['TSFE']->page['extensionArgumentsForCanonicalAndHrefLang'] =
'&tx_sgjobs_jobapplication[jobId]=' . $jobId;
if (version_compare(ExtensionManagementUtility::getExtensionVersion('sg_seo'), '5.0.0', '>=')) {
$headTagService = GeneralUtility::makeInstance(
HeadTagService::class,
FALSE,
$job->getTitle(),
$job->getDescription(),
'&tx_sgjobs_jobapplication[jobId]=' . $jobId
);
$headTagService->execute();
} else {
$GLOBALS['TSFE']->page['titlebyextension'] = $job->getTitle();
$GLOBALS['TSFE']->page['description'] = \strip_tags(\substr($job->getDescription(), 0, 200));
$GLOBALS['TSFE']->page['extensionArgumentsForCanonicalAndHrefLang'] =
'&tx_sgjobs_jobapplication[jobId]=' . $jobId;
}
}
$this->view->assign('job', $job);
} else {
......@@ -263,8 +314,11 @@ class JoblistController extends ActionController {
$site = GeneralUtility::makeInstance(SiteFinder::class)
->getSiteByPageId($GLOBALS['TSFE']->id)
->getLanguageById($sysLanguageUid);
$countryRepository = $this->objectManager->get(CountryRepository::class);
$countries = $countryRepository->findAllOrderedByLanguage($site->getTwoLetterIsoCode());
$countries = [];
if (ExtensionManagementUtility::isLoaded('project_base')) {
$countryRepository = $this->objectManager->get(CountryRepository::class);
$countries = $countryRepository->findAllOrderedByLanguage($site->getTwoLetterIsoCode());
}
$this->view->assign('countries', $countries);
$this->view->assign('sysLanguageUid', $sysLanguageUid);
......@@ -302,7 +356,6 @@ class JoblistController extends ActionController {
* @return void
* @throws NoSuchArgumentException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException
*/
protected function initializeApplyAction(): void {
try {
......@@ -333,17 +386,14 @@ class JoblistController extends ActionController {
* @param string $folderName
* @return void
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
* @throws \RuntimeException
* @throws \InvalidArgumentException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException
* @throws \TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException
*/
protected function submitApplicationFiles(JobApplication $applicationData, $folderName): void {
$resourceFactory = $this->objectManager->get(ResourceFactory::class);
$newName = \date('Ymd-His') . '_' . $applicationData->getJobId() . '-' . $applicationData->getFirstName()
. '-' . $applicationData->getLastName();
$storage = $resourceFactory->getStorageObject(1);
$applicationFilePath = Environment::getPublicPath() . '/' . $storage->getConfiguration()['basePath'] . 'JobApplication/' . $folderName .
$applicationFilePath = Environment::getPublicPath() . '/' . $storage->getConfiguration(
)['basePath'] . 'JobApplication/' . $folderName .
'/' . $newName . '.csv';
$this->writeApplicationFile($applicationData, $applicationFilePath);
}
......@@ -363,9 +413,7 @@ class JoblistController extends ActionController {
$applyData->setPid($GLOBALS['TSFE']->id);
$job = $applyData->getJob();
// look for a configured default job, in case of unsolicited application
if (($job === '' || $job === NULL || $applyData->getJobId() === NULL)
&& $applyData->getCompany() !== NULL
) {
if ((!$job || $applyData->getJobId() === NULL) && $applyData->getCompany() !== NULL) {
$applyData->setJobId($applyData->getCompany()->getJobId());
}
......@@ -378,7 +426,6 @@ class JoblistController extends ActionController {
$this->moveTmpFolder($folderName);
$this->submitApplicationFiles($applyData, $folderName);
/** @noinspection PhpMethodParametersCountMismatchInspection */
$mailService = $this->objectManager->get(
MailTemplateService::class, 'application_mail', 'sg_jobs',
$this->getApplicationMailMarkers($applyData)
......@@ -426,8 +473,11 @@ class JoblistController extends ActionController {
$redirectPageUid = (int) $this->settings['redirectPage'];
if ($redirectPageUid) {
$url = $this->configurationManager->getContentObject()->getTypoLink_URL($redirectPageUid);
$this->redirectToUri($url);
$contentObject = $this->configurationManager->getContentObject();
if ($contentObject) {
$url = $contentObject->getTypoLink_URL($redirectPageUid);
$this->redirectToUri($url);
}
}
$this->redirect('applyForm');
......@@ -448,7 +498,7 @@ class JoblistController extends ActionController {
* Assign filter values
*
* @param int $rootPageId
* @throws \InvalidArgumentException
* @throws \TYPO3\CMS\Core\Context\Exception\AspectNotFoundException
*/
protected function assignFilterValues($rootPageId): void {
$countries = $this->companyRepository->getAllCountries($rootPageId);
......@@ -473,7 +523,7 @@ class JoblistController extends ActionController {
* @param JobApplication $applyData
* @return array
*/
protected function getApplicationMailMarkers($applyData): array {
protected function getApplicationMailMarkers(JobApplication $applyData): array {
$location = '';
if ($applyData->getCompany() !== NULL) {
$location = $applyData->getCompany()->getCity();
......@@ -499,13 +549,36 @@ class JoblistController extends ActionController {
*
* @param JobApplication $data
* @param string $filePath
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
* @throws \InvalidArgumentException
* @throws \RuntimeException
* @throws \TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException
*/
protected function writeApplicationFile(JobApplication $data, $filePath): void {
$coverLetter = '';
$coverLetterObject = $data->getCoverLetter();
if ($coverLetterObject) {
$coverLetterObject = $coverLetterObject->getOriginalResource();
if ($coverLetterObject) {
$coverLetter = $coverLetterObject->getPublicUrl();
}
}
$cv = '';
$cvObject = $data->getCv();
if ($cvObject) {
$cvObject = $cvObject->getOriginalResource();
if ($cvObject) {
$cv = $cvObject->getPublicUrl();
}
}
$certificate = '';
$certificateObject = $data->getCertificate();
if ($certificateObject) {
$certificateObject = $certificateObject->getOriginalResource();
if ($certificateObject) {
$certificate = $certificateObject->getPublicUrl();
}
}
$dataToInsertArr = [
$data->getJobId(),
$data->getFirstName(),
......@@ -520,9 +593,9 @@ class JoblistController extends ActionController {
$data->getNationality(),
$data->getPhone(),
$data->getEmail(),
$data->getCoverLetter() === NULL ? '' : $data->getCoverLetter()->getOriginalResource()->getPublicUrl(),
$data->getCv() === NULL ? '' : $data->getCv()->getOriginalResource()->getPublicUrl(),
$data->getCertificate() === NULL ? '' : $data->getCertificate()->getOriginalResource()->getPublicUrl(),
$coverLetter,
$cv,
$certificate,
$data->getMessage()
];
......@@ -583,7 +656,7 @@ class JoblistController extends ActionController {
/**
* If for any reason something goes wrong, delete the tmp upload folder
*
* @return string|void
* @return void
* @throws NoSuchArgumentException
*/
public function errorAction() {
......
<?php
namespace SGalinski\SgJobs\Controller;
/***************************************************************
* 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 TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
/**
* Controller that handles the page browser.
*/
class PageBrowserController extends ActionController {
/**
* @var string
*/
protected $pageParameterName = '';
/**
* @var int
*/
protected $numberOfPages = 0;
/**
* @var int
*/
protected $currentPage = 0;
/**
* @var int
*/
protected $pagesBefore = 0;
/**
* @var int
*/
protected $pagesAfter = 0;
/**
* @var bool
*/
protected $enableMorePages = FALSE;
/**
* @var bool
*/
protected $enableLessPages = FALSE;
/**
* Renders the index view.
*
* @param int $currentPage
* @return void
*/
public function indexAction($currentPage = 0): void {
$this->currentPage = (int) $currentPage;
$this->initializeConfiguration();
$this->addDataToView();
}
/**
* Initializes the configuration.
*
* @return void
*/
protected function initializeConfiguration(): void {
$this->pageParameterName = 'tx_sgjobs_pagebrowser[currentPage]';
$this->numberOfPages = (int) $this->settings['numberOfPages'];
$this->pagesBefore = (int) $this->settings['pagesBefore'];
$this->pagesAfter = (int) $this->settings['pagesAfter'];
$this->enableMorePages = (bool) $this->settings['enableMorePages'];
$this->enableLessPages = (bool) $this->settings['enableLessPages'];
}
/**
* Adds the necessary data to the view.
*
* @return void
*/
protected function addDataToView(): void {
if ($this->numberOfPages <= 1) {
$this->view = NULL;
return;
}
$pageLinks = [];
$start = max($this->currentPage - $this->pagesBefore, 0);
$end = min($this->numberOfPages, $this->currentPage + $this->pagesAfter + 1);
for ($i = $start; $i < $end; $i++) {
$pageLinks[] = [
'number' => $i + 1,
'link' => $this->getPageLink($i),
'isCurrentPage' => $i === $this->currentPage,
];
}
$this->view->assignMultiple(
[
'enableLessPages' => $this->enableLessPages,
'enableMorePages' => $this->enableMorePages,
'previousLink' => $this->getPageLink($this->currentPage - 1),
'nextLink' => $this->getPageLink($this->currentPage + 1),
'enableLessPagesLink' => $this->getPageLink($this->currentPage - $this->pagesBefore - 1),
'enableMorePagesLink' => $this->getPageLink($this->currentPage + $this->pagesAfter + 1),
'pageLinks' => $pageLinks,
'prevPageExist' => $this->currentPage > 0,
'showLessPages' => ($this->currentPage - $this->pagesBefore) > 0,
'showNextPages' => ($this->currentPage + $this->pagesAfter + 1) < $this->numberOfPages,
'nextPageExist' => $this->currentPage < ($this->numberOfPages - 1),
]
);
}
/**
* Generates page link. Keeps all current URL parameters except for cHash and tx_pagebrowse_pi1[page].
*
* @param int $page Page number starting from 1
* @return string
*/
protected function getPageLink($page): string {
return $this->uriBuilder->reset()->setAddQueryString(TRUE)
->uriFor('index', ['currentPage' => $page,]);
}
}
......@@ -34,13 +34,6 @@ use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
* The Job model
*/
class Job extends AbstractEntity {
/**
* Job constructor.
*/
public function __construct() {
$this->attachment = new ObjectStorage();
}
/**
* @var string $title
*/
......@@ -102,6 +95,11 @@ class Job extends AbstractEntity {
*/
protected $startDate = 0;
/**
* @var string $location
*/
protected $location = '';
/**
* @var int $sorting
*/
......@@ -167,6 +165,16 @@ class Job extends AbstractEntity {
*/
protected $maxSalary = '';
/** @var string */
protected $applyExternalLink = '';
/**
* Job constructor.
*/
public function __construct() {
$this->attachment = new ObjectStorage();
}
/**
* @return string
*/
......@@ -339,6 +347,20 @@ class Job extends AbstractEntity {
$this->alternativeStartDate = $alternativeStartDate;
}
/**
* @return string
*/
public function getLocation() {
return $this->location;
}
/**
* @param string $location
*/
public function setLocation(string $location) {
$this->location = $location;
}
/**
* @return bool
*/
......@@ -520,4 +542,18 @@ class Job extends AbstractEntity {
public function setMaxSalary(string $maxSalary): void {
$this->maxSalary = $maxSalary;
}
/**
* @return string
*/
public function getApplyExternalLink() {
return $this->applyExternalLink;
}
/**
* @param string $applyExternalLink
*/
public function setApplyExternalLink(string $applyExternalLink) {
$this->applyExternalLink = $applyExternalLink;
}
}
......@@ -26,7 +26,6 @@ namespace SGalinski\SgJobs\Domain\Repository;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings;
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
......@@ -49,7 +48,6 @@ class JobRepository extends Repository {
public function __construct(ObjectManagerInterface $objectManager) {
parent::__construct($objectManager);
// Appearently some of the extbase classes still need the objectManager
$querySettings = $objectManager->get(Typo3QuerySettings::class);
$querySettings->setRespectStoragePage(TRUE);
$this->setDefaultQuerySettings($querySettings);
......@@ -77,7 +75,7 @@ class JobRepository extends Repository {
* @param int $limit
* @param int $offset
* @return mixed
* @throws \InvalidArgumentException
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
*/
public function findBackendJobs($recordPageId, array $filters = [], $limit = 0, $offset = 0) {
$query = $this->createQuery();
......@@ -111,7 +109,7 @@ class JobRepository extends Repository {
return $query->matching($query->logicalAnd($constraints))->execute();
}
if(\count($constraints) > 0) {
if (\count($constraints) > 0) {
return $query->matching($constraints[0])->execute();
}
......@@ -146,7 +144,7 @@ class JobRepository extends Repository {
$constraints = [];
if ($jobIds !== NULL && \is_array($jobIds) && \count($jobIds)) {
if (\is_array($jobIds) && \count($jobIds)) {
$companyConstraints = [];
foreach ($jobIds as $jobId) {
if ($jobId) {
......@@ -261,7 +259,6 @@ class JobRepository extends Repository {
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
*/
public function countAll(array $companies = []): int {
/** @var QueryInterface $query */
$query = $this->createQuery();
$constraints = [];
......@@ -284,32 +281,30 @@ class JobRepository extends Repository {
* Gets the featured jobs filtered by companies
*
* @param array $companies
* @return mixed
* @param int $limit
* @return array|ExtbaseQueryResultInterface
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
*/
public function findByFeaturedOffer(array $companies = []) {
/** @var QueryInterface $query */
public function findByFeaturedOffer(array $companies = [], int $limit = 3) {
$query = $this->createQuery();
$constraints = [];
$storagePageIds = $query->getQuerySettings()->getStoragePageIds();
if (empty($storagePageIds)) {
if (count($storagePageIds) <= 0) {
// if no record storage page has been selected in the plugin, ignore it
$query->getQuerySettings()->setRespectStoragePage(FALSE);
}
if (\count($companies) !== 0) {
$constraints[] = $query->in('company', $companies);
$query->setOrderings(
[
'featured_offer' => QueryInterface::ORDER_DESCENDING
]
);
$query->setLimit(3);
} else {
$constraints[] = $query->equals('featured_offer', TRUE);
if (\count($companies)) {
$query->matching($query->in('company', $companies));
}
return $query->matching($query->logicalAnd($constraints))->execute();
$query->setOrderings(
[
'featured_offer' => QueryInterface::ORDER_DESCENDING
]
);
$query->setLimit($limit);
return $query->execute();
}
}
......@@ -31,7 +31,10 @@ class AccessPageListEventListener {
*/
public function __invoke(AccessPageListEvent $event) {
$pageList = $event->getPageList();
$additionalPageList = $this->sitemapService->generatePagesList($event->getSysLanguageUid());
$additionalPageList = $this->sitemapService->generatePagesList(
$event->getSysLanguageUid(), $event->getSite()->getRootPageId()
);
ArrayUtility::mergeRecursiveWithOverrule($pageList, $additionalPageList);
$event->setPageList($pageList);
}
......
......@@ -3,6 +3,7 @@
namespace SGalinski\SgJobs\Service;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Context\LanguageAspect;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use SgJobsPageRepository;
......@@ -28,15 +29,19 @@ class SitemapService {
* Generate a pageList array for the sitemap generation
*
* @param int $sysLanguageUid
* @param int $rootPageId
* @return array
* @throws \TYPO3\CMS\Core\Context\Exception\AspectNotFoundException
*/
public function generatePagesList(int $sysLanguageUid): array {
public function generatePagesList(int $sysLanguageUid, int $rootPageId = 0): array {
$pageList = [];
// find sites where job detail plugin is added
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tt_content');
$databaseResource = $queryBuilder->select('pid', 'pages')
$databaseResource = $queryBuilder->select('tt_content.pid', 'pages', 'tt_content.tstamp')
->from('tt_content')
->innerJoin('tt_content', 'pages', 'pages', 'pages.uid = tt_content.pid
AND pages.no_search = 0')
->where(
$queryBuilder->expr()->andX(
$queryBuilder->expr()->eq('CType', $queryBuilder->createNamedParameter('list')),
......@@ -45,9 +50,9 @@ class SitemapService {
$queryBuilder->createNamedParameter(self::PLUGIN_NAME)
),
$queryBuilder->expr()->orX(
$queryBuilder->expr()->eq('sys_language_uid', -1),
$queryBuilder->expr()->eq('tt_content.sys_language_uid', -1),
$queryBuilder->expr()->eq(
'sys_language_uid',
'tt_content.sys_language_uid',
$queryBuilder->createNamedParameter($sysLanguageUid, Connection::PARAM_INT)
)
)
......@@ -55,11 +60,13 @@ class SitemapService {
)
->execute();
$rows = $databaseResource->fetchAll();
$context = GeneralUtility::makeInstance(Context::class);
foreach ($rows as $row) {
while ($row = $databaseResource->fetch()) {
try {
$site = GeneralUtility::makeInstance(SiteFinder::class)->getSiteByPageId($row['pid']);
if ($rootPageId > 0 && $site->getRootPageId() !== $rootPageId) {
continue;
}
$jobs = $this->getJobsByPid($row['pages'], $sysLanguageUid);
foreach ($jobs as $job) {
$url = $site->getRouter($context)->generateUri(
......@@ -73,7 +80,8 @@ class SitemapService {
);
$pageList[] = [
'url' => htmlspecialchars($url),
'title' => ''
'title' => '',
'SYS_LASTCHANGED' => $row['tstamp'],
];
}
} catch (SiteNotFoundException $exception) {
......@@ -107,6 +115,8 @@ class SitemapService {
$rows = $databaseResource->fetchAll();
$pageRepository = GeneralUtility::makeInstance(SgJobsPageRepository::class);
$isLanguageVisibilityLoaded = ExtensionManagementUtility::isLoaded('languagevisibility');
$languageAspect = GeneralUtility::makeInstance(Context::class)->getAspect('language');
$overlayType = $languageAspect->getLegacyOverlayType();
foreach ($rows as $row) {
$table = 'tx_sgjobs_domain_model_job';
......@@ -127,7 +137,11 @@ class SitemapService {
}
if ($languageId > 0) {
$row = $pageRepository->getRecordOverlay($table, $row, $languageId);
/** @var LanguageAspect $languageAspect */
$row = $pageRepository->getRecordOverlay($table, $row, $languageId, $overlayType);
if (!is_array($row) || !count($row)) {
continue;
}
}
$visibleRows[] = $row;
......
......@@ -26,6 +26,7 @@ namespace SGalinski\SgJobs\ViewHelpers\Backend;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use SGalinski\SgJobs\Domain\Model\Job;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -40,41 +41,31 @@ class ControlViewHelper extends AbstractViewHelper {
/**
* Initialize the ViewHelper arguments
*/
public function initializeArguments() {
public function initializeArguments(): void {
parent::initializeArguments();
$this->registerArgument('table', 'string', 'The table to control', TRUE);
$this->registerArgument('row', 'mixed', 'The row of the record', TRUE);
$this->registerArgument('sortingData', 'array', 'The sorting data', FALSE, []);
$this->registerArgument('row', 'object', 'The row of the record', TRUE);
}
/**
* Renders the control buttons for the specified record
*
* @return string
* @throws \InvalidArgumentException
* @throws \UnexpectedValueException
*/
public function render(): string {
$row = $this->arguments['row'];
$table = $this->arguments['table'];
$sortingData = $this->arguments['sortingData'];
/** @var Job $row */
$row = $this->arguments['row'];
$row = BackendUtility::getRecord('tx_sgjobs_domain_model_job', $row->getUid());
/** @var DatabaseRecordList $databaseRecordList */
$databaseRecordList = GeneralUtility::makeInstance(DatabaseRecordList::class);
if (!\is_array($row)) {
$row = BackendUtility::getRecord($table, $row->getUid());
}
$pageInfo = BackendUtility::readPageAccess($row['pid'], $GLOBALS['BE_USER']->getPagePermsClause(1));
$databaseRecordList->calcPerms = $GLOBALS['BE_USER']->calcPerms($pageInfo);
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/AjaxDataHandler');
$pageRenderer->addInlineLanguageLabelFile('EXT:backend/Resources/Private/Language/locallang_alt_doc.xlf');
$languageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Localization\LanguageService::class);
$languageService->includeLLFile('EXT:backend/Resources/Private/Language/locallang_alt_doc.xlf');
$databaseRecordList->calcPerms = $GLOBALS['BE_USER']->calcPerms($pageInfo);
$databaseRecordList->currentTable = $sortingData;
return $databaseRecordList->makeControl($table, $row);
}
}
<?php
namespace SGalinski\SgJobs\ViewHelpers\Backend;
/***************************************************************
* 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 TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
* Class EditLink
**/
class IconViewHelper extends AbstractViewHelper {
/**
* Register the ViewHelper arguments
*/
public function initializeArguments(): void {
parent::initializeArguments();
$this->registerArgument('table', 'string', 'The table for the icon', TRUE);
$this->registerArgument('row', 'object', 'The row of the record', TRUE);
$this->registerArgument('clickMenu', 'bool', 'Render a clickMenu around the icon', FALSE, TRUE);
}
/**
* Renders the icon for the specified record
*
* @return string
*/
public function render(): string {
$row = $this->arguments['row'];
$row = BackendUtility::getRecord('tx_sgjobs_domain_model_job', $row->getUid());
$table = $this->arguments['table'];
$clickMenu = $this->arguments['clickMenu'];
$iconFactory = GeneralUtility::makeInstance(IconFactory::class);
$toolTip = BackendUtility::getRecordToolTip($row, $table);
$iconImg = '<span ' . $toolTip . '>'
. $iconFactory->getIconForRecord($table, $row, Icon::SIZE_SMALL)->render()
. '</span>';
if ($clickMenu) {
return BackendUtility::wrapClickMenuOnIcon($iconImg, $table, $row['uid']);
}
return $iconImg;
}
}
<?php
namespace SGalinski\SgJobs\ViewHelpers\Backend\Widget\Controller;
/***************************************************************
* 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!
***************************************************************/
/**
* PaginateController
*/
class PaginateController extends \TYPO3\CMS\Fluid\ViewHelpers\Be\Widget\Controller\PaginateController {
/**
* @var mixed
*/
protected $objects;
/**
* Renders the paginator
*
* @param int $currentPage
* @return void
*/
public function indexAction($currentPage = 1) {
// set current page
$this->currentPage = (int) $currentPage;
if ($this->currentPage < 1) {
$this->currentPage = 1;
}
if ($this->currentPage > $this->numberOfPages) {
// set $modifiedObjects to NULL if the page does not exist
$modifiedObjects = NULL;
} else {
// modify query
$this->itemsPerPage = (int) $this->configuration['itemsPerPage'];
$this->offset = $this->itemsPerPage * ($this->currentPage - 1);
if (\is_array($this->objects)) {
$modifiedObjects = [];
for ($index = $this->offset; $index < $this->offset + $this->itemsPerPage; $index++) {
if (isset($this->objects[$index])) {
$modifiedObjects[] = $this->objects[$index];
} else {
break;
}
}
} else {
$query = $this->objects->getQuery();
$query->setLimit($this->itemsPerPage);
if ($this->currentPage > 1) {
$query->setOffset($this->offset);
}
$modifiedObjects = $query->execute();
}
}
$this->view->assign(
'contentArguments', [
$this->widgetConfiguration['as'] => $modifiedObjects
]
);
$this->view->assign('configuration', $this->configuration);
$this->view->assign('pagination', $this->buildPagination());
}
/**
* Returns an array with the keys "pages", "current", "numberOfPages",
* "nextPage" & "previousPage"
*
* @return array
*/
protected function buildPagination() {
$pagination = parent::buildPagination();
$pagination['totalObjects'] = \count($this->objects);
return $pagination;
}
}
<?php
namespace SGalinski\SgJobs\ViewHelpers\Backend\Widget;
/***************************************************************
* 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\SgJobs\ViewHelpers\Backend\Widget\Controller\PaginateController;
use TYPO3\CMS\Fluid\Core\Widget\AbstractWidgetViewHelper;
/**
* Class PaginateViewHelper
*
* @package SGalinski\SgJobs\ViewHelpers\Backend\Widget
*/
class PaginateViewHelper extends AbstractWidgetViewHelper {
/**
* @var PaginateController
*/
protected $controller;
/**
* Initializes the controller
*
* @param PaginateController $controller
*/
public function injectPaginateController(PaginateController $controller): void {
$this->controller = $controller;
}
/**
* Register the ViewHelper arguments
*/
public function initializeArguments(): void {
parent::initializeArguments();
$this->registerArgument('objects', 'array', 'The objects to paginate', TRUE);
$this->registerArgument('as', 'string', 'The name of the variable inside the pagination', TRUE);
$this->registerArgument(
'configuration',
'array',
'The configuration of the pagination',
FALSE,
[
'itemsPerPage' => 10,
'insertAbove' => FALSE,
'insertBelow' => TRUE,
'recordsLabel' => ''
]
);
}
/**
* Renders the paginator
*
* @return string
*/
public function render(): string {
return $this->initiateSubRequest();
}
}
......@@ -26,26 +26,34 @@ namespace SGalinski\SgJobs\ViewHelpers;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use TYPO3\CMS\Core\TypoScript\TypoScriptService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Fluid\View\StandaloneView;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
* View helper that renders a page browser based upon the pagebrowse extension.
*
* Example:
* {namespace sg=SGalinski\SgJobs\ViewHelpers}
* {namespace sg=SGalinski\SgNews\ViewHelpers}
* <sg:pageBrowser numberOfPages="" />
*/
class PageBrowserViewHelper extends AbstractViewHelper {
/**
* Specifies whether the escaping interceptors should be disabled or enabled for the render-result of this ViewHelper
*
* @see isOutputEscapingEnabled()
*
* @var boolean
*/
protected $escapeOutput = FALSE;
/**
* Register the ViewHelper arguments
* Initialize the ViewHelpers arguments
*/
public function initializeArguments() {
parent::initializeArguments();
$this->registerArgument('numberOfPages', 'int', 'The number of pages', TRUE);
$this->registerArgument('numberOfPages', 'int', 'The number of pages to browse', TRUE);
}
/**
......@@ -55,13 +63,48 @@ class PageBrowserViewHelper extends AbstractViewHelper {
* @throws \UnexpectedValueException
*/
public function render(): string {
$configuration = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_sgjobs.']['pagebrowser.'];
$configuration['settings.']['numberOfPages'] = (int) $this->arguments['numberOfPages'];
/** @var TypoScriptService $typoScriptService */
$typoScriptService = GeneralUtility::makeInstance(TypoScriptService::class);
$configuration = $typoScriptService->convertTypoScriptArrayToPlainArray(
$GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_sgjobs.']
);
$view = GeneralUtility::makeInstance(StandaloneView::class);
$view->setRenderingContext($this->renderingContext);
$view->setTemplateRootPaths($configuration['view']['templateRootPaths']);
$view->setPartialRootPaths($configuration['view']['partialRootPaths']);
$view->setLayoutRootPaths($configuration['view']['layoutRootPaths']);
$view->setTemplate('PageBrowser/Index');
$currentPage = 0;
$pageBrowserVars = GeneralUtility::_GP('tx_sgjobs_pagebrowser');
if (isset($pageBrowserVars['currentPage']) && (int) $pageBrowserVars['currentPage'] > 0) {
$currentPage = (int) $pageBrowserVars['currentPage'];
}
$pageLinks = [];
$start = \max($currentPage - 2, 0);
$end = \min($this->arguments['numberOfPages'], $currentPage + 2);
for ($i = $start; $i < $end; $i++) {
$pageLinks[] = [
'number' => $i + 1,
'page' => $i,
'isCurrentPage' => $i === $currentPage,
];
}
/** @var ContentObjectRenderer $contentObject */
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$contentObject = $objectManager->get(ContentObjectRenderer::class);
$contentObject->start([]);
return $contentObject->cObjGetSingle('USER', $configuration);
$view->assignMultiple(
[
'enableLessPages' => 1,
'enableMorePages' => 1,
'pageLinks' => $pageLinks,
'currentPage' => $currentPage,
'prevPageExist' => $currentPage >= 1,
'showLessPages' => ($currentPage - 1) > 1,
'showNextPages' => ($currentPage + 2) < $this->arguments['numberOfPages'],
'nextPageExist' => $currentPage < $this->arguments['numberOfPages'] - 1,
'numberOfPages' => $this->arguments['numberOfPages']
]
);
return $view->render();
}
}
<?php
namespace SGalinski\SgJobs\ViewHelpers\Widget;
/***************************************************************
* 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 TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
/**
* Class UriViewHelper
*/
class UriViewHelper extends AbstractViewHelper {
use CompileWithRenderStatic;
/**
* @var boolean
*/
protected $escapeOutput = FALSE;
/**
* @var boolean
*/
protected $escapeChildren = FALSE;
/**
* Initialize arguments
*/
public function initializeArguments(): void {
$this->registerArgument('addQueryStringMethod', 'string', 'Method to be used for query string');
$this->registerArgument('action', 'string', 'Target action');
$this->registerArgument('arguments', 'array', 'Arguments', FALSE, []);
$this->registerArgument('section', 'string', 'The anchor to be added to the URI', FALSE, '');
$this->registerArgument('format', 'string', 'The requested format, e.g. ".html', FALSE, '');
$this->registerArgument(
'ajax', 'bool', 'TRUE if the URI should be to an AJAX widget, FALSE otherwise.', FALSE, FALSE
);
}
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return string
*/
public static function renderStatic(
array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext
): string {
$ajax = $arguments['ajax'];
if ($ajax === TRUE) {
return static::getAjaxUri($renderingContext, $arguments);
}
return static::getWidgetUri($renderingContext, $arguments);
}
/**
* Render the Uri.
*
* @return string The rendered link
* @api
*/
public function render(): string {
$ajax = $this->arguments['ajax'];
if ($ajax === TRUE) {
return static::getAjaxUri($this->renderingContext, $this->arguments);
}
return static::getWidgetUri($this->renderingContext, $this->arguments);
}
/**
* Get the URI for an AJAX Request.
*
* @param RenderingContextInterface $renderingContext
* @param array $arguments
* @return string the AJAX URI
*/
protected static function getAjaxUri(RenderingContextInterface $renderingContext, array $arguments): string {
/** @var ControllerContext $controllerContext */
$controllerContext = $renderingContext->getControllerContext();
$action = $arguments['action'];
$arguments = $arguments['arguments'];
if ($action === NULL) {
$action = $controllerContext->getRequest()->getControllerActionName();
}
$arguments['id'] = $GLOBALS['TSFE']->id;
// @todo page type should be configurable
$arguments['type'] = 7076;
$arguments['fluid-widget-id'] = $controllerContext->getRequest()->getWidgetContext()->getAjaxWidgetIdentifier();
$arguments['action'] = $action;
return '?' . http_build_query($arguments, NULL, '&');
}
/**
* Get the URI for a non-AJAX Request.
*
* @param RenderingContextInterface $renderingContext
* @param array $arguments
* @return string the Widget URI
*/
protected static function getWidgetUri(RenderingContextInterface $renderingContext, array $arguments): string {
/** @var ControllerContext $controllerContext */
$controllerContext = $renderingContext->getControllerContext();
$uriBuilder = $controllerContext->getUriBuilder();
$argumentPrefix = $controllerContext->getRequest()->getArgumentPrefix();
$parentNamespace = $controllerContext->getRequest()->getWidgetContext()->getParentPluginNamespace();
$parentArguments = GeneralUtility::_GP($parentNamespace);
$allArguments = [$argumentPrefix => $arguments['arguments']] ?? [];
if ($parentArguments && isset($parentArguments['filters'])) {
$allArguments[$parentNamespace . '[filters]'] = $parentArguments['filters'];
}
if ($arguments['action'] ?? FALSE) {
$allArguments[$argumentPrefix]['action'] = $arguments['action'];
}
if (($arguments['format'] ?? '') !== '') {
$allArguments[$argumentPrefix]['format'] = $arguments['format'];
}
return $uriBuilder->reset()
->setArguments($allArguments)
->setSection($arguments['section'])
->setAddQueryString(TRUE)
->setAddQueryStringMethod($arguments['addQueryStringMethod'] ?? '')
->setArgumentsToBeExcludedFromQueryString([$argumentPrefix, 'cHash'])
->setFormat($arguments['format'])
->build();
}
}
......@@ -54,6 +54,7 @@
<type>select</type>
<renderType>selectMultipleSideBySide</renderType>
<foreign_table>tx_sgjobs_domain_model_company</foreign_table>
<foreign_table_where>AND tx_sgjobs_domain_model_company.sys_language_uid IN (0,-1) ORDER BY tx_sgjobs_domain_model_company.name ASC</foreign_table_where>
<wizards>
<suggest>
<type>suggest</type>
......
routeEnhancers:
PageBrowserJobs:
type: Plugin
namespace: tx_sgjobs_pagebrowser
routePath: '/{localizedSegment}/{currentPage}'
aspects:
localizedSegment:
type: LocaleModifier
default: page-jobs
localeMap:
-
locale: 'de_DE.*'
value: seite-jobs
SgJobApplication:
type: Extbase
extension: SgJobs
plugin: JobApplication
routes:
-
routePath: '/{localizedSegment}/{jobTitle}'
_controller: 'Joblist::applyForm'
_arguments:
jobTitle: jobId
-
routePath: '/{localizedSegment}'
_controller: 'Joblist::apply'
defaultController: 'Joblist::applyForm'
aspects:
jobTitle:
type: PersistedAliasMapper
tableName: tx_sgjobs_domain_model_job
routeFieldName: path_segment
localizedSegment:
type: LocaleModifier
default: apply
localeMap:
-
locale: 'de_DE.*'
value: bewerbung
SgJobList:
type: Extbase
extension: SgJobs
plugin: Joblist
routes:
-
routePath: '/job/{jobTitle}'
_controller: 'Joblist::index'
_arguments:
jobTitle: jobId
defaultController: 'Joblist::index'
aspects:
jobTitle:
type: PersistedAliasMapper
tableName: tx_sgjobs_domain_model_job
routeFieldName: path_segment
......@@ -71,8 +71,6 @@ $columns = [
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'foreign_table' => 'sys_language',
'foreign_table_where' => 'ORDER BY sys_language.title',
'special' => 'languages',
'default' => 0,
'items' => [
......
......@@ -69,8 +69,6 @@ $columns = [
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'foreign_table' => 'sys_language',
'foreign_table_where' => 'ORDER BY sys_language.title',
'special' => 'languages',
'default' => 0,
'items' => [
......@@ -79,7 +77,7 @@ $columns = [
-1,
'flags-multiple'
]
],
]
],
],
'l10n_parent' => [
......
......@@ -69,8 +69,6 @@ $columns = [
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'foreign_table' => 'sys_language',
'foreign_table_where' => 'ORDER BY sys_language.title',
'special' => 'languages',
'default' => 0,
'items' => [
......@@ -79,7 +77,7 @@ $columns = [
-1,
'flags-multiple'
]
],
]
],
],
'l10n_parent' => [
......
......@@ -36,7 +36,7 @@ $columns = [
'crdate' => 'crdate',
'cruser_id' => 'cruser_id',
'dividers2tabs' => TRUE,
'searchFields' => 'title, job_id, path_segment, start_date, alternative_start_date, company, contact, department, experience_level',
'searchFields' => 'title, job_id, path_segment, start_date, alternative_start_date, location, apply_external_link, description, task, qualification',
'versioningWS' => 2,
'versioning_followPages' => TRUE,
'origUid' => 't3_origuid',
......@@ -56,15 +56,14 @@ $columns = [
'types' => [
'1' => [
'showitem' => '--palette--;;sysLanguageAndHidden, --palette--;;palette_title,
--palette--;;palette_title_start,
--palette--;;palette_title_start_location,
--palette--;;palette_apply_function,
apply_external_link,
department,
experience_level,
company,
contact,
description,
attachment,
--div--; LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tca.qualification_tab, task, qualification,
--div--; LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tca.qualification_tab, description, task, qualification, attachment,
--div--; LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tca.seo_tab,
--palette--;;palette_location_specifications,
employment_types,
......@@ -80,7 +79,7 @@ $columns = [
'canNotCollapse' => 1,
],
'palette_title' => ['showitem' => 'title, path_segment, job_id', 'canNotCollapse' => 1],
'palette_title_start' => ['showitem' => 'start_date, alternative_start_date', 'canNotCollapse' => 1],
'palette_title_start_location' => ['showitem' => 'start_date, alternative_start_date, location', 'canNotCollapse' => 1],
'palette_apply_function' => ['showitem' => 'hide_apply_by_email, hide_apply_by_postal, featured_offer', 'canNotCollapse' => 1],
'palette_location_specifications' => ['showitem' => 'telecommute_possible, office_work_possible'],
'palette_seo_dates' => ['showitem' => 'date_posted, valid_through'],
......@@ -324,6 +323,15 @@ $columns = [
'eval' => 'trim'
],
],
'location' => [
'exclude' => TRUE,
'label' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job.location',
'config' => [
'type' => 'input',
'size' => 30,
'eval' => 'trim'
],
],
'task' => [
'exclude' => TRUE,
'label' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job.task',
......@@ -502,10 +510,19 @@ $columns = [
'max' => 15,
],
],
'apply_external_link' => [
'exclude' => TRUE,
'label' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job.apply_external_link',
'config' => [
'type' => 'input',
'size' => 512,
'eval' => 'trim'
],
],
],
];
if (version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '10.3.0', '<')) {
$columns['interface']['showRecordFieldList'] = 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, pid, title, path_segment, job_id, department, experience_level, hide_apply_by_email, hide_apply_by_postal, featured_offer, start_date, alternative_start_date,company, task, qualification, description, contact, telecommute, employment_types, date_posted, valid_through, salary_currency, base_salary, max_salary, salary_unit';
$columns['interface']['showRecordFieldList'] = 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, pid, title, path_segment, job_id, department, experience_level, hide_apply_by_email, hide_apply_by_postal, featured_offer, start_date, alternative_start_date, location, company, task, qualification, description, contact, telecommute, employment_types, date_posted, valid_through, salary_currency, base_salary, max_salary, salary_unit';
}
return $columns;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment