merged from STABLE
This commit is contained in:
+25
-1
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user