<?php

/*
* This file is part of eSales Media cookieconsent module
*
* (c) Benjamin Roth
*
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL
*/

/**
 * Extend the palettes.
 */
$GLOBALS['TL_DCA']['tl_page']['palettes']['__selector__'][] = 'cookieconsent_enable';
$GLOBALS['TL_DCA']['tl_page']['palettes']['root'] .= ';{cookieconsent_legend},cookieconsent_enable';

$GLOBALS['TL_DCA']['tl_page']['subpalettes']['cookieconsent_enable'] = 'cookieconsent_link,cookieconsent_statistics_analytics';

/*
 * Add the fields
 */
$GLOBALS['TL_DCA']['tl_page']['fields']['cookieconsent_enable'] = [
  'label' => &$GLOBALS['TL_LANG']['tl_page']['cookieconsent_enable'],
  'exclude' => true,
  'inputType' => 'checkbox',
  'eval' => array('submitOnChange' => true, 'tl_class' => 'clr'),
  'sql' => "char(1) NOT NULL default ''",
];

$GLOBALS['TL_DCA']['tl_page']['fields']['cookieconsent_link'] = [
  'label' => &$GLOBALS['TL_LANG']['tl_page']['cookieconsent_link'],
  'exclude' => true,
  'search' => true,
  'inputType' => 'text',
  'eval' => array('rgxp'=>'url', 'decodeEntities'=>true, 'maxlength'=>255, 'fieldType'=>'radio', 'tl_class'=>'clr wizard'),
  'wizard' => array
  (
    array('tl_content', 'pagePicker')
  ),
  'sql'=> "varchar(255) NOT NULL default ''"
];

$GLOBALS['TL_DCA']['tl_page']['fields']['cookieconsent_services'] = [
  'label' => &$GLOBALS['TL_LANG']['tl_page']['cookieconsent_services'],
  'exclude' => true,
  'inputType' => 'checkbox',
  'options' => array('analytics','matomo'),
  'eval' => array('tl_class' => 'clr'),
  'sql' => "char(1) NOT NULL default ''",
];