static function processDatamap_preProcessFieldArray(array &$incomingFieldArray, $table, $id, \TYPO3\CMS\Core\DataHandling\DataHandler &$reference) { global $TCA; $tca = $TCA[$table]['ctrl']['EXT']['wec_map']; $isMappable = $tca['isMappable']; if ($isMappable) { if ($tca['latlongFields']) { /* Grab the lat and long that were posted */ $newlat = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('wec_map_lat'); $newlong = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('wec_map_long'); $origlat = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('wec_map_original_lat'); $origlong = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('wec_map_original_long'); /* If the lat/long changed, then insert a new entry into the cache or update it. */ if (($newlat != $origlat or $newlong != $origlong) and !empty($newlat) && !empty($newlong) and is_numeric($newlat) && is_numeric($newlong)) { /* Get the names of the fields from the TCA */ $latField = tx_wecmap_shared::getLatLongField($table, 'lat'); $longField = tx_wecmap_shared::getLatLongField($table, 'long'); $incomingFieldArray[$latField] = $newlat; $incomingFieldArray[$longField] = $newlong; } } } }
/** * Adds a marker by getting the address info from the TCA * * @param string The db table that contains the mappable records * @param integer The uid of the record to be mapped * @param string The title for the marker popup. * @param string The description to be displayed in the marker popup. * @param integer Minimum zoom level for marker to appear. * @param integer Maximum zoom level for marker to appear. * @return marker object **/ function addMarkerByTCA($table, $uid, $title = '', $description = '', $minzoom = 0, $maxzoom = 18, $iconID = '') { $uid = intval($uid); // first get the mappable info from the TCA $tca = $GLOBALS['TCA'][$table]['ctrl']['EXT']['wec_map']; if (!$tca) { return false; } if (!$tca['isMappable']) { return false; } // get address from db for this record $record = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', $table, 'uid=' . intval($uid)); $record = $record[0]; if ($tca['addressFields']) { $streetfield = tx_wecmap_shared::getAddressField($table, 'street'); $cityfield = tx_wecmap_shared::getAddressField($table, 'city'); $statefield = tx_wecmap_shared::getAddressField($table, 'state'); $zipfield = tx_wecmap_shared::getAddressField($table, 'zip'); $countryfield = tx_wecmap_shared::getAddressField($table, 'country'); $street = $record[$streetfield]; $city = $record[$cityfield]; $state = $record[$statefield]; $zip = $record[$zipfield]; $country = $record[$countryfield]; if (empty($country) && $countryfield == 'static_info_country') { $country = $record['country']; } else { if (empty($country) && $countryfield == 'country') { $country = $record['static_info_country']; } } /* Geocode the address */ $latlong = tx_wecmap_cache::lookup($street, $city, $state, $zip, $country, $this->key); /* Create a marker at the specified latitude and longitude */ return $this->addMarkerByLatLong($latlong['lat'], $latlong['long'], $title, $description, $minzoom, $maxzoom, $iconID); } else { if ($tca['latlongFields']) { $latfield = tx_wecmap_shared::getLatLongField($table, 'lat'); $longfield = tx_wecmap_shared::getLatLongField($table, 'long'); $lat = $record[$latfield]; $long = $record[$longfield]; /* Create a marker at the specified latitude and longitude */ return $this->addMarkerByLatLong($lat, $long, $title, $description, $minzoom, $maxzoom, $iconID); } else { return false; } } }