Skip to content
Snippets Groups Projects
Commit ca72dbd6 authored by Kevin Ditscheid's avatar Kevin Ditscheid
Browse files

[TASK] Remove typo3 version constraint and legacy code

parent db600279
No related branches found
No related tags found
1 merge request!23Feature upgrade to typo3 10
......@@ -32,11 +32,8 @@ use SGalinski\SgJobs\Service\BackendService;
use TYPO3\CMS\Backend\Template\Components\DocHeaderComponent;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
......@@ -82,19 +79,6 @@ class BackendController extends ActionController {
$this->jobRepository = $jobRepository;
}
/**
* @param ViewInterface $view
*/
public function initializeView(ViewInterface $view): void {
parent::initializeView($view);
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->addJsInlineCode(
'typo3_version', 'TYPO3.version='
. VersionNumberUtility::convertVersionNumberToInteger(VersionNumberUtility::getCurrentTypo3Version())
. ';'
);
}
/**
* Show all job offers and options to manage them
*
......@@ -152,8 +136,6 @@ class BackendController extends ActionController {
/** @var QueryResultInterface $companies */
$companies = $this->companyRepository->findByPid($pageUid);
$this->view->assign('locationOptions', $companies);
$this->view->assign('typo3Version', VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version));
if ($totalJobCount || $companies->count()) {
$this->view->assign('jobs', $jobs);
$this->view->assign('filters', $filters);
......
......@@ -37,9 +37,10 @@ use SGalinski\SgJobs\Domain\Repository\JobRepository;
use SGalinski\SgJobs\Property\TypeConverter\UploadedFileReferenceConverter;
use SGalinski\SgMail\Service\MailTemplateService;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Resource\ResourceFactory;
use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException;
......@@ -256,15 +257,13 @@ class JoblistController extends ActionController {
}
// display country options
if (\version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) {
$sysLanguageUid = $GLOBALS['TSFE']->sys_language_uid;
} else {
$context = GeneralUtility::makeInstance(Context::class);
$sysLanguageUid = $context->getPropertyFromAspect('language', 'id');
}
$context = GeneralUtility::makeInstance(Context::class);
$sysLanguageUid = $context->getPropertyFromAspect('language', 'id');
$site = GeneralUtility::makeInstance(SiteFinder::class)
->getSiteByPageId($GLOBALS['TSFE']->id)
->getLanguageById($sysLanguageUid);
$countryRepository = $this->objectManager->get(CountryRepository::class);
$countries = $countryRepository->findAllOrderedByLanguage($GLOBALS['TSFE']->sys_language_isocode);
$countries = $countryRepository->findAllOrderedByLanguage($site->getTwoLetterIsoCode());
$this->view->assign('countries', $countries);
$this->view->assign('sysLanguageUid', $sysLanguageUid);
......@@ -336,7 +335,7 @@ class JoblistController extends ActionController {
$newName = \date('Ymd-His') . '_' . $applicationData->getJobId() . '-' . $applicationData->getFirstName()
. '-' . $applicationData->getLastName();
$storage = $resourceFactory->getStorageObject(1);
$applicationFilePath = PATH_site . $storage->getConfiguration()['basePath'] . 'JobApplication/' . $folderName .
$applicationFilePath = Environment::getPublicPath() . '/' . $storage->getConfiguration()['basePath'] . 'JobApplication/' . $folderName .
'/' . $newName . '.csv';
$this->writeApplicationFile($applicationData, $applicationFilePath);
}
......
......@@ -29,6 +29,7 @@ namespace SGalinski\SgJobs\Property\TypeConverter;
use SGalinski\SgJobs\Domain\Model\FileReference;
use TYPO3\CMS\Core\Resource\DuplicationBehavior;
use TYPO3\CMS\Core\Resource\File as FalFile;
use TYPO3\CMS\Core\Resource\FileInterface;
use TYPO3\CMS\Core\Resource\FileReference as FalFileReference;
use TYPO3\CMS\Core\Resource\ResourceFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -227,11 +228,13 @@ class UploadedFileReferenceConverter implements TypeConverterInterface {
* @param string $targetType
* @param string $propertyName
* @param PropertyMappingConfigurationInterface $configuration
* @return string
* @api
*/
public function getTypeOfChildProperty(
$targetType, $propertyName, PropertyMappingConfigurationInterface $configuration
) {
): string {
return '';
}
/**
......@@ -302,7 +305,7 @@ class UploadedFileReferenceConverter implements TypeConverterInterface {
* @param string $targetType
* @param array $convertedChildProperties
* @param PropertyMappingConfigurationInterface $configuration
* @return null|FileReference|Error
* @return null|FileInterface|Error
* @api
*/
public function convertFrom(
......
<?php
namespace SGalinski\SgJobs\Routing\Aspect;
/**
*
* 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\Database\ConnectionPool;
use TYPO3\CMS\Core\Routing\Aspect\PersistedMappableAspectInterface;
use TYPO3\CMS\Core\Routing\Aspect\StaticMappableAspectInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Class JobAspect
*
* @deprecated @TODO Drop it in one of the next breaking versions. It should not be used anymore. Look at the README. We switched already to the path_segment field.
*
* @package SGalinski\SgJobs\Routing\Aspect
* @author Kevin Ditscheid <kevin.ditscheid@sgalinski.de>
*/
class JobTitleMapper implements PersistedMappableAspectInterface, StaticMappableAspectInterface {
/**
* Generate the job title from the job id given to this function as the $value parameter
*
* @param string $value
* @return string|null
* @throws \Exception
*/
public function generate(string $value): ?string {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_sgjobs_domain_model_job');
$job = $queryBuilder->select('job.uid', 'job.title')
->from('tx_sgjobs_domain_model_job', 'job')
->where(
$queryBuilder->expr()->eq('job.uid', $queryBuilder->createNamedParameter($value, \PDO::PARAM_INT))
)
->setMaxResults(1)
->execute()->fetch();
return \urlencode(
\preg_replace('/[^a-zA-Z0-9_]/', '', \str_replace([' ', '-'], '_', \strtolower($job['title'])))
. '-' . $job['uid']
);
}
/**
* Resolve a job title given by the $value parameter to a job id. It is slicing the string into the various parts
* via regular expression and searches the database for a record, that matches the parts.
*
* @param string $value
* @return string|null
*/
public function resolve(string $value): ?string {
if (!\preg_match('/^(?P<title>.+)-(?P<uid>.+)/', $value, $matches)) {
return NULL;
}
$jobUid = (int) $matches['uid'];
return ($jobUid > 0 ? $jobUid : NULL);
}
}
......@@ -34,7 +34,6 @@ use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
use TYPO3\CMS\Extbase\Mvc\Request;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
......@@ -86,16 +85,9 @@ class BackendService {
public static function makeButtons($docHeaderComponent, $request): void {
/** @var ButtonBar $buttonBar */
$buttonBar = $docHeaderComponent->getButtonBar();
/** @var IconFactory $iconFactory */
$iconFactory = GeneralUtility::makeInstance(IconFactory::class);
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) {
$locallangPath = 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:';
} else {
$locallangPath = 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:';
}
$locallangPath = 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:';
// Refresh
$refreshButton = $buttonBar->makeLinkButton()
->setHref(GeneralUtility::getIndpEnv('REQUEST_URI'))
......
......@@ -29,7 +29,7 @@ namespace SGalinski\SgJobs\SignalSlot;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\Page\PageRepository;
use \TYPO3\CMS\Core\Domain\Repository\PageRepository;
use TYPO3\Languagevisibility\Service\FrontendServices;
/**
......
......@@ -29,7 +29,6 @@ namespace SGalinski\SgJobs\ViewHelpers\Backend;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
use TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
......@@ -71,12 +70,7 @@ class ControlViewHelper extends AbstractViewHelper {
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/AjaxDataHandler');
$pageRenderer->addInlineLanguageLabelFile('EXT:backend/Resources/Private/Language/locallang_alt_doc.xlf');
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) {
$languageService = GeneralUtility::makeInstance(\TYPO3\CMS\Lang\LanguageService::class);
} else {
$languageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Localization\LanguageService::class);
}
$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;
......
......@@ -13,14 +13,7 @@
</div>
<div class="module-docheader-bar-column-right">
<span class="typo3-docheader-pagePath">
<f:if condition="{typo3Version} < 9000000">
<f:then>
<f:translate key="LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.path" />: <f:format.raw>{docHeader.metaInformation.path}</f:format.raw>
</f:then>
<f:else>
<f:translate key="LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.path" />: <f:format.raw>{docHeader.metaInformation.path}</f:format.raw>
</f:else>
</f:if>
<f:translate key="LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.path" />: <f:format.raw>{docHeader.metaInformation.path}</f:format.raw>
</span>
<f:format.raw>{docHeader.metaInformation.recordInformation}</f:format.raw>
</div>
......
......@@ -32,7 +32,7 @@ define([
init: function() {
$('.sg-jobs_pageswitch').on('click', function(event) {
event.preventDefault();
SgJobs.goTo('web_SgJobsBackend', event.target.dataset.page, event.target.dataset.path);
SgJobs.goTo('web_SgJobsBackend', event.target.dataset.page);
});
},
/**
......@@ -40,34 +40,16 @@ define([
*
* @param module
* @param id
* @param path
*/
goTo: function(module, id, path) {
if (TYPO3.version < 9000000) {
var tree = top.Ext.getCmp('typo3-pagetree');
if (tree) {
tree.activeTree.selectPath(path);
} else if (top.nav) {
top.nav.invokePageId(id, function(path) {
var callback = top.Ext.createDelegate(top.nav.mainTree.selectPath, top.nav.mainTree);
callback.apply(this, arguments);
var node = top.nav.getSelected();
if (node) {
top.TYPO3.Components.PageTree.Actions.singleClick(node, top.TYPO3.Components.PageTree.Tree);
}
});
goTo: function(module, id) {
var pageTreeNodes = Viewport.NavigationContainer.PageTree.instance.nodes;
for (var nodeIndex in pageTreeNodes) {
if (pageTreeNodes.hasOwnProperty(nodeIndex) && pageTreeNodes[nodeIndex].identifier === parseInt(id)) {
Viewport.NavigationContainer.PageTree.selectNode(pageTreeNodes[nodeIndex]);
break;
}
parent.TYPO3.ModuleMenu.App.showModule(module, 'id=' + id);
} else {
var pageTreeNodes = Viewport.NavigationContainer.PageTree.instance.nodes;
for (var nodeIndex in pageTreeNodes) {
if (pageTreeNodes.hasOwnProperty(nodeIndex) && pageTreeNodes[nodeIndex].identifier === parseInt(id)) {
Viewport.NavigationContainer.PageTree.selectNode(pageTreeNodes[nodeIndex]);
break;
}
}
ModuleMenu.App.showModule(module, 'id=' + id);
}
ModuleMenu.App.showModule(module, 'id=' + id);
}
};
TYPO3.SgJobs = SgJobs;
......
......@@ -101,10 +101,6 @@ call_user_func(
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'][\SGalinski\SgJobs\Updates\DepartmentUpdateWizard::IDENTIFIER]
= \SGalinski\SgJobs\Updates\DepartmentUpdateWizard::class;
if (version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '>')) {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['routing']['aspects']['JobTitleMapper'] = \SGalinski\SgJobs\Routing\Aspect\JobTitleMapper::class;
}
//include Plugin sg_jobs
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig(
'<INCLUDE_TYPOSCRIPT: source="FILE:EXT:' . $extKey . '/Configuration/TsConfig/Page/NewContentElementWizard.tsconfig">'
......
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