/** * Migrates all course files referenced from the hypertext using the given filemanager * * This is typically used to convert images embedded into the intro fields. * * @param string $text hypertext containing $@FILEPHP@$ referenced * @param moodle1_file_manager $fileman file manager to use for the file migration * @return string the original $text with $@FILEPHP@$ references replaced with the new @@PLUGINFILE@@ */ public static function migrate_referenced_files($text, moodle1_file_manager $fileman) { $files = self::find_referenced_files($text); if (!empty($files)) { foreach ($files as $file) { try { $fileman->migrate_file('course_files'.$file, dirname($file)); } catch (moodle1_convert_exception $e) { // file probably does not exist $fileman->log('error migrating file', backup::LOG_WARNING, 'course_files'.$file); } } $text = self::rewrite_filephp_usage($text, $files); } return $text; }