Use translateable coordinate validator.

This commit is contained in:
David Molineus
2016-10-06 09:47:12 +02:00
parent ca4e4e0d2d
commit a6ffe76134
7 changed files with 20 additions and 36 deletions

View File

@@ -271,7 +271,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_icon'] = array
'exclude' => true, 'exclude' => true,
'inputType' => 'text', 'inputType' => 'text',
'save_callback' => array( 'save_callback' => array(
array('Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks', 'validateCoordinate') \Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateCoordinates')
), ),
'eval' => array( 'eval' => array(
'maxlength' => 255, 'maxlength' => 255,
@@ -286,7 +286,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_icon'] = array
'exclude' => true, 'exclude' => true,
'inputType' => 'text', 'inputType' => 'text',
'save_callback' => array( 'save_callback' => array(
array('Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks', 'validateCoordinate') \Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateCoordinates')
), ),
'eval' => array( 'eval' => array(
'maxlength' => 255, 'maxlength' => 255,
@@ -301,7 +301,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_icon'] = array
'exclude' => true, 'exclude' => true,
'inputType' => 'text', 'inputType' => 'text',
'save_callback' => array( 'save_callback' => array(
array('Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks', 'validateCoordinate') \Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateCoordinates')
), ),
'eval' => array( 'eval' => array(
'maxlength' => 255, 'maxlength' => 255,

View File

@@ -180,7 +180,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_map'] = array
'exclude' => true, 'exclude' => true,
'inputType' => 'text', 'inputType' => 'text',
'save_callback' => array( 'save_callback' => array(
array('Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks', 'validateCoordinate') \Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateCoordinates'),
), ),
'wizard' => array( 'wizard' => array(
array('Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks', 'getGeocoder') array('Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks', 'getGeocoder')

View File

@@ -189,7 +189,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_marker'] = array
'exclude' => true, 'exclude' => true,
'inputType' => 'text', 'inputType' => 'text',
'save_callback' => array( 'save_callback' => array(
array('Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks', 'validateCoordinate'), \Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateCoordinates'),
array('Netzmacht\Contao\Leaflet\Dca\MarkerCallbacks', 'saveCoordinates') array('Netzmacht\Contao\Leaflet\Dca\MarkerCallbacks', 'saveCoordinates')
), ),
'load_callback' => array( 'load_callback' => array(

View File

@@ -231,7 +231,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_popup'] = array
'exclude' => true, 'exclude' => true,
'inputType' => 'text', 'inputType' => 'text',
'save_callback' => array( 'save_callback' => array(
array('Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks', 'validateCoordinate') \Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateCoordinates')
), ),
'eval' => array( 'eval' => array(
'maxlength' => 255, 'maxlength' => 255,

View File

@@ -311,7 +311,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_vector'] = array
'exclude' => true, 'exclude' => true,
'inputType' => 'text', 'inputType' => 'text',
'save_callback' => array( 'save_callback' => array(
array('Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks', 'validateCoordinate') \Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateCoordinates')
), ),
'wizard' => array( 'wizard' => array(
array('Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks', 'getGeocoder') array('Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks', 'getGeocoder')
@@ -320,6 +320,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_vector'] = array
'maxlength' => 255, 'maxlength' => 255,
'tl_class' => 'long clr', 'tl_class' => 'long clr',
'nullIfEmpty' => true, 'nullIfEmpty' => true,
'mandatory' => true,
), ),
'sql' => "varchar(255) NULL" 'sql' => "varchar(255) NULL"
), ),

View File

@@ -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'][0] = 'Tile layer';
$GLOBALS['TL_LANG']['leaflet_layer']['tile'][1] = 'Tile layer with full config options.'; $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'][0] = 'Polyline';
$GLOBALS['TL_LANG']['leaflet_vector']['polyline'][1] = 'Polyline overlay. For more details read the <a href="http://leafletjs.com/reference.html#polyline" target="_blank">Leaflet documentation</a>.'; $GLOBALS['TL_LANG']['leaflet_vector']['polyline'][1] = 'Polyline overlay. For more details read the <a href="http://leafletjs.com/reference.html#polyline" target="_blank">Leaflet documentation</a>.';
$GLOBALS['TL_LANG']['leaflet_vector']['multiPolyline'][0] = 'Multi polylines'; $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 <a href="http://leafletjs.com/reference.html#multipolyline" target="_blank">Leaflet documentation</a>.'; $GLOBALS['TL_LANG']['leaflet_vector']['multiPolyline'][1] = 'Multi polylines with shared styling. For more details read the <a href="http://leafletjs.com/reference.html#multipolyline" target="_blank">Leaflet documentation</a>.';
$GLOBALS['TL_LANG']['leaflet_vector']['polygon'][0] = 'Polygon'; $GLOBALS['TL_LANG']['leaflet_vector']['polygon'][0] = 'Polygon';
$GLOBALS['TL_LANG']['leaflet_vector']['polygon'][1] = 'Polygon overlay. For more details read the <a href="http://leafletjs.com/reference.html#polygon" target="_blank">Leaflet documentation</a>.'; $GLOBALS['TL_LANG']['leaflet_vector']['polygon'][1] = 'Polygon overlay. For more details read the <a href="http://leafletjs.com/reference.html#polygon" target="_blank">Leaflet documentation</a>.';
$GLOBALS['TL_LANG']['leaflet_vector']['multiPolygon'][0] = 'Multi polygons'; $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 <a href="http://leafletjs.com/reference.html#multipolygon" target="_blank">Leaflet documentation</a>.'; $GLOBALS['TL_LANG']['leaflet_vector']['multiPolygon'][1] = 'Multi polygons with shared styling. For more details read the <a href="http://leafletjs.com/reference.html#multipolygon" target="_blank">Leaflet documentation</a>.';
$GLOBALS['TL_LANG']['leaflet_vector']['circle'][0] = 'Circle'; $GLOBALS['TL_LANG']['leaflet_vector']['circle'][0] = 'Circle';
$GLOBALS['TL_LANG']['leaflet_vector']['circle'][1] = 'Circle overlay. For more details read the <a href="http://leafletjs.com/reference.html#circle" target="_blank">Leaflet documentation</a>.'; $GLOBALS['TL_LANG']['leaflet_vector']['circle'][1] = 'Circle overlay. For more details read the <a href="http://leafletjs.com/reference.html#circle" target="_blank">Leaflet documentation</a>.';
$GLOBALS['TL_LANG']['leaflet_vector']['circleMarker'][0] = 'Circle marker'; $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 <a href="http://leafletjs.com/reference.html#circlemarker" target="_blank">Leaflet documentation</a>.'; $GLOBALS['TL_LANG']['leaflet_vector']['circleMarker'][1] = 'Circle marker with fixed pixel width. For more details read the <a href="http://leafletjs.com/reference.html#circlemarker" target="_blank">Leaflet documentation</a>.';
$GLOBALS['TL_LANG']['leaflet_vector']['rectangle'][0] = 'Rectangle'; $GLOBALS['TL_LANG']['leaflet_vector']['rectangle'][0] = 'Rectangle';
$GLOBALS['TL_LANG']['leaflet_vector']['rectangle'][1] = 'Rectangle overlay. For more details read the <a href="http://leafletjs.com/reference.html#rectangle" target="_blank">Leaflet documentation</a>.'; $GLOBALS['TL_LANG']['leaflet_vector']['rectangle'][1] = 'Rectangle overlay. For more details read the <a href="http://leafletjs.com/reference.html#rectangle" target="_blank">Leaflet documentation</a>.';
$GLOBALS['TL_LANG']['leaflet']['searchPosition'] = 'Search location'; $GLOBALS['TL_LANG']['leaflet']['searchPosition'] = 'Search location';
$GLOBALS['TL_LANG']['leaflet']['applyPosition'] = 'Apply position'; $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.';

View File

@@ -24,24 +24,6 @@ use Netzmacht\LeafletPHP\Value\LatLng;
*/ */
class LeafletCallbacks 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. * Create the zoom range.
* *