Browse files

in XML source files of HP quizzes, convert relative URLs to absolute …

…URLs in links using window.open(...)
  • Loading branch information...
1 parent a0001e3 commit e29a752173ca45cab364f6f64b14be682955fecd gbateson committed Jun 26, 2007
Showing with 10 additions and 4 deletions.
  1. +10 −4 mod/hotpot/lib.php
View
14 mod/hotpot/lib.php
@@ -1533,19 +1533,25 @@ function hotpot_xml_quiz(&$obj, $read_file=true, $parse_xml=true, $convert_urls=
$this->source = preg_replace($search, $replace, $this->source);
// relative URLs in <a ... onclick="window.open('...')...">...</a>
- $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 <a ... onclick="window.open('...')...">...</a>
+ $search = '|'.'(?<='.'onclick=&quot;'."window.open\\(&apos;".')'."(.*?)".'(?='."&apos;\\);return false;".'&quot;)'.'|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 @@ function hotpot_xml_quiz(&$obj, $read_file=true, $parse_xml=true, $convert_urls=
} // 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) {

0 comments on commit e29a752

Please sign in to comment.