Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #2543

Merged
merged 4 commits into from
Oct 30, 2024
Merged

Dev #2543

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions Build/php-cs-fixer/php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,20 @@
->setRiskyAllowed(true)
->setRules([
'@DoctrineAnnotation' => true,
'@PER' => true,
'@PER-CS' => true,
'array_syntax' => ['syntax' => 'short'],
'blank_line_after_opening_tag' => true,
'braces' => ['allow_single_line_closure' => true],
'cast_spaces' => ['space' => 'none'],
'compact_nullable_typehint' => true,
'compact_nullable_type_declaration' => true,
'concat_space' => ['spacing' => 'one'],
'declare_equal_normalize' => ['space' => 'none'],
'dir_constant' => true,
'function_typehint_space' => true,
'type_declaration_spaces' => true,
'lowercase_cast' => true,
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
'modernize_types_casting' => true,
'native_function_casing' => true,
'new_with_braces' => true,
'new_with_parentheses' => true,
'no_alias_functions' => true,
'no_blank_lines_after_phpdoc' => true,
'no_empty_phpdoc' => true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

declare(strict_types=1);

/*
* This file is part of the "news" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*/

namespace GeorgRinger\News\Event\Listener;

use TYPO3\CMS\Backend\View\Event\ModifyDatabaseQueryForRecordListingEvent;
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Core\Database\Connection;

#[AsEventListener(
identifier: 'ext-news/backend/modify-query-for-record-listing-news-color',
)]
final class ModifyDatabaseQueryForRecordListingEventListenerTopNewsColor
{
public function __invoke(ModifyDatabaseQueryForRecordListingEvent $event): void
{
if ($event->getTable() !== 'tx_news_domain_model_news') {
return;
}

$queryBuilder = $event->getQueryBuilder();
$queryBuilder->addSelectLiteral(
$queryBuilder->expr()->if(
$queryBuilder->expr()->eq('istopnews', $queryBuilder->createNamedParameter(1, Connection::PARAM_INT)),
$queryBuilder->quote('news-istopnews'),
$queryBuilder->quote(''),
'_CSSCLASS'
),
);

$event->setQueryBuilder($queryBuilder);
}
}
85 changes: 85 additions & 0 deletions Classes/Event/Listener/ModifyPageTreeItems.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php

declare(strict_types=1);

/*
* This file is part of the "news" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*/

namespace GeorgRinger\News\Event\Listener;

use TYPO3\CMS\Backend\Controller\Event\AfterPageTreeItemsPreparedEvent;
use TYPO3\CMS\Backend\Dto\Tree\Status\StatusInformation;
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
use TYPO3\CMS\Core\Utility\GeneralUtility;

#[AsEventListener(
identifier: 'ext-news/backend/modify-page-tree-items',
)]
final class ModifyPageTreeItems
{
private const NEWS_TYPES = [
'news_pi1' => 'ext-news-plugin-news-list',
'news_newsliststicky' => 'ext-news-plugin-news-list-sticky',
'news_newsdetail' => 'ext-news-plugin-news-detail',
'news_newsselectedlist' => 'ext-news-plugin-news-selected-list',
'news_newsdatemenu' => 'ext-news-plugin-news-date-menu',
'news_categorylist' => 'ext-news-plugin-category-list',
'news_newssearchform' => 'ext-news-plugin-news-search-form',
'news_newssearchresult' => 'ext-news-plugin-news-search-result',
'news_taglist' => 'ext-news-plugin-tag-list',
];

public function __invoke(AfterPageTreeItemsPreparedEvent $event): void
{
$items = $event->getItems();
foreach ($items as &$item) {
$ctype = $this->getFirstFoundNewsType($item['_page']['uid']);
if ($ctype === null) {
continue;
}
$pluginNameForLabel = str_replace(['ext-news-plugin-', '-'], ['', '_'], self::NEWS_TYPES[$ctype]);
$label = 'LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:plugin.' . $pluginNameForLabel . '.title';
$item['statusInformation'][] = new StatusInformation(
label: $this->getLanguageService()->sL($label),
severity: ContextualFeedbackSeverity::INFO,
priority: 0,
icon: self::NEWS_TYPES[$ctype],
overlayIcon: '',
);
}

$event->setItems($items);
}

private function getFirstFoundNewsType(int $pageId): ?string
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content');
$row = $queryBuilder
->select('CType', 'header')
->from('tt_content')
->where(
$queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($pageId, Connection::PARAM_INT)),
$queryBuilder->expr()->in('CType', $queryBuilder->createNamedParameter(array_keys(self::NEWS_TYPES), Connection::PARAM_STR_ARRAY)),
)
->orderBy('colPos', 'desc')
->addOrderBy('sorting', 'asc')
->setMaxResults(1)
->executeQuery()
->fetchAssociative();

return $row['CType'] ?? null;
}

private function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
}
46 changes: 23 additions & 23 deletions Configuration/Icons.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@

$iconList = [];
foreach ([
'apps-pagetree-folder-contains-news' => 'ext-news-folder-tree.svg',
'apps-pagetree-page-contains-news' => 'ext-news-page-tree.svg',
'ext-news-wizard-icon' => 'plugin-list-with-detail.svg',
'ext-news-plugin-news-list' => 'plugin-list-with-detail.svg',
'ext-news-plugin-news-list-sticky' => 'plugin-list.svg',
'ext-news-plugin-news-detail' => 'plugin-detail.svg',
'ext-news-plugin-news-date-menu' => 'plugin-date-menu.svg',
'ext-news-plugin-news-search-form' => 'plugin-search-form.svg',
'ext-news-plugin-news-search-result' => 'plugin-search-results.svg',
'ext-news-plugin-news-selected-list' => 'plugin-selected-list.svg',
'ext-news-plugin-category-list' => 'plugin-category-menu.svg',
'ext-news-plugin-tag-list' => 'plugin-tag-menu.svg',
'ext-news-type-default' => 'news_domain_model_news.svg',
'ext-news-type-internal' => 'news_domain_model_news_internal.svg',
'ext-news-type-external' => 'news_domain_model_news_external.svg',
'ext-news-tag' => 'news_domain_model_tag.svg',
'ext-news-link' => 'news_domain_model_link.svg',
'ext-news-donation' => 'donation.svg',
'ext-news-paypal' => 'donation_paypal.svg',
'ext-news-patreon' => 'donation_patreon.svg',
'ext-news-amazon' => 'donation_amazon.svg',
'ext-news-doublecheck' => 'double_check.svg',
] as $identifier => $path) {
'apps-pagetree-folder-contains-news' => 'ext-news-folder-tree.svg',
'apps-pagetree-page-contains-news' => 'ext-news-page-tree.svg',
'ext-news-wizard-icon' => 'plugin-list-with-detail.svg',
'ext-news-plugin-news-list' => 'plugin-list-with-detail.svg',
'ext-news-plugin-news-list-sticky' => 'plugin-list.svg',
'ext-news-plugin-news-detail' => 'plugin-detail.svg',
'ext-news-plugin-news-date-menu' => 'plugin-date-menu.svg',
'ext-news-plugin-news-search-form' => 'plugin-search-form.svg',
'ext-news-plugin-news-search-result' => 'plugin-search-results.svg',
'ext-news-plugin-news-selected-list' => 'plugin-selected-list.svg',
'ext-news-plugin-category-list' => 'plugin-category-menu.svg',
'ext-news-plugin-tag-list' => 'plugin-tag-menu.svg',
'ext-news-type-default' => 'news_domain_model_news.svg',
'ext-news-type-internal' => 'news_domain_model_news_internal.svg',
'ext-news-type-external' => 'news_domain_model_news_external.svg',
'ext-news-tag' => 'news_domain_model_tag.svg',
'ext-news-link' => 'news_domain_model_link.svg',
'ext-news-donation' => 'donation.svg',
'ext-news-paypal' => 'donation_paypal.svg',
'ext-news-patreon' => 'donation_patreon.svg',
'ext-news-amazon' => 'donation_amazon.svg',
'ext-news-doublecheck' => 'double_check.svg',
] as $identifier => $path) {
$iconList[$identifier] = [
'provider' => SvgIconProvider::class,
'source' => 'EXT:news/Resources/Public/Icons/' . $path,
Expand Down
4 changes: 4 additions & 0 deletions Resources/Public/Css/Backend/RecordList.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#recordlist-tx_news_domain_model_news .news-istopnews td:first-child {
/*border-left:3px solid #d9534f;*/
border-inline-start:3px solid var(--token-color-red-40) !important;
}
4 changes: 2 additions & 2 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use GeorgRinger\News\Controller\CategoryController;
use GeorgRinger\News\Controller\NewsController;
use GeorgRinger\News\Controller\TagController;
use GeorgRinger\News\Hooks\Backend\RecordListQueryHook;
use GeorgRinger\News\Hooks\DataHandlerHook;
use GeorgRinger\News\Routing\NewsCategoryMapper;
use GeorgRinger\News\Routing\NewsTagMapper;
Expand All @@ -13,7 +12,6 @@
use GeorgRinger\News\Utility\ClassLoader;
use GeorgRinger\News\Xclass\ExtensionServiceXclassed;
use TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseRowInitializeNew;
use TYPO3\CMS\Backend\RecordList\DatabaseRecordList;
use TYPO3\CMS\Core\Cache\Backend\FileBackend;
use TYPO3\CMS\Core\Cache\Frontend\PhpFrontend;
use TYPO3\CMS\Core\Cache\Frontend\VariableFrontend;
Expand Down Expand Up @@ -230,6 +228,8 @@
$GLOBALS['TYPO3_CONF_VARS']['SYS']['routing']['aspects']['NewsCategory'] = NewsCategoryMapper::class;
$GLOBALS['TYPO3_CONF_VARS']['SYS']['routing']['aspects']['NewsTag'] = NewsTagMapper::class;
$GLOBALS['TYPO3_CONF_VARS']['SYS']['routing']['aspects']['NewsTitle'] = NewsTitleMapper::class;

$GLOBALS['TYPO3_CONF_VARS']['BE']['stylesheets']['news'] = 'EXT:news/Resources/Public/Css/Backend/RecordList.css';
};

$boot();
Expand Down
Loading