MDL-10970 Someone was using

$locations = array('location1');
$locations += array('location2', 'location3', 'location4');

to save the hassle of doing one $locations[] = 'location1'; for each location.

But += doesn't add any entry if the key of the new array already exists in the original array. So, using my example, the resulting array would be:

$locations: array('location1', 'location3', 'location4');
This commit is contained in:
nicolasconnault 2007-08-24 06:01:15 +00:00
parent 658d357c61
commit 3565ff92e4
2 changed files with 9 additions and 6 deletions

View File

@ -35,7 +35,7 @@ function print_grade_plugin_selector($courseid, $active_type, $active_plugin, $r
if ($active_type == 'report' and $active_plugin == $plugin ) {
$active = $url;
}
$reportnames[$url] = get_string('modulename', 'gradereport_'.$plugin, NULL, $CFG->dirroot.'/grade/report/'.$plugin.'lang/');
$reportnames[$url] = get_string('modulename', 'gradereport_'.$plugin, NULL, $CFG->dirroot.'/grade/report/'.$plugin.'/lang/');
}
asort($reportnames);
}
@ -59,7 +59,7 @@ function print_grade_plugin_selector($courseid, $active_type, $active_plugin, $r
if ($active_type == 'import' and $active_plugin == $plugin ) {
$active = $url;
}
$importnames[$url] = get_string('modulename', 'gradeimport_'.$plugin, NULL, $CFG->dirroot.'/grade/import/'.$plugin.'lang/');
$importnames[$url] = get_string('modulename', 'gradeimport_'.$plugin, NULL, $CFG->dirroot.'/grade/import/'.$plugin.'/lang/');
}
asort($importnames);
}
@ -83,7 +83,7 @@ function print_grade_plugin_selector($courseid, $active_type, $active_plugin, $r
if ($active_type == 'export' and $active_plugin == $plugin ) {
$active = $url;
}
$exportnames[$url] = get_string('modulename', 'gradeexport_'.$plugin, NULL, $CFG->dirroot.'/grade/export/'.$plugin.'lang/');
$exportnames[$url] = get_string('modulename', 'gradeexport_'.$plugin, NULL, $CFG->dirroot.'/grade/export/'.$plugin.'/lang/');
}
asort($exportnames);
}

View File

@ -4481,10 +4481,13 @@ function get_string($identifier, $module='', $a=NULL, $extralocations=NULL) {
if (isset($CFG->running_installer)) {
$module = 'installer';
$filetocheck = 'installer.php';
$locations += array( $CFG->dirroot.'/install/lang/', $CFG->dataroot.'/lang/', $CFG->dirroot.'/lang/' );
$locations[] = $CFG->dirroot.'/install/lang/';
$locations[] = $CFG->dataroot.'/lang/';
$locations[] = $CFG->dirroot.'/lang/';
$defaultlang = 'en_utf8';
} else {
$locations += array( $CFG->dataroot.'/lang/', $CFG->dirroot.'/lang/' );
$locations[] = $CFG->dataroot.'/lang/';
$locations[] = $CFG->dirroot.'/lang/';
}
/// Add extra places to look for strings for particular plugin types.
@ -4525,7 +4528,7 @@ function get_string($identifier, $module='', $a=NULL, $extralocations=NULL) {
eval($result);
return $resultstring;
}
}
}
}
/// If the preferred language was English (utf8) we can abort now