You are here

function clean_getstring_data in Quiz 6.6

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

Parameters

mixed $a An object, string or number that can be used:

Return value

mixed the supplied parameter 'cleaned'

1 call to clean_getstring_data()
get_string in includes/moodle_support.php
Moodle localized string function from moodle/lib/moodlelib.php reimplemented hackedly for within the Drupal Quiz module e.g. get_string("wronggrade", "quiz", $nLineCounter).' '.get_string("fractionsnomax",…

File

includes/moodle_support.php, line 416

Code

function clean_getstring_data($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_getstring_data($a_var);
    }
    return (object) $new_a_vars;
  }
  else {
    return $a;
  }
}