From 3d71ea3052ac7fae42d88887041ccbaa45324982 Mon Sep 17 00:00:00 2001 From: Torben Freudewald Date: Wed, 21 Aug 2024 16:03:42 +0200 Subject: [PATCH] [TASK] Add plugin for selected projects --- Classes/Controller/ProjectController.php | 10 ++++------ Classes/Domain/Repository/ProjectRepository.php | 6 +++++- Configuration/TCA/Overrides/tt_content.php | 12 ++++++++++++ .../Page/Mod/Wizards/NewContentElement.tsconfig | 13 +++++++++++-- Resources/Private/Language/de.locallang_db.xlf | 8 ++++++++ Resources/Private/Language/locallang_db.xlf | 6 ++++++ ext_localconf.php | 10 ++++++++++ 7 files changed, 56 insertions(+), 9 deletions(-) diff --git a/Classes/Controller/ProjectController.php b/Classes/Controller/ProjectController.php index f3e210b..8694f1b 100644 --- a/Classes/Controller/ProjectController.php +++ b/Classes/Controller/ProjectController.php @@ -31,12 +31,10 @@ public function listAction(?ProjectFilter $filter = null): ResponseInterface $projects = $this->projectRepository->findByFilter( $filter, - GeneralUtility::intExplode( - ',', - $this->configurationManager->getContentObject() - ? $this->configurationManager->getContentObject()->data['pages'] - : [] - ) + $this->configurationManager->getContentObject()->data['pages'] !== '' + ? GeneralUtility::intExplode(',', $this->configurationManager->getContentObject()->data['pages']) + : [], + $this->configurationManager->getContentObject()->data['list_type'] === 'academicprojects_projectlistsingle' ? true : false ); $categories =$this->categoryRepository->findAllApplicable($projects); diff --git a/Classes/Domain/Repository/ProjectRepository.php b/Classes/Domain/Repository/ProjectRepository.php index 2276717..2b2b5bc 100644 --- a/Classes/Domain/Repository/ProjectRepository.php +++ b/Classes/Domain/Repository/ProjectRepository.php @@ -19,7 +19,8 @@ class ProjectRepository extends Repository */ public function findByFilter( ?ProjectFilter $filter = null, - array $pages = [] + array $pages = [], + bool $selected = false ): QueryResult { $query = $this->createQuery(); @@ -35,6 +36,9 @@ public function findByFilter( } } } + if ($selected && !empty($pages)) { + $constraints[] = $query->in('uid', $pages); + } $query->matching( $query->logicalAnd($constraints) diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index 19f5634..60ddc27 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -13,12 +13,24 @@ $ll('tx_academic_projects_p1.name'), 'actions-code-merge' ); + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin( + 'AcademicProjects', + 'ProjectListSingle', + $ll('tx_academic_projects_p2.name'), + 'actions-code-merge' + ); $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['academicprojects_projectlist'] = 'layout,recursive'; $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['academicprojects_projectlist'] = 'pi_flexform'; + $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['academicprojects_projectlistsingle'] = 'layout,recursive'; + $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['academicprojects_projectlistsingle'] = 'pi_flexform'; \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue( 'academicprojects_projectlist', 'FILE:EXT:academic_projects/Configuration/FlexForms/ProjectSettings.xml' ); + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue( + 'academicprojects_projectlistsingle', + 'FILE:EXT:academic_projects/Configuration/FlexForms/ProjectSettings.xml' + ); })(); diff --git a/Configuration/TsConfig/Page/Mod/Wizards/NewContentElement.tsconfig b/Configuration/TsConfig/Page/Mod/Wizards/NewContentElement.tsconfig index 251ddba..1c770fb 100644 --- a/Configuration/TsConfig/Page/Mod/Wizards/NewContentElement.tsconfig +++ b/Configuration/TsConfig/Page/Mod/Wizards/NewContentElement.tsconfig @@ -12,7 +12,16 @@ mod.wizards { list_type = academicprojects_projectlist } } + academicprojects_projectlistsingle { + iconIdentifier = actions-code-merge + title = LLL:EXT:academic_projects/Resources/Private/Language/locallang_db.xlf:tx_academic_projects_p2.name + description = LLL:EXT:academic_projects/Resources/Private/Language/locallang_db.xlf:tx_academic_projects_p2.description + tt_content_defValues { + CType = list + list_type = academicprojects_projectlistsingle + } + } } - show := addToList(academicprojects_projectlist) + show := addToList(academicprojects_projectlist, academicprojects_projectlistsingle) } -} \ No newline at end of file +} diff --git a/Resources/Private/Language/de.locallang_db.xlf b/Resources/Private/Language/de.locallang_db.xlf index d4f749a..5ea7546 100644 --- a/Resources/Private/Language/de.locallang_db.xlf +++ b/Resources/Private/Language/de.locallang_db.xlf @@ -41,6 +41,14 @@ List of academic projects with sorting and filtering Liste akademischer Projekte mit Sortierung und Filterung + + Academic Projects (selected) + Akademische Projekte (ausgewählte) + + + List of selected academic projects with sorting and filtering + Liste ausgewählter akademischer Projekte mit Sortierung und Filterung + Academic Akademisch diff --git a/Resources/Private/Language/locallang_db.xlf b/Resources/Private/Language/locallang_db.xlf index aac5212..80112c2 100644 --- a/Resources/Private/Language/locallang_db.xlf +++ b/Resources/Private/Language/locallang_db.xlf @@ -32,6 +32,12 @@ List of academic projects with sorting and filtering + + Academic Projects (selected) + + + List of selected academic projects with sorting and filtering + Academic diff --git a/ext_localconf.php b/ext_localconf.php index deff68b..2306239 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -25,4 +25,14 @@ \FGTCLB\AcademicProjects\Controller\ProjectController::class => 'list', ] ); + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( + 'AcademicProjects', + 'ProjectListSingle', + [ + \FGTCLB\AcademicProjects\Controller\ProjectController::class => 'list', + ], + [ + \FGTCLB\AcademicProjects\Controller\ProjectController::class => 'list', + ] + ); })();