<?php

declare(strict_types=1);

use Contao\System;

$GLOBALS['TL_DCA']['tl_content']['palettes']['__selector__'][] = 'vr_bw_addImage';
$GLOBALS['TL_DCA']['tl_content']['palettes']['__selector__'][] = 'vr_bw_minHeight';
$GLOBALS['TL_DCA']['tl_content']['palettes']['__selector__'][] = 'vr_bw_width';
$GLOBALS['TL_DCA']['tl_content']['palettes']['background_wrapper'] = '
    {type_legend},type,headline;
    {background_legend},vr_bw_addImage,vr_bw_bgColor,vr_bw_bgWidthRestriction;
    {content_legend},vr_bw_minHeight,vr_bw_width,vr_bw_vAlign,vr_bw_padding,vr_bw_colorInvert;
    {template_legend:hide},customTpl;
    {protected_legend:hide},protected;
    {expert_legend:hide},cssID;
    {invisible_legend:hide},invisible,start,stop
';

$GLOBALS['TL_DCA']['tl_content']['subpalettes']['vr_bw_addImage'] = 'vr_bw_bgSRC,size,vr_bw_bgSize,vr_bw_bgPos,vr_bw_bgOpacity';
$GLOBALS['TL_DCA']['tl_content']['subpalettes']['vr_bw_minHeight_-mh-ratio'] = 'vr_bw_mh_ratio';
$GLOBALS['TL_DCA']['tl_content']['subpalettes']['vr_bw_minHeight_-mh-vh'] = 'vr_bw_mh_viewport';
$GLOBALS['TL_DCA']['tl_content']['subpalettes']['vr_bw_width_-width-extended'] = 'vr_bw_widthText';
$GLOBALS['TL_DCA']['tl_content']['subpalettes']['vr_bw_width_-width-default-left'] = 'vr_bw_widthText';
$GLOBALS['TL_DCA']['tl_content']['subpalettes']['vr_bw_width_-width-default-right'] = 'vr_bw_widthText';
$GLOBALS['TL_DCA']['tl_content']['subpalettes']['vr_bw_width_-width-extended-left'] = 'vr_bw_widthText';
$GLOBALS['TL_DCA']['tl_content']['subpalettes']['vr_bw_width_-width-extended-right'] = 'vr_bw_widthText';

$GLOBALS['TL_DCA']['tl_content']['fields']['vr_bw_addImage'] = [
    'inputType'               => 'checkbox',
    'eval'                    => ['submitOnChange' =>true],
    'sql'                     => ['type' => 'boolean', 'default' => false]
];

$GLOBALS['TL_DCA']['tl_content']['fields']['vr_bw_bgSRC'] = [
    'inputType' => 'fileTree',
    'eval'      => [
        'tl_class'   => 'clr',
        'multiple'   => false,
        'fieldType'  => 'radio',
        'filesOnly'  => true,
        'extensions' => array_merge(System::getContainer()->getParameter('contao.image.valid_extensions'),['mp4', 'm4v', 'mov', 'wmv', 'webm', 'ogv']),
    ],
    'sql'       => "binary(16) NULL"
];

$GLOBALS['TL_DCA']['tl_content']['fields']['vr_bw_bgSize'] = [
    'inputType' => 'select',
    'options'   => [
        ''          => 'Beschnitten',
        '-bg-size-contain'   => 'Proportional',
        '-bg-size-stretch' => 'Verzerrt',
        '-bg-size-auto' => 'Originalgröße',
    ],
    'eval'      => ['tl_class' => 'w50'],
    'sql'       => "varchar(16) NOT NULL default ''"
];

$GLOBALS['TL_DCA']['tl_content']['fields']['vr_bw_bgPos'] = [
    'inputType' => 'select',
    'options'   => [
        '-bg-pos-0-0'       => 'Links | Oben',
        '-bg-pos-50-0'     => 'Mitte | Oben',
        '-bg-pos-100-0'    => 'Rechts | Oben',
        '-bg-pos-0-50'     => 'Links | Mitte',
        '-bg-pos-50-50'   => 'Mitte | Mitte',
        '-bg-pos-100-50'  => 'Rechts | Mitte',
        '-bg-pos-0-100'    => 'Links | Unten',
        '-bg-pos-50-100'  => 'Mitte | Unten',
        '-bg-pos-100-100' => 'Rechts | Unten',
    ],
    'eval'      => ['tl_class' => 'w50', 'includeBlankOption' => true],
    'sql'       => "varchar(16) NOT NULL default ''"
];

$GLOBALS['TL_DCA']['tl_content']['fields']['vr_bw_bgOpacity'] = [
    'inputType' => 'select',
    'options'   => [
        '-bg-opacity-10'  => '10%',
        '-bg-opacity-20'  => '20%',
        '-bg-opacity-30'  => '30%',
        '-bg-opacity-40'  => '40%',
        '-bg-opacity-50'  => '50%',
        '-bg-opacity-60'  => '60%',
        '-bg-opacity-70'  => '70%',
        '-bg-opacity-80'  => '80%',
        '-bg-opacity-90'  => '90%',
        '-bg-opacity-100' => '100%',
    ],
    'eval'      => ['tl_class' => 'w50', 'includeBlankOption' => true],
    'sql'       => "varchar(16) NOT NULL default ''"
];

$GLOBALS['TL_DCA']['tl_content']['fields']['vr_bw_bgColor'] = [
    'inputType' => 'select',
    'options'   => [
        '-alt-color-1'  => 'Alternative 1',
        '-alt-color-2' => 'Alternative 2',
        '-alt-color-3' => 'Alternative 3',
        '-alt-color-black' => 'Schwarz',
        '-alt-color-white' => 'Weiß',
    ],
    'eval'      => ['tl_class' => 'w50', 'includeBlankOption' => true],
    'sql'       => "varchar(16) NOT NULL default ''"
];

$GLOBALS['TL_DCA']['tl_content']['fields']['vr_bw_bgWidthRestriction'] = [
    'inputType'               => 'checkbox',
    'eval'                    => ['tl_class' => 'w50 m12'],
    'sql'                     => ['type' => 'boolean', 'default' => false]
];

$GLOBALS['TL_DCA']['tl_content']['fields']['vr_bw_minHeight'] = [
    'inputType' => 'select',
    'options'   => [
        '-mh-small'          => 'Schmal',
        '-mh-medium'         => 'Mittel',
        '-mh-large'          => 'Groß',
        '-mh-vh'        => 'Am Viewport orientiert',
        '-mh-ratio'        => 'Seitenverhältnis',
        '-mh-bgimage'        => 'an Hintergrundbild ausrichten',
        '-mh-custom' => 'Projektdefiniert',
    ],
    'eval'      => ['tl_class' => 'w50', 'includeBlankOption' => true, 'submitOnChange' =>true],
    'sql'       => "varchar(16) NOT NULL default ''"
];

$GLOBALS['TL_DCA']['tl_content']['fields']['vr_bw_mh_ratio'] = [
    'inputType' => 'select',
    'options'   => [
        '-mh-ratio-21-9' => '21:9',
        '-mh-ratio-16-10' => '16:10',
        '-mh-ratio-16-9' => '16:9',
        '-mh-ratio-8-3' => '8:3',
        '-mh-ratio-5-4' => '5:4',
        '-mh-ratio-4-3' => '4:3',
        '-mh-ratio-3-2' => '3:2',
        '-mh-ratio-5-1' => '5:1',
        '-mh-ratio-4-1' => '4:1',
        '-mh-ratio-3-1' => '3:1',
        '-mh-ratio-2-1' => '2:1',
        '-mh-ratio-1-1' => '1:1',
    ],
    'eval'      => ['mandatory' => true, 'tl_class' => 'w50', 'includeBlankOption' => true],
    'sql'       => "varchar(16) NOT NULL default ''"
];

$GLOBALS['TL_DCA']['tl_content']['fields']['vr_bw_mh_viewport'] = [
    'inputType' => 'select',
    'options'   => [
        '-mh-viewport-100' => '100%',
        '-mh-viewport-66' => '66%',
        '-mh-viewport-50' => '50%',
        '-mh-viewport-33' => '33%',
    ],
    'eval'      => ['mandatory' => true, 'tl_class' => 'w50', 'includeBlankOption' => true],
    'sql'       => "varchar(16) NOT NULL default ''"
];

$GLOBALS['TL_DCA']['tl_content']['fields']['vr_bw_vAlign'] = [
    'inputType' => 'select',
    'options'   => [
        ''          => 'oben',
        '-va-center'         => 'mitte',
        '-va-bottom'          => 'unten',
    ],
    'eval'      => ['tl_class' => 'clr w50'],
    'sql'       => "varchar(16) NOT NULL default ''"
];

$GLOBALS['TL_DCA']['tl_content']['fields']['vr_bw_width'] = [
    'inputType' => 'select',
    'options' => [
        ''                      => 'Standard',
        '-width-small'          => 'Schmal',
        '-width-extended'       => 'Erweitert',
        '-width-default-left'   => 'Nach links versetzt',
        '-width-default-right'  => 'Nach rechts versetzt',
        '-width-extended-left'  => 'Nach links erweitert',
        '-width-extended-right' => 'Nach rechts erweitert',
        '-width-full'           => 'Gesamte Viewport-Breite',
    ],
    'eval'      => ['mandatory' => false, 'tl_class' => 'clr w50'],
    'sql'       => "varchar(24) NOT NULL default ''"
];

$GLOBALS['TL_DCA']['tl_content']['fields']['vr_bw_widthText'] = [
    'inputType'               => 'checkbox',
    'eval'                    => ['tl_class' => 'w50 m12'],
    'sql'                     => ['type' => 'boolean', 'default' => false]
];

$GLOBALS['TL_DCA']['tl_content']['fields']['vr_bw_colorInvert'] = [
    'inputType'               => 'checkbox',
    'eval'                    => ['tl_class' => 'w50 m12'],
    'sql'                     => ['type' => 'boolean', 'default' => false]
];

$GLOBALS['TL_DCA']['tl_content']['fields']['vr_bw_padding'] = [
    'inputType' => 'select',
    'options'   => [
        ''                       => '-',
        '-padding'               => 'Default',
        '-padding-medium'        => 'Medium',
        '-padding-large'         => 'Large',
        '-padding-top'           => 'Small Top',
        '-padding-top-medium'    => 'Medium Top',
        '-padding-top-large'     => 'Large Top',
        '-padding-bottom'        => 'Small Bottom',
        '-padding-bottom-medium' => 'Medium Bottom',
        '-padding-bottom-large'  => 'Large Bottom',
    ],
    'eval'      => ['mandatory' => false, 'tl_class' => 'w50'],
    'sql'       => "varchar(16) NOT NULL default ''"
];