[ 'dataContainer' => Contao\DC_Table::class, 'enableVersioning' => true, 'sql' => [ 'keys' => [ 'id' => 'primary', 'published' => 'index', 'hervorgehoben' => 'index', ], ], ], 'list' => [ 'sorting' => [ 'mode' => 1, 'fields' => ['hervorgehoben DESC', 'dateAdded DESC'], 'flag' => 6, 'panelLayout' => 'filter;sort,search,limit', ], 'label' => [ 'fields' => ['ueberschrift', 'dateAdded', 'dateModified'], 'showColumns' => true, ], 'global_operations' => [ 'all' => [ 'href' => 'act=select', 'class' => 'header_edit_all', 'attributes' => 'onclick="Backend.getScrollOffset()" accesskey="e"', ], ], 'operations' => [ 'edit' => [ 'href' => 'act=edit', 'icon' => 'edit.svg', ], 'copy' => [ 'href' => 'act=copy', 'icon' => 'copy.svg', ], 'delete' => [ 'href' => 'act=delete', 'icon' => 'delete.svg', 'attributes' => 'onclick="if(!confirm(\'' . ($GLOBALS['TL_LANG']['MSC']['deleteConfirm'] ?? 'Möchten Sie den Eintrag wirklich löschen?') . '\'))return false;Backend.getScrollOffset()"', ], 'toggle' => [ 'href' => 'act=toggle&field=published', 'icon' => 'visible.svg', ], 'show' => [ 'href' => 'act=show', 'icon' => 'show.svg', ], ], ], 'palettes' => [ 'default' => '{title_legend},ueberschrift,text,link,bild;{meta_legend},dateAdded,dateModified;{publish_legend},published,hervorgehoben', ], 'fields' => [ 'id' => [ 'sql' => 'int(10) unsigned NOT NULL auto_increment', ], 'tstamp' => [ 'sql' => 'int(10) unsigned NOT NULL default 0', ], 'ueberschrift' => [ 'exclude' => true, 'search' => true, 'sorting' => true, 'inputType' => 'text', 'eval' => ['mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'], 'sql' => "varchar(255) NOT NULL default ''", ], 'text' => [ 'exclude' => true, 'search' => true, 'inputType' => 'textarea', 'eval' => ['mandatory' => true, 'maxlength' => 3000, 'tl_class' => 'clr'], 'sql' => 'text NULL', ], 'link' => [ 'exclude' => true, 'search' => true, 'inputType' => 'text', 'eval' => ['rgxp' => 'url', 'decodeEntities' => true, 'maxlength' => 2048, 'dcaPicker' => true, 'tl_class' => 'w50'], 'sql' => "varchar(2048) NOT NULL default ''", ], 'bild' => [ 'exclude' => true, 'inputType' => 'fileTree', 'eval' => ['filesOnly' => true, 'fieldType' => 'radio', 'extensions' => Contao\Config::get('validImageTypes'), 'mandatory' => false, 'tl_class' => 'w50 clr'], 'sql' => 'binary(16) NULL', ], 'dateAdded' => [ 'sorting' => true, 'flag' => 6, 'inputType' => 'text', 'default' => time(), 'eval' => ['rgxp' => 'datim', 'datepicker' => true, 'mandatory' => true, 'tl_class' => 'w50 wizard'], 'sql' => 'int(10) unsigned NOT NULL default 0', ], 'dateModified' => [ 'sorting' => true, 'flag' => 6, 'inputType' => 'text', 'default' => time(), 'eval' => ['rgxp' => 'datim', 'readonly' => true, 'tl_class' => 'w50'], 'sql' => 'int(10) unsigned NOT NULL default 0', ], 'published' => [ 'exclude' => true, 'filter' => true, 'toggle' => true, 'inputType' => 'checkbox', 'eval' => ['doNotCopy' => true, 'tl_class' => 'w50 m12'], 'sql' => "char(1) NOT NULL default ''", ], 'hervorgehoben' => [ 'exclude' => true, 'filter' => true, 'toggle' => true, 'inputType' => 'checkbox', 'eval' => ['tl_class' => 'w50 m12'], 'sql' => "char(1) NOT NULL default ''", ], ], ]; $GLOBALS['TL_DCA']['tl_pinnwand']['fields']['ueberschrift']['save_callback'][] = static function (string $value, DataContainer $dataContainer): string { if ('copy' !== Input::get('act')) { return $value; } $baseHeadline = trim($value); if ('' === $baseHeadline) { return $value; } $start = 2; $base = $baseHeadline; if (preg_match('/^(.*)\s\((\d+)\)$/', $baseHeadline, $matches)) { $base = trim($matches[1]); $start = (int) $matches[2] + 1; } $id = (int) ($dataContainer->id ?? 0); $number = max(2, $start); $candidate = sprintf('%s (%d)', $base, $number); do { $exists = Database::getInstance() ->prepare('SELECT id FROM tl_pinnwand WHERE ueberschrift=? AND id!=?') ->execute($candidate, $id); if ($exists->numRows < 1) { return $candidate; } ++$number; $candidate = sprintf('%s (%d)', $base, $number); } while (true); }; $GLOBALS['TL_DCA']['tl_pinnwand']['fields']['dateAdded']['load_callback'][] = static function (mixed $value): int { $timestamp = (int) $value; return $timestamp > 0 ? $timestamp : time(); }; $GLOBALS['TL_DCA']['tl_pinnwand']['fields']['dateModified']['load_callback'][] = static function (mixed $value): int { $timestamp = (int) $value; return $timestamp > 0 ? $timestamp : time(); };