diff --git a/admin/register.php b/admin/register.php index d90140d53d0e2..be78389d6c61f 100644 --- a/admin/register.php +++ b/admin/register.php @@ -71,7 +71,7 @@ echo '
'; echo '
'; echo '
'; - echo html_writer::select(get_list_of_countries(), "country", $admin->country, array(''=>get_string("selectacountry")."...")); + echo html_writer::select(get_string_manager()->get_list_of_countries(), "country", $admin->country, array(''=>get_string("selectacountry")."...")); echo '
'; echo '
'; diff --git a/admin/uploaduser_form.php b/admin/uploaduser_form.php index 4132fc9953dc2..d2327d5bf17e5 100644 --- a/admin/uploaduser_form.php +++ b/admin/uploaduser_form.php @@ -199,7 +199,7 @@ function definition (){ $mform->setType('city', PARAM_MULTILANG); $mform->setDefault('city', $templateuser->city); - $mform->addElement('select', 'country', get_string('selectacountry'), get_list_of_countries()); + $mform->addElement('select', 'country', get_string('selectacountry'), get_string_manager()->get_list_of_countries()); $mform->setDefault('country', $templateuser->country); $mform->setAdvanced('country'); diff --git a/admin/user.php b/admin/user.php index 707b5729877ee..98325b484ccc7 100644 --- a/admin/user.php +++ b/admin/user.php @@ -179,7 +179,7 @@ } else { - $countries = get_list_of_countries(); + $countries = get_string_manager()->get_list_of_countries(false); if (empty($mnethosts)) { $mnethosts = $DB->get_records('mnet_host', null, 'id', 'id,wwwroot,name'); } diff --git a/admin/user/user_bulk_display.php b/admin/user/user_bulk_display.php index b3648019eda33..1e8514a21fea9 100755 --- a/admin/user/user_bulk_display.php +++ b/admin/user/user_bulk_display.php @@ -22,7 +22,7 @@ echo $OUTPUT->header(); -$countries = get_list_of_countries(); +$countries = get_string_manager()->get_list_of_countries(true); foreach ($users as $key => $id) { $user = $DB->get_record('user', array('id'=>$id), 'id, firstname, lastname, username, email, country, lastaccess, city'); diff --git a/enrol/authorize/enrol_form.php b/enrol/authorize/enrol_form.php index 92b7f3d4d4582..a27157bafe62d 100755 --- a/enrol/authorize/enrol_form.php +++ b/enrol/authorize/enrol_form.php @@ -124,7 +124,7 @@ function definition() $mform->setDefault('cccity', $USER->city); $mform->setDefault('ccstate', ''); - $mform->addElement('select', 'cccountry', get_string('country'), get_list_of_countries()); + $mform->addElement('select', 'cccountry', get_string('country'), get_string_manager()->get_list_of_countries()); $mform->addRule('cccountry', get_string('missingcountry'), 'required', null, 'client'); $mform->setType('cccountry', PARAM_ALPHA); $mform->setDefault('cccountry', $USER->country); diff --git a/iplookup/index.php b/iplookup/index.php index f2d2231e72d51..0f0b34ebeed8e 100644 --- a/iplookup/index.php +++ b/iplookup/index.php @@ -75,7 +75,7 @@ } if (!empty($location->country_code)) { - $countries = get_list_of_countries(); + $countries = get_string_manager()->get_list_of_countries(true); if (isset($countries[$location->country_code])) { // prefer our localized country names $info[] = $countries[$location->country_code]; @@ -111,7 +111,7 @@ if (preg_match('/COUNTRY:\s*([^<]*)/', $ipdata, $matches)) { if (!empty($matches[1])) { $countrycode = $matches[1]; - $countries = get_list_of_countries(); + $countries = get_string_manager()->get_list_of_countries(true); if (isset($countries[$countrycode])) { // prefer our localized country names $info[] = $countries[$countrycode]; diff --git a/lib/adminlib.php b/lib/adminlib.php index 8689c08414aa0..dd00bf3d6042d 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -3529,7 +3529,9 @@ public function write_setting($data) { * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class admin_settings_country_select extends admin_setting_configselect { - public function __construct($name, $visiblename, $description, $defaultsetting) { + protected $includeall; + public function __construct($name, $visiblename, $description, $defaultsetting, $includeall=false) { + $this->includeall = $includeall; parent::__construct($name, $visiblename, $description, $defaultsetting, NULL); } @@ -3543,7 +3545,7 @@ public function load_choices() { } $this->choices = array_merge( array('0' => get_string('choosedots')), - get_list_of_countries()); + get_string_manager()->get_list_of_countries($this->includeall)); return true; } } diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index bea81a9a2e121..112172826821f 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -55,7 +55,6 @@ function get_list_of_languages($refreshcache=false, $returnall=false) { return get_string_manager()->get_list_of_translations($returnall); } - /** * Returns a list of currencies in the current language * @deprecated @@ -66,6 +65,16 @@ function get_list_of_currencies() { return get_string_manager()->get_list_of_currencies(); } +/** + * Returns a list of all enabled country names in the current translation + * @deprecated + * @return array two-letter country code => translated name. + */ +function get_list_of_countries() { + debugging('get_list_of_countries() is deprecated, please use get_string_manager()->get_list_of_countries() instead.'); + return get_string_manager()->get_list_of_countries(false); +} + /** * @deprecated */ diff --git a/lib/moodlelib.php b/lib/moodlelib.php index e7415df79dca7..bdb252ed50a55 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -6533,14 +6533,6 @@ function get_list_of_charsets() { return $charsets; } -/** - * 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(false); -} - /** * Returns a list of valid and compatible themes * diff --git a/login/signup_form.php b/login/signup_form.php index 41a5bc80c1e52..37eaf9c15f133 100644 --- a/login/signup_form.php +++ b/login/signup_form.php @@ -54,7 +54,7 @@ function definition() { $mform->setType('city', PARAM_TEXT); $mform->addRule('city', get_string('missingcity'), 'required', null, 'server'); - $country = get_list_of_countries(); + $country = get_string_manager()->get_list_of_countries(); $default_country[''] = get_string('selectacountry'); $country = array_merge($default_country, $country); $mform->addElement('select', 'country', get_string('country'), $country); diff --git a/user/editlib.php b/user/editlib.php index 21cff4d514cdd..c7f000a74635f 100644 --- a/user/editlib.php +++ b/user/editlib.php @@ -200,7 +200,7 @@ function useredit_shared_definition(&$mform, $editoroptions = null) { $mform->addRule('city', $strrequired, 'required', null, 'client'); - $choices = get_list_of_countries(); + $choices = get_string_manager()->get_list_of_countries(); $choices= array(''=>get_string('selectacountry').'...') + $choices; $mform->addElement('select', 'country', get_string('selectacountry'), $choices); $mform->addRule('country', $strrequired, 'required', null, 'client'); diff --git a/user/filters/lib.php b/user/filters/lib.php index 1efc1406509f0..5c3d6996658bf 100644 --- a/user/filters/lib.php +++ b/user/filters/lib.php @@ -106,7 +106,7 @@ function get_field($fieldname, $advanced) { case 'firstname': return new user_filter_text('firstname', get_string('firstname'), $advanced, 'firstname'); case 'email': return new user_filter_text('email', get_string('email'), $advanced, 'email'); case 'city': return new user_filter_text('city', get_string('city'), $advanced, 'city'); - case 'country': return new user_filter_select('country', get_string('country'), $advanced, 'country', get_list_of_countries(), $USER->country); + case 'country': return new user_filter_select('country', get_string('country'), $advanced, 'country', get_string_manager()->get_list_of_countries(), $USER->country); case 'confirmed': return new user_filter_yesno('confirmed', get_string('confirmed', 'admin'), $advanced, 'confirmed'); case 'profile': return new user_filter_profilefield('profile', get_string('profile'), $advanced); case 'courserole': return new user_filter_courserole('courserole', get_string('courserole', 'filters'), $advanced); diff --git a/user/index.php b/user/index.php index 7303479de9ecc..61c29fff4ea60 100644 --- a/user/index.php +++ b/user/index.php @@ -97,7 +97,7 @@ $bulkoperations = has_capability('moodle/course:bulkmessaging', $context); - $countries = get_list_of_countries(); + $countries = get_string_manager()->get_list_of_countries(); $strnever = get_string('never'); @@ -632,7 +632,7 @@ $context = get_context_instance(CONTEXT_COURSE, $course->id); $usercontext = get_context_instance(CONTEXT_USER, $user->id); - $countries = get_list_of_countries(); + $countries = get_string_manager()->get_list_of_countries(); /// Get the hidden field list if (has_capability('moodle/course:viewhiddenuserfields', $context)) { diff --git a/user/view.php b/user/view.php index 36814fde21edc..27f7fb8630b22 100644 --- a/user/view.php +++ b/user/view.php @@ -265,7 +265,7 @@ echo ''; if (! isset($hiddenfields['country']) && $user->country) { - $countries = get_list_of_countries(); + $countries = get_string_manager()->get_list_of_countries(); print_row(get_string('country') . ':', $countries[$user->country]); }