mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
merged from STABLE
This commit is contained in:
parent
8e941c81e0
commit
415b7eac8e
@ -4302,6 +4302,30 @@ function print_string($identifier, $module='', $a=NULL) {
|
||||
echo get_string($identifier, $module, $a);
|
||||
}
|
||||
|
||||
/**
|
||||
* fix up the optional data in get_string()/print_string() etc
|
||||
* ensure possible sprintf() format characters are escaped correctly
|
||||
* needs to handle arbitrary strings and objects
|
||||
* @param mixed $a An object, string or number that can be used
|
||||
* @return mixed the supplied parameter 'cleaned'
|
||||
*/
|
||||
function clean_a( $a ) {
|
||||
if (is_string($a)) {
|
||||
return str_replace( '%','%%',$a );
|
||||
}
|
||||
elseif (is_object($a)) {
|
||||
$a_vars = get_object_vars( $a );
|
||||
$new_a_vars = array();
|
||||
foreach ($a_vars as $fname => $a_var) {
|
||||
$new_a_vars[$fname] = clean_a( $a_var );
|
||||
}
|
||||
return (object)$new_a_vars;
|
||||
}
|
||||
else {
|
||||
return $a;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a localized string.
|
||||
*
|
||||
@ -4372,7 +4396,7 @@ function get_string($identifier, $module='', $a=NULL) {
|
||||
}
|
||||
|
||||
// if $a happens to have % in it, double it so sprintf() doesn't break
|
||||
$a = str_replace( '%','%%',$a );
|
||||
$a = clean_a( $a );
|
||||
|
||||
/// Define the two or three major locations of language strings for this module
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user