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

[TASK] ECS

parent 06314387
No related branches found
No related tags found
1 merge request!38Feature upgrade to typo3 11
Showing
with 107 additions and 77 deletions
......@@ -110,10 +110,8 @@ class BackendController extends ActionController {
if ($this->pageInfo) {
if (version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '11.0.0', '<')) {
$this->docHeaderComponent = GeneralUtility::makeInstance(DocHeaderComponent::class);
}
else {
} else {
$this->getDocHeaderComponent();
}
if ($this->pageUid) {
$this->rootPageUid = BackendNewsUtility::getRootUidByPageUid($this->pageUid);
......@@ -190,10 +188,10 @@ class BackendController extends ActionController {
$this->view->assign('showNewsList', $showNewsList);
if (version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '11.0.0', '<')) {
$this->view->assign('V11', false);
$this->view->assign('V11', FALSE);
return NULL;
} else {
$this->view->assign('V11', true);
$this->view->assign('V11', TRUE);
return $this->createBackendResponse();
}
}
......
......@@ -70,7 +70,8 @@ class OverviewController extends AbstractController {
/**
* @param CategoryRepository $categoryRepository
*/
public function injectCategoryRepository(CategoryRepository $categoryRepository
public function injectCategoryRepository(
CategoryRepository $categoryRepository
) {
$this->categoryRepository = $categoryRepository;
}
......@@ -122,14 +123,15 @@ class OverviewController extends AbstractController {
public function overviewAction(array $newsFilter = [], int $currentPageBrowserPage = 0): ?\Psr\Http\Message\ResponseInterface {
if ((int) $this->settings['groupBy'] === 0 && (bool) $this->settings['enableFilter'] === FALSE) {
if (version_compare(
\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '11.0.0', '<'
\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(),
'11.0.0',
'<'
)) {
$this->forward('overviewWithoutCategories', NULL, NULL, $this->request->getArguments());
}
else {
} else {
return (new \TYPO3\CMS\Extbase\Http\ForwardResponse(
'overviewWithoutCategories'
))
))
->withArguments($this->request->getArguments());
}
}
......@@ -144,9 +146,9 @@ class OverviewController extends AbstractController {
$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'] ?? false);
$isCategoryFiltered = $useAllFilters || $this->settings['groupBy'] === 1 ? 1: 0;
$isTagFiltered = $useAllFilters || $this->settings['groupBy'] === 2 ? 1: 0;
$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);
......@@ -156,7 +158,7 @@ class OverviewController extends AbstractController {
$tagPid = $GLOBALS['TSFE']->id;
}
if ($this->settings['onlyNewsWithinThisPageSection'] ?? false) {
if ($this->settings['onlyNewsWithinThisPageSection'] ?? FALSE) {
$categories = $this->categoryRepository->findCategoriesInRootLine($GLOBALS['TSFE']->id);
$tags = $this->tagRepository->findTagsInRootLine($tagPid);
} else {
......@@ -205,7 +207,7 @@ class OverviewController extends AbstractController {
// Get category ids or use the one in the filter
$categoryIds = [];
if ($newsFilter['category'] ?? false) {
if ($newsFilter['category'] ?? FALSE) {
$categoryIds = [(int) $newsFilter['category']];
} elseif ($isCategoryFiltered) {
foreach ($categories as $category) {
......@@ -217,7 +219,7 @@ class OverviewController extends AbstractController {
// Get tag ids or use the one in the filter
$tagIds = [];
if ($newsFilter['tag'] ?? false) {
if ($newsFilter['tag'] ?? FALSE) {
$tagIds = [(int) $newsFilter['tag']];
} elseif ($isTagFiltered) {
foreach ($tags as $tag) {
......@@ -229,7 +231,14 @@ class OverviewController extends AbstractController {
// Get all news by category and tag ids
$news = $this->newsRepository->findAllSortedNewsByCategories(
$categoryIds, $newsLimit, $offset, $sortBy, $tagIds, $startTime, $endTime, $sortDirection
$categoryIds,
$newsLimit,
$offset,
$sortBy,
$tagIds,
$startTime,
$endTime,
$sortDirection
);
// Process news result query based on filters
......@@ -239,8 +248,8 @@ class OverviewController extends AbstractController {
foreach ($news as $newsEntry) {
/** @var News $newsEntry */
$newsCategory = $this->categoryRepository->findOriginalLanguageById(
$newsEntry->getPid()
) ?? $this->categoryRepository->findByUid($newsEntry->getPid());
$newsEntry->getPid()
) ?? $this->categoryRepository->findByUid($newsEntry->getPid());
$newsCategoryId = $newsCategory->getUid();
$newsMetaData = $this->newsService->getMetaDataForNews($newsEntry, $newsCategory);
......@@ -350,10 +359,13 @@ class OverviewController extends AbstractController {
switch ($columnAmount) {
case 4:
$columnClasses .= 'col-lg-3 ';
// no break
case 3:
$columnClasses .= 'col-md-4 ';
// no break
case 2:
$columnClasses .= 'col-sm-6 ';
// no break
default:
$columnClasses .= 'col-xs-12';
}
......@@ -375,7 +387,15 @@ class OverviewController extends AbstractController {
/** @var News $highlightedNews */
$highlightedNews = $this->newsRepository
->findLastUpdatedOrHighlightedNewsByCategories(
1, FALSE, $categoryIds, 0, FALSE, $this->settings['sortBy'], $tagIds, $startTime, $endTime
1,
FALSE,
$categoryIds,
0,
FALSE,
$this->settings['sortBy'],
$tagIds,
$startTime,
$endTime
)->getFirst();
if (!$highlightedNews) {
return;
......@@ -387,7 +407,6 @@ class OverviewController extends AbstractController {
if ($category) {
$highlightedNewsMetaData = $this->newsService->getMetaDataForNews($highlightedNews, $category);
}
}
/**
......@@ -415,7 +434,9 @@ class OverviewController extends AbstractController {
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
*/
protected function overviewWithoutCategoriesAction(
array $newsMetaData = [], array $newsFilter = NULL, int $currentPageBrowserPage = 0
array $newsMetaData = [],
array $newsFilter = NULL,
int $currentPageBrowserPage = 0
) {
// remember selection of the filter values, if any
$selectedTag = $this->tagRepository->findByUid((int) $newsFilter['tag']);
......@@ -493,7 +514,14 @@ class OverviewController extends AbstractController {
}
$news = $this->newsRepository->findAllSortedNewsByCategories(
$categoryIds, $newsPerPage, $offset, $sortBy, $tagIds, $startTime, $endTime, $sortDirection
$categoryIds,
$newsPerPage,
$offset,
$sortBy,
$tagIds,
$startTime,
$endTime,
$sortDirection
);
foreach ($news as $newsEntry) {
/** @var News $newsEntry */
......
......@@ -77,7 +77,9 @@ class SingleViewController extends AbstractController {
$news = $this->newsRepository->findByUid($currentId);
if (!$news) {
if (version_compare(
\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '11.0.0', '<'
\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(),
'11.0.0',
'<'
)) {
return NULL;
} else {
......@@ -89,7 +91,9 @@ class SingleViewController extends AbstractController {
$newsCategory = $this->categoryRepository->findByUid($news->getPid());
if (!$newsCategory) {
if (version_compare(
\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '11.0.0', '<'
\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(),
'11.0.0',
'<'
)) {
return NULL;
} else {
......
......@@ -581,9 +581,9 @@ class NewsRepository extends AbstractRepository {
// Here we fetch the lastUpdated of the $limit amount of news with older lastUpdated dates
$result = $qb->where(
$qb->expr()->eq('doktype', $qb->createNamedParameter(News::DOK_TYPE_NEWS, Connection::PARAM_INT)),
$qb->expr()->lte('lastUpdated', $news->getLastUpdated()->getTimestamp())
)->andWhere(...$constraints)
$qb->expr()->eq('doktype', $qb->createNamedParameter(News::DOK_TYPE_NEWS, Connection::PARAM_INT)),
$qb->expr()->lte('lastUpdated', $news->getLastUpdated()->getTimestamp())
)->andWhere(...$constraints)
->orderBy('lastUpdated', 'asc')
->execute();
$oldest = $result->fetchOne();
......
......@@ -28,10 +28,10 @@ namespace SGalinski\SgNews\Domain\Service;
use SGalinski\SgNews\Domain\Model\Category;
use SGalinski\SgNews\Domain\Model\News;
use TYPO3\CMS\Core\Resource\FileRepository;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
use TYPO3\CMS\Core\Resource\FileRepository;
/**
* This service takes care of meta data generation for the news objects
......
......@@ -45,7 +45,7 @@ class PageLayoutController {
* @return string
* @throws \InvalidArgumentException
*/
public function addNewsModuleLink(array $parameters = [], CorePageLayoutController $controller = null): string {
public function addNewsModuleLink(array $parameters = [], CorePageLayoutController $controller = NULL): string {
$out = '';
$pageRow = BackendUtility::getRecord('pages', $controller->id);
$acceptedDoktypes = [BackendNewsUtility::NEWS_DOKTYPE, BackendNewsUtility::CATEGORY_DOKTYPE];
......
......@@ -35,7 +35,6 @@ use TYPO3\CMS\Fluid\View\StandaloneView;
* @package SGalinski\SgNews\Hook\PagelayoutView\PluginRenderer
*/
class PluginRenderer implements PageLayoutViewDrawItemHookInterface {
protected PreviewService $previewService;
public function init() {
......@@ -112,9 +111,9 @@ class PluginRenderer implements PageLayoutViewDrawItemHookInterface {
*/
protected function adaptPluginHeaderContent(&$headerContent, $row): void {
$headerContent = '<h4>' . $this->getPluginNameForHeaderContent(
(int) $row['pid'],
$row['list_type']
) . $headerContent . '</h4>';
(int) $row['pid'],
$row['list_type']
) . $headerContent . '</h4>';
}
/**
......
......@@ -74,16 +74,15 @@ final class QueryBuilderPaginator extends AbstractPaginator {
->setFirstResult(0)
->count('uid')
->execute()->fetchOne();
}
catch (\Exception $e){
} catch (\Exception $e) {
$totalItems = $countBuilder
->setMaxResults(99999)
->setFirstResult(0)
->count('p.uid')
->execute()->fetchOne();
}
$this->setTotalItems($totalItems ?: 0);
return $totalItems ?: 0;
$this->setTotalItems($totalItems ?: 0);
return $totalItems ?: 0;
}
protected function getAmountOfItemsOnCurrentPage(): int {
......
......@@ -115,5 +115,4 @@ class PreviewRenderer implements PreviewRendererInterface {
public function wrapPageModulePreview(string $previewHeader, string $previewContent, GridColumnItem $item): string {
return $previewHeader . $previewContent;
}
}
......@@ -27,7 +27,6 @@ use TYPO3\CMS\Fluid\View\StandaloneView;
* small helper class, aslong as we use PageLayout hook + Previewrenderer....
*/
class PreviewService {
public const RETURNTYPE_ARR = 'array';
/**
......@@ -118,7 +117,7 @@ class PreviewService {
$categories = $this->passVDefOnKeyToTemplate($pluginConfiguration, 'settings.categories');
$tags = $this->passVDefOnKeyToTemplate($pluginConfiguration, 'settings.tags');
$templateData = [
'newsLimitPerPage' =>$this->passVDefOnKeyToTemplate($pluginConfiguration, 'settings.newsLimitPerPage'),
'newsLimitPerPage' => $this->passVDefOnKeyToTemplate($pluginConfiguration, 'settings.newsLimitPerPage'),
'categories' => is_string($categories) ? $this->addFieldContentsToRecordIdList(
'pages',
$categories
......@@ -145,7 +144,6 @@ class PreviewService {
* @return StandaloneView
*/
public function getNewsByAuthorView(array $row): StandaloneView {
$view = $this->createViewWithTemplate('NewsByAuthor');
$view->assign('uid', $row['uid']);
......@@ -174,10 +172,10 @@ class PreviewService {
$excludedNewsListWithTitles = [];
foreach ($excludedNewsIds as $excludedNewsId) {
$excludedNewsListWithTitles[] = BackendUtility::getRecord(
'pages',
$excludedNewsId,
'title'
)['title'] . ' [' . $excludedNewsId . ']';
'pages',
$excludedNewsId,
'title'
)['title'] . ' [' . $excludedNewsId . ']';
}
$templateData['excludedNews'] = $excludedNewsListWithTitles;
......@@ -192,12 +190,12 @@ class PreviewService {
* @return array|mixed|string
*/
private function passVDefOnKeyToTemplate(array $conf, string $key, string $returnType = '') {
if(isset($conf[$key])) {
if (isset($conf[$key])) {
return $conf[$key]['vDEF'];
}
// check if we got a possible returntype:
if($returnType === self::RETURNTYPE_ARR) {
if ($returnType === self::RETURNTYPE_ARR) {
return [];
}
......@@ -242,10 +240,10 @@ class PreviewService {
foreach ($recordIdsArray as $recordId) {
$recordsWithTitlesArray[] = BackendUtility::getRecord(
$table,
$recordId,
$field
)[$field] . ' [' . $recordId . ']';
$table,
$recordId,
$field
)[$field] . ' [' . $recordId . ']';
}
return implode(', ', $recordsWithTitlesArray);
}
......
......@@ -81,6 +81,5 @@ class HeaderMetaDataService {
'&tx_sgnews_pagebrowser[currentPage]=' . $currentPage
);
$headTagService->execute();
}
}
......@@ -447,7 +447,7 @@ class BackendNewsUtility {
)
);
}
if($limit > 0){
if ($limit > 0) {
$queryBuilder->setMaxResults($limit);
}
......
......@@ -68,8 +68,7 @@ class ControlViewHelper extends AbstractViewHelper {
if ($table === 'pages') {
if (version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '11.0.0', '<')) {
$databaseRecordList->searchlevels = 1;
}
else {
} else {
// searchLevels is Init with 0 and can only be set by using ->start
$databaseRecordList->start($row['uid'], $table, 0, '', 1, 1);
}
......@@ -79,8 +78,7 @@ class ControlViewHelper extends AbstractViewHelper {
$pageInfo = BackendUtility::readPageAccess($row['pid'], $backendUser->getPagePermsClause(1));
if (version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '11.0.0', '<')) {
$databaseRecordList->calcPerms = $GLOBALS['BE_USER']->calcPerms($pageInfo);
}
else {
} else {
$databaseRecordList->calcPerms = new \TYPO3\CMS\Core\Type\Bitmask\Permission($GLOBALS['BE_USER']->calcPerms($pageInfo));
}
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
......
......@@ -19,7 +19,7 @@ class RelatedViewHelper extends AbstractViewHelper {
/**
* @var bool
*/
protected $escapeOutput = false;
protected $escapeOutput = FALSE;
/**
* Initialize the view helper arguments
......@@ -45,7 +45,8 @@ class RelatedViewHelper extends AbstractViewHelper {
TRUE
);
$this->registerArgument(
'iteration', 'string',
'iteration',
'string',
'The name of the variable to store iteration information (index, cycle, isFirst, isLast, isEven, isOdd)'
);
$this->registerArgument(
......@@ -68,7 +69,9 @@ class RelatedViewHelper extends AbstractViewHelper {
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
*/
public static function renderStatic(
array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
) {
$newsService = GeneralUtility::makeInstance(NewsService::class);
$categoryRepository = GeneralUtility::makeInstance(CategoryRepository::class);
......
<?php
defined('TYPO3') or die();
/**
*
......@@ -105,7 +106,7 @@ $GLOBALS['TCA']['pages']['types'][\SGalinski\SgNews\Utility\BackendNewsUtility::
--palette--;;media,
--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.metadata,
--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.abstract;abstract,
seo_title,canonical_link, ' . (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('yoast_seo') || \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('seo') ? '':'description,') . '
seo_title,canonical_link, ' . (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('yoast_seo') || \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('seo') ? '' : 'description,') . '
--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.appearance,
--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.layout;layout,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,
......@@ -399,7 +400,7 @@ $GLOBALS['TCA']['pages']['types'][\SGalinski\SgNews\Utility\BackendNewsUtility::
$GLOBALS['TCA']['pages']['palettes']['titleDescriptionAndHighlightFlag'] = [
'showitem' => 'subtitle;' . $localLangDbPath . 'pages.subtitle.inPalette,
--linebreak--, title,
' . (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('yoast_seo') || \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('seo') ? '':'--linebreak--, description,') . '
' . (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('yoast_seo') || \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('seo') ? '' : '--linebreak--, description,') . '
--linebreak--, slug,
--linebreak--, tx_projectbase_path_segment, tx_projectbase_excludefromsluggeneration,
--linebreak--, tx_realurl_pathsegment, tx_realurl_exclude,
......
<?php
defined('TYPO3') or die();
/**
*
......
<?php
defined('TYPO3') or die();
/**
*
......
<?php
defined('TYPO3') or die();
/**
*
......@@ -36,50 +37,50 @@ call_user_func(
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'SgNews',
'Overview',
[\SGalinski\SgNews\Controller\OverviewController::class => 'overview',],
[\SGalinski\SgNews\Controller\OverviewController::class => 'overview',]
[\SGalinski\SgNews\Controller\OverviewController::class => 'overview', ],
[\SGalinski\SgNews\Controller\OverviewController::class => 'overview', ]
);
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'SgNews',
'ListByCategory',
[\SGalinski\SgNews\Controller\ListByCategoryController::class => 'index',],
[\SGalinski\SgNews\Controller\ListByCategoryController::class => '',]
[\SGalinski\SgNews\Controller\ListByCategoryController::class => 'index', ],
[\SGalinski\SgNews\Controller\ListByCategoryController::class => '', ]
);
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'SgNews',
'SingleView',
[\SGalinski\SgNews\Controller\SingleViewController::class => 'singleView',],
[\SGalinski\SgNews\Controller\SingleViewController::class => '',]
[\SGalinski\SgNews\Controller\SingleViewController::class => 'singleView', ],
[\SGalinski\SgNews\Controller\SingleViewController::class => '', ]
);
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'SgNews',
'NewsFeed',
[\SGalinski\SgNews\Controller\NewsFeedController::class => 'index',],
[\SGalinski\SgNews\Controller\NewsFeedController::class => '',]
[\SGalinski\SgNews\Controller\NewsFeedController::class => 'index', ],
[\SGalinski\SgNews\Controller\NewsFeedController::class => '', ]
);
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'SgNews',
'Latest',
[\SGalinski\SgNews\Controller\LatestController::class => 'index',],
[\SGalinski\SgNews\Controller\LatestController::class => '',]
[\SGalinski\SgNews\Controller\LatestController::class => 'index', ],
[\SGalinski\SgNews\Controller\LatestController::class => '', ]
);
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'SgNews',
'ListByCategory',
[\SGalinski\SgNews\Controller\ListByCategoryController::class => 'index',],
[\SGalinski\SgNews\Controller\ListByCategoryController::class => '',]
[\SGalinski\SgNews\Controller\ListByCategoryController::class => 'index', ],
[\SGalinski\SgNews\Controller\ListByCategoryController::class => '', ]
);
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'SgNews',
'NewsByAuthor',
[\SGalinski\SgNews\Controller\NewsByAuthorController::class => 'list',],
[\SGalinski\SgNews\Controller\NewsByAuthorController::class => '',]
[\SGalinski\SgNews\Controller\NewsByAuthorController::class => 'list', ],
[\SGalinski\SgNews\Controller\NewsByAuthorController::class => '', ]
);
if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('sg_ajax')) {
......
<?php
defined('TYPO3') or die();
/**
*
......
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