<html
    xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
    xmlns:core="http://typo3.org/ns/TYPO3/CMS/Core/ViewHelpers"
    data-namespace-typo3-fluid="true"
>

<f:layout name="Module" />

<f:section name="Before">
    <f:asset.module identifier="@typo3/backend/security/element/csp-reports.js"/>
</f:section>

<f:section name="Content">
    <h1><f:translate key="LLL:EXT:backend/Resources/Private/Language/Modules/content-security-policy.xlf:module.headline" /></h1>
    <p>
        <f:if condition="{extLowlevelAvailable}">
            <f:then>
                <f:variable name="moduleLink">
                    <f:be.link route="system_config" parameters="{tree: 'contentSecurityPolicyMutations'}"><f:translate key="LLL:EXT:backend/Resources/Private/Language/Modules/content-security-policy.xlf:module.introtext.moduleName" /></f:be.link>
                </f:variable>
                <f:sanitize.html>
                    <f:translate
                        key="LLL:EXT:backend/Resources/Private/Language/Modules/content-security-policy.xlf:module.introtext"
                        arguments="{0: '{moduleLink}'}" />
                </f:sanitize.html>
            </f:then>
            <f:else>
                <f:translate
                    key="LLL:EXT:backend/Resources/Private/Language/Modules/content-security-policy.xlf:module.introtextLowlevelMissing"
                    arguments="{0: '{f:translate(key:\'LLL:EXT:backend/Resources/Private/Language/Modules/content-security-policy.xlf:module.introtext.moduleName\')}'}" />
            </f:else>
        </f:if>
    </p>

    <f:if condition="{configurationStatus.featureDisabled.backend} || {configurationStatus.featureDisabled.frontend}">
        <f:be.infobox
            state="{f:constant(name: 'TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper::STATE_INFO')}"
            title="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/Modules/content-security-policy.xlf:module.callout.featureDisabled.title')}"
        >
            <p>
                <f:translate key="LLL:EXT:backend/Resources/Private/Language/Modules/content-security-policy.xlf:module.callout.featureDisabled.message" />
            </p>
            <ul class="mb-0">
                <f:for each="{configurationStatus.featureDisabled}" as="dispositions" key="scope">
                    <f:for each="{dispositions}" as="disposition" iteration="iteration">
                        <li><code>security.{scope}.{disposition}ContentSecurityPolicy</code></li>
                    </f:for>
                </f:for>
            </ul>
        </f:be.infobox>
    </f:if>

    <f:if condition="{configurationStatus.customReporting.BE} || {configurationStatus.customReporting.FE}">
        <f:be.infobox
            state="{f:constant(name: 'TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper::STATE_INFO')}"
            title="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/Modules/content-security-policy.xlf:module.callout.customReporting.title')}"
        >
            <p>
                <f:translate key="LLL:EXT:backend/Resources/Private/Language/Modules/content-security-policy.xlf:module.callout.customReporting.message" />
            </p>
            <ul class="mb-0">
                <f:for each="{configurationStatus.customReporting}" as="value" key="key">
                    <li><code>$GLOBALS['TYPO3_CONF_VARS']['{key}']['contentSecurityPolicyReportingUrl'] = '{value}'</code></li>
                </f:for>
            </ul>
        </f:be.infobox>
    </f:if>

    <typo3-backend-security-csp-reports
        scopes="{scopes -> f:format.json()}"
        controlUri="{controlUri}">
    </typo3-backend-security-csp-reports>

</f:section>

</html>
