Skip to content
Snippets Groups Projects
Commit f7aa96d4 authored by Matthias Adrowski's avatar Matthias Adrowski
Browse files

[TASK] Fix issues wiith php 8.1 on listview

parent 51071380
No related branches found
No related tags found
1 merge request!38Feature upgrade to typo3 11
...@@ -70,14 +70,26 @@ class LatestController extends AbstractController { ...@@ -70,14 +70,26 @@ class LatestController extends AbstractController {
$configurationService = GeneralUtility::makeInstance(ConfigurationService::class); $configurationService = GeneralUtility::makeInstance(ConfigurationService::class);
$sortBy = $configurationService->getConfiguration('sortBy', $this->settings); $sortBy = $configurationService->getConfiguration('sortBy', $this->settings);
$categoryUids = GeneralUtility::intExplode(',', $this->settings['categories'], TRUE); $categoryUids = NULL;
$tagUids = GeneralUtility::intExplode(',', $this->settings['tags'], TRUE); $tagUids = NULL;
if (isset($this->settings['categories'])) {
$categoryUids = GeneralUtility::intExplode(',', $this->settings['categories'], TRUE);
}
if (isset($this->settings['tags'])) {
$tagUids = GeneralUtility::intExplode(',', $this->settings['tags'], TRUE);
}
if ((int) $GLOBALS['TSFE']->page['doktype'] === 117 && !count($categoryUids)) { if ((int) $GLOBALS['TSFE']->page['doktype'] === 117 && !count($categoryUids)) {
$categoryUids = [$GLOBALS['TSFE']->id]; $categoryUids = [$GLOBALS['TSFE']->id];
} }
$startTime = (int) $this->settings['starttime']; $startTime = 0;
$endTime = (int) $this->settings['endtime']; $endTime = 0;
if (isset($this->settings['starttime'])) {
$startTime = (int) $this->settings['starttime'];
}
if (isset($this->settings['endtime'])) {
$endTime = (int) $this->settings['endtime'];
}
$latestNewsEntries = $this->newsRepository->findLastUpdatedOrHighlightedNewsByCategories( $latestNewsEntries = $this->newsRepository->findLastUpdatedOrHighlightedNewsByCategories(
$limit, $limit,
FALSE, FALSE,
...@@ -91,11 +103,16 @@ class LatestController extends AbstractController { ...@@ -91,11 +103,16 @@ class LatestController extends AbstractController {
); );
$categories = []; $categories = [];
$category = NULL;
foreach ($latestNewsEntries as $latestNewsEntry) { foreach ($latestNewsEntries as $latestNewsEntry) {
/** @var News $latestNewsEntry */ /** @var News $latestNewsEntry */
/** @var Category $category */ /** @var Category $category */
$categoryUid = $latestNewsEntry->getPid(); $categoryUid = $latestNewsEntry->getPid();
$category = $categories[$categoryUid];
if (isset($categories[$categoryUid])) {
$category = $categories[$categoryUid];
}
if (!$category) { if (!$category) {
$category = $this->categoryRepository->findByUid($categoryUid); $category = $this->categoryRepository->findByUid($categoryUid);
if (!$category) { if (!$category) {
......
...@@ -91,7 +91,9 @@ class OverviewController extends AbstractController { ...@@ -91,7 +91,9 @@ class OverviewController extends AbstractController {
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentNameException * @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentNameException
*/ */
public function initializeOverviewAction() { public function initializeOverviewAction() {
$currentPageBrowserPage = (int) GeneralUtility::_GP('tx_sgnews_pagebrowser')['currentPage']; $currentPageBrowserPage = GeneralUtility::_GP('tx_sgnews_pagebrowser') ? (int) GeneralUtility::_GP(
'tx_sgnews_pagebrowser'
)['currentPage'] : 0;
if ($currentPageBrowserPage > 0) { if ($currentPageBrowserPage > 0) {
$this->request->setArgument('currentPageBrowserPage', $currentPageBrowserPage); $this->request->setArgument('currentPageBrowserPage', $currentPageBrowserPage);
} }
...@@ -107,7 +109,8 @@ class OverviewController extends AbstractController { ...@@ -107,7 +109,8 @@ class OverviewController extends AbstractController {
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
* @throws \TYPO3\CMS\Extbase\Configuration\Exception\InvalidConfigurationTypeException * @throws \TYPO3\CMS\Extbase\Configuration\Exception\InvalidConfigurationTypeException
*/ */
public function overviewAction(array $newsFilter = [], int $currentPageBrowserPage = 0): ?\Psr\Http\Message\ResponseInterface { public function overviewAction(array $newsFilter = [], int $currentPageBrowserPage = 0
): ?\Psr\Http\Message\ResponseInterface {
switch ((int) $this->settings['groupBy']) { switch ((int) $this->settings['groupBy']) {
case 1: case 1:
$this->overviewWithCategories([], [], $newsFilter, $currentPageBrowserPage); $this->overviewWithCategories([], [], $newsFilter, $currentPageBrowserPage);
...@@ -116,10 +119,14 @@ class OverviewController extends AbstractController { ...@@ -116,10 +119,14 @@ class OverviewController extends AbstractController {
$this->overviewWithTags([], [], $newsFilter, $currentPageBrowserPage); $this->overviewWithTags([], [], $newsFilter, $currentPageBrowserPage);
break; break;
default: default:
if (version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '11.0.0', '<')) { if (version_compare(
\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '11.0.0', '<'
)) {
$this->forward('overviewWithoutCategories', NULL, NULL, $this->request->getArguments()); $this->forward('overviewWithoutCategories', NULL, NULL, $this->request->getArguments());
} else { } else {
return (new \TYPO3\CMS\Extbase\Http\ForwardResponse('overviewWithoutCategories'))->withControllerName('Record') return (new \TYPO3\CMS\Extbase\Http\ForwardResponse(
'overviewWithoutCategories'
))->withControllerName('Record')
->withExtensionName('Extension') ->withExtensionName('Extension')
->withArguments($this->request->getArguments()); ->withArguments($this->request->getArguments());
} }
...@@ -141,8 +148,15 @@ class OverviewController extends AbstractController { ...@@ -141,8 +148,15 @@ class OverviewController extends AbstractController {
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException * @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
*/ */
protected function highlightBestFitNews(array $categoryIds = NULL, array $tagIds = NULL) { protected function highlightBestFitNews(array $categoryIds = NULL, array $tagIds = NULL) {
$startTime = (int) $this->settings['starttime']; $startTime = 0;
$endTime = (int) $this->settings['endtime']; if (isset($this->settings['starttime'])) {
$startTime = (int) $this->settings['starttime'];
}
$endTime = 0;
if (isset($this->settings['endtime'])) {
$endTime = (int) $this->settings['endtime'];
}
/** @var News $highlightedNews */ /** @var News $highlightedNews */
$highlightedNews = $this->newsRepository $highlightedNews = $this->newsRepository
...@@ -212,24 +226,26 @@ class OverviewController extends AbstractController { ...@@ -212,24 +226,26 @@ class OverviewController extends AbstractController {
return; return;
} }
$categoryRestrictions = GeneralUtility::intExplode(',', $this->settings['categoryRestrictions'], TRUE); if (isset($this->settings['categoryRestrictions'])) {
if (count($categoryRestrictions) > 0) { $categoryRestrictions = GeneralUtility::intExplode(',', $this->settings['categoryRestrictions'], TRUE);
foreach ($categories as $key => $category) { if (count($categoryRestrictions) > 0) {
$categoryId = $category->getUid(); foreach ($categories as $key => $category) {
$categoryId = $category->getUid();
// older version compatibility with selection of categories in translations and so on // older version compatibility with selection of categories in translations and so on
$categoryIdTranslated = $categoryId; $categoryIdTranslated = $categoryId;
if ($category->_getProperty('_languageUid') > 0) { if ($category->_getProperty('_languageUid') > 0) {
$originalLangCategory = $this->categoryRepository->findOriginalLanguageById($categoryId); $originalLangCategory = $this->categoryRepository->findOriginalLanguageById($categoryId);
if ($originalLangCategory) { if ($originalLangCategory) {
$categoryIdTranslated = $originalLangCategory->getUid(); $categoryIdTranslated = $originalLangCategory->getUid();
}
} }
}
if (!in_array($categoryId, $categoryRestrictions, TRUE) && if (!in_array($categoryId, $categoryRestrictions, TRUE) &&
!in_array($categoryIdTranslated, $categoryRestrictions, TRUE) !in_array($categoryIdTranslated, $categoryRestrictions, TRUE)
) { ) {
unset($categories[$key]); unset($categories[$key]);
}
} }
} }
} }
...@@ -238,8 +254,15 @@ class OverviewController extends AbstractController { ...@@ -238,8 +254,15 @@ class OverviewController extends AbstractController {
return; return;
} }
$startTime = (int) $this->settings['starttime']; $startTime = 0;
$endTime = (int) $this->settings['endtime']; if (isset($this->settings['starttime'])) {
$startTime = (int) $this->settings['starttime'];
}
$endTime = 0;
if (isset($this->settings['endtime'])) {
$endTime = (int) $this->settings['endtime'];
}
$configurationService = GeneralUtility::makeInstance(ConfigurationService::class); $configurationService = GeneralUtility::makeInstance(ConfigurationService::class);
$sortBy = $configurationService->getConfiguration('sortBy', $this->settings); $sortBy = $configurationService->getConfiguration('sortBy', $this->settings);
...@@ -265,7 +288,7 @@ class OverviewController extends AbstractController { ...@@ -265,7 +288,7 @@ class OverviewController extends AbstractController {
} }
$tagIds = NULL; $tagIds = NULL;
if ($newsFilter['tag']) { if (isset($newsFilter['tag']) && $newsFilter['tag']) {
$tagIds = [(int) $newsFilter['tag']]; $tagIds = [(int) $newsFilter['tag']];
} }
foreach ($categoryIdsForSelect as $categoryIdsForSelectId) { foreach ($categoryIdsForSelect as $categoryIdsForSelectId) {
...@@ -321,7 +344,7 @@ class OverviewController extends AbstractController { ...@@ -321,7 +344,7 @@ class OverviewController extends AbstractController {
} }
$tagIds = NULL; $tagIds = NULL;
if ($newsFilter['tag']) { if (isset($newsFilter['tag']) && $newsFilter['tag']) {
$tagIds = [(int) $newsFilter['tag']]; $tagIds = [(int) $newsFilter['tag']];
} }
$news = $this->newsRepository->findAllSortedNewsByCategories( $news = $this->newsRepository->findAllSortedNewsByCategories(
...@@ -372,7 +395,10 @@ class OverviewController extends AbstractController { ...@@ -372,7 +395,10 @@ class OverviewController extends AbstractController {
} }
// remember selection of the filter values, if any // remember selection of the filter values, if any
$selectedTag = $this->tagRepository->findByUid((int) $newsFilter['tag']); $selectedTag = NULL;
if (isset($newsFilter['tag'])) {
$selectedTag = $this->tagRepository->findByUid((int) $newsFilter['tag']);
}
$this->view->assign('selectedTag', $selectedTag); $this->view->assign('selectedTag', $selectedTag);
$this->view->assign('tags', $tags); $this->view->assign('tags', $tags);
$this->view->assign('categories', $categories); $this->view->assign('categories', $categories);
...@@ -649,7 +675,9 @@ class OverviewController extends AbstractController { ...@@ -649,7 +675,9 @@ class OverviewController extends AbstractController {
} }
if ($newsCount <= 0) { if ($newsCount <= 0) {
if (version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '11.0.0', '<')) { if (version_compare(
\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '11.0.0', '<'
)) {
return NULL; return NULL;
} else { } else {
return $this->htmlResponse(); return $this->htmlResponse();
......
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