<?php
defined('TYPO3') || die();

$_EXTKEY = 'stwm_sitepackage';

/***************
 * Add default RTE configuration
 */
$GLOBALS['TYPO3_CONF_VARS']['RTE']['Presets']['stwm_sitepackage'] = 'EXT:stwm_sitepackage/Configuration/RTE/Default.yaml';


/***************
 * amds_bear
 */
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig(
    '<INCLUDE_TYPOSCRIPT: source="FILE:EXT:stwm_sitepackage/Configuration/TSconfig/User.tsconfig">'
);

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig(
    '<INCLUDE_TYPOSCRIPT: source="FILE:EXT:stwm_sitepackage/Configuration/PageTS/Mod/Wizards/NewContentElement.tsconfig">'
);


/***************
 * Register Icons
 */
$iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);

$iconsContentElements = [
    'alert',
    'hero',
    'menucard',
    'teaserbox'
];
foreach ($iconsContentElements as $icon) {
    $iconRegistry->registerIcon(
        'tx_stwm_' . $icon,
        \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class,
        ['source' => 'EXT:' . $_EXTKEY . '/Resources/Public/Icons/ContentElements/' . $icon . '.svg']
    );
}


$iconsBackendLayouts = [
    'default',
    'frontpage',
    'heroless',
    'jumbotron-sidebar-left',
    'jumbotron-sidebar-right',
    'sidebar-left',
    'sidebar-right',
];
foreach ($iconsBackendLayouts as $icon) {
    $iconRegistry->registerIcon(
        'tx_stwm_' . $icon,
        \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class,
        ['source' => 'EXT:' . $_EXTKEY . '/Resources/Public/Icons/BackendLayouts/' . $icon . '.svg']
    );
}



// Add custom fields to Rootlinefields
$rootlinefields = &$GLOBALS["TYPO3_CONF_VARS"]["FE"]["addRootLineFields"];
if ($rootlinefields != '') {
    $rootlinefields .= ' , ';
}
$rootlinefields .= 'html_class';



///***************
// * Register custom EXT:form configuration
// */
//if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('form')) {
//    \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScriptSetup(trim('
//        module.tx_form.settings.yamlConfigurations.1699285665 = EXT:' . $_EXTKEY . '/Configuration/Form/Setup.yaml
//        plugin.tx_form.settings.yamlConfigurations.1699285665 = EXT:' . $_EXTKEY . '/Configuration/Form/Setup.yaml
//    '));
//}
