コード例 #1
0
 protected function translate(QtiImportSettings $settings, $question, $text)
 {
     $pattern = '/src="[^"]*"/';
     $matches = array();
     preg_match_all($pattern, $text, $matches, PREG_SET_ORDER);
     foreach ($matches as $match) {
         $match = reset($match);
         $match = str_replace('src="', '', $match);
         $match = trim($match, '"');
         $replace = $this->translate_path($match);
         $text = str_ireplace('src="' . $match . '"', 'src="' . $replace . '"', $text);
         $name = end(explode('/', $match));
         $question->resources[$name] = $settings->get_directory() . $match;
     }
     return $text;
 }