<?php
/**
 * Created by PhpStorm.
 * User: bbaer
 * Date: 5/3/19
 * Time: 6:33 PM
 */

/*
 * The type name is generated by combining the extension key and plugin name, all lowercase and concatenated with `_'
 */

defined('TYPO3') or defined('TYPO3_MODE') or die ('No Typo3 detected');

(static function() {

    $extKey = 'qfq';
    $pluginName = 'qfq_qfq';

    $version = \TYPO3\CMS\Core\Utility\VersionNumberUtility::getNumericTypo3Version();
    $versionBelow9 = explode('.', $version)[0] < 9;

    if (is_array($GLOBALS['TCA']['tt_content']['palettes'])) {
        $GLOBALS['TCA']['tt_content']['palettes']['introheader']['showitem'] = 'header, subheader, CType';
        $GLOBALS['TCA']['tt_content']['palettes']['startendtime']['showitem'] = 'starttime, endtime';
        $GLOBALS['TCA']['tt_content']['palettes']['layoutpalette1']['showitem'] = 'colPos, header_position, sys_language_uid';
        $GLOBALS['TCA']['tt_content']['palettes']['layoutpalette2']['showitem'] = 'layout, header_layout';
        $GLOBALS['TCA']['tt_content']['palettes']['spacearound']['showitem'] = 'spaceBefore, spaceAfter';
    }

    if (is_array($GLOBALS['TCA']['tt_content']['types'])) {
        $GLOBALS['TCA']['tt_content']['types'][$pluginName] = [
            'showitem' => '
                --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
                    --palette--;;introheader,
                    custom,
                 bodytext;Code:;;nowrap,
                --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,
                    hidden, fe_group, deleted,
                    --palette--;;startendtime,
                --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.appearance,
                    --palette--;;layoutpalette1,
                    --palette--;;layoutpalette2,
                    --palette--;;spacearound,
                    linkToTop, section_frame, sectionIndex,
                --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language,
                    sys_language_uid, l18n_parent, l18n_diffsource
                ',
            'columnsOverrides' => [
                'bodytext' => [
                    'config' => [
                        'renderType' => 't3editor',
                        'format' => $versionBelow9 ? 'sparql' : 'qfq',
                        'rows' => 100
                    ],
                    'constants' => [
                        'renderType' => 't3editor',
                        'format' => $versionBelow9 ? 'sparql' : 'qfq',
                    ]
                ],
                'subheader' => [
                    'label' => 'QFQ Function Name'
                ]
            ]
        ];
    }

})();






