You are here

function gmap_todim in GMap Module 6.2

Same name and namespace in other branches
  1. 5 gmap.module \gmap_todim()
  2. 6 gmap.module \gmap_todim()
  3. 7.2 gmap.module \gmap_todim()
  4. 7 gmap.module \gmap_todim()

Make sure a string is a valid css dimension.

2 calls to gmap_todim()
GMapSimpleAPITest::testGMapToDim in tests/gmap.test
Verify gmap_todim().
gmap_dimension_validate in ./gmap.module
Ensure a textfield is a valid css dimension string.

File

./gmap.module, line 439
GMap -- Routines to use the Google Maps API in Drupal.

Code

function gmap_todim($instring) {
  if (!is_string($instring)) {
    return FALSE;
  }
  $s = strtolower(trim($instring));
  $matches = array();
  if (preg_match('/^([\\d.]+)\\s*(em|ex|px|in|cm|mm|pt|pc|%)$/', $s, $matches)) {
    return $matches[1] . $matches[2];
  }
  else {
    return FALSE;
  }
}