]> git.mjollnir.org Git - moodle.git/commitdiff
improved readability of reg. exp. in adjust_media_urls function
authorgbateson <gbateson>
Sun, 16 Apr 2006 02:10:14 +0000 (02:10 +0000)
committergbateson <gbateson>
Sun, 16 Apr 2006 02:10:14 +0000 (02:10 +0000)
mod/hotpot/lib.php

index f56b408083e4eed6b27c7275e7c5a3f3d2ea7ca1..dd4c13840cdf3996e82771543203dba7db72df85 100644 (file)
@@ -1640,10 +1640,11 @@ class hotpot_xml_quiz extends hotpot_xml_tree {
                        // exclude swf files from the filter\r
                        //$CFG->filter_mediaplugin_ignore_swf = true;\r
 \r
-                       $q = '["'."']?"; // single, double, or no quote\r
+                       $space = '\s(?:.+\s)?';\r
+                       $quote = '["'."']?"; // single, double, or no quote\r
 \r
                        // patterns to media files types and paths\r
-                       $filetype = "avi|mpeg|mpg|mp3|mov|swf|wmv";\r
+                       $filetype = "avi|mpeg|mpg|mp3|mov|wmv";\r
                        $filepath = ".*?\.($filetype)";\r
 \r
                        $tagopen = '(?:(<)|(\\\\u003C))'; // left angle-bracket (uses two parenthese)\r
@@ -1651,17 +1652,17 @@ class hotpot_xml_quiz extends hotpot_xml_tree {
                        $tagreopen = '(?(1)<|(?(2)\\\\u003C))'; // another left angle-bracket (to match the first one)\r
 \r
                        // pattern to match <PARAM> tags which contain the file path\r
-                       //      wmp          : url\r
+                       //      wmp        : url\r
                        //      quicktime  : src\r
                        //      realplayer : src\r
                        //      flash      : movie (doesn't need replacing)\r
-                       $param_url = "/{$tagopen}PARAM\s+.*?NAME=$q(?:movie|src|url)$q\s+.*?VALUE=$q($filepath)$q.*?$tagclose/is";\r
+                       $param_url = "/{$tagopen}param{$space}name=$quote(?:movie|src|url)$quote{$space}value=$quote($filepath)$quote.*?$tagclose/is";\r
 \r
                        // pattern to match <a> tags which link to multimedia files\r
-                       $link_url = "/{$tagopen}A\s.*?HREF=$q($filepath)$q.*?$tagclose.*?$tagreopen\/A$tagclose/is";\r
+                       $link_url = "/{$tagopen}a{$space}href=$quote($filepath)$quote.*?$tagclose.*?$tagreopen\/A$tagclose/is";\r
 \r
-                       // extract <OBJECT> tags\r
-                       preg_match_all("/{$tagopen}OBJECT\s+.*?{$tagclose}(.*?){$tagreopen}\/OBJECT{$tagclose}/is", $this->html, $objects);\r
+                       // extract <object> tags\r
+                       preg_match_all("/{$tagopen}object\s.*?{$tagclose}(.*?){$tagreopen}\/object{$tagclose}/is", $this->html, $objects);\r
 \r
                        $i_max = count($objects[0]);\r
                        for ($i=0; $i<$i_max; $i++) {\r
@@ -1673,6 +1674,7 @@ class hotpot_xml_quiz extends hotpot_xml_tree {
                                }\r
 \r
                                if ($url) {\r
+                                       // strip inner tags (e.g. <embed>)\r
                                        $txt = preg_replace("/$tagopen.*?$tagclose/", '', $objects[3][$i]);\r
 \r
                                        // if url is in the query string, remove the leading characters\r