<?php
use TYPO3\CMS\Core\Page\AssetCollector;

defined('TYPO3') or die();
$GLOBALS['TYPO3_CONF_VARS']['RTE']['Presets']['default'] = 'EXT:zab_site/Configuration/RTE/Custom.yaml';
$GLOBALS['TYPO3_CONF_VARS']['RTE']['Presets']['minimal'] = 'EXT:zab_site/Configuration/RTE/Minimal.yaml';
// Nothing specific needed - TYPO3 automatically picks up language files

// Exclude indexed_search parameters from cHash to allow GET search
$GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'][] = '^tx_indexedsearch_pi2';

// Exclude FAQs list pagination/filter parameters from cHash (prefix match)
$GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'][] = '^tx_zabfaqs';

// Exclude info hub tab parameter from cHash to allow deep links via query string
$GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'][] = 'infoHub';

// Use filename as indexed title for PDFs instead of PDF metadata title
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['indexed_search']['external_parsers']['pdf'] = \Zab\ZabSite\Search\PdfFileContentParser::class;

// load backend.css on backend
$GLOBALS['TYPO3_CONF_VARS']['BE']['stylesheets']['zab_site'] = 'EXT:zab_site/Resources/Public/Dist/assets/backend.css';
// load backend.js on backend
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-preProcess'][] =
  static function (array $params, \TYPO3\CMS\Core\Page\PageRenderer $pageRenderer): void {
    $request = $GLOBALS['TYPO3_REQUEST'] ?? null;
    if ($request instanceof \Psr\Http\Message\ServerRequestInterface
        && \TYPO3\CMS\Core\Http\ApplicationType::fromRequest($request)->isBackend()
    ) {
        $pageRenderer->loadJavaScriptModule('@zab-site/backend');
    }
  };

// Flush frontend page cache after backend record save.
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] =
  \Zab\ZabSite\EventListener\SiteConfigurationCacheFlushListener::class;
  