From e29a752173ca45cab364f6f64b14be682955fecd Mon Sep 17 00:00:00 2001 From: gbateson Date: Tue, 26 Jun 2007 04:59:56 +0000 Subject: [PATCH] in XML source files of HP quizzes, convert relative URLs to absolute URLs in links using window.open(...) --- mod/hotpot/lib.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/mod/hotpot/lib.php b/mod/hotpot/lib.php index cb75a652fd6..090097812ae 100644 --- a/mod/hotpot/lib.php +++ b/mod/hotpot/lib.php @@ -1533,19 +1533,25 @@ class hotpot_xml_quiz extends hotpot_xml_tree { $this->source = preg_replace($search, $replace, $this->source); // relative URLs in ... - $search = '|'.'(?<='.'onclick="'."window.open\\('".')'."([^']*)".'(?='."'\\);return false;".'")'.'|ise'; + $search = '|'.'(?<='.'onclick="'."window.open\\('".')'."(.*?)".'(?='."'\\);return false;".'")'.'|ise'; $replace = "hotpot_convert_url('".$this->get_baseurl()."','".$this->reference."','\\1')"; $this->source = preg_replace($search, $replace, $this->source); } else { - if ($this->parse_xml) { + + // relative URLs in ... + $search = '|'.'(?<='.'onclick="'."window.open\\('".')'."(.*?)".'(?='."'\\);return false;".'")'.'|ise'; + $replace = "hotpot_convert_url('".$this->get_baseurl()."','".$this->reference."','\\1')"; + $this->source = preg_replace($search, $replace, $this->source); + + if ($this->parse_xml) { $this->filetype = 'xml'; // encode "gap fill" text in JCloze exercise $this->encode_cdata($this->source, 'gap-fill'); - // convert source to xml tree + // convert source to xml tree $this->hotpot_xml_tree($this->source); $keys = array_keys($this->xml); @@ -1609,7 +1615,7 @@ class hotpot_xml_quiz extends hotpot_xml_tree { } // end $this->create_html } // end if html/xml file - } // end if $this->read_file + } // end if $this->read_file } // end constructor function function hotpot_convert_relative_urls(&$str) {