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 {
$configurationService = GeneralUtility::makeInstance(ConfigurationService::class);
$sortBy = $configurationService->getConfiguration('sortBy', $this->settings);
$categoryUids = GeneralUtility::intExplode(',', $this->settings['categories'], TRUE);
$tagUids = GeneralUtility::intExplode(',', $this->settings['tags'], TRUE);
$categoryUids = NULL;
$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)) {
$categoryUids = [$GLOBALS['TSFE']->id];
}
$startTime = (int) $this->settings['starttime'];
$endTime = (int) $this->settings['endtime'];
$startTime = 0;
$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(
$limit,
FALSE,
......@@ -91,11 +103,16 @@ class LatestController extends AbstractController {
);
$categories = [];
$category = NULL;
foreach ($latestNewsEntries as $latestNewsEntry) {
/** @var News $latestNewsEntry */
/** @var Category $category */
$categoryUid = $latestNewsEntry->getPid();
$category = $categories[$categoryUid];
if (isset($categories[$categoryUid])) {
$category = $categories[$categoryUid];
}
if (!$category) {
$category = $this->categoryRepository->findByUid($categoryUid);
if (!$category) {
......
......@@ -91,7 +91,9 @@ class OverviewController extends AbstractController {
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentNameException
*/
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) {
$this->request->setArgument('currentPageBrowserPage', $currentPageBrowserPage);
}
......@@ -107,7 +109,8 @@ class OverviewController extends AbstractController {
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
* @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']) {
case 1:
$this->overviewWithCategories([], [], $newsFilter, $currentPageBrowserPage);
......@@ -116,10 +119,14 @@ class OverviewController extends AbstractController {
$this->overviewWithTags([], [], $newsFilter, $currentPageBrowserPage);
break;
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());
} else {
return (new \TYPO3\CMS\Extbase\Http\ForwardResponse('overviewWithoutCategories'))->withControllerName('Record')
return (new \TYPO3\CMS\Extbase\Http\ForwardResponse(
'overviewWithoutCategories'
))->withControllerName('Record')
->withExtensionName('Extension')
->withArguments($this->request->getArguments());
}
......@@ -141,8 +148,15 @@ class OverviewController extends AbstractController {
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
*/
protected function highlightBestFitNews(array $categoryIds = NULL, array $tagIds = NULL) {
$startTime = (int) $this->settings['starttime'];
$endTime = (int) $this->settings['endtime'];
$startTime = 0;
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 */
$highlightedNews = $this->newsRepository
......@@ -212,24 +226,26 @@ class OverviewController extends AbstractController {
return;
}
$categoryRestrictions = GeneralUtility::intExplode(',', $this->settings['categoryRestrictions'], TRUE);
if (count($categoryRestrictions) > 0) {
foreach ($categories as $key => $category) {
$categoryId = $category->getUid();
if (isset($this->settings['categoryRestrictions'])) {
$categoryRestrictions = GeneralUtility::intExplode(',', $this->settings['categoryRestrictions'], TRUE);
if (count($categoryRestrictions) > 0) {
foreach ($categories as $key => $category) {
$categoryId = $category->getUid();
// older version compatibility with selection of categories in translations and so on
$categoryIdTranslated = $categoryId;
if ($category->_getProperty('_languageUid') > 0) {
$originalLangCategory = $this->categoryRepository->findOriginalLanguageById($categoryId);
if ($originalLangCategory) {
$categoryIdTranslated = $originalLangCategory->getUid();
// older version compatibility with selection of categories in translations and so on
$categoryIdTranslated = $categoryId;
if ($category->_getProperty('_languageUid') > 0) {
$originalLangCategory = $this->categoryRepository->findOriginalLanguageById($categoryId);
if ($originalLangCategory) {
$categoryIdTranslated = $originalLangCategory->getUid();
}
}
}
if (!in_array($categoryId, $categoryRestrictions, TRUE) &&
!in_array($categoryIdTranslated, $categoryRestrictions, TRUE)
) {
unset($categories[$key]);
if (!in_array($categoryId, $categoryRestrictions, TRUE) &&
!in_array($categoryIdTranslated, $categoryRestrictions, TRUE)
) {
unset($categories[$key]);
}
}
}
}
......@@ -238,8 +254,15 @@ class OverviewController extends AbstractController {
return;
}
$startTime = (int) $this->settings['starttime'];
$endTime = (int) $this->settings['endtime'];
$startTime = 0;
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);
$sortBy = $configurationService->getConfiguration('sortBy', $this->settings);
......@@ -265,7 +288,7 @@ class OverviewController extends AbstractController {
}
$tagIds = NULL;
if ($newsFilter['tag']) {
if (isset($newsFilter['tag']) && $newsFilter['tag']) {
$tagIds = [(int) $newsFilter['tag']];
}
foreach ($categoryIdsForSelect as $categoryIdsForSelectId) {
......@@ -321,7 +344,7 @@ class OverviewController extends AbstractController {
}
$tagIds = NULL;
if ($newsFilter['tag']) {
if (isset($newsFilter['tag']) && $newsFilter['tag']) {
$tagIds = [(int) $newsFilter['tag']];
}
$news = $this->newsRepository->findAllSortedNewsByCategories(
......@@ -372,7 +395,10 @@ class OverviewController extends AbstractController {
}
// 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('tags', $tags);
$this->view->assign('categories', $categories);
......@@ -649,7 +675,9 @@ class OverviewController extends AbstractController {
}
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;
} else {
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