本文整理汇总了PHP中Locales::getDistinctCountries方法的典型用法代码示例。如果您正苦于以下问题:PHP Locales::getDistinctCountries方法的具体用法?PHP Locales::getDistinctCountries怎么用?PHP Locales::getDistinctCountries使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Locales
的用法示例。
在下文中一共展示了Locales::getDistinctCountries方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: chooseAction
function chooseAction()
{
// TODO maybe? - prevent people from viewing this page if localization is not enabled
$default_locale = strtolower(Bolts_Registry::get('default_locale', 'default'));
$request = new Bolts_Request($this->getRequest());
// TODO - get cookie value and validate it
// TODO - only redirect if a valid cookie value exists !
if (!$request->has('change') && false) {
$this->_redirect("/" . $this->locale_code);
}
// Force the use of en-US
if ($this->locale_code != $default_locale) {
$this->locale_code = $default_locale;
$this->_redirect("/" . $this->_request->getModuleName() . "/" . $this->_request->getControllerName() . "/" . $this->_request->getActionName() . "/");
}
$locales_table = new Locales();
$tmp_regions = $locales_table->getDistinctRegions();
$choices = array();
foreach ($tmp_regions as $tmp_region) {
if ($tmp_region['region_name'] == 'Global') {
continue;
}
$tmp_countries = $locales_table->getDistinctCountries($tmp_region['region_name']);
$tmp_pseudo_countries = $locales_table->getDistinctPseudoCountryCodes($tmp_region['region_name']);
foreach ($tmp_countries as $tmp_country) {
if (!empty($tmp_pseudo_countries) && in_array($tmp_country['country_code'], $tmp_pseudo_countries[0])) {
continue;
}
$tmp_lang = $locales_table->getLanguages($tmp_region['region_name'], $tmp_country['country_code']);
$tmp_country['languages'] = array();
foreach ($tmp_lang as $lan) {
if (!is_null($lan['pseudo_country_code'])) {
$tmp_locale_code = strtolower($lan['language_code'] . "-" . $lan['pseudo_country_code']);
} else {
$tmp_locale_code = strtolower($lan['language_code'] . "-" . $tmp_country['country_code']);
}
if (in_array($tmp_locale_code, $this->live_locales)) {
$tmp_country['languages'][] = $lan;
}
}
if (count($tmp_country['languages']) > 0) {
$tmp_region['countries'][] = $tmp_country;
}
}
if (array_key_exists('countries', $tmp_region) && count($tmp_region['countries']) > 0) {
$choices[] = $tmp_region;
}
}
$this->view->choices = $choices;
if ($request->has('inline')) {
$this->view->inline = $request->inline;
}
}