### Eclipse Workspace Patch 1.0 #P cck_gmapaddress Index: cck_gmapaddress.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cck_gmapaddress/cck_gmapaddress.module,v retrieving revision 1.1.2.1 diff -u -r1.1.2.1 cck_gmapaddress.module --- cck_gmapaddress.module 20 Jun 2009 02:59:34 -0000 1.1.2.1 +++ cck_gmapaddress.module 22 Jun 2009 11:27:50 -0000 @@ -38,6 +38,11 @@ '#default_value' => $field['accuracy'], '#options' => _cck_gmapaddress_accuracy(), ); + $form['validation_not_mandatory'] = array( + '#type' => 'checkbox', + '#title' => t('Validation is not mandatory'), + '#default_value' => $field['validation_not_mandatory'], + ); //GMAP SIMPLE $form['gmap_simple'] = array( '#type' => 'fieldset', @@ -222,7 +227,7 @@ case 'validate': break; case 'save': - return array('tld', 'accuracy', 'gmap_all', 'gmap_simple', 'route_single', 'route_all'); + return array('tld', 'validation_not_mandatory', 'accuracy', 'gmap_all', 'gmap_simple', 'route_single', 'route_all'); case 'database columns': $columns = array( 'longitude' => array('type' => 'decimal', 'length' => '18,15', 'unsigned' => FALSE, 'not null' => TRUE, 'default' => 0), @@ -260,7 +265,7 @@ case 'validate': foreach ($node_field as $key => $item) { //Proofs for empty - if (($key == 0 && $field['required']) || $item['address']!='') { + if (($key == 0 && $field['required']) || $item['address'] != '') { //Proofs on valid geo location in gmap if (drupal_strlen($field['tld']) < 2) $field['tld'] = 'com'; if (!$item['status']) { @@ -270,6 +275,9 @@ if ($item['status'] == 610) { form_set_error($field['field_name'] .']['. $key .'][address', t('No valid Google Map Key! Set correct key in !link', array('!link' => l('GMap Admin', base_path() .'admin/settings/gmap')))); } + elseif($field['validation_not_mandatory'] && $item['status']!= 200) { + drupal_set_message(t('The address %address in %field could not be validated as correct address! Look at !link to check your address.', array('%address' => $item['address'], '%field' => $field['field_name'] ."[$key]", '!link' => l('Maps.Google.'. $field['tld'], "http://maps.google.{$field['tld']}/maps", array(), "q={$item['address']}"))), 'warning'); + } elseif ($item['status']!= 200) { form_set_error($field['field_name'] .']['. $key .'][address', t('The address %address in %field could not be validated as correct address! Look at !link to check your address.', array('%address' => $item['address'], '%field' => $field['field_name'] ."[$key]", '!link' => l('Maps.Google.'. $field['tld'], "http://maps.google.{$field['tld']}/maps", array(), "q={$item['address']}")))); } @@ -454,6 +462,7 @@ // return t('lon: %lon - lat: %lat',array('%lon' => $item['longitude'],'%lat' => $item['latitude'])); $lon = $item['longitude']; $lat = $item['latitude']; + if ($lon == 0 && $lat == 0) return ; if ($lon < 0) { $lon = -$lon; $lonc = 'W'; @@ -472,7 +481,7 @@ } $latd = floor($lat); $latm = ($lat - $latd) * 60; - return t("$latc @latd° @latm' $lonc @lond° @lonm'", array('%latd' => $latd, '@latm' => sprintf("%6.3f", $latm), '@lond' => $lond, '@lonm' => sprintf("%6.3f", $lonm))); //direct input of $latc and $lonc allows them to be translated within the string, so there are 4 locale strings for translation + return t("$latc @latd° @latm' $lonc @lond° @lonm'", array('@latd' => $latd, '@latm' => sprintf("%6.3f", $latm), '@lond' => $lond, '@lonm' => sprintf("%6.3f", $lonm))); //direct input of $latc and $lonc allows them to be translated within the string, so there are 4 locale strings for translation case 'accuracy': if (!($item['longitude']*1) && !($item['latitude']*1)) return ; return _cck_gmapaddress_accuracy($item['accuracy']);