getRegionNameFromCodes() public static method

Returns a region name for a country code + region code.
public static getRegionNameFromCodes ( string $countryCode, string $regionCode ) : string
$countryCode string
$regionCode string
return string The region name or 'Unknown' (translated).
Esempio n. 1
0
 public function getRegionName()
 {
     $region = $this->getRegionCode();
     if ($region != '' && $region != Visit::UNKNOWN_CODE) {
         return GeoIp::getRegionNameFromCodes($this->details['location_country'], $region);
     }
     return null;
 }
Esempio n. 2
0
/**
 * 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 = GeoIp::getRegionNameFromCodes($countryCode, $regionCode);
            $result .= ', ' . $regionName;
        }
        $result .= ', ' . countryTranslate($countryCode);
    }
    return $result;
}