MDL-22015 more get_list_of_countries() refactoring

This commit is contained in:
Petr Skoda
2010-04-14 14:27:10 +00:00
parent 42b702a627
commit 0aa759b01c
14 changed files with 27 additions and 24 deletions
+1 -1
View File
@@ -71,7 +71,7 @@
echo '<div class="fitem">';
echo '<div class="fitemtitle"><label for="menucountry">'.get_string("country").'</label></div>';
echo '<div class="felement ftext">';
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 '</div>';
echo '</div>';
+1 -1
View File
@@ -199,7 +199,7 @@ class admin_uploaduser_form2 extends moodleform {
$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');
+1 -1
View File
@@ -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');
}
+1 -1
View File
@@ -22,7 +22,7 @@ $strnever = get_string('never');
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');
+1 -1
View File
@@ -124,7 +124,7 @@ class enrol_authorize_form extends moodleform
$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);
+2 -2
View File
@@ -75,7 +75,7 @@ if (!empty($CFG->geoipfile) and file_exists($CFG->geoipfile)) {
}
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 (!empty($CFG->geoipfile) and file_exists($CFG->geoipfile)) {
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];
+4 -2
View File
@@ -3529,7 +3529,9 @@ class admin_setting_langlist extends admin_setting_configtext {
* @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 @@ class admin_settings_country_select extends admin_setting_configselect {
}
$this->choices = array_merge(
array('0' => get_string('choosedots')),
get_list_of_countries());
get_string_manager()->get_list_of_countries($this->includeall));
return true;
}
}
+10 -1
View File
@@ -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
*/
-8
View File
@@ -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
*
+1 -1
View File
@@ -54,7 +54,7 @@ class login_signup_form extends moodleform {
$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);
+1 -1
View File
@@ -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');
+1 -1
View File
@@ -106,7 +106,7 @@ class user_filtering {
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);
+2 -2
View File
@@ -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)) {
+1 -1
View File
@@ -265,7 +265,7 @@ if ($user->description && !isset($hiddenfields['description'])) {
echo '<table class="list">';
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]);
}