Skip to content

Commit

Permalink
[FEATURE] Make the page tree enhancement configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
georgringer committed Nov 5, 2024
1 parent 448ef5c commit eb739a6
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Classes/Domain/Model/Dto/EmConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ public function __construct(array $configuration = [])
/** @var string */
protected $slugBehaviour = 'unique';

/** @var bool */
protected $pageTreePluginPreview = true;

public function getTagPid(): int
{
return (int)$this->tagPid;
Expand Down Expand Up @@ -168,4 +171,10 @@ public function getSlugBehaviour(): string
{
return $this->slugBehaviour;
}

public function getPageTreePluginPreview(): bool
{
return (bool)$this->pageTreePluginPreview;
}

}
10 changes: 10 additions & 0 deletions Classes/Event/Listener/ModifyPageTreeItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace GeorgRinger\News\Event\Listener;

use GeorgRinger\News\Domain\Model\Dto\EmConfiguration;
use TYPO3\CMS\Backend\Controller\Event\AfterPageTreeItemsPreparedEvent;
use TYPO3\CMS\Backend\Dto\Tree\Status\StatusInformation;
use TYPO3\CMS\Core\Attribute\AsEventListener;
Expand All @@ -25,6 +26,7 @@
)]
final class ModifyPageTreeItems
{
private EmConfiguration $emConfiguration;
private const NEWS_TYPES = [
'news_pi1' => 'ext-news-plugin-news-list',
'news_newsliststicky' => 'ext-news-plugin-news-list-sticky',
Expand All @@ -37,8 +39,16 @@ final class ModifyPageTreeItems
'news_taglist' => 'ext-news-plugin-tag-list',
];

public function __construct()
{
$this->emConfiguration = GeneralUtility::makeInstance(EmConfiguration::class);
}

public function __invoke(AfterPageTreeItemsPreparedEvent $event): void
{
if (!$this->emConfiguration->getPageTreePluginPreview()) {
return;
}
$items = $event->getItems();
foreach ($items as &$item) {
$ctype = $this->getFirstFoundNewsType($item['_page']['uid']);
Expand Down
14 changes: 14 additions & 0 deletions Documentation/Reference/ExtensionConfiguration/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,20 @@ Slug behaviour `slugBehaviour`
unique
The same news title in different sites will lead to different slug names.

.. _extensionConfigurationPageTreePluginPreview:

Page Tree Plugin Preview
------------------------

.. confval:: pageTreePluginPreview

:type: bool
:Default: 1

If set, pages which contain a news plugin will show an additional icon right to the title in the page tree. This makes it easier to identify pages which are related to EXT:news.

This setting is only relevant since TYPO3 13!

Backend Module
==============

Expand Down
3 changes: 3 additions & 0 deletions Resources/Private/Language/locallang_be.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,9 @@
<trans-unit id="extmng.slugBehaviour" xml:space="preserve">
<source>Slug behaviour: uniqueInSite: The same slug can be used for news in different sites. Use this setting *only* if no news records are shared between sites. "unique" means that same news title will lead to different slug names.</source>
</trans-unit>
<trans-unit id="extmng.pageTreePluginPreview" xml:space="preserve">
<source>Plugin preview in page tree: If enabled pages with news plugins are highlighted by showing the plugin icon as status information [TYPO3 13 only]</source>
</trans-unit>
<trans-unit id="usersettings.overlay" xml:space="preserve">
<source>Use this overlay for news categories in the Backend</source>
</trans-unit>
Expand Down
3 changes: 3 additions & 0 deletions ext_conf_template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ advancedMediaPreview = 1
# cat=records/enable/155; type=options[unique=unique,uniqueInSite=uniqueInSite,uniqueInPid=uniqueInPid]; label=LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:extmng.slugBehaviour
slugBehaviour = unique

# cat=records/enable/300; type=boolean; label=LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:extmng.pageTreePluginPreview
pageTreePluginPreview = 1

# Backend module

# cat=backend module/enable/10; type=boolean; label=LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:extmng.showAdministrationModule
Expand Down

0 comments on commit eb739a6

Please sign in to comment.