diff --git a/Classes/Controller/TermController.php b/Classes/Controller/TermController.php index b7f5526..350c4c5 100755 --- a/Classes/Controller/TermController.php +++ b/Classes/Controller/TermController.php @@ -52,7 +52,15 @@ public function __construct(TermRepository $termRepository) public function listAction(string $currentCharacter = null): ResponseInterface { $listMode = $this->settings['listmode'] ?? 'normal'; - $terms = $this->termRepository->findAll(); + + $searchTerm = $this->request->hasArgument('searchTerm') + ? trim((string)$this->request->getArgument('searchTerm')) + : null + ; + $terms = empty($searchTerm) + ? $terms = $this->termRepository->findAll() + : $this->termRepository->findByTerm($searchTerm) + ; switch ($listMode) { case 'character': @@ -96,6 +104,7 @@ public function listAction(string $currentCharacter = null): ResponseInterface $this->view->assignMultiple([ 'listmode' => $listMode, 'terms' => $terms, + 'searchTerm' => $searchTerm, ]); return $this->htmlResponse(); diff --git a/Classes/Domain/Repository/TermRepository.php b/Classes/Domain/Repository/TermRepository.php index 52fb9b1..8e4994e 100644 --- a/Classes/Domain/Repository/TermRepository.php +++ b/Classes/Domain/Repository/TermRepository.php @@ -15,6 +15,8 @@ ***/ use Featdd\DpnGlossary\Domain\Model\Term; +use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser; use TYPO3\CMS\Extbase\Persistence\QueryInterface; use TYPO3\CMS\Extbase\Persistence\QueryResultInterface; @@ -23,6 +25,27 @@ */ class TermRepository extends AbstractTermRepository { + public function findByTerm( + string $term + ): QueryResultInterface { + $query = $this->createQuery(); + + $queryParser = GeneralUtility::makeInstance(Typo3DbQueryParser::class); + $queryBuilder = $queryParser->convertQueryToDoctrineQueryBuilder($query); + + $searchTerm = $queryBuilder->getConnection()->escapeLikeWildcards($term) . '%'; + + $query->matching($query->logicalOr( + $query->like('name', $searchTerm), + $query->like('synonyms.name', $searchTerm), + $query->like('descriptions.meaning', $searchTerm), + )); + $queryBuilder = $queryParser->convertQueryToDoctrineQueryBuilder($query); + + $result = $query->execute(); + return $result; + } + /** * finds the newest terms * diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index a9c8230..a2abe46 100755 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -71,6 +71,10 @@ plugin.tx_dpnglossary { groupedListCharacters < .pagination.characters + list { + enableSearchForm = 0 + } + termWraps = CASE termWraps { key.field = term_type diff --git a/Resources/Private/Language/de.locallang.xlf b/Resources/Private/Language/de.locallang.xlf index 7c33abd..548682a 100755 --- a/Resources/Private/Language/de.locallang.xlf +++ b/Resources/Private/Language/de.locallang.xlf @@ -186,6 +186,12 @@ Inhalt parsen + + + + Submit + Absenden + diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index 7f95b60..ef3a143 100755 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -186,6 +186,11 @@ Parse content element for glossary terms + + + + Submit + diff --git a/Resources/Private/Partials/Utilities/SearchForm.html b/Resources/Private/Partials/Utilities/SearchForm.html new file mode 100644 index 0000000..60e3d45 --- /dev/null +++ b/Resources/Private/Partials/Utilities/SearchForm.html @@ -0,0 +1,16 @@ + + + + +
+ + + {f:translate(key: 'list.searchform.submitButton.label')} + +
+
+
+ + diff --git a/Resources/Private/Templates/Term/List.html b/Resources/Private/Templates/Term/List.html index ad1febb..d4d2ccd 100755 --- a/Resources/Private/Templates/Term/List.html +++ b/Resources/Private/Templates/Term/List.html @@ -11,6 +11,8 @@

{f:translate(key: 'tx_dpnglossary_domain_model_term.listheadline')}

+ +