mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 08:22:07 +02:00
question import/export: MDL-20299 fix regression I introduced yesterday in hotpot import/export
This commit is contained in:
parent
d0fdb92ccf
commit
964c571975
@ -508,3 +508,29 @@ class qformat_hotpot extends qformat_default {
|
||||
return $str;
|
||||
}
|
||||
} // end class
|
||||
|
||||
function hotpot_convert_relative_urls($str, $baseurl, $filename) {
|
||||
$tagopen = '(?:(<)|(<)|(&#x003C;))'; // left angle bracket
|
||||
$tagclose = '(?(2)>|(?(3)>|(?(4)&#x003E;)))'; // right angle bracket (to match left angle bracket)
|
||||
|
||||
$space = '\s+'; // at least one space
|
||||
$anychar = '(?:[^>]*?)'; // any character
|
||||
|
||||
$quoteopen = '("|"|&quot;)'; // open quote
|
||||
$quoteclose = '\\5'; // close quote (to match open quote)
|
||||
|
||||
$replace = "hotpot_convert_relative_url('".$baseurl."', '".$filename."', '\\1', '\\6', '\\7')";
|
||||
|
||||
$tags = array('script'=>'src', 'link'=>'href', 'a'=>'href','img'=>'src','param'=>'value', 'object'=>'data', 'embed'=>'src');
|
||||
foreach ($tags as $tag=>$attribute) {
|
||||
if ($tag=='param') {
|
||||
$url = '\S+?\.\S+?'; // must include a filename and have no spaces
|
||||
} else {
|
||||
$url = '.*?';
|
||||
}
|
||||
$search = "%($tagopen$tag$space$anychar$attribute=$quoteopen)($url)($quoteclose$anychar$tagclose)%ise";
|
||||
$str = preg_replace($search, $replace, $str);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user