function hotpot_convert_url in Quiz 6.6
Same name and namespace in other branches
- 6.5 includes/moodle/question/format/hotpot/format.php \hotpot_convert_url()
1 call to hotpot_convert_url()
- hotpot_convert_relative_url in includes/moodle/question/format/hotpot/format.php
File
- includes/moodle/question/format/hotpot/format.php, line 745
Code
function hotpot_convert_url($baseurl, $filename, $url, $stripslashes = true) {
static $HOTPOT_RELATIVE_URLS = array();
if ($stripslashes) {
$url = stripslashes($url);
}
if (preg_match('%^(http://|/|javascript:)%i', $url)) {
}
else {
if (isset($HOTPOT_RELATIVE_URLS[$url])) {
$url = $HOTPOT_RELATIVE_URLS[$url];
}
else {
$relativeurl = $url;
$dir = dirname($filename);
while (preg_match('|^(\\.{1,2})/(.*)$|', $url, $matches)) {
if ($matches[1] == '..') {
$dir = dirname($dir);
}
$url = $matches[2];
}
if ($dir && $dir != '.') {
$baseurl .= "{$dir}/";
}
$url = "{$baseurl}{$url}";
$HOTPOT_RELATIVE_URLS[$relativeurl] = $url;
}
}
return $url;
}