[ 'dataContainer' => DC_Table::class, 'enableVersioning' => true, 'sql' => [ 'keys' => [ 'id' => 'primary', 'alias' => 'index', 'published' => 'index', 'title' => 'index', ], ], ], 'list' => [ 'sorting' => [ 'mode' => 1, 'fields' => ['title'], 'flag' => 1, 'panelLayout' => 'search,limit', ], 'label' => [ 'fields' => ['title', 'city'], 'format' => '%s (%s)', ], '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(\'' . (string) ($GLOBALS['TL_LANG']['MSC']['deleteConfirm'] ?? '') . '\'))return false;Backend.getScrollOffset()"', ], 'toggle' => [ 'href' => 'act=toggle&field=published', 'icon' => 'visible.svg', ], 'show' => [ 'href' => 'act=show', 'icon' => 'show.svg', ], ], ], 'palettes' => [ '__selector__' => [], 'default' => '{title_legend},title,alias,image;{address_legend},street,street2,postal,city,state,country;{geo_legend},lat,lng;{description_legend},description;{publish_legend},published', ], 'fields' => [ 'id' => [ 'sql' => ['type' => 'integer', 'unsigned' => true, 'autoincrement' => true], ], 'tstamp' => [ 'sql' => ['type' => 'integer', 'unsigned' => true, 'default' => 0], ], 'dateAdded' => [ 'sql' => ['type' => 'integer', 'unsigned' => true, 'default' => 0], ], 'title' => [ 'label' => &$GLOBALS['TL_LANG']['tl_location']['title'], 'exclude' => true, 'search' => true, 'sorting' => true, 'inputType' => 'text', 'eval' => ['mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'], 'sql' => ['type' => 'string', 'length' => 255, 'default' => ''], ], 'alias' => [ 'label' => &$GLOBALS['TL_LANG']['tl_location']['alias'], 'exclude' => true, 'search' => true, 'inputType' => 'text', 'eval' => ['rgxp' => 'alias', 'unique' => true, 'maxlength' => 128, 'tl_class' => 'w50'], 'sql' => ['type' => 'string', 'length' => 128, 'default' => ''], ], 'description' => [ 'label' => &$GLOBALS['TL_LANG']['tl_location']['description'], 'exclude' => true, 'inputType' => 'textarea', 'eval' => ['rte' => 'tinyMCE', 'tl_class' => 'clr'], 'sql' => ['type' => 'text', 'notnull' => false], ], 'street' => [ 'label' => &$GLOBALS['TL_LANG']['tl_location']['street'], 'exclude' => true, 'inputType' => 'text', 'eval' => ['maxlength' => 255, 'tl_class' => 'w50'], 'sql' => ['type' => 'string', 'length' => 255, 'default' => ''], ], 'street2' => [ 'label' => &$GLOBALS['TL_LANG']['tl_location']['street2'], 'exclude' => true, 'inputType' => 'text', 'eval' => ['maxlength' => 255, 'tl_class' => 'w50'], 'sql' => ['type' => 'string', 'length' => 255, 'default' => ''], ], 'postal' => [ 'label' => &$GLOBALS['TL_LANG']['tl_location']['postal'], 'exclude' => true, 'inputType' => 'text', 'eval' => ['maxlength' => 255, 'tl_class' => 'w50'], 'sql' => ['type' => 'string', 'length' => 255, 'default' => ''], ], 'city' => [ 'label' => &$GLOBALS['TL_LANG']['tl_location']['city'], 'exclude' => true, 'search' => true, 'sorting' => true, 'inputType' => 'text', 'eval' => ['maxlength' => 255, 'tl_class' => 'w50'], 'sql' => ['type' => 'string', 'length' => 255, 'default' => ''], ], 'state' => [ 'label' => &$GLOBALS['TL_LANG']['tl_location']['state'], 'exclude' => true, 'inputType' => 'text', 'eval' => ['maxlength' => 255, 'tl_class' => 'w50'], 'sql' => ['type' => 'string', 'length' => 255, 'default' => ''], ], 'country' => [ 'label' => &$GLOBALS['TL_LANG']['tl_location']['country'], 'exclude' => true, 'inputType' => 'text', 'eval' => ['maxlength' => 2, 'tl_class' => 'w50'], 'sql' => ['type' => 'string', 'length' => 2, 'default' => 'de'], ], 'lat' => [ 'label' => &$GLOBALS['TL_LANG']['tl_location']['lat'], 'exclude' => true, 'inputType' => 'text', 'eval' => ['maxlength' => 11, 'tl_class' => 'w50'], 'sql' => ['type' => 'decimal', 'precision' => 11, 'scale' => 8, 'default' => '0.00000000'], ], 'lng' => [ 'label' => &$GLOBALS['TL_LANG']['tl_location']['lng'], 'exclude' => true, 'inputType' => 'text', 'eval' => ['maxlength' => 11, 'tl_class' => 'w50'], 'sql' => ['type' => 'decimal', 'precision' => 11, 'scale' => 8, 'default' => '0.00000000'], ], 'image' => [ 'label' => &$GLOBALS['TL_LANG']['tl_location']['image'], 'exclude' => true, 'inputType' => 'fileTree', 'eval' => ['filesOnly' => true, 'fieldType' => 'radio', 'tl_class' => 'clr'], 'sql' => ['type' => 'binary', 'length' => 16, 'notnull' => false], ], 'published' => [ 'label' => &$GLOBALS['TL_LANG']['tl_location']['published'], 'exclude' => true, 'filter' => true, 'toggle' => true, 'inputType' => 'checkbox', 'eval' => ['doNotCopy' => true], 'sql' => ['type' => 'string', 'length' => 1, 'fixed' => true, 'default' => ''], ], ], ]; $GLOBALS['TL_DCA']['tl_location']['fields']['alias']['save_callback'][] = static function (string $value, DataContainer $dc): string { if ($value !== '') { return $value; } $value = StringUtil::generateAlias($dc->activeRecord?->title ?? ''); $exists = Database::getInstance() ->prepare('SELECT id FROM tl_location WHERE alias=? AND id!=?') ->execute($value, (int) ($dc->id ?? 0)); if ($exists->numRows > 0) { throw new \RuntimeException(sprintf((string) ($GLOBALS['TL_LANG']['tl_location']['aliasExists'] ?? '%s'), $value)); } return $value; };