Skip to content

Commit

Permalink
[TASK] Remove obsolete code for TYPO3 11 and below
Browse files Browse the repository at this point in the history
  • Loading branch information
christianbltr committed Sep 27, 2024
1 parent acb5243 commit 161835b
Show file tree
Hide file tree
Showing 16 changed files with 183 additions and 799 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Upcoming version for TYPO3 13
[TASK] Don't use QueryBuilder->add() anymore because it has been removed, https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/13.0/Breaking-102875-QueryBuilderChanges.html
[TASK] Remove language-related function from AbstractPlugin and use custom translate function instead
[TASK] Migrate database queries to use type constants from Connection instead of PDO, https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Database/QueryBuilder/Index.html#database-query-builder-create-named-parameter
[TASK] Remove obsolete code for TYPO3 11 and below

Version 5.5.2, 23 August 2024
[BUGFIX] Fix cropping if "resultChars" is empty. Thanks to Andreas Kießling. https://github.com/tpwd/ke_search/issues/242
Expand Down
119 changes: 7 additions & 112 deletions Classes/Controller/BackendModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
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 Tpwd\KeSearch\Utility\SanityCheckUtility;
use TYPO3\CMS\Backend\Module\ModuleData;
Expand All @@ -38,8 +37,6 @@
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Http\HtmlResponse;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Pagination\ArrayPaginator;
use TYPO3\CMS\Core\Pagination\SlidingWindowPagination;
Expand Down Expand Up @@ -79,18 +76,10 @@ public function __invoke(ServerRequestInterface $request): ResponseInterface
$this->pageId = (int)($request->getQueryParams()['id'] ?? 0);
$this->do = $request->getQueryParams()['do'] ?? null;
$backendUser = $this->getBackendUser();
$function = 'function1';

if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() > 11) {
/** @var ModuleData $moduleData */
$moduleData = $request->getAttribute('moduleData');
$function = $moduleData->get('function', 'function1');
} else {
$moduleData = $backendUser->getModuleData('web_KeSearchBackendModule');
if ($moduleData['function'] ?? '') {
$function = $moduleData['function'];
}
}
/** @var ModuleData $moduleData */
$moduleData = $request->getAttribute('moduleData');
$function = $moduleData->get('function', 'function1');

if ($this->do) {
switch ($this->do) {
Expand All @@ -106,15 +95,8 @@ public function __invoke(ServerRequestInterface $request): ResponseInterface
$function = 'function5';
break;
}
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() > 11) {
$moduleData->set('function', $function);
$backendUser->pushModuleData($moduleData->getModuleIdentifier(), $moduleData->toArray());
} else {
$moduleData = [
'function' => $function,
];
$backendUser->pushModuleData('web_KeSearchBackendModule', $moduleData);
}
$moduleData->set('function', $function);
$backendUser->pushModuleData($moduleData->getModuleIdentifier(), $moduleData->toArray());
}

switch ($function) {
Expand Down Expand Up @@ -142,13 +124,7 @@ public function startIndexingAction(ServerRequestInterface $request, ModuleTempl
$indexer = GeneralUtility::makeInstance(IndexerRunner::class);
$indexerConfigurations = $indexer->getConfigurations();
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);

if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 12) {
$this->pageRenderer->addJsFile('EXT:ke_search/Resources/Public/JavaScript/v11/getIndexerStatusRequest.js');
} else {
// @phpstan-ignore-next-line
$this->pageRenderer->loadJavaScriptModule('@tpwd/ke-search/getIndexerStatusRequest.js');
}
$this->pageRenderer->loadJavaScriptModule('@tpwd/ke-search/getIndexerStatusRequest.js');

$indexingMode = (int)($request->getQueryParams()['indexingMode'] ?? IndexerBase::INDEXING_MODE_FULL);
if (!in_array($indexingMode, [IndexerBase::INDEXING_MODE_INCREMENTAL, IndexerBase::INDEXING_MODE_FULL])) {
Expand Down Expand Up @@ -266,17 +242,6 @@ public function startIndexingAction(ServerRequestInterface $request, ModuleTempl
$content .= ' <a class="btn btn-default" id="kesearch-button-reload" href="' . $moduleUrl . '">Reload</a>';

$this->addMainMenu($request, $moduleTemplate, 'startIndexing');

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()->setTemplatePathAndFilename('EXT:ke_search/Resources/Private/Templates/BackendModule/StartIndexing.html');
$moduleTemplate->getView()->assign('content', $content);
$moduleTemplate->getView()->assign('mySqlIndexEnabled', SanityCheckUtility::IsIndexTableIndexesEnabled());
$moduleTemplate->getView()->assign('indexerIsRunning', $this->indexerStatusService->isRunning());
// @extensionScannerIgnoreLine
return new HtmlResponse($moduleTemplate->renderContent());
}
$moduleTemplate->assign('content', $content);
$moduleTemplate->assign('mySqlIndexEnabled', SanityCheckUtility::IsIndexTableIndexesEnabled());
$moduleTemplate->assign('indexerIsRunning', $this->indexerStatusService->isRunning());
Expand All @@ -296,45 +261,16 @@ public function indexedContentAction(ServerRequestInterface $request, ModuleTemp
$indexRecords = $this->indexRepository->findByPageUidToShowIndexedContent($this->pageId);
$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);
}
$pagination = new SlidingWindowPagination($paginator, 15);
}

$this->addMainMenu($request, $moduleTemplate, 'indexedContent');

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('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('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');
}

Expand All @@ -346,15 +282,6 @@ public function indexTableInformationAction(ServerRequestInterface $request, Mod
$content = $this->renderIndexTableInformation();

$this->addMainMenu($request, $moduleTemplate, 'indexTableInformation');

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()->setTemplatePathAndFilename('EXT:ke_search/Resources/Private/Templates/BackendModule/IndexTableInformation.html');
$moduleTemplate->getView()->assign('content', $content);
// @extensionScannerIgnoreLine
return new HtmlResponse($moduleTemplate->renderContent());
}
$moduleTemplate->assign('content', $content);
return $moduleTemplate->renderResponse('BackendModule/IndexTableInformation');
}
Expand All @@ -375,18 +302,6 @@ public function searchwordStatisticsAction(ServerRequestInterface $request, Modu
}

$this->addMainMenu($request, $moduleTemplate, 'searchwordStatistics');

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()->setTemplatePathAndFilename('EXT:ke_search/Resources/Private/Templates/BackendModule/SearchwordStatistics.html');
$moduleTemplate->getView()->assign('days', $days);
$moduleTemplate->getView()->assign('data', $data);
$moduleTemplate->getView()->assign('error', $error);
$moduleTemplate->getView()->assign('languages', $this->getLanguages());
// @extensionScannerIgnoreLine
return new HtmlResponse($moduleTemplate->renderContent());
}
$moduleTemplate->assign('days', $days);
$moduleTemplate->assign('data', $data);
$moduleTemplate->assign('error', $error);
Expand Down Expand Up @@ -420,17 +335,6 @@ public function clearSearchIndexAction(ServerRequestInterface $request, ModuleTe
);

$this->addMainMenu($request, $moduleTemplate, 'clearSearchIndex');

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()->setTemplatePathAndFilename('EXT:ke_search/Resources/Private/Templates/BackendModule/ClearSearchIndex.html');
$moduleTemplate->getView()->assign('moduleUrl', $moduleUrl);
$moduleTemplate->getView()->assign('isAdmin', $this->getBackendUser()->isAdmin());
$moduleTemplate->getView()->assign('indexCount', $this->indexRepository->getTotalNumberOfRecords());
// @extensionScannerIgnoreLine
return new HtmlResponse($moduleTemplate->renderContent());
}
$moduleTemplate->assign('moduleUrl', $moduleUrl);
$moduleTemplate->assign('isAdmin', $this->getBackendUser()->isAdmin());
$moduleTemplate->assign('indexCount', $this->indexRepository->getTotalNumberOfRecords());
Expand All @@ -443,15 +347,6 @@ public function clearSearchIndexAction(ServerRequestInterface $request, ModuleTe
public function lastIndexingReportAction(ServerRequestInterface $request, ModuleTemplate $moduleTemplate): ResponseInterface
{
$this->addMainMenu($request, $moduleTemplate, 'lastIndexingReport');

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()->setTemplatePathAndFilename('EXT:ke_search/Resources/Private/Templates/BackendModule/LastIndexingReport.html');
$moduleTemplate->getView()->assign('logEntry', $this->getLastIndexingReport());
// @extensionScannerIgnoreLine
return new HtmlResponse($moduleTemplate->renderContent());
}
$moduleTemplate->assign('logEntry', $this->getLastIndexingReport());
return $moduleTemplate->renderResponse('BackendModule/LastIndexingReport');
}
Expand Down
158 changes: 0 additions & 158 deletions Classes/Pagination/SlidingWindowPagination.php

This file was deleted.

Loading

0 comments on commit 161835b

Please sign in to comment.