/** * 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; } } }
/** * Shows map * * @return String **/ function showMap() { global $LANG; /* Create the Map object */ $width = 500; $height = 500; $conf = $GLOBALS['BE_USER']->getModuleData('tools_txwecmapM2'); // get options $scale = $conf['scale']; $minimap = $conf['minimap']; $maptype = $conf['maptype']; $mapcontrolsize = $conf['mapcontrolsize']; $streetField = tx_wecmap_shared::getAddressField('fe_users', 'street'); $cityField = tx_wecmap_shared::getAddressField('fe_users', 'city'); $stateField = tx_wecmap_shared::getAddressField('fe_users', 'state'); $zipField = tx_wecmap_shared::getAddressField('fe_users', 'zip'); $countryField = tx_wecmap_shared::getAddressField('fe_users', 'country'); $map = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\tx_wecmap_map_google::class, $apiKey, $width, $height); // evaluate map controls based on configuration switch ($mapcontrolsize) { case 'large': $map->addControl('largeMap'); break; case 'small': $map->addControl('smallMap'); break; case 'zoomonly': $map->addControl('smallZoom'); break; default: // do nothing break; } if ($scale) { $map->addControl('scale'); } if ($minimap) { $map->addControl('overviewMap'); } if ($maptype) { $map->addControl('mapType'); } $map->enableDirections(false, 'directions'); /* Select all frontend users */ $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'fe_users', ''); // create country and zip code array to keep track of which country and state we already added to the map. // the point is to create only one marker per country on a higher zoom level to not // overload the map with all the markers and do the same with zip codes. $countries = array(); $cities = array(); while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { // add check for country and use different field if empty // @TODO: make this smarter with TCA or something if (empty($row[$countryField]) && $countryField == 'static_info_country') { $countryField = 'country'; } else { if (empty($row[$countryField]) && $countryField == 'country') { $countryField = 'static_info_country'; } } /* Only try to add marker if there's a city */ if ($row[$cityField] != '') { // if we haven't added a marker for this country yet, do so. if (!in_array($row[$countryField], $countries) && !empty($row[$countryField])) { // add this country to the array $countries[] = $row[$countryField]; // add a little info so users know what to do $title = ''; $description = '<div class="description">' . sprintf($LANG->getLL('country_zoominfo_desc'), $row[$countryField]) . '</div>'; // add a marker for this country and only show it between zoom levels 0 and 2. $map->addMarkerByAddress(null, $row[$cityField], $row[$stateField], $row[$zipField], $row[$countryField], $title, $description, 0, 2); } // if we haven't added a marker for this zip code yet, do so. if (!in_array($row[$cityField], $cities) && !empty($cityField)) { // add this country to the array $cities[] = $row[$cityField]; // add a little info so users know what to do $title = ''; $description = '<div class="description">' . $LANG->getLL('area_zoominfo_desc') . '</div>'; // add a marker for this country and only show it between zoom levels 0 and 2. $map->addMarkerByAddress(null, $row[$cityField], $row[$stateField], $row[$zipField], $row[$countryField], $title, $description, 3, 7); } // make title and description $title = '<div style="font-size: 110%; font-weight: bold;">' . $row['name'] . '</div>'; $content = '<div>' . $row[$streetField] . '<br />' . $row[$cityField] . ', ' . $row[$stateField] . ' ' . $row[$zipField] . '<br />' . $row[$countryField] . '</div>'; // add all the markers starting at zoom level 3 so we don't crowd the map right away. // if private was checked, don't use address to geocode if ($private) { $map->addMarkerByAddress(null, $row[$cityField], $row[$stateField], $row[$zipField], $row[$countryField], $title, $content, 8); } else { $map->addMarkerByAddress($row[$streetField], $row[$cityField], $row[$stateField], $row[$zipField], $row[$countryField], $title, $content, 8); } } } $content = $map->drawMap(); $content .= '<div id="directions"></div>'; return $content; }
/** * Checks the TCA for address mapping rules and returns the address value. * If a mapping rule is defined, this tells us what field contains address * related information. If no rules are defined, we pick default fields * to use. * * @param string The portion of the address we're trying to map. * @param array Array of field related data. * @return string The specified portion of the address. * @todo Refactor this to use getFieldNameForTable(). */ static function getFieldValue($key, $PA) { global $TCA; $table = $PA['table']; $row = $PA['row']; /* If the address mapping array has a mapping for this address, use it */ $addressFields = $PA['fieldConf']['config']['params']['addressFields']; if (isset($addressFields[$key])) { $fieldName = $addressFields[$key]; } else { /* If the address mapping array has a mapping for this lat/long, use it */ $latlongFields = $PA['fieldConf']['config']['params']['latlongFields']; if (isset($latlongFields[$key])) { $fieldName = $latlongFields[$key]; } else { /* If the ctrl section of the TCA has a name, use it */ if (isset($ctrlAddressFields[$key])) { $fieldName = tx_wecmap_shared::getAddressField($table, $key); } else { /* Otherwise, use the default name */ $fieldName = $key; } } } /* If the source data has a value for the address field, grab it */ if (isset($row[$fieldName])) { $value = $row[$fieldName]; } else { /* Otherwise, use an empty string */ $value = ''; } return $value; }
/** * Draws a Google map containing all frontend users of a website. * * @param array $content The content array. * @param array $conf The conf array. * @return string HTML / Javascript representation of a Google map. */ function main($content, $conf) { $this->conf = $conf; $this->pi_setPiVarDefaults(); $this->pi_loadLL(); $out = ''; // check for WEC Map API static template inclusion if (empty($conf['output']) && !(empty($conf['marker.']['title']) && empty($conf['marker.']['description']))) { global $LANG; $LANG->includeLLFile('EXT:wec_map/locallang_db.xml'); $out .= $LANG->getLL('wecApiTemplateNotIncluded'); // syslog start \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog('WEC Map API template not included on page id ' . $GLOBALS['TSFE']->id, 'wec_map', 3); // syslog end return $out; } // check for WEC FE Map static template inclusion if (empty($conf['marker.']['title']) && empty($conf['marker.']['description'])) { global $LANG; $LANG->includeLLFile('EXT:wec_map/locallang_db.xml'); $out .= $LANG->getLL('pi2TemplateNotIncluded'); \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog('WEC FE User template not included on page id ' . $GLOBALS['TSFE']->id, 'wec_map', 3); return $out; } /* Initialize the Flexform and pull the data into a new object */ $this->pi_initPIflexform(); $piFlexForm = $this->cObj->data['pi_flexform']; // get config from flexform or TS. Flexforms take precedence. $width = $this->pi_getFFvalue($piFlexForm, 'mapWidth', 'default'); empty($width) ? $width = $this->cObj->stdWrap($conf['width'], $conf['width.']) : null; $height = $this->pi_getFFvalue($piFlexForm, 'mapHeight', 'default'); empty($height) ? $height = $this->cObj->stdWrap($conf['height'], $conf['height.']) : null; $this->height = $height; $userGroups = $this->pi_getFFvalue($piFlexForm, 'userGroups', 'default'); empty($userGroups) ? $userGroups = $this->cObj->stdWrap($conf['userGroups'], $conf['userGroups.']) : null; $pid = $this->pi_getFFvalue($piFlexForm, 'pid', 'default'); empty($pid) ? $pid = $this->cObj->stdWrap($conf['pid'], $conf['pid.']) : null; $mapControlSize = $this->pi_getFFvalue($piFlexForm, 'mapControlSize', 'mapControls'); empty($mapControlSize) || $mapControlSize == 'none' ? $mapControlSize = $this->cObj->stdWrap($conf['controls.']['mapControlSize'], $conf['controls.']['mapControlSize.']) : null; $overviewMap = $this->pi_getFFvalue($piFlexForm, 'overviewMap', 'mapControls'); empty($overviewMap) ? $overviewMap = $this->cObj->stdWrap($conf['controls.']['showOverviewMap'], $conf['controls.']['showOverviewMap.']) : null; $mapType = $this->pi_getFFvalue($piFlexForm, 'mapType', 'mapControls'); empty($mapType) ? $mapType = $this->cObj->stdWrap($conf['controls.']['showMapType'], $conf['controls.']['showMapType.']) : null; $googleEarth = $this->pi_getFFvalue($piFlexForm, 'googleEarth', 'mapControls'); empty($googleEarth) ? $googleEarth = $this->cObj->stdWrap($conf['controls.']['showGoogleEarth'], $conf['controls.']['showGoogleEarth.']) : null; $initialMapType = $this->pi_getFFvalue($piFlexForm, 'initialMapType', 'default'); empty($initialMapType) ? $initialMapType = $this->cObj->stdWrap($conf['initialMapType'], $conf['initialMapType.']) : null; $scale = $this->pi_getFFvalue($piFlexForm, 'scale', 'mapControls'); empty($scale) ? $scale = $this->cObj->stdWrap($conf['controls.']['showScale'], $conf['controls.']['showScale.']) : null; $private = $this->pi_getFFvalue($piFlexForm, 'privacy', 'default'); empty($private) ? $private = $this->cObj->stdWrap($conf['private'], $conf['private.']) : null; $showDirs = $this->pi_getFFvalue($piFlexForm, 'showDirections', 'default'); empty($showDirs) ? $showDirs = $this->cObj->stdWrap($conf['showDirections'], $conf['showDirections.']) : null; $this->showDirections = $showDirs; $showWrittenDirs = $this->pi_getFFvalue($piFlexForm, 'showWrittenDirections', 'default'); empty($showWrittenDirs) ? $showWrittenDirs = $this->cObj->stdWrap($conf['showWrittenDirections'], $conf['showWrittenDirections.']) : null; $prefillAddress = $this->pi_getFFvalue($piFlexForm, 'prefillAddress', 'default'); empty($prefillAddress) ? $prefillAddress = $this->cObj->stdWrap($conf['prefillAddress'], $conf['prefillAddress.']) : null; $showRadiusSearch = $this->pi_getFFvalue($piFlexForm, 'showRadiusSearch', 'default'); empty($showRadiusSearch) ? $showRadiusSearch = $this->cObj->stdWrap($conf['showRadiusSearch'], $conf['showRadiusSearch.']) : null; $showSidebar = $this->pi_getFFvalue($piFlexForm, 'showSidebar', 'default'); empty($showSidebar) ? $showSidebar = $this->cObj->stdWrap($conf['showSidebar'], $conf['showSidebar.']) : null; $this->showSidebar = $showSidebar; $kml = $this->cObj->stdWrap($conf['kml'], $conf['kml.']); $centerLat = $this->cObj->stdWrap($conf['centerLat'], $conf['centerLat.']); $centerLong = $this->cObj->stdWrap($conf['centerLong'], $conf['centerLong.']); $zoomLevel = $this->cObj->stdWrap($conf['zoomLevel'], $conf['zoomLevel.']); $maxAutoZoom = $this->cObj->stdWrap($conf['maxAutoZoom'], $conf['maxAutoZoom.']); $enableOverlappingMarkerManager = $this->cObj->stdWrap($conf['enableOverlappingMarkerManager'], $conf['enableOverlappingMarkerManager.']); $overlappingMarkerLatDev = $this->cObj->stdWrap($conf['overlappingMarkerLatDev'], $conf['overlappingMarkerLatDev.']); $overlappingMarkerLongDev = $this->cObj->stdWrap($conf['overlappingMarkerLongDev'], $conf['overlappingMarkerLongDev.']); $static = $this->cObj->stdWrap($conf['static.']['enabled'], $conf['static.']['enabled.']); $staticMode = $this->cObj->stdWrap($conf['static.']['mode'], $conf['static.']['mode.']); $staticExtent = $this->cObj->stdWrap($conf['static.']['extent'], $conf['static.']['extent.']); $staticUrlParam = $this->cObj->stdWrap($conf['static.']['urlParam'], $conf['static.']['urlParam.']); $staticLimit = $this->cObj->stdWrap($conf['static.']['limit'], $conf['static.']['limit.']); $mapName = $this->cObj->stdWrap($conf['mapName'], $conf['mapName.']); if (empty($mapName)) { $mapName = 'map' . $this->cObj->data['uid']; } $this->mapName = $mapName; /** @var \tx_wecmap_map_google $map */ $map = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\tx_wecmap_map_google::class, null, $width, $height, $centerLat, $centerLong, $zoomLevel, $mapName); // get kml urls for each included record if (!empty($kml)) { $where = 'uid IN (' . $GLOBALS['TYPO3_DB']->cleanIntList($kml) . ')'; $res = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('url', 'tx_wecmap_external', $where); foreach ($res as $key => $url) { $link = trim($url['url']); $oldAbs = $GLOBALS['TSFE']->absRefPrefix; $GLOBALS['TSFE']->absRefPrefix = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL'); $linkConf = array('parameter' => $link, 'returnLast' => 'url'); $link = $this->cObj->typolink('', $linkConf); $GLOBALS['TSFE']->absRefPrefix = $oldAbs; $map->addKML($link); } } // evaluate map controls based on configuration if ($mapControlSize == 'large') { $map->addControl('largeMap'); } else { if ($mapControlSize == 'small') { $map->addControl('smallMap'); } else { if ($mapControlSize == 'zoomonly') { $map->addControl('smallZoom'); } } } $map->setMaxAutoZoom($maxAutoZoom); if ($enableOverlappingMarkerManager) { $map->addOption('enableOverlappingMarkerManager', true); } if ($scale) { $map->addControl('scale'); } if ($overviewMap) { $map->addControl('overviewMap'); } if ($mapType) { $map->addControl('mapType'); } if ($initialMapType) { $map->setType($initialMapType); } if ($googleEarth) { $map->addControl('googleEarth'); } if ($static) { $map->enableStatic($staticMode, $staticExtent, $staticUrlParam, $staticLimit); } // set up groups: // country if (is_array($conf['groups.']['country.']) || $private) { $countryConf = array(); $countryConf['icon'] = $conf['groups.']['country.']['icon.']; $countryConf['minzoom'] = $this->cObj->stdWrap($conf['groups.']['country.']['zoom.']['min'], $conf['groups.']['country.']['zoom.']['min.']); $countryConf['maxzoom'] = $this->cObj->stdWrap($conf['groups.']['country.']['zoom.']['max'], $conf['groups.']['country.']['zoom.']['max.']); // country icon, if configured if (!empty($countryConf['icon']['imagepath']) || !empty($countryConf['icon']['imagepath.'])) { $map->addMarkerIcon($countryConf['icon'], $this->cObj); } else { $countryConf['icon']['iconID'] ? null : ($countryConf['icon']['iconID'] = null); } $showCountries = true; } else { $showCountries = false; } // city if (is_array($conf['groups.']['city.']) || $private) { $cityConf = array(); $cityConf['icon'] = $conf['groups.']['city.']['icon.']; $cityConf['minzoom'] = $this->cObj->stdWrap($conf['groups.']['city.']['zoom.']['min'], $conf['groups.']['city.']['zoom.']['min.']); $cityConf['maxzoom'] = $this->cObj->stdWrap($conf['groups.']['city.']['zoom.']['max'], $conf['groups.']['city.']['zoom.']['max.']); // city icon, if configured if (!empty($cityConf['icon']['imagepath']) || !empty($cityConf['icon']['imagepath.'])) { $map->addMarkerIcon($cityConf['icon'], $this->cObj); } else { $cityConf['icon']['iconID'] ? null : ($cityConf['icon']['iconID'] = null); } $showCities = true; } else { $showCities = false; } // single $singleConf = array(); $singleConf['icon'] = $conf['groups.']['single.']['icon.']; $singleConf['minzoom'] = $this->cObj->stdWrap($conf['groups.']['single.']['zoom.']['min'], $conf['groups.']['single.']['zoom.']['min.']); $singleConf['maxzoom'] = $this->cObj->stdWrap($conf['groups.']['single.']['zoom.']['max'], $conf['groups.']['single.']['zoom.']['max.']); // country icon, if configured if (!empty($singleConf['icon']['imagepath']) || !empty($singleConf['icon']['imagepath.'])) { $map->addMarkerIcon($singleConf['icon'], $this->cObj); } else { $singleConf['icon']['iconID'] ? null : ($singleConf['icon']['iconID'] = null); } // check whether to show the directions tab and/or prefill addresses and/or written directions if ($showDirs && $showWrittenDirs && $prefillAddress) { $map->enableDirections(true, $mapName . '_directions'); } if ($showDirs && $showWrittenDirs && !$prefillAddress) { $map->enableDirections(false, $mapName . '_directions'); } if ($showDirs && !$showWrittenDirs && $prefillAddress) { $map->enableDirections(true); } if ($showDirs && !$showWrittenDirs && !$prefillAddress) { $map->enableDirections(); } // process radius search if ($showRadiusSearch) { // check for POST vars for our map. If there are any, proceed. $pRadius = intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_POST($mapName . '_radius')); if (!empty($pRadius)) { $pAddress = strip_tags(\TYPO3\CMS\Core\Utility\GeneralUtility::_POST($mapName . '_address')); $pCity = strip_tags(\TYPO3\CMS\Core\Utility\GeneralUtility::_POST($mapName . '_city')); $pState = strip_tags(\TYPO3\CMS\Core\Utility\GeneralUtility::_POST($mapName . '_state')); $pZip = strip_tags(\TYPO3\CMS\Core\Utility\GeneralUtility::_POST($mapName . '_zip')); $pCountry = strip_tags(\TYPO3\CMS\Core\Utility\GeneralUtility::_POST($mapName . '_country')); $pKilometers = intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_POST($mapName . '_kilometers')); $data = array('street' => $pAddress, 'city' => $pCity, 'state' => $pState, 'zip' => $pZip, 'country' => $pCountry); $desc = tx_wecmap_shared::render($data, $conf['defaultdescription.']); $map->addMarkerIcon($conf['homeicon.'], $this->cObj); $map->addMarkerByAddress($pAddress, $pCity, $pState, $pZip, $pCountry, '', $desc, 0, 18, 'homeicon'); $map->setCenterByAddress($pAddress, $pCity, $pState, $pZip, $pCountry); $map->setRadius($pRadius, $pKilometers); } } $streetField = tx_wecmap_shared::getAddressField('fe_users', 'street'); $cityField = tx_wecmap_shared::getAddressField('fe_users', 'city'); $stateField = tx_wecmap_shared::getAddressField('fe_users', 'state'); $zipField = tx_wecmap_shared::getAddressField('fe_users', 'zip'); $countryField = tx_wecmap_shared::getAddressField('fe_users', 'country'); // start where clause $where = '1=1'; // if a user group was set, make sure only those users from that group // will be selected in the query if ($userGroups) { $where .= tx_wecmap_shared::listQueryFromCSV('usergroup', $userGroups, 'fe_users'); } // if a storage folder pid was specified, filter by that if ($pid) { $where .= tx_wecmap_shared::listQueryFromCSV('pid', $pid, 'fe_users', 'OR'); } // additional condition set by TypoScript $additionalWhere = $this->cObj->stdWrap($conf['table.']['additionalWhere'], $conf['table.']['additionalWhere.']); if ($additionalWhere) { $where .= 'AND (' . $additionalWhere . ') '; } // filter out records that shouldn't be shown, e.g. deleted, hidden $where .= $this->cObj->enableFields('fe_users'); // sorting $orderBy = $this->cObj->stdWrap($conf['table.']['orderBy'], $conf['table.']['orderBy.']); // limit $limit = $this->cObj->stdWrap($conf['table.']['limit'], $conf['table.']['limit.']); /* Select all frontend users */ $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'fe_users', $where, '', $orderBy, $limit); // create country and zip code array to keep track of which country and state we already added to the map. // the point is to create only one marker per country on a higher zoom level to not // overload the map with all the markers, and do the same with zip codes. $countries = array(); $cities = array(); while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { // add check for country and use different field if empty // @TODO: make this smarter with TCA or something if (empty($row[$countryField]) && $countryField == 'static_info_country') { $countryField = 'country'; } else { if (empty($row[$countryField]) && $countryField == 'country') { $countryField = 'static_info_country'; } } /* Only try to add marker if there's a city */ if ($row[$cityField] != '') { // if we haven't added a marker for this country yet, do so. if ($showCountries && !in_array($row[$countryField], $countries) && !empty($row[$countryField])) { // add this country to the array $countries[] = $row[$countryField]; // combine title config to pass to render function $title_conf = array('title' => $conf['marker.']['title'], 'title.' => $conf['marker.']['title.']); // add a little info so users know what to do $title = tx_wecmap_shared::render(array('name' => $this->pi_getLL('country_zoominfo_title')), $title_conf); $description = sprintf($this->pi_getLL('country_zoominfo_desc'), $row[$countryField]); // add a marker for this country and only show it between the configured zoom level. $map->addMarkerByAddress(null, $row[$cityField], $row[$stateField], $row[$zipField], $row[$countryField], $title, $description, $countryConf['minzoom'], $countryConf['maxzoom'], $countryConf['icon']['iconID']); } // if we haven't added a marker for this zip code yet, do so. if ($showCities && !in_array($row[$cityField], $cities) && !empty($row[$cityField])) { // add this country to the array $cities[] = $row[$cityField]; // combine title config to pass to render function $title_conf = array('title' => $conf['marker.']['title'], 'title.' => $conf['marker.']['title.']); // add a little info so users know what to do $title = tx_wecmap_shared::render(array('name' => 'Info'), $title_conf); $countWhere = $cityField . '=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($row[$cityField], 'fe_users'); if ($zipField) { $countWhere .= ' AND ' . $zipField . '=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($row[$zipField], 'fe_users'); } if ($additionalWhere) { $countWhere .= 'AND (' . $additionalWhere . ') '; } $count = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('count(*)', 'fe_users', $countWhere); $count = $count[0]['count(*)']; // extra processing if private is turned on if ($private) { $maxzoom = $singleConf['maxzoom']; if ($count == 1) { $description = sprintf($this->pi_getLL('citycount_si'), $row[$cityField]); } else { $description = sprintf($this->pi_getLL('citycount_pl'), $count, $row[$cityField]); } } else { $maxzoom = $cityConf['maxzoom']; $description = sprintf($this->pi_getLL('city_zoominfo_desc'), $row[$cityField]); } // add a marker for the city level and only show it // either from city-min to single-max or city-min to city-max, depending on privacy settings $marker = $map->addMarkerByAddress(null, $row[$cityField], $row[$stateField], $row[$zipField], $row[$countryField], $title, $description, $cityConf['minzoom'], $maxzoom, $cityConf['icon']['iconID']); } // make title and description $title = tx_wecmap_shared::render($row, $conf['marker.']['title.']); $description = tx_wecmap_shared::render($row, $conf['marker.']['description.']); // unless we are using privacy, add individual markers as well if (!$private) { $marker = $map->addMarkerByAddress($row[$streetField], $row[$cityField], $row[$stateField], $row[$zipField], $row[$countryField], $title, $description, $singleConf['minzoom'], $singleConf['maxzoom'], $singleConf['icon']['iconID']); if ($overlappingMarkerLatDev && $overlappingMarkerLongDev) { $map->handleOverlappingMarker($marker, $overlappingMarkerLatDev, $overlappingMarkerLongDev); } $row['info_title'] = $title; $row['info_description'] = $description; $this->addSidebarItem($marker, $row); $this->addDirectionsMenu($marker); } } } // gather all the content together $content = array(); $content['map'] = $map->drawMap(); if ($showRadiusSearch) { $content['addressForm'] = $this->getAddressForm(); } if ($showWrittenDirs) { $content['directions'] = $this->getDirections(); } if ($showSidebar) { $content['sidebar'] = $this->getSidebar(); } // run all the content pieces through TS to assemble them $output = tx_wecmap_shared::render($content, $conf['output.']); return $this->pi_wrapInBaseClass($output); }
/** * Gets the address of the user who is currently logged in * * @return string **/ function getUserAddress() { if ($this->prefillAddress) { if (TYPO3_MODE == 'FE') { $feuser_id = $GLOBALS['TSFE']->fe_user->user['uid']; if (!empty($feuser_id)) { $table = 'fe_users'; $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'); $select = $streetField . ', ' . $cityField . ', ' . $stateField . ', ' . $zipField . ', ' . $countryField; $selectArray = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $select, true); $select = implode(',', $selectArray); $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows($select, 'fe_users', '`uid`=' . intval($feuser_id)); return $rows[0][$streetField] . ', ' . $rows[0][$cityField] . ', ' . $rows[0][$stateField] . ' ' . $rows[0][$zipField] . ', ' . $rows[0][$countryField]; } } else { } } return ''; }
/** * Performs geocoding on an individual table. * * @param string Name of the table. * @return none */ function geocodeTable($table) { global $TYPO3_DB; $addressFields = array('street' => tx_wecmap_shared::getAddressField($table, 'street'), 'city' => tx_wecmap_shared::getAddressField($table, 'city'), 'state' => tx_wecmap_shared::getAddressField($table, 'state'), 'zip' => tx_wecmap_shared::getAddressField($table, 'zip'), 'country' => tx_wecmap_shared::getAddressField($table, 'country')); $where = "1=1" . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table); $result = $TYPO3_DB->exec_SELECTquery('*', $table, $where); while ($row = $TYPO3_DB->sql_fetch_assoc($result)) { if ($this->stopGeocoding()) { return; } else { $this->geocodeRecord($row, $addressFields); } } }
public function test_get_city_field_for_fe_users() { $city = tx_wecmap_shared::getAddressField('fe_users', 'city'); $this->assertEquals('city', $city); }
/** * returns an array with title and description * * @return array **/ function getTitleAndDescription($conf, $data) { // merge the table into the data $data = array_merge($data, array('table' => $conf['table'])); // process title only if TS config is present if (!empty($conf['title.'])) { $title = tx_wecmap_shared::render($data, $conf['title.'], $conf['table']); } else { $data['name'] = $this->getRecordTitle($conf['table'], $data); $title = tx_wecmap_shared::render($data, $this->conf['defaulttitle.'], $conf['table']); } // process description also only if TS config is present, // otherwise display the address if (!empty($conf['description.'])) { $desc = tx_wecmap_shared::render($data, $conf['description.'], $conf['table']); } else { $ad = array(); $ad['street'] = $data[tx_wecmap_shared::getAddressField($conf['table'], 'street')]; $ad['city'] = $data[tx_wecmap_shared::getAddressField($conf['table'], 'city')]; $ad['state'] = $data[tx_wecmap_shared::getAddressField($conf['table'], 'state')]; $ad['zip'] = $data[tx_wecmap_shared::getAddressField($conf['table'], 'zip')]; $ad['country'] = $data[tx_wecmap_shared::getAddressField($conf['table'], 'country')]; $desc = tx_wecmap_shared::render($ad, $this->conf['defaultdescription.'], $conf['table']); } return array($title, $desc); }