diff --git a/ChangeLog b/ChangeLog index 630e45ebc..b64d246c8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ ChangeLog +Upcoming verions +[FEATURE] Add pagination in the backend module "Indexed content" function and avoid out of memory error. https://github.com/tpwd/ke_search/issues/100 + Version 5.4.1, 19 April 2024 [BUGFIX] Always remove duplicates from tags, not only when a tag is set in the indexer configuration. https://github.com/tpwd/ke_search/issues/211 [BUGFIX] Fix TypeError after 'RemoveLock'. Thanks to Stephan Bauer. https://github.com/tpwd/ke_search/issues/223 diff --git a/Classes/Controller/BackendModuleController.php b/Classes/Controller/BackendModuleController.php index 7a4c664ec..c16bf9310 100644 --- a/Classes/Controller/BackendModuleController.php +++ b/Classes/Controller/BackendModuleController.php @@ -28,6 +28,7 @@ use Tpwd\KeSearch\Indexer\IndexerRunner; use Tpwd\KeSearch\Lib\Db; use Tpwd\KeSearch\Lib\SearchHelper; +use Tpwd\KeSearch\Pagination\SlidingWindowPagination as BackportedSlidingWindowPagination; use Tpwd\KeSearch\Service\IndexerStatusService; use TYPO3\CMS\Backend\Module\ModuleData; use TYPO3\CMS\Backend\Routing\UriBuilder; @@ -39,7 +40,7 @@ use TYPO3\CMS\Core\Information\Typo3Version; use TYPO3\CMS\Core\Page\PageRenderer; use TYPO3\CMS\Core\Pagination\ArrayPaginator; -use TYPO3\CMS\Core\Pagination\SimplePagination; +use TYPO3\CMS\Core\Pagination\SlidingWindowPagination; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; @@ -281,28 +282,23 @@ public function startIndexingAction(ServerRequestInterface $request, ModuleTempl */ public function indexedContentAction(ServerRequestInterface $request, ModuleTemplate $moduleTemplate): ResponseInterface { - $pagination = null; - $paginator = null; - $currentPageNumber = (int)($request->getQueryParams()['currentPageNumber'] ?? 1); - if ($this->pageId) { $perms_clause = $this->getBackendUser()->getPagePermsClause(1); $pageInfo = BackendUtility::readPageAccess($this->pageId, $perms_clause); - // page is selected: get indexed content - $content = '

Index content for PID ' . $this->pageId; - $content .= '' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.path') - . ': ' . GeneralUtility::fixed_lgd_cs($pageInfo['_thePath'], -50) . '

'; + $pagePath = GeneralUtility::fixed_lgd_cs($pageInfo['_thePath'], -200); + $indexRecords = $this->indexRepository->findByPageUidToShowIndexedContent($this->pageId); - $paginator = new ArrayPaginator($indexRecords, $currentPageNumber, 20); - $pagination = new SimplePagination($paginator); - } else { - // no page selected: show message - $content = '
' - . LocalizationUtility::translate( - 'LLL:EXT:ke_search/Resources/Private/Language/locallang_mod.xlf:select_a_page', - 'KeSearch' - ) - . '
'; + $currentPage = (int)($request->getQueryParams()['currentPage'] ?? 1); + $paginator = new ArrayPaginator($indexRecords, $currentPage, 20); + if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 12) { + $pagination = new BackportedSlidingWindowPagination($paginator, 15); + } else { + // PHPStan is complaining that the SlidingWindowPagination class does not exist in TYPO3 11, + // so we ignore this error for now + // Todo: Remove the PHPStan annotation below once support for TYPO3 11 is dropped + // @phpstan-ignore-next-line + $pagination = new SlidingWindowPagination($paginator, 15); + } } $this->addMainMenu($request, $moduleTemplate, 'indexedContent'); @@ -310,22 +306,28 @@ public function indexedContentAction(ServerRequestInterface $request, ModuleTemp if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 12) { $moduleTemplate->getView()->setTemplateRootPaths(['EXT:ke_search/Resources/Private/Templates/BackendModule']); $moduleTemplate->getView()->setLayoutRootPaths(['EXT:ke_search/Resources/Private/Layouts/']); + $moduleTemplate->getView()->setPartialRootPaths( + array_merge( + $moduleTemplate->getView()->getPartialRootPaths(), + ['EXT:ke_search/Resources/Private/Partials/'] + ) + ); $moduleTemplate->getView()->setTemplatePathAndFilename('EXT:ke_search/Resources/Private/Templates/BackendModule/IndexedContent.html'); - $moduleTemplate->getView()->assign('content', $content); - $moduleTemplate->getView()->assign('pagination', $pagination); - $moduleTemplate->getView()->assign('paginator', $paginator); - $moduleTemplate->getView()->assign('do', $this->do); - $moduleTemplate->getView()->assign('id', $this->pageId); - $moduleTemplate->getView()->assign('currentPageNumber', $currentPageNumber); + $moduleTemplate->getView()->assign('pagination', $pagination ?? null); + $moduleTemplate->getView()->assign('paginator', $paginator ?? null); + $moduleTemplate->getView()->assign('do', $this->do ?? ''); + $moduleTemplate->getView()->assign('pageId', $this->pageId ?? 0); + $moduleTemplate->getView()->assign('currentPage', $currentPage ?? 1); + $moduleTemplate->getView()->assign('pagePath', $pagePath ?? ''); // @extensionScannerIgnoreLine return new HtmlResponse($moduleTemplate->renderContent()); } - $moduleTemplate->assign('content', $content); - $moduleTemplate->assign('pagination', $pagination); - $moduleTemplate->assign('paginator', $paginator); - $moduleTemplate->assign('do', $this->do); - $moduleTemplate->assign('id', $this->pageId); - $moduleTemplate->assign('currentPageNumber', $currentPageNumber); + $moduleTemplate->assign('pagination', $pagination ?? null); + $moduleTemplate->assign('paginator', $paginator ?? null); + $moduleTemplate->assign('do', $this->do ?? ''); + $moduleTemplate->assign('pageId', $this->pageId ?? 0); + $moduleTemplate->assign('currentPage', $currentPage ?? 1); + $moduleTemplate->assign('pagePath', $pagePath ?? ''); return $moduleTemplate->renderResponse('BackendModule/IndexedContent'); } diff --git a/Classes/Domain/Repository/IndexRepository.php b/Classes/Domain/Repository/IndexRepository.php index d59d8244c..dca9940d2 100644 --- a/Classes/Domain/Repository/IndexRepository.php +++ b/Classes/Domain/Repository/IndexRepository.php @@ -296,5 +296,4 @@ public function findByPageUidToShowIndexedContent(int $pageUid) ->executeQuery() ->fetchAllAssociative(); } - } diff --git a/Classes/ViewHelpers/Count/WordsViewHelper.php b/Classes/ViewHelpers/Count/WordsViewHelper.php index f3809712b..5db98d553 100644 --- a/Classes/ViewHelpers/Count/WordsViewHelper.php +++ b/Classes/ViewHelpers/Count/WordsViewHelper.php @@ -1,4 +1,5 @@ + + + + diff --git a/Resources/Private/Templates/BackendModule/IndexedContent.html b/Resources/Private/Templates/BackendModule/IndexedContent.html index ebe563ccd..b09251fc1 100644 --- a/Resources/Private/Templates/BackendModule/IndexedContent.html +++ b/Resources/Private/Templates/BackendModule/IndexedContent.html @@ -1,7 +1,5 @@ @@ -9,99 +7,97 @@
-

Show Indexed Content

- {content} - - Records {paginator.keyOfFirstPaginatedItem + 1} - {paginator.keyOfLastPaginatedItem + 1} -
    - -
  • - - - {page} - {page} - - -
  • -
    -
-
-
- - - - - - - - - - - - - + + +

Indexed Content

+
Page ID {pageId}: {pagePath}
+ + + +
+
TitleTypeLanguageWordsCreatedModifiedTags
+ + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + + + + +
TitleTypeLanguageWordsCreatedModifiedTags
{record.title}{record.type}{record.language}{record.content}{record.crdate}{record.tstamp} + {tag} +
{record.title}{record.type}{record.language}{record.content}{record.crdate}{record.tstamp} - {tag} -
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Original PIDOriginal UIDFE GroupSort DateStart DateEnd DateTarget PageURL Params
{record.orig_pid}{record.orig_uid}{record.fe_group}{record.sortdate}{record.starttime}{record.endtime}{record.targetpid}{record.params}
+ +

Abstract

+ {record.abstract} +
+ +

Content

+ {record.content} +
+ +

Hidden content

+ {record.hidden_content} +
+
+
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Original PIDOriginal UIDFE GroupSort DateStart DateEnd DateTarget PageURL Params
{record.orig_pid}{record.orig_uid}{record.fe_group}{record.sortdate}{record.starttime}{record.endtime}{record.targetpid}{record.params}
- -

Abstract

- {record.abstract} -
- -

Content

- {record.content} -
- -

Hidden content

- {record.hidden_content} -
-
- - - - -
+ + +
+ Please select a page. +
+
+