isPluginActivated('GeoIp2') || LocationProvider::getCurrentProvider() instanceof GeoIp) { return GeoIp::getRegionNameFromCodes($countryCode, $regionCode); } $name = GeoIp2::getRegionNameFromCodes($countryCode, $regionCode); // fallback if no translation for with GeoIP2 if ($name == Piwik::translate('General_Unknown')) { $name = GeoIp::getRegionNameFromCodes($countryCode, $regionCode); } return $name; } /** * Returns the region name using the label of a Visits by Region report. * * @param string $label A label containing a region code followed by '|' and a country code, eg, * 'P3|GB'. * @return string|false The region name or false if $label == DataTable::LABEL_SUMMARY_ROW. */ function getRegionName($label) { if ($label == DataTable::LABEL_SUMMARY_ROW) { return false; // so no metadata/column is added } if ($label == '') { return Piwik::translate('General_Unknown'); } list($regionCode, $countryCode) = explode(Archiver::LOCATION_SEPARATOR, $label); return getRegionNameFromCodes($countryCode, $regionCode); } /** * Returns the name of a region + the name of the region's country using the label of * a Visits by Region report. * * @param string $label A label containing a region code followed by '|' and a country code, eg, * 'P3|GB'. * @return string|false eg. 'Ile de France, France' or false if $label == DataTable::LABEL_SUMMARY_ROW. */ function getPrettyRegionName($label) { if ($label == DataTable::LABEL_SUMMARY_ROW) { return $label; } if ($label == '') { return Piwik::translate('General_Unknown'); } list($regionCode, $countryCode) = explode(Archiver::LOCATION_SEPARATOR, $label); $result = getRegionNameFromCodes($countryCode, $regionCode); if ($countryCode != Visit::UNKNOWN_CODE && $countryCode != '') { $result .= ', ' . countryTranslate($countryCode); } return $result; } /** * Returns the name of a city + the name of its region + the name of its country using * the label of a Visits by City report. * * @param string $label A label containing a city name, region code + country code, * separated by two '|' chars: 'Paris|A8|FR' * @return string|false eg. 'Paris, Ile de France, France' or false if $label == * DataTable::LABEL_SUMMARY_ROW. */ function getPrettyCityName($label) { if ($label == DataTable::LABEL_SUMMARY_ROW) { return $label; } if ($label == '') { return Piwik::translate('General_Unknown'); } // get city name, region code & country code $parts = explode(Archiver::LOCATION_SEPARATOR, $label); $cityName = $parts[0]; $regionCode = $parts[1]; $countryCode = @$parts[2]; if ($cityName == Visit::UNKNOWN_CODE || $cityName == '') { $cityName = Piwik::translate('General_Unknown'); } $result = $cityName; if ($countryCode != Visit::UNKNOWN_CODE && $countryCode != '') { if ($regionCode != '' && $regionCode != Visit::UNKNOWN_CODE) { $regionName = getRegionNameFromCodes($countryCode, $regionCode); $result .= ', ' . $regionName; } $result .= ', ' . countryTranslate($countryCode); } return $result; }