Applied atutor changes for flowplayer and adapted content
authorCindy Li <cli@ocad.ca>
Mon, 18 Oct 2010 14:45:51 +0000 (14:45 -0000)
committerCindy Li <cli@ocad.ca>
Mon, 18 Oct 2010 14:45:51 +0000 (14:45 -0000)
docs/home/classes/ContentUtility.class.php
docs/home/course/content.php

index b1485d0..cb18256 100644 (file)
@@ -142,46 +142,35 @@ class ContentUtility {
                \r
                $media_replace = array();\r
                $media_matches = array();\r
+               $flowplayerholder_class = "atutor.flowplayerholder";  // style class used to play flowplayer medias\r
+               $flowplayerholder_def = '$f("*.'.$flowplayerholder_class.'"';   // javascript definition for atutor.flowplayerholder \r
                \r
-               // .flv (playing file via full URL)\r
-               preg_match_all("#\[media[0-9a-z\|]*\]http://([\w\./-]+)\.flv\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER);\r
-               $media_replace[] ="<a class=\"flowplayerholder\" style=\"display:block;width:##WIDTH##px;height:##HEIGHT##px;\" href=\"http://##MEDIA1##.flv\"></a>";\r
-               \r
-               // .flv (playing file from TR_content_dir)\r
+               // .flv\r
                preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+)\.flv\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER);\r
-               $media_replace[] ="<a class=\"flowplayerholder\" style=\"display:block;width:##WIDTH##px;height:##HEIGHT##px;\" href=\"".TR_BASE_HREF."get.php/".$content_base_href."##MEDIA1##.flv\"></a>";\r
-               \r
-               // .mp4 (playing file via full URL)\r
-               preg_match_all("#\[media[0-9a-z\|]*\]http://([\w\./-]+)\.mp4\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER);\r
-               $media_replace[] ="<a class=\"flowplayerholder\" style=\"display:block;width:##WIDTH##px;height:##HEIGHT##px;\" href=\"http://##MEDIA1##.mp4\"></a>";\r
+               $media_replace[] ="<object>\n".\r
+                                 "  <div>\n".\r
+                                 "    <a class=\"".$flowplayerholder_class."\" style=\"display:block;width:##WIDTH##px;height:##HEIGHT##px;\" href=\"##MEDIA1##.flv\"></a>\n".\r
+                                 "  </div>\n".\r
+                                 "  <div style=\"margin-top:-2em;\">\n".\r
+                                 "    <a href=\"##MEDIA1##.flv\">##MEDIA1##.flv</a>\n".\r
+                                 "  </div>\n".\r
+                                 "</object>";\r
                \r
-               // .mp4 (playing file from TR_content_dir)\r
+               // .mp4\r
                preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+)\.mp4\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER);\r
-               $media_replace[] ="<a class=\"flowplayerholder\" style=\"display:block;width:##WIDTH##px;height:##HEIGHT##px;\" href=\"".TR_BASE_HREF."get.php/".$content_base_href."##MEDIA1##.mp4\"></a>";\r
-               \r
-               // .mov (playing file via full URL)\r
-               preg_match_all("#\[media[0-9a-z\|]*\]http://([\w\./-]+)\.mov\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER);\r
-               $media_replace[] ="<a class=\"flowplayerholder\" style=\"display:block;width:##WIDTH##px;height:##HEIGHT##px;\" href=\"http://##MEDIA1##.mov\"></a>";\r
-               \r
-               // .mov (playing file from TR_content_dir)\r
-               preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+)\.mov\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER);\r
-               $media_replace[] ="<a class=\"flowplayerholder\" style=\"display:block;width:##WIDTH##px;height:##HEIGHT##px;\" href=\"".TR_BASE_HREF."get.php/".$content_base_href."##MEDIA1##.mov\"></a>";\r
-               \r
-               // .mp3 (playing file via full URL)\r
-               preg_match_all("#\[media[0-9a-z\|]*\]http://([\w\./-]+)\.mp3\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER);\r
-               $media_replace[] ="<a class=\"flowplayerholder\" style=\"display:block;width:##WIDTH##px;height:##HEIGHT##px;\" href=\"http://##MEDIA1##.mp3\"></a>";\r
-               \r
-               // .mp3 (playing file from TR_content_dir)\r
-               preg_match_all("#\[media[0-9a-z\|]*\](.+[^\s\"]+)\.mp3\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER);\r
-               $media_replace[] ="<a class=\"flowplayerholder\" style=\"display:block;width:##WIDTH##px;height:##HEIGHT##px;\" href=\"".TR_BASE_HREF."get.php/".$content_base_href."##MEDIA1##.mp3\"></a>";\r
-               \r
-               $has_flv = false;\r
+               //$media_replace[] ="<a class=\"".$flowplayerholder_class."\" style=\"display:block;width:##WIDTH##px;height:##HEIGHT##px;\" href=\"".AT_BASE_HREF."get.php/".$_content_base_href."##MEDIA1##.mp4\"></a>";\r
+               $media_replace[] ="<object>\n".\r
+                                 "  <div>\n".\r
+                                 "    <a class=\"".$flowplayerholder_class."\" style=\"display:block;width:##WIDTH##px;height:##HEIGHT##px;\" href=\"##MEDIA1##.mp4\"></a>\n".\r
+                                 "  </div>\n".\r
+                                 "  <div style=\"margin-top:-2em;\">\n".\r
+                                 "    <a href=\"##MEDIA1##.mp4\">##MEDIA1##.mp4</a>\n".\r
+                                 "  </div>\n".\r
+                                 "</object>";\r
                // Executing the replace\r
                for ($i=0;$i<count($media_replace);$i++){\r
                        foreach($media_matches[$i] as $media)\r
                        {\r
-                               if (is_array($media)) $has_flv = true;\r
-                               \r
                                //find width and height for each matched media\r
                                if (preg_match("/\[media\|([0-9]*)\|([0-9]*)\]*/", $media[0], $matches)) \r
                                {\r
@@ -204,25 +193,29 @@ class ContentUtility {
                        }\r
                }\r
                \r
-               if ($has_flv)\r
+               // Include the javascript only if:\r
+               // 1. $flowplayerholder_class is used but not defined\r
+               // 2. exclude from export common cartridge or content package\r
+               if (strpos($text, $flowplayerholder_class) \r
+                   && !strpos($text, $flowplayerholder_def)\r
+                   && !strpos($_SERVER['PHP_SELF'], "ims_export.php"))\r
                {\r
-                       $text .= '\r
-                       <script language="JavaScript">\r
-                               $f("a.flowplayerholder", "'.TR_BASE_HREF.'include/jscripts/flowplayer/flowplayer-3.2.4.swf", { \r
-                               clip: { autoPlay: false },  \r
-                       plugins:  { \r
-                               controls: { \r
-                                   buttons:true, \r
-                                   play: true,  \r
-                                   scrubber: true, \r
-                                       autoHide:false\r
-                               }         \r
-                           }\r
-                       });\r
-                       </script>\r
-                       ';\r
+                       $text .= '<script type="text/javascript">\r
+'.$flowplayerholder_def.', "'.TR_BASE_HREF.'include/jscripts/flowplayer/flowplayer-3.2.4.swf", { \r
+  clip: { \r
+  autoPlay: false,\r
+  baseUrl: \''.TR_BASE_HREF.'get.php/'.$content_base_href.'\'},\r
+  plugins:  { \r
+    controls: { \r
+      buttons:true, \r
+      play: true,  \r
+      scrubber: true, \r
+      autoHide:false\r
+    }         \r
+  }\r
+});\r
+</script>'."\n";\r
                }\r
-               \r
                return $text;           \r
        }\r
        \r
@@ -262,52 +255,75 @@ class ContentUtility {
                $text = preg_replace("/(\[media\])([\s]*)(.*)(\[\/media\])/", '$1$3$4', $text);\r
                $text = preg_replace("/(\[media\])(.*)([\s]*)(\[\/media\])/U", '$1$2$4', $text);\r
                \r
-               $media_matches = Array();\r
+               $media_matches = array();\r
+               $media_replace = array();\r
                \r
                // First, we search though the text for all different kinds of media defined by media tags and store the results in $media_matches.\r
-        // Then the different replacements for the different media tags are stored in $media_replace.\r
-        // Lastly, we loop through all $media_matches / $media_replaces. (We choose $media_replace as index because $media_matches is multi-dimensioned.) It is important that for each $media_matches there is a $media_replace with the same index. For each media match we check the width/height, or we use the default value of 425x350. We then replace the height/width/media1/media2 parameter placeholders in $media_replace with the correct ones, before running a str_replace on $text, replacing the given media with its correct replacement.\r
-               \r
+               // Then the different replacements for the different media tags are stored in $media_replace.\r
+               // Lastly, we loop through all $media_matches / $media_replaces. (We choose $media_replace as index because $media_matches is multi-dimensioned.) It is important that for each $media_matches there is a $media_replace with the same index. For each media match we check the width/height, or we use the default value of 425x350. We then replace the height/width/media1/media2 parameter placeholders in $media_replace with the correct ones, before running a str_replace on $text, replacing the given media with its correct replacement.\r
+       \r
                // youtube videos\r
-        preg_match_all("#\[media[0-9a-z\|]*\]http://([a-z0-9\.]*)?youtube.com/watch\?v=(.*)\[/media\]#iU",$text,$media_matches[1],PREG_SET_ORDER);\r
-        $media_replace[1] = '<object width="##WIDTH##" height="##HEIGHT##"><param name="movie" value="http://##MEDIA1##youtube.com/v/##MEDIA2##"></param><embed src="http://##MEDIA1##youtube.com/v/##MEDIA2##" type="application/x-shockwave-flash" width="##WIDTH##" height="##HEIGHT##"></embed></object>';\r
-                               \r
+               preg_match_all("#\[media[0-9a-z\|]*\]http://([a-z0-9\.]*)?youtube.com/watch\?v=(.*)\[/media\]#iU",$text,$media_matches[],PREG_SET_ORDER);\r
+               $media_replace[] = '<object width="##WIDTH##" height="##HEIGHT##"><param name="movie" value="http://##MEDIA1##youtube.com/v/##MEDIA2##"></param><embed src="http://##MEDIA1##youtube.com/v/##MEDIA2##" type="application/x-shockwave-flash" width="##WIDTH##" height="##HEIGHT##"></embed></object>';\r
+               \r
                // .mpg\r
-               preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+).mpg\[/media\]#i",$text,$media_matches[2],PREG_SET_ORDER);\r
-               $media_replace[2] = "<object data=\"##MEDIA1##.mpg\" type=\"video/mpeg\" width=\"##WIDTH##\" height=\"##HEIGHT##\"><param name=\"src\" value=\"##MEDIA1##.mpg\"><param name=\"autoplay\" value=\"false\"><param name=\"autoStart\" value=\"0\"><a href=\"##MEDIA1##.mpg\">##MEDIA1##.mpg</a></object>";\r
+               preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+).mpg\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER);\r
+               $media_replace[] = "<object data=\"##MEDIA1##.mpg\" type=\"video/mpeg\" width=\"##WIDTH##\" height=\"##HEIGHT##\"><param name=\"src\" value=\"##MEDIA1##.mpg\"><param name=\"autoplay\" value=\"false\"><param name=\"autoStart\" value=\"0\"><a href=\"##MEDIA1##.mpg\">##MEDIA1##.mpg</a></object>";\r
                \r
                // .avi\r
-               preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+).avi\[/media\]#i",$text,$media_matches[3],PREG_SET_ORDER);\r
-               $media_replace[3] = "<object data=\"##MEDIA1##.avi\" type=\"video/x-msvideo\" width=\"##WIDTH##\" height=\"##HEIGHT##\"><param name=\"src\" value=\"##MEDIA1##.avi\"><param name=\"autoplay\" value=\"false\"><param name=\"autoStart\" value=\"0\"><a href=\"##MEDIA1##.avi\">##MEDIA1##.avi</a></object>";\r
+               preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+).avi\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER);\r
+               $media_replace[] = "<object data=\"##MEDIA1##.avi\" type=\"video/x-msvideo\" width=\"##WIDTH##\" height=\"##HEIGHT##\"><param name=\"src\" value=\"##MEDIA1##.avi\"><param name=\"autoplay\" value=\"false\"><param name=\"autoStart\" value=\"0\"><a href=\"##MEDIA1##.avi\">##MEDIA1##.avi</a></object>";\r
                \r
                // .wmv\r
-               preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+).wmv\[/media\]#i",$text,$media_matches[4],PREG_SET_ORDER);\r
-               $media_replace[4] = "<object data=\"##MEDIA1##.wmv\" type=\"video/x-ms-wmv\" width=\"##WIDTH##\" height=\"##HEIGHT##\"><param name=\"src\" value=\"##MEDIA1##.wmv\"><param name=\"autoplay\" value=\"false\"><param name=\"autoStart\" value=\"0\"><a href=\"##MEDIA1##.wmv\">##MEDIA1##.wmv</a></object>";\r
+               preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+).wmv\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER);\r
+               $media_replace[] = "<object data=\"##MEDIA1##.wmv\" type=\"video/x-ms-wmv\" width=\"##WIDTH##\" height=\"##HEIGHT##\"><param name=\"src\" value=\"##MEDIA1##.wmv\"><param name=\"autoplay\" value=\"false\"><param name=\"autoStart\" value=\"0\"><a href=\"##MEDIA1##.wmv\">##MEDIA1##.wmv</a></object>";\r
+               \r
+               // .mov\r
+               preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+).mov\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER);\r
+               $media_replace[] = "<object classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" codebase=\"http://www.apple.com/qtactivex/qtplugin.cab\" width=\"##WIDTH##\" height=\"##HEIGHT##\">\n".\r
+                                  "  <param name=\"src\" value=\"##MEDIA1##.mov\">\n".\r
+                                  "  <param name=\"controller\" value=\"true\">\n".\r
+                                  "  <param name=\"autoplay\" value=\"false\">\n".\r
+                                  "  <!--[if gte IE 7] > <!-->\n".\r
+                                  "  <object type=\"video/quicktime\" data=\"##MEDIA1##.mov\" width=\"##WIDTH##\" height=\"##HEIGHT##\">\n".\r
+                                  "    <param name=\"controller\" value=\"true\">\n".\r
+                                  "    <param name=\"autoplay\" value=\"false\">\n".\r
+                                  "    <a href=\"##MEDIA1##.mov\">##MEDIA1##.mov</a>\n".\r
+                                  "  </object>\n".\r
+                                  "  <!--<![endif]-->\n".\r
+                                  "  <!--[if lt IE 7]>\n".\r
+                                  "  <a href=\"##MEDIA1##.mov\">##MEDIA1##.mov</a>\n".\r
+                                  "  <![endif]-->\n".\r
+                                  "</object>";\r
                \r
                // .swf\r
-               preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+).swf\[/media\]#i",$text,$media_matches[5],PREG_SET_ORDER);\r
-               $media_replace[5] = "<object type=\"application/x-shockwave-flash\" data=\"##MEDIA1##.swf\" width=\"##WIDTH##\" height=\"##HEIGHT##\">  <param name=\"movie\" value=\"##MEDIA1##.swf\"><param name=\"loop\" value=\"false\"><a href=\"##MEDIA1##.swf\">##MEDIA1##.swf</a></object>";\r
+               preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+).swf\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER);\r
+               $media_replace[] = "<object type=\"application/x-shockwave-flash\" data=\"##MEDIA1##.swf\" width=\"##WIDTH##\" height=\"##HEIGHT##\">  <param name=\"movie\" value=\"##MEDIA1##.swf\"><param name=\"loop\" value=\"false\"><a href=\"##MEDIA1##.swf\">##MEDIA1##.swf</a></object>";\r
+       \r
+               // .mp3\r
+               preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+).mp3\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER);\r
+               $media_replace[] = "<object type=\"audio/mpeg\" data=\"##MEDIA1##.mp3\" width=\"##WIDTH##\" height=\"##HEIGHT##\"><param name=\"src\" value=\"##MEDIA1##.mp3\"><param name=\"autoplay\" value=\"false\"><param name=\"autoStart\" value=\"0\"><a href=\"##MEDIA1##.mp3\">##MEDIA1##.mp3</a></object>";\r
                \r
                // .wav\r
-               preg_match_all("#\[media[0-9a-z\|]*\](.+[^\s\"]+).wav\[/media\]#i",$text,$media_matches[6],PREG_SET_ORDER);\r
-               $media_replace[6] ="<object type=\"audio/x-wav\" data=\"##MEDIA1##.wav\" width=\"##WIDTH##\" height=\"##HEIGHT##\"><param name=\"src\" value=\"##MEDIA1##.wav\"><param name=\"autoplay\" value=\"false\"><param name=\"autoStart\" value=\"0\"><a href=\"##MEDIA1##.wav\">##MEDIA1##.wav</a></object>";\r
+               preg_match_all("#\[media[0-9a-z\|]*\](.+[^\s\"]+).wav\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER);\r
+               $media_replace[] ="<object type=\"audio/x-wav\" data=\"##MEDIA1##.wav\" width=\"##WIDTH##\" height=\"##HEIGHT##\"><param name=\"src\" value=\"##MEDIA1##.wav\"><param name=\"autoplay\" value=\"false\"><param name=\"autoStart\" value=\"0\"><a href=\"##MEDIA1##.wav\">##MEDIA1##.wav</a></object>";\r
                \r
                // .ogg\r
-               preg_match_all("#\[media[0-9a-z\|]*\](.+[^\s\"]+).ogg\[/media\]#i",$text,$media_matches[7],PREG_SET_ORDER);\r
-               $media_replace[7] ="<object type=\"application/ogg\" data=\"##MEDIA1##.ogg\" width=\"##WIDTH##\" height=\"##HEIGHT##\"><param name=\"src\" value=\"##MEDIA1##.ogg\"><a href=\"##MEDIA1##.ogg\">##MEDIA1##.ogg</a></object>";\r
-\r
-        // .ogm\r
-        preg_match_all("#\[media[0-9a-z\|]*\](.+[^\s\"]+).ogm\[/media\]#i",$text,$media_matches[8],PREG_SET_ORDER);\r
-        $media_replace[8] ="<object type=\"application/ogm\" data=\"##MEDIA1##.ogm\" width=\"##WIDTH##\" height=\"##HEIGHT##\"><param name=\"src\" value=\"##MEDIA1##.ogm\"><a href=\"##MEDIA1##.ogg\">##MEDIA1##.ogm</a></object>";\r
+               preg_match_all("#\[media[0-9a-z\|]*\](.+[^\s\"]+).ogg\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER);\r
+               $media_replace[] ="<object type=\"application/ogg\" data=\"##MEDIA1##.ogg\" width=\"##WIDTH##\" height=\"##HEIGHT##\"><param name=\"src\" value=\"##MEDIA1##.ogg\"><a href=\"##MEDIA1##.ogg\">##MEDIA1##.ogg</a></object>";\r
+               \r
+               // .ogm\r
+               preg_match_all("#\[media[0-9a-z\|]*\](.+[^\s\"]+).ogm\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER);\r
+               $media_replace[] ="<object type=\"application/ogm\" data=\"##MEDIA1##.ogm\" width=\"##WIDTH##\" height=\"##HEIGHT##\"><param name=\"src\" value=\"##MEDIA1##.ogm\"><a href=\"##MEDIA1##.ogg\">##MEDIA1##.ogm</a></object>";\r
                \r
                // .mid\r
-               preg_match_all("#\[media[0-9a-z\|]*\](.+[^\s\"]+).mid\[/media\]#i",$text,$media_matches[9],PREG_SET_ORDER);\r
-               $media_replace[9] ="<object type=\"application/x-midi\" data=\"##MEDIA1##.mid\" width=\"##WIDTH##\" height=\"##HEIGHT##\"><param name=\"src\" value=\"##MEDIA1##.mid\"><a href=\"##MEDIA1##.mid\">##MEDIA1##.mid</a></object>";\r
+               preg_match_all("#\[media[0-9a-z\|]*\](.+[^\s\"]+).mid\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER);\r
+               $media_replace[] ="<object type=\"application/x-midi\" data=\"##MEDIA1##.mid\" width=\"##WIDTH##\" height=\"##HEIGHT##\"><param name=\"src\" value=\"##MEDIA1##.mid\"><a href=\"##MEDIA1##.mid\">##MEDIA1##.mid</a></object>";\r
                \r
                $text = preg_replace("#\[media[0-9a-z\|]*\](.+[^\s\"]+).mid\[/media\]#i", "<object type=\"application/x-midi\" data=\"\\1.mid\" width=\"".$width."\" height=\"".$height."\"><param name=\"src\" value=\"\\1.mid\"><a href=\"\\1.mid\">\\1.mid</a></object>", $text);\r
        \r
                // Executing the replace\r
-               for ($i=1;$i<=count($media_replace);$i++){\r
+               for ($i=0;$i<count($media_replace);$i++){\r
                        foreach($media_matches[$i] as $media)\r
                        {\r
                                \r
@@ -743,13 +759,6 @@ class ContentUtility {
                include_once(TR_INCLUDE_PATH.'classes/DAO/DAO.class.php');\r
                $dao = new DAO();\r
                \r
-               // All a4a resources have "&" converted to "&amp;". To match content with resources, \r
-        // need the same conversion on content. \r
-        $content = convertAmp($content);\r
-        \r
-        // keep &lt; (content saved in plain text format) as it is instead of &amp;lt;\r
-        $content = str_replace('&amp;lt;', '&lt;', $content);\r
-        \r
         $video_exts = array("mpg", "avi", "wmv", "mov", "swf", "mp4", "flv");\r
         \r
         $audio_exts = array("mp3", "wav", "ogg", "mid");\r
@@ -781,6 +790,13 @@ class ContentUtility {
                                return array($has_text_alternative, $has_audio_alternative, $has_visual_alternative, $has_sign_lang_alternative);\r
                        }\r
                }\r
+               // All a4a resources have "&" converted to "&amp;". To match content with resources, \r
+        // need the same conversion on content. \r
+        $content = convertAmp($content);\r
+        \r
+        // keep &lt; (content saved in plain text format) as it is instead of &amp;lt;\r
+        $content = str_replace('&amp;lt;', '&lt;', $content);\r
+        \r
                // get all relations between primary resources and their alternatives\r
         $sql = "SELECT DISTINCT c.content_path, pr.resource, ";\r
         \r
@@ -860,7 +876,6 @@ class ContentUtility {
                         // use default media size for video medias\r
                         $target = '[media]'.$row['secondary_resource'].'[/media]';\r
                     }\r
-                    $target = ContentUtility::embedFLV(ContentUtility::embedMedia($target));\r
                 }\r
                                // a text primary to be replaced by a visual alternative \r
                                else if (in_array($ext, $txt_exts))\r
index b38de92..dc19d6d 100644 (file)
@@ -195,20 +195,20 @@ if ($content_row['text'] == '' && empty($content_test_ids)){
        $msg->addInfo('NO_PAGE_CONTENT');
        $savant->assign('body', '');
 } else {
-    $content = ContentUtility::formatContent($content_row['text'], $content_row['formatting']);
-
     // find whether the body has alternatives defined
        list($has_text_alternative, $has_audio_alternative, $has_visual_alternative, $has_sign_lang_alternative)
-       = ContentUtility::applyAlternatives($cid, $content, true);
+       = ContentUtility::applyAlternatives($cid, $content_row['text'], true);
 
        // apply alternatives
        if (intval($_GET['alternative']) > 0) {
-               $content = ContentUtility::applyAlternatives($cid, $content, false, intval($_GET['alternative']));
+               $content = ContentUtility::applyAlternatives($cid, $content_row['text'], false, intval($_GET['alternative']));
        } else {
-               $content = ContentUtility::applyAlternatives($cid, $content);
+               $content = $content_row['text'];
        }
 
-       $content_array = ContentUtility::getContentTable($content);
+    $content = ContentUtility::formatContent($content, $content_row['formatting']);
+
+       $content_array = ContentUtility::getContentTable($content, $content_row['formatting']);
        
        $savant->assign('content_table', $content_array[0]);
        $savant->assign('body', $content_array[1]);