<?php

/**
 * JustifiedGallery for Contao
 *
 * Copyright (c) 2016 Benjamin Roth
 *
 * @license LGPL-3.0+
 */


/**
 * Table tl_content
 */

/**
 * Add palettes to tl_content
 */
$GLOBALS['TL_DCA']['tl_content']['palettes']['__selector__'][] = 'eSM_jg_enable';
$GLOBALS['TL_DCA']['tl_content']['palettes']['gallery'] = str_replace(array('{template_legend}','{template_legend:hide}'), array('{justifiedGallery_legend:hide},eSM_jg_enable;{template_legend}','{justifiedGallery_legend:hide},eSM_jg_enable;{template_legend:hide}'), $GLOBALS['TL_DCA']['tl_content']['palettes']['gallery']);

/**
 * Add subpalettes to tl_content
 */
$GLOBALS['TL_DCA']['tl_content']['subpalettes']['eSM_jg_enable'] = 'eSM_jg_height,eSM_jg_fixedHeight,eSM_jg_maxHeight,eSM_jg_margins,eSM_jg_captions,eSM_jg_waitLoaded';

/**
 * Add fields to tl_content
 */

$GLOBALS['TL_DCA']['tl_content']['fields']['eSM_jg_enable'] = array
(
  'label'                   => &$GLOBALS['TL_LANG']['tl_content']['eSM_jg_enable'],
  'exclude'                 => true,
  'inputType'               => 'checkbox',
  'eval'                    => array('tl_class'=>'','submitOnChange'=>true),
  'sql'                     => "char(1) NOT NULL default ''"
);

$GLOBALS['TL_DCA']['tl_content']['fields']['eSM_jg_fixedHeight'] = array
(
  'label'                   => &$GLOBALS['TL_LANG']['tl_content']['eSM_jg_fixedHeight'],
  'exclude'                 => true,
  'inputType'               => 'checkbox',
  'eval'                    => array('tl_class'=>'w50 m12'),
  'sql'                     => "char(1) NOT NULL default ''"
);

$GLOBALS['TL_DCA']['tl_content']['fields']['eSM_jg_height'] = array
(
  'label'                   => &$GLOBALS['TL_LANG']['tl_content']['eSM_jg_height'],
  'exclude'                 => true,
  'inputType'               => 'text',
  'eval'                    => array('tl_class'=>'w50','rgxp'=>'natural'),
  'sql'                     => "int(10) unsigned NOT NULL default '0'"
);

$GLOBALS['TL_DCA']['tl_content']['fields']['eSM_jg_maxHeight'] = array
(
  'label'                   => &$GLOBALS['TL_LANG']['tl_content']['eSM_jg_maxHeight'],
  'exclude'                 => true,
  'inputType'               => 'inputUnit',
  'options'                 => array('px','%'),
  'eval'                    => array('rgxp'=>'natural', 'tl_class'=>'w50'),
  'sql'                     => "varchar(64) NOT NULL default ''"
);

$GLOBALS['TL_DCA']['tl_content']['fields']['eSM_jg_margins'] = array
(
  'label'                   => &$GLOBALS['TL_LANG']['tl_content']['eSM_jg_margins'],
  'exclude'                 => true,
  'inputType'               => 'text',
  'eval'                    => array('tl_class'=>'w50','rgxp'=>'natural'),
  'sql'                     => "int(10) unsigned NOT NULL default '5'"
);

$GLOBALS['TL_DCA']['tl_content']['fields']['eSM_jg_captions'] = array
(
  'label'                   => &$GLOBALS['TL_LANG']['tl_content']['eSM_jg_captions'],
  'exclude'                 => true,
  'inputType'               => 'checkbox',
  'eval'                    => array('tl_class'=>'w50 m12'),
  'sql'                     => "char(1) NOT NULL default ''"
);

$GLOBALS['TL_DCA']['tl_content']['fields']['eSM_jg_waitLoaded'] = array
(
  'label'                   => &$GLOBALS['TL_LANG']['tl_content']['eSM_jg_waitLoaded'],
  'exclude'                 => true,
  'inputType'               => 'checkbox',
  'eval'                    => array('tl_class'=>'w50 m12'),
  'sql'                     => "char(1) NOT NULL default '1'"
);