Commit 094d4c29 authored by Johannes Kreiner's avatar Johannes Kreiner
Browse files

[TASK] Use built-in description for Layout content TCA

parent 4544d579
<?php
namespace SGalinski\SgMail\Form\NodeExpansion;
/***************************************************************
* Copyright notice
*
* (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use TYPO3\CMS\Backend\Form\AbstractNode;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
/**
* Renders additional TCA field information.
*/
class FieldInformation extends AbstractNode {
/**
* @return array Result array
*/
public function render(): array {
$result = $this->initializeResultArray();
$options = $this->data['renderData']['fieldInformationOptions']
?? $this->data['renderData']['fieldWizardOptions'];
if (
!isset($options['text'])
&& (!isset($options['parentFields'], $options['parentTable'], $options['parentUidField']))
) {
return $result;
}
$text = \trim($options['text'] ?? '');
if ($text === '') {
return $result;
}
if (\strpos($text, 'LLL') === 0) {
$text = LocalizationUtility::translate($text);
}
$tagOpen = '<span>';
$tagClose = '</span>';
if (isset($options['tag'])) {
$tag = \trim(\str_replace(['<', '>'], '', $options['tag']));
$tagSplit = GeneralUtility::trimExplode(' ', $tag);
$tagName = $tagSplit[0];
if ($tagName !== '') {
$tagOpen = '<' . $tag . '>';
$tagClose = '</' . $tagName . '>';
}
}
$result['html'] = '<div>' . $tagOpen . $text . $tagClose . '</div>';
return $result;
}
}
......@@ -126,17 +126,10 @@ return [
'content' => [
'exclude' => TRUE,
'label' => 'LLL:EXT:sg_mail/Resources/Private/Language/locallang_db.xlf:tx_sgmail_domain_model_layout.content',
'description' => 'LLL:EXT:sg_mail/Resources/Private/Language/locallang_db.xlf:tx_sgmail_domain_model_layout.content.info',
'config' => [
'type' => 'text',
'renderType' => 't3editor',
'fieldInformation' => [
'info' => [
'renderType' => 'sgMailFieldInformation',
'options' => [
'text' => 'LLL:EXT:sg_mail/Resources/Private/Language/locallang_db.xlf:tx_sgmail_domain_model_layout.content.info'
]
],
],
'renderType' => 't3editor'
],
],
]
......
......@@ -51,13 +51,6 @@ call_user_func(
'className' => \SGalinski\SgMail\XClass\Form\FormManagerController::class,
];
// Register FormEngine node type resolvers
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry']['sgMailFieldInformation'] = [
'nodeName' => 'sgMailFieldInformation',
'priority' => 10,
'class' => \SGalinski\SgMail\Form\NodeExpansion\FieldInformation::class,
];
// Datamap process hook
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = \SGalinski\SgMail\Hooks\ProcessDatamap::class;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment