Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
svewap committed Jun 18, 2024
1 parent 1dbcc72 commit a94bbb9
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 57 deletions.
22 changes: 13 additions & 9 deletions Classes/Controller/GlossaryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -13,22 +14,18 @@

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;

}

/**
* @param string $char
*
* @throws InvalidQueryException
*/
public function indexAction($char = null)
public function indexAction($char = null): ResponseInterface
{
if (!empty($char)) {
$glossaryItems = $this->glossaryRepository->findAllWithChar($char);
Expand All @@ -54,25 +51,32 @@ 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();
}

/**
* @param string $q
*
* @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();
}
}
11 changes: 2 additions & 9 deletions Classes/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down Expand Up @@ -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),
Expand Down
10 changes: 10 additions & 0 deletions Configuration/Icons.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

use TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider;

return [
'tx-a21glossary' => [
'provider' => SvgIconProvider::class,
'source' => 'EXT:a21glossary/Resources/Public/Icons/Extension.svg',
],
];
9 changes: 8 additions & 1 deletion Configuration/TCA/Overrides/tt_content.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
9 changes: 6 additions & 3 deletions Configuration/TCA/tx_a21glossary_main.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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' => [
Expand Down
4 changes: 4 additions & 0 deletions Resources/Private/Language/de.locallang_db.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
<source>Glossary</source>
<target>Glossar</target>
</trans-unit>
<trans-unit id="tx_a21glossary_main.entry">
<source>Glossary entry</source>
<target>Glossareintrag</target>
</trans-unit>
<trans-unit id="tx_a21glossary_main.short">
<source>Short form</source>
<target>Kurzform</target>
Expand Down
3 changes: 3 additions & 0 deletions Resources/Private/Language/locallang_db.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<trans-unit id="tx_a21glossary_main">
<source>Glossary</source>
</trans-unit>
<trans-unit id="tx_a21glossary_main.entry">
<source>Glossary entry</source>
</trans-unit>
<trans-unit id="tx_a21glossary_main.short">
<source>Short form</source>
</trans-unit>
Expand Down
28 changes: 24 additions & 4 deletions ext_localconf.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
<?php

use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;
use WapplerSystems\A21glossary\Controller\GlossaryController;


$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-all']['tx_a21glossary'] = WapplerSystems\A21glossary\Hooks\FrontendHook::class . '->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
}
}
}
}
}
'));
1 change: 0 additions & 1 deletion ext_tables.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
<?php

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_a21glossary_main');
61 changes: 31 additions & 30 deletions ext_tables.sql
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
#
# Table structure for table 'tx_a21glossary_main'
#
CREATE TABLE tx_a21glossary_main (
uid int(11) DEFAULT '0' NOT NULL auto_increment,
pid int(11) DEFAULT '0' NOT NULL,
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
crdate int(11) unsigned DEFAULT '0' NOT NULL,
cruser_id int(11) unsigned DEFAULT '0' NOT NULL,
t3ver_oid int(11) unsigned DEFAULT '0' NOT NULL,
t3ver_id int(11) unsigned DEFAULT '0' NOT NULL,
t3ver_label varchar(30) DEFAULT '' NOT NULL,
sys_language_uid int(11) DEFAULT '0' NOT NULL,
l18n_parent int(11) DEFAULT '0' NOT NULL,
l18n_diffsource mediumblob NOT NULL,
deleted tinyint(4) unsigned DEFAULT '0' NOT NULL,
hidden tinyint(4) unsigned DEFAULT '0' NOT NULL,
starttime int(11) unsigned DEFAULT '0' NOT NULL,
endtime int(11) unsigned DEFAULT '0' NOT NULL,
fe_group varchar(200) DEFAULT '0' NOT NULL,
short tinytext NOT NULL,
shortcut tinytext NOT NULL,
longversion tinytext NOT NULL,
shorttype tinytext NOT NULL,
language char(2) DEFAULT '' NOT NULL,
description text NOT NULL,
link tinytext NOT NULL,
exclude tinyint(3) DEFAULT '0' NOT NULL,
force_linking int(11) DEFAULT '0' NOT NULL,
force_case int(11) DEFAULT '0' NOT NULL,
force_preservecase int(11) DEFAULT '0' NOT NULL,
force_regexp int(11) DEFAULT '0' NOT NULL,
force_global int(11) DEFAULT '0' NOT NULL,
CREATE TABLE tx_a21glossary_main
(
uid int(11) DEFAULT '0' NOT NULL auto_increment,
pid int(11) DEFAULT '0' NOT NULL,
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
crdate int(11) unsigned DEFAULT '0' NOT NULL,
cruser_id int(11) unsigned DEFAULT '0' NOT NULL,
t3ver_oid int(11) unsigned DEFAULT '0' NOT NULL,
t3ver_id int(11) unsigned DEFAULT '0' NOT NULL,
t3ver_label varchar(30) DEFAULT '' NOT NULL,
sys_language_uid int(11) DEFAULT '0' NOT NULL,
l18n_parent int(11) DEFAULT '0' NOT NULL,
l18n_diffsource mediumblob NOT NULL,
deleted tinyint(4) unsigned DEFAULT '0' NOT NULL,
hidden tinyint(4) unsigned DEFAULT '0' NOT NULL,
starttime int(11) unsigned DEFAULT '0' NOT NULL,
endtime int(11) unsigned DEFAULT '0' NOT NULL,
fe_group varchar(200) DEFAULT '0' NOT NULL,
short tinytext NOT NULL,
shortcut tinytext NOT NULL,
longversion tinytext NOT NULL,
shorttype tinytext NOT NULL,
language char(2) DEFAULT '' NOT NULL,
description text NOT NULL,
link tinytext NOT NULL,
exclude tinyint(3) DEFAULT '0' NOT NULL,
force_linking int(11) DEFAULT '0' NOT NULL,
force_case int(11) DEFAULT '0' NOT NULL,
force_preservecase int(11) DEFAULT '0' NOT NULL,
force_regexp int(11) DEFAULT '0' NOT NULL,
force_global int(11) DEFAULT '0' NOT NULL,

PRIMARY KEY (uid),
KEY parent (pid)
Expand Down

0 comments on commit a94bbb9

Please sign in to comment.