diff --git a/module/dca/tl_leaflet_control.php b/module/dca/tl_leaflet_control.php index 6177904..3bc5278 100644 --- a/module/dca/tl_leaflet_control.php +++ b/module/dca/tl_leaflet_control.php @@ -166,7 +166,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_control'] = array 'inputType' => 'text', 'search' => true, 'save_callback' => array( - \Netzmacht\Contao\Toolkit\Dca::createGenerateAliasCallback('tl_leaflet_control', 'title'), + \Netzmacht\Contao\Leaflet\Dca\Helper::createGenerateAliasCallback('tl_leaflet_control', 'title'), ), 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true), 'sql' => "varchar(255) NOT NULL default ''" diff --git a/module/dca/tl_leaflet_icon.php b/module/dca/tl_leaflet_icon.php index 806908f..677888b 100644 --- a/module/dca/tl_leaflet_icon.php +++ b/module/dca/tl_leaflet_icon.php @@ -174,7 +174,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_icon'] = array 'exclude' => true, 'inputType' => 'text', 'save_callback' => array( - \Netzmacht\Contao\Toolkit\Dca::createGenerateAliasCallback('tl_leaflet_icon', 'title'), + \Netzmacht\Contao\Leaflet\Dca\Helper::createGenerateAliasCallback('tl_leaflet_icon', 'title'), ), 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true), 'sql' => "varchar(255) NOT NULL default ''" diff --git a/module/dca/tl_leaflet_layer.php b/module/dca/tl_leaflet_layer.php index 1d10ccd..ed526fd 100644 --- a/module/dca/tl_leaflet_layer.php +++ b/module/dca/tl_leaflet_layer.php @@ -261,7 +261,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = array 'inputType' => 'text', 'search' => true, 'save_callback' => array( - \Netzmacht\Contao\Toolkit\Dca::createGenerateAliasCallback('tl_leaflet_layer', 'title'), + \Netzmacht\Contao\Leaflet\Dca\Helper::createGenerateAliasCallback('tl_leaflet_layer', 'title'), ), 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true), 'sql' => "varchar(255) NOT NULL default ''" diff --git a/module/dca/tl_leaflet_map.php b/module/dca/tl_leaflet_map.php index 76fce22..c283bf5 100644 --- a/module/dca/tl_leaflet_map.php +++ b/module/dca/tl_leaflet_map.php @@ -163,7 +163,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_map'] = array 'inputType' => 'text', 'search' => true, 'save_callback' => array( - \Netzmacht\Contao\Toolkit\Dca::createGenerateAliasCallback('tl_leaflet_map', 'title'), + \Netzmacht\Contao\Leaflet\Dca\Helper::createGenerateAliasCallback('tl_leaflet_map', 'title'), ), 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true), 'sql' => "varchar(255) NOT NULL default ''" diff --git a/module/dca/tl_leaflet_marker.php b/module/dca/tl_leaflet_marker.php index 12bfb6d..beab48d 100644 --- a/module/dca/tl_leaflet_marker.php +++ b/module/dca/tl_leaflet_marker.php @@ -172,7 +172,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_marker'] = array 'inputType' => 'text', 'search' => true, 'save_callback' => array( - \Netzmacht\Contao\Toolkit\Dca::createGenerateAliasCallback('tl_leaflet_marker', 'title'), + \Netzmacht\Contao\Leaflet\Dca\Helper::createGenerateAliasCallback('tl_leaflet_marker', 'title'), ), 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true), 'sql' => "varchar(255) NOT NULL default ''" diff --git a/module/dca/tl_leaflet_popup.php b/module/dca/tl_leaflet_popup.php index ef59223..d6e35aa 100644 --- a/module/dca/tl_leaflet_popup.php +++ b/module/dca/tl_leaflet_popup.php @@ -160,7 +160,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_popup'] = array 'exclude' => true, 'inputType' => 'text', 'save_callback' => array( - \Netzmacht\Contao\Toolkit\Dca::createGenerateAliasCallback('tl_leaflet_popup', 'title'), + \Netzmacht\Contao\Leaflet\Dca\Helper::createGenerateAliasCallback('tl_leaflet_popup', 'title'), ), 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true), 'sql' => "varchar(255) NOT NULL default ''" diff --git a/module/dca/tl_leaflet_style.php b/module/dca/tl_leaflet_style.php index 0c8a6f3..f3ea5d9 100644 --- a/module/dca/tl_leaflet_style.php +++ b/module/dca/tl_leaflet_style.php @@ -153,7 +153,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_style'] = array 'exclude' => true, 'inputType' => 'text', 'save_callback' => array( - \Netzmacht\Contao\Toolkit\Dca::createGenerateAliasCallback('tl_leaflet_style', 'title'), + \Netzmacht\Contao\Leaflet\Dca\Helper::createGenerateAliasCallback('tl_leaflet_style', 'title'), ), 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true), 'sql' => "varchar(255) NOT NULL default ''" diff --git a/module/dca/tl_leaflet_vector.php b/module/dca/tl_leaflet_vector.php index 44c8944..dcf6d4a 100644 --- a/module/dca/tl_leaflet_vector.php +++ b/module/dca/tl_leaflet_vector.php @@ -198,7 +198,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_vector'] = array 'inputType' => 'text', 'search' => true, 'save_callback' => array( - \Netzmacht\Contao\Toolkit\Dca::createGenerateAliasCallback('tl_leaflet_vector', 'title'), + \Netzmacht\Contao\Leaflet\Dca\Helper::createGenerateAliasCallback('tl_leaflet_vector', 'title'), ), 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true), 'sql' => "varchar(255) NOT NULL default ''" diff --git a/src/Netzmacht/Contao/Leaflet/Dca/Helper.php b/src/Netzmacht/Contao/Leaflet/Dca/Helper.php new file mode 100644 index 0000000..5735699 --- /dev/null +++ b/src/Netzmacht/Contao/Leaflet/Dca/Helper.php @@ -0,0 +1,43 @@ + + * @copyright 2015 netzmacht creative David Molineus + * @license LGPL 3.0 + * @filesource + * + */ + +namespace Netzmacht\Contao\Leaflet\Dca; + +use Netzmacht\Contao\Toolkit\Dca; +use Netzmacht\Contao\Toolkit\Dca\Callback\GenerateAliasCallback; + +/** + * Helper class for dca functions. + * + * @package Netzmacht\Contao\Leaflet\Dca + */ +class Helper +{ + /** + * Generate an alias callback which creates a valid javascript var name. + * + * @param string $table The table. + * @param string $column The value column, + * + * @return GenerateAliasCallback + */ + public static function createGenerateAliasCallback($table, $column) + { + $callback = Dca::createGenerateAliasCallback($table, $column); + $callback->getGenerator()->addFilter( + function ($value) { + return str_replace('-', '_', $value); + } + ); + + return $callback; + } +}