| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 | <?php/** * @file * CCK Field for Swedish phone numbers. */function phone_se_metadata() {  // These strings are translated using t() on output.  return array(    'error' => '"%value" is not a valid Swedish mobile phone number<br>Swedish phone numbers should only ...',  );}/** * Verifies that $phonenumber is valid * * @param string $phonenumber * @return boolean Returns boolean FALSE if the phone number is not valid. */function valid_se_phone_number($phonenumber) {  // define regular expression  $regex = "/^(([+]\d{2}[ ][1-9]\d{0,2}[ ])|([0]\d{1,3}[-]))((\d{2}([ ]\d{2}){2})|(\d{3}([ ]\d{3})*([ ]\d{2})+))$/i";  // return true if valid, false otherwise  return (bool) preg_match($regex, $phonenumber);}/** * Formatting for Sweden Phone Numbers. * * @param string $phonenumber * @return string Returns a string containting the phone number with some formatting. */function format_se_phone_number($phonenumber, $field) {  //$phonenumber = trim($phonenumber);   // do some formatting on the phone number/* ==> to be done ==> add the country code    if ($field['phone_country_code']) {      if ($matches[1] != "+39") {  	$phonenumber = "+39" . " " . $phonenumber;      }   }*/    return $phonenumber;}
 |