protected function genCustomInputLocation($aInput) { $sProto = 0 == strncmp('https', BX_DOL_URL_ROOT, 5) ? 'https' : 'http'; $this->oTemplate->addJs($sProto . '://maps.google.com/maps/api/js?sensor=false'); $aInput['checked'] = $this->getCleanValue($aInput['name'] . '_lat') && $this->getCleanValue($aInput['name'] . '_lng') ? 1 : 0; $aVars = array('name' => $aInput['name'], 'id_status' => $this->getInputId($aInput) . '_status', 'location_string' => _t('_sys_location_undefined')); $aLocationIndexes = array('lat', 'lng', 'country', 'state', 'city', 'zip'); foreach ($aLocationIndexes as $sKey) { $aVars[$sKey] = $this->getLoctionVal($aInput, $sKey); } if ($aVars['country']) { $aCountries = BxDolFormQuery::getDataItems('Country'); $aVars['location_string'] = ($aVars['city'] ? $aVars['city'] . ', ' : '') . $aCountries[$aVars['country']]; } if ($this->getLoctionVal($aInput, 'lat') && $this->getLoctionVal($aInput, 'lng')) { $aInput['checked'] = true; } $aVars['input'] = $this->genInputSwitcher($aInput); return $this->oTemplate->parseHtmlByName('form_field_location.html', $aVars); }
/** * Get locations string with links * @param $iId content id * @return string with links to country and city */ public function locationsString($iId) { bx_import('BxDolForm'); bx_import('BxDolFormQuery'); $aCountries = BxDolFormQuery::getDataItems('Country'); $aLocation = $this->locationGet($iId); if (!$aLocation || !$aLocation['country'] || !isset($aCountries[$aLocation['country']])) { return ''; } $sCountryUrl = '<a href="' . BX_DOL_URL_ROOT . 'searchKeyword.php?type=location_country&keyword=' . $aLocation['country'] . '">' . $aCountries[$aLocation['country']] . '</a>'; if (!$aLocation['city']) { return _t('_sys_location_country', $sCountryUrl); } $sCityUrl = '<a href="' . BX_DOL_URL_ROOT . 'searchKeyword.php?type=location_country_city&keyword=' . $aLocation['country'] . '&state=' . rawurlencode($aLocation['state']) . '&city=' . rawurlencode($aLocation['city']) . '">' . $aLocation['city'] . '</a>'; return _t('_sys_location_country_city', $sCountryUrl, $sCityUrl); }
/** * Get data items array * @param $sKey data items identifier * @param $isUseForSet convert data items keys to use in set fields, make it power of 2 (1,2,4,8,16,etc). * @param $sUseValues use default(BX_DATA_VALUES_DEFAULT) or additional(BX_DATA_VALUES_ADDITIONAL) value titles, if additinal value title is missing default title is used * @return data items array */ public static function getDataItems($sKey, $isUseForSet = false, $sUseValues = BX_DATA_VALUES_DEFAULT) { return BxDolFormQuery::getDataItems($sKey, $isUseForSet, $sUseValues); }