<?php

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

/**
 * Palettes
 */
$GLOBALS['TL_DCA']['tl_module']['palettes']['__selector__'][] = 'showTeaserImg';
$GLOBALS['TL_DCA']['tl_module']['palettes']['pagelist'] = '{title_legend},name,headline,type;{config_legend},showProtected,showTeaserImg,perPage;{reference_legend},defineRoot;{template_legend:hide},customTpl,eSM_pagelist_template;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space';
$GLOBALS['TL_DCA']['tl_module']['subpalettes']['showTeaserImg'] = 'imgSize';

/**
 * Fields
 */
$GLOBALS['TL_DCA']['tl_module']['fields']['showTeaserImg'] = array
(
    'label'                   => &$GLOBALS['TL_LANG']['tl_module']['showTeaserImg'],
    'exclude'                 => true,
    'inputType'               => 'checkbox',
    'eval'                    => array('tl_class'=>'w50', 'submitOnChange'=>true),
    'sql'                     => "char(1) NOT NULL default ''"
);

$GLOBALS['TL_DCA']['tl_module']['fields']['eSM_pagelist_template'] = array
(
    'label'                   => &$GLOBALS['TL_LANG']['tl_module']['eSM_pagelist_template'],
    'exclude'                 => true,
    'default'                 => 'espl_default',
    'inputType'               => 'select',
    'options_callback'        => array('tl_module_esm_pagelist', 'getPagelistTemplates'),
    'eval'                    => array('tl_class'=>'w50'),
    'sql'                     => "varchar(64) NOT NULL default ''"
);

/**
 * Class tl_module_esm_pagelist
 * Provide miscellaneous methods that are used by the data configuration array.
 */
class tl_module_esm_pagelist extends Backend
{
    /**
     * Return all clientsShowcase snippet templates as array
     * @return array
     */
    public function getPagelistTemplates()
    {
        return $this->getTemplateGroup('espl_');
    }
}