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

[BUGFIX] Fix the selection of news by category if categories are translated...

[BUGFIX] Fix the selection of news by category if categories are translated but news are just set to "force" by languagevisibility
parent ef0c1fde
No related branches found
No related tags found
No related merge requests found
......@@ -93,7 +93,14 @@ class ListByCategoryController extends AbstractController {
$categories = [];
foreach ($categoryUids as $categoryUid) {
$categories[$categoryUid] = $this->categoryRepository->findByUid($categoryUid);
$category = $this->categoryRepository->findByUid($categoryUid);
$categories[$categoryUid] = $category;
if ($category->_getProperty('_languageUid')>0) {
$originalLangCategory = $this->categoryRepository->findOriginalLanguageById($category->getUid());
if ($originalLangCategory) {
$categoriesById[$originalLangCategory->getUid()] = $originalLangCategory;
}
}
}
$startTime = (int) $this->settings['starttime'];
......
......@@ -172,6 +172,13 @@ class OverviewController extends AbstractController {
$categoryId = $category->getUid();
$categoryIds[] = $category->getUid();
$categoriesById[$categoryId] = $category;
if ($category->_getProperty('_languageUid')>0) {
$originalLangCategory = $this->categoryRepository->findOriginalLanguageById($category->getUid());
if ($originalLangCategory) {
$categoryIds[] = $originalLangCategory->getUid();
$categoriesById[$originalLangCategory->getUid()] = $originalLangCategory;
}
}
$tagIds = NULL;
if ($newsFilter['tag']) {
......@@ -476,9 +483,15 @@ class OverviewController extends AbstractController {
/** @var QueryResult $categories */
foreach ($categories as $category) {
/** @var $category Category */
$categoryId = $category->getUid();
$categoryIds[] = $categoryId;
$categoriesById[$categoryId] = $category;
$categoriesById[$category->getUid()] = $category;
$categoryIds[] = $category->getUid();
if ($category->_getProperty('_languageUid')>0) {
$originalLangCategory = $this->categoryRepository->findOriginalLanguageById($category->getUid());
if ($originalLangCategory) {
$categoryIds[] = $originalLangCategory->getUid();
$categoriesById[$originalLangCategory->getUid()] = $originalLangCategory;
}
}
}
// filter by category and tag if selected in the filter
......
......@@ -2,32 +2,60 @@
namespace SGalinski\SgNews\Domain\Repository;
/***************************************************************
* 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!
***************************************************************/
/***************************************************************
* 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\SgNews\Domain\Model\Category;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper;
/**
* Category Repository
*/
class CategoryRepository extends AbstractRepository {
/**
* Find the original language category record
*
* @param int $uid
* @return Category|null
*/
public function findOriginalLanguageById(int $uid): ?Category {
$dataMapper = $this->objectManager->get(DataMapper::class);
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
$row = $queryBuilder->select('default.*')
->from('pages', 'translation')
->leftJoin('translation', 'pages', 'default', 'translation.l10n_parent=default.uid')
->where(
$queryBuilder->expr()->eq('translation.uid', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT))
)
->setMaxResults(1)
->execute()->fetch();
if ($row) {
return current($dataMapper->map($this->objectType, [$row]));
} else {
return NULL;
}
}
}
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