array
(
'dataContainer' => 'Table',
'enableVersioning' => true,
'onload_callback' => array
(
),
'oncopy_callback' => array
(
),
'onsubmit_callback' => array
(
),
'sql' => array
(
'keys' => array
(
'id' => 'primary',
)
)
),
// List
'list' => array
(
'sorting' => array
(
'mode' => 1,
'flag' => 11,
'fields' => array('type','title'),
'panelLayout' => 'filter,search,limit',
),
'label' => array
(
'fields' => array('title'),
'format' => '%s'
// 'showColumns' => true,
// 'label_callback' => array('tl_member', 'addIcon')
),
'global_operations' => array
(
'all' => array
(
'label' => &$GLOBALS['TL_LANG']['MSC']['all'],
'href' => 'act=select',
'class' => 'header_edit_all',
'attributes' => 'onclick="Backend.getScrollOffset()" accesskey="e"'
),
'back' => array
(
'label' => &$GLOBALS['TL_LANG']['MSC']['backBT'],
'href' => '',
'class' => 'header_back',
'button_callback' => array('tl_esm_clients_settings', 'backBT')
)
),
'operations' => array
(
'edit' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_esm_clients_settings']['edit'],
'href' => 'act=edit',
'icon' => 'edit.gif',
),
'copy' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_esm_clients_settings']['copy'],
'href' => 'act=copy',
'icon' => 'copy.gif'
),
'delete' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_esm_clients_settings']['delete'],
'href' => 'act=delete',
'icon' => 'delete.gif',
'attributes' => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\'))return false;Backend.getScrollOffset()"'
),
'show' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_esm_clients_settings']['show'],
'href' => 'act=show',
'icon' => 'show.gif'
)
)
),
// Palettes
'palettes' => array
(
'__selector__' => array('type'),
'default' => '{type_legend},type;{attribute_legend},title',
'services' => '{type_legend},type;{attribute_legend},title,url',
'tech' => '{type_legend},type;{attribute_legend},title,url'
),
// Fields
'fields' => array
(
'id' => array
(
'sql' => "int(10) unsigned NOT NULL auto_increment"
),
'tstamp' => array
(
'sql' => "int(10) unsigned NOT NULL default '0'"
),
'type' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_esm_clients_settings']['type'],
'inputType' => 'select',
'exclude' => true,
'filter' => true,
'options' => array('branch','type','services','tech'),
'reference' => $GLOBALS['TL_LANG']['tl_esm_clients_settings']['REF'],
'eval' => array('mandatory'=>true, 'includeBlankOption'=>true,'submitOnChange'=>true, 'csv'=>','),
'sql' => "text NULL"
),
'title' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_esm_clients_settings']['title'],
'inputType' => 'text',
'exclude' => true,
'search' => true,
'eval' => array('mandatory'=>true, 'maxlength'=>128, 'tl_class'=>'w50'),
'sql' => "varchar(128) NOT NULL default ''"
),
'url' => array
(
'label' => &$GLOBALS['TL_LANG']['MSC']['url'],
'exclude' => true,
'search' => true,
'inputType' => 'text',
'eval' => array('mandatory'=>true, 'rgxp'=>'url', 'decodeEntities'=>true, 'maxlength'=>255, 'fieldType'=>'radio', 'tl_class'=>'w50 wizard'),
'wizard' => array
(
array('tl_esm_clients_settings', 'pagePicker')
),
'sql' => "varchar(255) NOT NULL default ''"
),
)
);
class tl_esm_clients_settings extends Backend
{
/**
* Import the back end user object
*/
public function __construct()
{
parent::__construct();
$this->import('BackendUser', 'User');
}
/**
* Return the back button
* @param string
* @param string
* @param string
* @param string
* @param string
* @return string
*/
public function backBT($href, $label, $title, $class, $attributes)
{
return ''.$label.' ';
}
/**
* Return the file picker wizard
* @param \DataContainer
* @return string
*/
public function filePicker(DataContainer $dc)
{
return ' ' . Image::getHtml('pickfile.gif', $GLOBALS['TL_LANG']['MSC']['filepicker'], 'style="vertical-align:top;cursor:pointer"') . '';
}
/**
* Return the link picker wizard
* @param \DataContainer
* @return string
*/
public function pagePicker(DataContainer $dc)
{
return ' field . '\',\'tag\':\'ctrl_'. $dc->field . ((Input::get('act') == 'editAll') ? '_' . $dc->id : '') . '\',\'self\':this});return false">' . Image::getHtml('pickpage.gif', $GLOBALS['TL_LANG']['MSC']['pagepicker'], 'style="vertical-align:top;cursor:pointer"') . '';
}
/**
* Return the "toggle visibility" button
* @param array
* @param string
* @param string
* @param string
* @param string
* @param string
* @return string
*/
public function toggleIcon($row, $href, $label, $title, $icon, $attributes)
{
if (strlen(Input::get('tid')))
{
$this->toggleVisibility(Input::get('tid'), (Input::get('state') == 1));
$this->redirect($this->getReferer());
}
// Check permissions AFTER checking the tid, so hacking attempts are logged
if (!$this->User->hasAccess('tl_esm_clients_settings::invisible', 'alexf'))
{
return '';
}
$href .= '&id='.Input::get('id').'&tid='.$row['id'].'&state='.$row['invisible'];
if ($row['invisible'])
{
$icon = 'invisible.gif';
}
return ''.Image::getHtml($icon, $label).' ';
}
/**
* Toggle the visibility of an element
* @param integer
* @param boolean
*/
public function toggleVisibility($intId, $blnVisible)
{
// Check permissions to edit
Input::setGet('id', $intId);
Input::setGet('act', 'toggle');
// The onload_callbacks vary depending on the dynamic parent table (see #4894)
if (is_array($GLOBALS['TL_DCA']['tl_esm_clients_settings']['config']['onload_callback']))
{
foreach ($GLOBALS['TL_DCA']['tl_esm_clients_settings']['config']['onload_callback'] as $callback)
{
if (is_array($callback))
{
$this->import($callback[0]);
$this->$callback[0]->$callback[1]($this);
}
elseif (is_callable($callback))
{
$callback($this);
}
}
}
// Check permissions to publish
if (!$this->User->hasAccess('tl_esm_clients_settings::invisible', 'alexf'))
{
$this->log('Not enough permissions to show/hide content element ID "'.$intId.'"', __METHOD__, TL_ERROR);
$this->redirect('contao/main.php?act=error');
}
$objVersions = new Versions('tl_content', $intId);
$objVersions->initialize();
// Trigger the save_callback
if (is_array($GLOBALS['TL_DCA']['tl_esm_clients_settings']['fields']['invisible']['save_callback']))
{
foreach ($GLOBALS['TL_DCA']['tl_esm_clients_settings']['fields']['invisible']['save_callback'] as $callback)
{
if (is_array($callback))
{
$this->import($callback[0]);
$blnVisible = $this->$callback[0]->$callback[1]($blnVisible, $this);
}
elseif (is_callable($callback))
{
$blnVisible = $callback($blnVisible, $this);
}
}
}
// Update the database
$this->Database->prepare("UPDATE tl_esm_clients_settings SET tstamp=". time() .", invisible='" . ($blnVisible ? '' : 1) . "' WHERE id=?")
->execute($intId);
$objVersions->create();
$this->log('A new version of record "tl_esm_clients_settings.id='.$intId.'" has been created', __METHOD__, TL_GENERAL);
}
}