diff --git a/Classes/Controller/OverviewController.php b/Classes/Controller/OverviewController.php index 11361cd06c7c775b8fa0c73f1b9be1c72a8d4cb0..e8ccc77cb877af5e2899253166d449686e310349 100644 --- a/Classes/Controller/OverviewController.php +++ b/Classes/Controller/OverviewController.php @@ -102,7 +102,7 @@ class OverviewController extends AbstractController { * @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentNameException */ public function initializeOverviewAction() { - $currentPageBrowserPage = (int) GeneralUtility::_GP('tx_sgnews_pagebrowser')['currentPage']; + $currentPageBrowserPage = (int) (GeneralUtility::_GP('tx_sgnews_pagebrowser')['currentPage'] ?? 0); if ($currentPageBrowserPage > 0) { $this->request->setArgument('currentPageBrowserPage', $currentPageBrowserPage); } @@ -135,28 +135,28 @@ class OverviewController extends AbstractController { } // Setup settings - $startTime = (int) $this->settings['starttime']; - $endTime = (int) $this->settings['endtime']; - $newsLimit = (int) $this->settings['newsLimit']; + $startTime = (int) ($this->settings['starttime'] ?? 0); + $endTime = (int) ($this->settings['endtime'] ?? 0); + $newsLimit = (int) ($this->settings['newsLimit'] ?? 0); $offset = $this->calculatePaginationOffset($currentPageBrowserPage, $newsLimit); $configurationService = GeneralUtility::makeInstance(ConfigurationService::class); $sortBy = $configurationService->getConfiguration('sortBy', $this->settings); $sortDirection = $configurationService->getConfiguration('sortDirection', $this->settings); $this->tagRepository->setDefaultOrderings(['sorting' => QueryInterface::ORDER_ASCENDING]); $this->categoryRepository->setDefaultOrderings(['sorting' => QueryInterface::ORDER_ASCENDING]); - $useAllFilters = (bool) $this->settings['enableFilter']; - $isCategoryFiltered = $useAllFilters || (int) $this->settings['groupBy'] === 1; - $isTagFiltered = $useAllFilters || (int) $this->settings['groupBy'] === 2; + $useAllFilters = (bool) ($this->settings['enableFilter'] ?? false); + $isCategoryFiltered = $useAllFilters || $this->settings['groupBy'] === 1 ? 1: 0; + $isTagFiltered = $useAllFilters || $this->settings['groupBy'] === 2 ? 1: 0; HeaderMetaDataService::addPageNumberToCanonical($currentPageBrowserPage); // Get tag pid - $tagPid = (int) $this->settings['tagPid']; + $tagPid = (int) ($this->settings['tagPid'] ?? 0); if (!$tagPid) { $tagPid = $GLOBALS['TSFE']->id; } - if ($this->settings['onlyNewsWithinThisPageSection']) { + if ($this->settings['onlyNewsWithinThisPageSection'] ?? false) { $categories = $this->categoryRepository->findCategoriesInRootLine($GLOBALS['TSFE']->id); $tags = $this->tagRepository->findTagsInRootLine($tagPid); } else { @@ -165,7 +165,7 @@ class OverviewController extends AbstractController { } // Apply category restrictions - $categoryRestrictions = GeneralUtility::intExplode(',', $this->settings['categoryRestrictions'], TRUE); + $categoryRestrictions = GeneralUtility::intExplode(',', $this->settings['categoryRestrictions'] ?? '', TRUE); if (!$isCategoryFiltered) { $categoryRestrictions = []; } @@ -191,7 +191,7 @@ class OverviewController extends AbstractController { } // Apply tag restrictions - $tagRestrictions = GeneralUtility::intExplode(',', $this->settings['tagRestrictions'], TRUE); + $tagRestrictions = GeneralUtility::intExplode(',', $this->settings['tagRestrictions'] ?? '', TRUE); if (!$isTagFiltered) { $tagRestrictions = []; } @@ -205,7 +205,7 @@ class OverviewController extends AbstractController { // Get category ids or use the one in the filter $categoryIds = []; - if ($newsFilter['category']) { + if ($newsFilter['category'] ?? false) { $categoryIds = [(int) $newsFilter['category']]; } elseif ($isCategoryFiltered) { foreach ($categories as $category) { @@ -217,7 +217,7 @@ class OverviewController extends AbstractController { // Get tag ids or use the one in the filter $tagIds = []; - if ($newsFilter['tag']) { + if ($newsFilter['tag'] ?? false) { $tagIds = [(int) $newsFilter['tag']]; } elseif ($isTagFiltered) { foreach ($tags as $tag) { @@ -302,8 +302,8 @@ class OverviewController extends AbstractController { } // remember selection of the filter values, if any - $selectedTag = $this->tagRepository->findByUid((int) $newsFilter['tag']); - $selectedCategory = $this->categoryRepository->findByUid((int) $newsFilter['category']); + $selectedTag = $this->tagRepository->findByUid((int) ($newsFilter['tag'] ?? 0)); + $selectedCategory = $this->categoryRepository->findByUid((int) ($newsFilter['category'] ?? 0)); $this->view->assign('selectedCategory', $selectedCategory); $this->view->assign('selectedTag', $selectedTag); $this->view->assign('tags', $tags); @@ -313,7 +313,7 @@ class OverviewController extends AbstractController { $this->view->assign('allNews', $allNews); $this->setupGridColumns(); - switch ($this->settings['groupBy']) { + switch ($this->settings['groupBy'] ?? '') { case 1: $this->view->assign('groupBy', 'category'); $this->view->assign('categoryTabs', TRUE); @@ -369,8 +369,8 @@ 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 = (int) ($this->settings['starttime'] ?? 0); + $endTime = (int) ($this->settings['endtime'] ?? 0); /** @var News $highlightedNews */ $highlightedNews = $this->newsRepository