diff --git a/module/dca/tl_leaflet_icon.php b/module/dca/tl_leaflet_icon.php index 3b30655..a82483a 100644 --- a/module/dca/tl_leaflet_icon.php +++ b/module/dca/tl_leaflet_icon.php @@ -271,7 +271,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_icon'] = array 'exclude' => true, 'inputType' => 'text', 'save_callback' => array( - array('Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks', 'validateCoordinate') + \Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateCoordinates') ), 'eval' => array( 'maxlength' => 255, @@ -286,7 +286,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_icon'] = array 'exclude' => true, 'inputType' => 'text', 'save_callback' => array( - array('Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks', 'validateCoordinate') + \Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateCoordinates') ), 'eval' => array( 'maxlength' => 255, @@ -301,7 +301,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_icon'] = array 'exclude' => true, 'inputType' => 'text', 'save_callback' => array( - array('Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks', 'validateCoordinate') + \Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateCoordinates') ), 'eval' => array( 'maxlength' => 255, diff --git a/module/dca/tl_leaflet_map.php b/module/dca/tl_leaflet_map.php index c41838e..ac4b537 100644 --- a/module/dca/tl_leaflet_map.php +++ b/module/dca/tl_leaflet_map.php @@ -180,7 +180,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_map'] = array 'exclude' => true, 'inputType' => 'text', 'save_callback' => array( - array('Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks', 'validateCoordinate') + \Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateCoordinates'), ), 'wizard' => array( array('Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks', 'getGeocoder') diff --git a/module/dca/tl_leaflet_marker.php b/module/dca/tl_leaflet_marker.php index 4af7254..ed56ecf 100644 --- a/module/dca/tl_leaflet_marker.php +++ b/module/dca/tl_leaflet_marker.php @@ -189,7 +189,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_marker'] = array 'exclude' => true, 'inputType' => 'text', 'save_callback' => array( - array('Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks', 'validateCoordinate'), + \Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateCoordinates'), array('Netzmacht\Contao\Leaflet\Dca\MarkerCallbacks', 'saveCoordinates') ), 'load_callback' => array( diff --git a/module/dca/tl_leaflet_popup.php b/module/dca/tl_leaflet_popup.php index b8a47db..120ae01 100644 --- a/module/dca/tl_leaflet_popup.php +++ b/module/dca/tl_leaflet_popup.php @@ -231,7 +231,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_popup'] = array 'exclude' => true, 'inputType' => 'text', 'save_callback' => array( - array('Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks', 'validateCoordinate') + \Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateCoordinates') ), 'eval' => array( 'maxlength' => 255, diff --git a/module/dca/tl_leaflet_vector.php b/module/dca/tl_leaflet_vector.php index 182e701..59b766f 100644 --- a/module/dca/tl_leaflet_vector.php +++ b/module/dca/tl_leaflet_vector.php @@ -311,7 +311,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_vector'] = array 'exclude' => true, 'inputType' => 'text', 'save_callback' => array( - array('Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks', 'validateCoordinate') + \Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateCoordinates') ), 'wizard' => array( array('Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks', 'getGeocoder') @@ -320,6 +320,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_vector'] = array 'maxlength' => 255, 'tl_class' => 'long clr', 'nullIfEmpty' => true, + 'mandatory' => true, ), 'sql' => "varchar(255) NULL" ), diff --git a/module/languages/en/leaflet.php b/module/languages/en/leaflet.php index 9cc5aec..9285a61 100644 --- a/module/languages/en/leaflet.php +++ b/module/languages/en/leaflet.php @@ -28,22 +28,23 @@ $GLOBALS['TL_LANG']['leaflet_layer']['markercluster'][1] = 'Marker cluster layer $GLOBALS['TL_LANG']['leaflet_layer']['tile'][0] = 'Tile layer'; $GLOBALS['TL_LANG']['leaflet_layer']['tile'][1] = 'Tile layer with full config options.'; -$GLOBALS['TL_LANG']['leaflet_vector']['polyline'][0] = 'Polyline'; -$GLOBALS['TL_LANG']['leaflet_vector']['polyline'][1] = 'Polyline overlay. For more details read the Leaflet documentation.'; -$GLOBALS['TL_LANG']['leaflet_vector']['multiPolyline'][0] = 'Multi polylines'; -$GLOBALS['TL_LANG']['leaflet_vector']['multiPolyline'][1] = 'Multi polylines with shared styling. For more details read the Leaflet documentation.'; -$GLOBALS['TL_LANG']['leaflet_vector']['polygon'][0] = 'Polygon'; -$GLOBALS['TL_LANG']['leaflet_vector']['polygon'][1] = 'Polygon overlay. For more details read the Leaflet documentation.'; +$GLOBALS['TL_LANG']['leaflet_vector']['polyline'][0] = 'Polyline'; +$GLOBALS['TL_LANG']['leaflet_vector']['polyline'][1] = 'Polyline overlay. For more details read the Leaflet documentation.'; +$GLOBALS['TL_LANG']['leaflet_vector']['multiPolyline'][0] = 'Multi polylines'; +$GLOBALS['TL_LANG']['leaflet_vector']['multiPolyline'][1] = 'Multi polylines with shared styling. For more details read the Leaflet documentation.'; +$GLOBALS['TL_LANG']['leaflet_vector']['polygon'][0] = 'Polygon'; +$GLOBALS['TL_LANG']['leaflet_vector']['polygon'][1] = 'Polygon overlay. For more details read the Leaflet documentation.'; $GLOBALS['TL_LANG']['leaflet_vector']['multiPolygon'][0] = 'Multi polygons'; $GLOBALS['TL_LANG']['leaflet_vector']['multiPolygon'][1] = 'Multi polygons with shared styling. For more details read the Leaflet documentation.'; -$GLOBALS['TL_LANG']['leaflet_vector']['circle'][0] = 'Circle'; -$GLOBALS['TL_LANG']['leaflet_vector']['circle'][1] = 'Circle overlay. For more details read the Leaflet documentation.'; +$GLOBALS['TL_LANG']['leaflet_vector']['circle'][0] = 'Circle'; +$GLOBALS['TL_LANG']['leaflet_vector']['circle'][1] = 'Circle overlay. For more details read the Leaflet documentation.'; $GLOBALS['TL_LANG']['leaflet_vector']['circleMarker'][0] = 'Circle marker'; $GLOBALS['TL_LANG']['leaflet_vector']['circleMarker'][1] = 'Circle marker with fixed pixel width. For more details read the Leaflet documentation.'; -$GLOBALS['TL_LANG']['leaflet_vector']['rectangle'][0] = 'Rectangle'; -$GLOBALS['TL_LANG']['leaflet_vector']['rectangle'][1] = 'Rectangle overlay. For more details read the Leaflet documentation.'; +$GLOBALS['TL_LANG']['leaflet_vector']['rectangle'][0] = 'Rectangle'; +$GLOBALS['TL_LANG']['leaflet_vector']['rectangle'][1] = 'Rectangle overlay. For more details read the Leaflet documentation.'; $GLOBALS['TL_LANG']['leaflet']['searchPosition'] = 'Search location'; $GLOBALS['TL_LANG']['leaflet']['applyPosition'] = 'Apply position'; -$GLOBALS['TL_LANG']['leaflet']['invalidAlias'] = 'Invalid alias given. Alias may not be empty, begin with a numeric value nor contain any special chars (underscore allowed).'; +$GLOBALS['TL_LANG']['leaflet']['invalidAlias'] = 'Invalid alias given. Alias may not be empty, begin with a numeric value nor contain any special chars (underscore allowed).'; +$GLOBALS['TL_LANG']['leaflet']['invalidCoordinates'] = 'Invalid coordinate values given.'; diff --git a/src/Netzmacht/Contao/Leaflet/Dca/LeafletCallbacks.php b/src/Netzmacht/Contao/Leaflet/Dca/LeafletCallbacks.php index b112d46..3c9b706 100644 --- a/src/Netzmacht/Contao/Leaflet/Dca/LeafletCallbacks.php +++ b/src/Netzmacht/Contao/Leaflet/Dca/LeafletCallbacks.php @@ -24,24 +24,6 @@ use Netzmacht\LeafletPHP\Value\LatLng; */ class LeafletCallbacks { - /** - * Validate a coordinate. - * - * @param mixed $value The given value. - * - * @return mixed - */ - public function validateCoordinate($value) - { - if (!empty($value)) { - // Validate by creating latlng object. Throws an exception. - - LatLng::fromString($value); - } - - return $value; - } - /** * Create the zoom range. *