diff --git a/Classes/Controller/GlossaryController.php b/Classes/Controller/GlossaryController.php index de7380a..e6183db 100644 --- a/Classes/Controller/GlossaryController.php +++ b/Classes/Controller/GlossaryController.php @@ -3,6 +3,7 @@ namespace WapplerSystems\A21glossary\Controller; use GeorgRinger\NumberedPagination\NumberedPagination; +use Psr\Http\Message\ResponseInterface; use TYPO3\CMS\Core\Pagination\SimplePagination; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; @@ -13,14 +14,10 @@ class GlossaryController extends ActionController { - /** - * @var \WapplerSystems\A21glossary\Domain\Repository\GlossaryRepository - */ - protected $glossaryRepository; - public function injectGlossaryRepository(GlossaryRepository $glossaryRepository) + public function __construct(readonly GlossaryRepository $glossaryRepository) { - $this->glossaryRepository = $glossaryRepository; + } /** @@ -28,7 +25,7 @@ public function injectGlossaryRepository(GlossaryRepository $glossaryRepository) * * @throws InvalidQueryException */ - public function indexAction($char = null) + public function indexAction($char = null): ResponseInterface { if (!empty($char)) { $glossaryItems = $this->glossaryRepository->findAllWithChar($char); @@ -54,6 +51,8 @@ public function indexAction($char = null) $this->view->assign('index', $this->glossaryRepository->findAllForIndex()); $this->view->assign('currentChar', $char); $this->view->assign('pagination', ['pagination' => $pagination, 'paginator' => $paginator]); + + return $this->htmlResponse(); } /** @@ -61,18 +60,23 @@ public function indexAction($char = null) * * @throws InvalidQueryException */ - public function searchAction($q) + public function searchAction($q): ResponseInterface { $this->view->assign('q', $q); $this->view->assign('items', $this->glossaryRepository->findAllWithQuery($q)); + + return $this->htmlResponse(); } /** * @param Glossary $entry * @return void */ - public function showAction(Glossary $entry) { + public function showAction(Glossary $entry): ResponseInterface + { $this->view->assign('item', $entry); + + return $this->htmlResponse(); } } diff --git a/Classes/Processor.php b/Classes/Processor.php index 577225d..3dc8e6e 100644 --- a/Classes/Processor.php +++ b/Classes/Processor.php @@ -147,14 +147,8 @@ public function main(string $content, array $config = []): string return $content; } - if (GeneralUtility::inList($this->config['excludePages'], $this->pageId)) { - if ($this->config['excludePages'][$this->pageId]) { - // disable glossary only for certain glossary types - $this->config['excludeTypes'] .= ',' . $this->config['excludePages'][$this->pageId]; - } else { - // disable glossary completly on current page: stop glossary rendering immediately - return $content; - } + if (is_string($this->config['excludePages']) && GeneralUtility::inList($this->config['excludePages'], $this->pageId)) { + return $content; } $items = $this->fetchGlossaryItems($this->config['pidList']); @@ -414,7 +408,6 @@ protected function fetchGlossaryItems(string $pidList): array $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tx_a21glossary_main'); $query = $connection->createQueryBuilder(); - $query->getRestrictions()->removeAll(); $query = $query->select('*')->from('tx_a21glossary_main') ->where( $query->expr()->in('pid', $aPidList), diff --git a/Configuration/Icons.php b/Configuration/Icons.php new file mode 100644 index 0000000..7d0d36f --- /dev/null +++ b/Configuration/Icons.php @@ -0,0 +1,10 @@ + [ + 'provider' => SvgIconProvider::class, + 'source' => 'EXT:a21glossary/Resources/Public/Icons/Extension.svg', + ], +]; diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index dbd9692..78641fa 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -3,5 +3,12 @@ use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; use TYPO3\CMS\Extbase\Utility\ExtensionUtility; -ExtensionUtility::registerPlugin('a21glossary', 'Pi1', 'LLL:EXT:a21glossary/Resources/Private/Language/locallang_db.xml:plugins.pi1.title'); +ExtensionUtility::registerPlugin( + 'a21glossary', + 'Pi1', + 'LLL:EXT:a21glossary/Resources/Private/Language/locallang_db.xml:plugins.pi1.title', + null, + 'a21glossary'); + + ExtensionManagementUtility::addToInsertRecords('tx_a21glossary_main'); diff --git a/Configuration/TCA/tx_a21glossary_main.php b/Configuration/TCA/tx_a21glossary_main.php index d0749a0..10dcb08 100644 --- a/Configuration/TCA/tx_a21glossary_main.php +++ b/Configuration/TCA/tx_a21glossary_main.php @@ -2,7 +2,7 @@ return [ 'ctrl' => [ - 'title' => 'LLL:EXT:a21glossary/Resources/Private/Language/locallang_db.xml:tx_a21glossary_main', + 'title' => 'LLL:EXT:a21glossary/Resources/Private/Language/locallang_db.xlf:tx_a21glossary_main.entry', 'label' => 'short', 'tstamp' => 'tstamp', 'crdate' => 'crdate', @@ -19,8 +19,11 @@ 'endtime' => 'endtime', 'fe_group' => 'fe_group' ], - 'iconfile' => 'EXT:a21glossary/Resources/Public/Icons/Extension.svg.svg', - 'searchFields' => 'short,shortcut,longversion' + 'iconfile' => 'EXT:a21glossary/Resources/Public/Icons/Extension.svg', + 'searchFields' => 'short,shortcut,longversion', + 'security' => [ + 'ignorePageTypeRestriction' => true + ] ], 'columns' => [ 'sys_language_uid' => [ diff --git a/Resources/Private/Language/de.locallang_db.xlf b/Resources/Private/Language/de.locallang_db.xlf index a9400c6..07292ed 100644 --- a/Resources/Private/Language/de.locallang_db.xlf +++ b/Resources/Private/Language/de.locallang_db.xlf @@ -8,6 +8,10 @@ Glossary Glossar + + Glossary entry + Glossareintrag + Short form Kurzform diff --git a/Resources/Private/Language/locallang_db.xlf b/Resources/Private/Language/locallang_db.xlf index 8c3793b..6d44d15 100644 --- a/Resources/Private/Language/locallang_db.xlf +++ b/Resources/Private/Language/locallang_db.xlf @@ -7,6 +7,9 @@ Glossary + + Glossary entry + Short form diff --git a/ext_localconf.php b/ext_localconf.php index 195c7de..5250dc0 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -1,14 +1,34 @@ processHook'; - - TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( 'a21glossary', 'Pi1', [GlossaryController::class => 'index,search,show'], - [GlossaryController::class => 'search'] + [GlossaryController::class => 'search'], + pluginType: ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT ); + + +ExtensionManagementUtility::addPageTSConfig(trim( + ' + mod.wizards.newContentElement.wizardItems { + plugins { + elements { + a21glossary { + title = Glossary + description = Show glossary entries + iconIdentifier = tx-a21glossary + tt_content_defValues { + CType = a21glossary_pi1 + } + } + } + } + } + + ')); diff --git a/ext_tables.php b/ext_tables.php index 4057702..a4abe2d 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -1,3 +1,2 @@