Skip to content

Commit

Permalink
MDL-22015 improved country lists
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Apr 14, 2010
1 parent 0bd0282 commit adea062
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lang/en/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
$string['computedfromlogs'] = 'Computed from logs since {$a}.';
$string['condifmodeditdefaults'] = 'The values you set here define the default values that are used in the activity settings form when you create a new activity. You can also configure which activity settings are considered advanced.';
$string['confeditorhidebuttons'] = 'Select the buttons that should be hidden in the HTML editor.';
$string['configallcountrycodes'] = 'This is the list of countries that may be selected in various places, for example in a user\'s profile. If blank (the default) the list in countries.php in the standard English language pack is used. That is the list from ISO 3166-1. Otherwise, you can specify a comma-separated list of codes, for example \'GB,FR,ES\'. If you add new, non-standard codes here, you will need to add them to countries.php in your language pack.';
$string['configallcountrycodes'] = 'This is the list of countries that may be selected in various places, for example in a user\'s profile. If blank (the default) the list in countries.php in the standard English language pack is used. That is the list from ISO 3166-1. Otherwise, you can specify a comma-separated list of codes, for example \'GB,FR,ES\'. If you add new, non-standard codes here, you will need to add them to countries.php in \'en\' and your language pack.';
$string['configallowassign'] = 'You can allow people who have the roles on the left side to assign some of the column roles to other people';
$string['configallowblockstodock'] = 'If enabled and supported by the selected theme users can choose to move blocks to a special dock.';
$string['configallowcategorythemes'] = 'If you enable this, then themes can be set at the category level. This will affect all child categories and courses unless they have specifically set their own theme. WARNING: Enabling category themes may affect performance.';
Expand Down
49 changes: 38 additions & 11 deletions lib/moodlelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -5716,10 +5716,12 @@ public function get_string($identifier, $component = '', $a = NULL);
public function string_exists($identifier, $component);

/**
* Returns a localised list of all country names
* Returns a localised list of all country names, sorted by country keys.
* @param bool $returnall return all or just enabled
* @param string $lang moodle translation language, NULL means use current
* @return array two-letter country code => translated name.
*/
public function get_list_of_countries();
public function get_list_of_countries($returnall = false, $lang = NULL);

/**
* Returns a localised list of languages, sorted by code keys.
Expand Down Expand Up @@ -5997,12 +5999,34 @@ public function get_string($identifier, $component = '', $a = NULL) {
}

/**
* Returns a localised list of all country names
* Returns a localised list of all country names, sorted by country keys.
*
* @param bool $returnall return all or just enabled
* @param string $lang moodle translation language, NULL means use current
* @return array two-letter country code => translated name.
*/
public function get_list_of_countries() {
$lang = current_language();
return $this->load_component_strings('countries', $lang);
public function get_list_of_countries($returnall = false, $lang = NULL) {
global $CFG;

if ($lang === NULL) {
$lang = current_language();
}

$countries = $this->load_component_strings('core_countries', $lang);
ksort($countries);

if (!$returnall and !empty($CFG->allcountrycodes)) {
$enabled = explode(',', $CFG->allcountrycodes);
$return = array();
foreach ($enabled as $c) {
if (isset($countries[$c])) {
$return[$c] = $countries[$c];
}
}
return $return;
}

return $countries;
}

/**
Expand All @@ -6019,7 +6043,7 @@ public function get_list_of_languages($lang = NULL, $standard = 'iso6392') {
}
if ($standard === 'iso6392') {
$langs = $this->load_component_strings('core_iso6392', $lang);
$lang = ksort($langs);
ksort($langs);
return $langs;
} else {
debugging('Unsupported $standard parameter in get_list_of_languages() method: '.$standard);
Expand Down Expand Up @@ -6214,10 +6238,13 @@ public function get_string($identifier, $component = '', $a = NULL) {
}

/**
* Returns a localised list of all country names
* Returns a localised list of all country names, sorted by country keys.
*
* @param bool $returnall return all or just enabled
* @param string $lang moodle translation language, NULL means use current
* @return array two-letter country code => translated name.
*/
public function get_list_of_countries() {
public function get_list_of_countries($returnall = false, $lang = NULL) {
//not used in installer
return array();
}
Expand Down Expand Up @@ -6415,11 +6442,11 @@ function get_list_of_charsets() {
}

/**
* Returns a list of country names in the current language
* Returns a list of all enabled country names in the current translation
* @return array two-letter country code => translated name.
*/
function get_list_of_countries() {
return get_string_manager()->get_list_of_countries();
return get_string_manager()->get_list_of_countries(false);
}

/**
Expand Down

0 comments on commit adea062

Please sign in to comment.