From c659cbe58780fbd3322ae25f3e5ef7c98fbd67f7 Mon Sep 17 00:00:00 2001 From: Torben Hansen Date: Sat, 30 Nov 2024 12:11:41 +0100 Subject: [PATCH] [FEATURE] Add recursive folder filter option in admin module #1299 --- .../Controller/AdministrationController.php | 58 ++++++++++++++++--- Resources/Private/Language/locallang_be.xlf | 19 ++++++ .../Templates/Administration/List.html | 30 +++++----- Resources/Public/Css/administration.css | 8 +++ 4 files changed, 92 insertions(+), 23 deletions(-) diff --git a/Classes/Controller/AdministrationController.php b/Classes/Controller/AdministrationController.php index 908837983..684ac3fcd 100644 --- a/Classes/Controller/AdministrationController.php +++ b/Classes/Controller/AdministrationController.php @@ -23,6 +23,7 @@ use DERHANSEN\SfEventMgt\Service\ExportService; use DERHANSEN\SfEventMgt\Service\MaintenanceService; use DERHANSEN\SfEventMgt\Service\SettingsService; +use DERHANSEN\SfEventMgt\Utility\PageUtility; use Psr\Http\Message\ResponseInterface; use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Backend\Template\Components\ButtonBar; @@ -258,18 +259,19 @@ public function listAction(?SearchDemand $searchDemand = null, array $overwriteD ]; } - $eventDemand = GeneralUtility::makeInstance(EventDemand::class); - $eventDemand = $this->overwriteEventDemandObject($eventDemand, $overwriteDemand); - $eventDemand->setOrderFieldAllowed($this->settings['orderFieldAllowed'] ?? ''); - $eventDemand->setSearchDemand($searchDemand); - $eventDemand->setStoragePage((string)$this->pid); - $eventDemand->setIgnoreEnableFields(true); - $events = []; $pagination = null; - if ($this->getBackendUser()->isInWebMount($this->pid) && + $pageUids = $this->resolveSearchPageUids((int)($overwriteDemand['recursive'] ?? 0)); + if ($pageUids !== '' && $this->getBackendUser()->check('tables_select', 'tx_sfeventmgt_domain_model_event') ) { + $eventDemand = GeneralUtility::makeInstance(EventDemand::class); + $eventDemand = $this->overwriteEventDemandObject($eventDemand, $overwriteDemand); + $eventDemand->setOrderFieldAllowed($this->settings['orderFieldAllowed'] ?? ''); + $eventDemand->setSearchDemand($searchDemand); + $eventDemand->setIgnoreEnableFields(true); + $eventDemand->setStoragePage($pageUids); + $events = $this->eventRepository->findDemanded($eventDemand); $pagination = $this->getPagination($events, $this->settings['pagination'] ?? []); } @@ -281,6 +283,7 @@ public function listAction(?SearchDemand $searchDemand = null, array $overwriteD 'searchDemand' => $searchDemand, 'orderByFields' => $this->getOrderByFields(), 'orderDirections' => $this->getOrderDirections(), + 'recursiveLevels' => $this->getRecursiveLevels(), 'overwriteDemand' => $overwriteDemand, 'pagination' => $pagination, ], @@ -293,6 +296,30 @@ public function listAction(?SearchDemand $searchDemand = null, array $overwriteD return $this->initModuleTemplateAndReturnResponse('Administration/List', $variables); } + /** + * Resolves the page UIDs to search in respecting the given recursive option and additionally checking, if + * the current backend user is allowed to affected pages + */ + private function resolveSearchPageUids(int $recursive): string + { + $extendedPageUids = PageUtility::extendPidListByChildren( + (string)$this->pid, + $recursive + ); + $extendedPageUids = GeneralUtility::intExplode(',', $extendedPageUids, true); + + $pageUids = []; + foreach ($extendedPageUids as $extendedPageUid) { + if (!in_array($extendedPageUid, $pageUids, true) && + $this->getBackendUser()->isInWebMount($extendedPageUid) + ) { + $pageUids[] = $extendedPageUid; + } + } + + return implode(',', $pageUids); + } + /** * Returns, if reset filter operation has been used */ @@ -478,6 +505,21 @@ public function getOrderDirections(): array ]; } + /** + * Returns an array with possible recursive levels + */ + public function getRecursiveLevels(): array + { + return [ + $this->getLanguageService()->sL(self::LANG_FILE . 'administration.recursiveLevel.current'), + $this->getLanguageService()->sL(self::LANG_FILE . 'administration.recursiveLevel.level1'), + $this->getLanguageService()->sL(self::LANG_FILE . 'administration.recursiveLevel.level2'), + $this->getLanguageService()->sL(self::LANG_FILE . 'administration.recursiveLevel.level3'), + $this->getLanguageService()->sL(self::LANG_FILE . 'administration.recursiveLevel.level4'), + $this->getLanguageService()->sL(self::LANG_FILE . 'administration.recursiveLevel.level5'), + ]; + } + /** * Returns an array with possible orderBy fields */ diff --git a/Resources/Private/Language/locallang_be.xlf b/Resources/Private/Language/locallang_be.xlf index 017f6e849..21ceaf82c 100644 --- a/Resources/Private/Language/locallang_be.xlf +++ b/Resources/Private/Language/locallang_be.xlf @@ -498,6 +498,25 @@ Records + + Current folder + + + 1 level down + + + 2 levels down + + + 3 levels down + + + 4 levels down + + + 5 levels down + + Time Restriction diff --git a/Resources/Private/Templates/Administration/List.html b/Resources/Private/Templates/Administration/List.html index fbe28cac8..29e0c7b1d 100644 --- a/Resources/Private/Templates/Administration/List.html +++ b/Resources/Private/Templates/Administration/List.html @@ -11,26 +11,26 @@

-
-
+
+
- -
-
+
-
+
-
+
-
+
-
+
- -
-
- +
+ + +
-
+
{f:translate(key:'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:search')} Reset
diff --git a/Resources/Public/Css/administration.css b/Resources/Public/Css/administration.css index b87c06ec1..36afaa505 100644 --- a/Resources/Public/Css/administration.css +++ b/Resources/Public/Css/administration.css @@ -27,6 +27,14 @@ tr.db_list_normal td.logdate { text-decoration: none; } +select.recursiveLevel { + max-width: 140px; +} + +.date-field { + max-width: 200px; +} + /** * Action Buttons */