<?php

/**
 * References for Contao
 *
 * Copyright (c) 2014 Benjamin Roth [http://www.esales-media.de]
 *
 * @package eSM_clients
 * @link    http://www.esales-media.de
 * @license commercial
 */

/**
 * Table tl_esm_clients
 */
$GLOBALS['TL_DCA']['tl_esm_clients'] = array
(

	// Config
	'config' => array
	(
		'dataContainer'               => 'Table',
		'ctable'                      => array('tl_esm_clients_projects'),
		'switchToEdit'                => true,
		'enableVersioning'            => true,
		'doNotCopyRecords'            => true,
		'onload_callback' => array
		(
		),
		'oncopy_callback' => array
		(
		),
		'onsubmit_callback' => array
		(
		),
		'sql' => array
		(
			'keys' => array
			(
				'id' => 'primary',
			)
		)
	),

	// List
	'list' => array
	(
		'sorting' => array
		(
			'mode'                    => 2,
			'fields'                  => array('title'),
			'panelLayout'             => 'filter;search,limit',
		),
		'label' => array
		(
			'fields'                  => array('title'),
			'showColumns'             => true,
//			'label_callback'          => array('tl_member', 'addIcon')
		),
		'global_operations' => array
		(
			'settings' => array
			(
				'label'               => &$GLOBALS['TL_LANG']['tl_esm_clients']['settings'],
				'href'                => 'table=tl_esm_clients_settings',
				'icon'                => 'settings.gif',
			),
			'sort' => array
			(
				'label'               => &$GLOBALS['TL_LANG']['tl_esm_clients']['sort'],
				'href'                => 'key=sort',
				'icon'                => 'tablewizard.gif',
			),
			'all' => array
			(
				'label'               => &$GLOBALS['TL_LANG']['MSC']['all'],
				'href'                => 'act=select',
				'class'               => 'header_edit_all',
				'attributes'          => 'onclick="Backend.getScrollOffset()" accesskey="e"'
			)
		),
		'operations' => array
		(
			'edit' => array
			(
				'label'               => &$GLOBALS['TL_LANG']['tl_esm_clients']['edit'],
				'href'                => 'table=tl_esm_clients_projects',
				'icon'                => 'edit.gif',
			),
			'editheader' => array
			(
				'label'               => &$GLOBALS['TL_LANG']['tl_esm_clients']['editheader'],
				'href'                => 'act=edit',
				'icon'                => 'header.gif',
			),
			'copy' => array
			(
				'label'               => &$GLOBALS['TL_LANG']['tl_esm_clients']['copy'],
				'href'                => 'act=copy',
				'icon'                => 'copy.gif'
			),
			'delete' => array
			(
				'label'               => &$GLOBALS['TL_LANG']['tl_esm_clients']['delete'],
				'href'                => 'act=delete',
				'icon'                => 'delete.gif',
				'attributes'          => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\'))return false;Backend.getScrollOffset()"'
			),
			'toggle' => array
			(
				'label'               => &$GLOBALS['TL_LANG']['tl_esm_clients']['toggle'],
				'icon'                => 'visible.gif',
				'attributes'          => 'onclick="Backend.getScrollOffset();return AjaxRequest.toggleVisibility(this,%s)"',
				'button_callback'     => array('tl_esm_clients', 'toggleIcon')
			),
			'show' => array
			(
				'label'               => &$GLOBALS['TL_LANG']['tl_esm_clients']['show'],
				'href'                => 'act=show',
				'icon'                => 'show.gif'
			)
		)
	),

	// Select
	'select' => array
	(
		'buttons_callback' => array
		(
			array('tl_esm_clients', 'addAliasButton')
		)
	),

	// Palettes
	'palettes' => array
	(
		'default'                     => '{title_legend},title,alias;{categorize_legend},branch;{teaser_legend},text;{style_legend},basecolor,logo_neutral,logo_original;{invisible_legend:hide},invisible,start,stop'
	),

	// Fields
	'fields' => array
	(
		'id' => array
		(
			'sql'                     => "int(10) unsigned NOT NULL auto_increment"
		),
		'sorting' => array
		(
			'sql'                     => "int(10) unsigned NOT NULL default '0'"
		),
		'tstamp' => array
		(
			'sql'                     => "int(10) unsigned NOT NULL default '0'"
		),
		'alias' => array
		(
			'label'                   => &$GLOBALS['TL_LANG']['tl_esm_clients']['alias'],
			'exclude'                 => true,
			'search'                  => true,
			'inputType'               => 'text',
			'eval'                    => array('rgxp'=>'alias', 'unique'=>true, 'maxlength'=>128, 'tl_class'=>'w50'),
			'save_callback' => array
			(
				array('tl_esm_clients', 'generateAlias')
			),
			'sql'                     => "varchar(128) COLLATE utf8_bin NOT NULL default ''"
		),
		'title' => array
		(
			'label'                   => &$GLOBALS['TL_LANG']['tl_esm_clients']['title'],
			'inputType'               => 'text',
			'exclude'                 => true,
			'search'                  => true,
			'flag'                    => 1,
			'eval'                    => array('mandatory'=>true, 'maxlength'=>128, 'tl_class'=>'w50'),
			'sql'                     => "varchar(128) NOT NULL default ''"
		),
		'branch' => array
		(
			'label'                   => &$GLOBALS['TL_LANG']['tl_esm_clients']['branch'],
			'inputType'               => 'checkbox',
			'exclude'                 => true,
			'options_callback'        => array('tl_esm_clients','getBranches'),
			'eval'                    => array('mandatory'=>true, 'multiple'=>true, 'csv'=>','),
			'sql'                     => "text NULL",
			'relation'                => array('type'=>'hasOne','load'=>'lazy','table'=>'tl_esm_clients_settings')
		),
		'text' => array
		(
			'label'                   => &$GLOBALS['TL_LANG']['tl_esm_clients']['text'],
			'inputType'               => 'textarea',
			'exclude'                 => true,
			'eval'                    => array('mandatory'=>true, 'maxlength'=>1024, 'rte'=>'tinyMCE'),
			'sql'                     => "varchar(1024) NOT NULL default ''"
		),
		'basecolor' => array
		(
			'label'                   => &$GLOBALS['TL_LANG']['tl_esm_clients']['basecolor'],
			'inputType'               => 'text',
			'eval'                    => array('mandatory'=>true,'maxlength'=>6, 'multiple'=>true, 'size'=>2, 'colorpicker'=>true, 'isHexColor'=>true, 'decodeEntities'=>true, 'tl_class'=>'w50 wizard'),
			'sql'                     => "varchar(64) NOT NULL default ''"
		),
		'logo_neutral' => array
		(
			'label'                   => &$GLOBALS['TL_LANG']['tl_esm_clients']['logo_neutral'],
			'exclude'                 => true,
			'inputType'               => 'fileTree',
			'eval'                    => array('filesOnly'=>true, 'fieldType'=>'radio', 'mandatory'=>true, 'tl_class'=>'clr', 'extensions'=>Config::get('validImageTypes')),
			'sql'                     => "binary(16) NULL",
		),
		'logo_original' => array
		(
			'label'                   => &$GLOBALS['TL_LANG']['tl_esm_clients']['logo_original'],
			'exclude'                 => true,
			'inputType'               => 'fileTree',
			'eval'                    => array('filesOnly'=>true, 'fieldType'=>'radio', 'mandatory'=>true, 'tl_class'=>'clr', 'extensions'=>Config::get('validImageTypes')),
			'sql'                     => "binary(16) NULL",
		),
		'invisible' => array
		(
			'label'                   => &$GLOBALS['TL_LANG']['tl_esm_clients']['invisible'],
			'exclude'                 => true,
			'filter'                  => true,
			'inputType'               => 'checkbox',
			'eval'                    => array('doNotCopy'=>true),
			'sql'                     => "char(1) NOT NULL default ''"
		),
		'start' => array
		(
			'exclude'                 => true,
			'label'                   => &$GLOBALS['TL_LANG']['tl_esm_clients']['start'],
			'inputType'               => 'text',
			'eval'                    => array('rgxp'=>'datim', 'datepicker'=>true, 'tl_class'=>'w50 wizard'),
			'sql'                     => "varchar(10) NOT NULL default ''"
		),
		'stop' => array
		(
			'exclude'                 => true,
			'label'                   => &$GLOBALS['TL_LANG']['tl_esm_clients']['stop'],
			'inputType'               => 'text',
			'eval'                    => array('rgxp'=>'datim', 'datepicker'=>true, 'tl_class'=>'w50 wizard'),
			'sql'                     => "varchar(10) NOT NULL default ''"
		)
	)
);