/** @param $s 3-letter country code (SWE, NOR) */ function getCountryName($s) { if (is_numeric($s)) { $s = getCountryCode($s); } else { $s = strtoupper($s); if (strlen($s) == 2) { $s = country_2_to_3_letters($s); } } $c3 = array('SWE' => 'Sweden', 'NOR' => 'Norway', 'DNK' => 'Denmark', 'FIN' => 'Finland', 'USA' => 'United States of America', 'GBR' => 'United Kingdom', 'DEU' => 'Germany', 'JPN' => 'Japan', 'EUR' => 'European Union'); if (!isset($c3[$s])) { throw new \Exception('Unknown country name ' . $s); } return $c3[$s]; }
function countryFlag($s) { if (is_numeric($s)) { $s = getCountryCode($s); } else { if (!is_alphanumeric($s)) { throw new \Exception('hey'); } if (strlen($s) == 2) { $s = country_2_to_3_letters($s); } $s = strtoupper($s); } $locale = \cd\LocaleHandler::getInstance(); $title = getCountryName($s); if (!$title) { throw new \Exception('unhandled country flag code ' . $s); } return '<img src="' . relurl('core_dev/gfx/flags/' . $s . '.png') . '" alt="' . $title . '" title="' . $title . '"/>'; }