<?php

/*
 * This file is part of newsmailer bundle for Contao.
 *
 * (c) Benjamin Roth
 *
 * @license LGPL-3.0-or-later
 */

use Contao\CoreBundle\DataContainer\PaletteManipulator;

/**
 * Palettes
 */

//$GLOBALS['TL_DCA']['tl_news']['palettes']['default'] = str_replace(array('{publish_legend}','{publish_legend:hide}'),array('{nc_legend:hide},nc_sent,nc_testmail;{publish_legend}','{nc_legend:hide},nc_sent,nc_testmail;{publish_legend:hide}'),$GLOBALS['TL_DCA']['tl_news']['palettes']['default']);
PaletteManipulator::create()
    ->addLegend('nc_legend','publish_legend',PaletteManipulator::POSITION_BEFORE)
    ->addField('nc_sent','nc_legend', PaletteManipulator::POSITION_APPEND)
    ->addField('nc_testmail','nc_legend', PaletteManipulator::POSITION_APPEND)
    ->applyToPalette('default','tl_news')
;

/**
 * Fields
 */

$GLOBALS['TL_DCA']['tl_news']['fields']['nc_sent'] = array
(
  'exclude'                 => true,
  'inputType'               => 'checkbox',
  'default'                 => 1,
  'eval'                    => array('doNotCopy'=>true),
  'sql'                     => "char(1) NOT NULL default '1'"
);

$GLOBALS['TL_DCA']['tl_news']['fields']['nc_testmail'] = array
(
  'exclude'                 => true,
  'inputType'               => 'checkbox',
  'eval'                    => array('doNotSaveEmpty'=>true),
);