Skip to content

Commit

Permalink
MDL-22015 more get_list_of_countries() refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Apr 14, 2010
1 parent 42b702a commit 0aa759b
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 24 deletions.
2 changes: 1 addition & 1 deletion admin/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -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>';

Expand Down
2 changes: 1 addition & 1 deletion admin/uploaduser_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
2 changes: 1 addition & 1 deletion admin/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
2 changes: 1 addition & 1 deletion admin/user/user_bulk_display.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion enrol/authorize/enrol_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions iplookup/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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];
Expand Down
6 changes: 4 additions & 2 deletions lib/adminlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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;
}
}
Expand Down
11 changes: 10 additions & 1 deletion lib/deprecatedlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
*/
Expand Down
8 changes: 0 additions & 8 deletions lib/moodlelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
2 changes: 1 addition & 1 deletion login/signup_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion user/editlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion user/filters/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions user/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion user/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@
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]);
}

Expand Down

0 comments on commit 0aa759b

Please sign in to comment.