http://atutor.ca/atutor/mantis/view.php?id=4894
authorCindy Li <cli@ocad.ca>
Thu, 13 Oct 2011 16:47:00 +0000 (16:47 -0000)
committerCindy Li <cli@ocad.ca>
Thu, 13 Oct 2011 16:47:00 +0000 (16:47 -0000)
The proper functioning of flowplayer requires flash to be installed. Coverts the [media] tag into flowplayer type only when the flash is available, otherwise, converts to a plain <a> link instead.

docs/home/classes/ContentUtility.class.php

index 1a217de..0baae42 100644 (file)
@@ -147,26 +147,30 @@ class ContentUtility {
                \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[] ="<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
+               if (isset($_SESSION['flash']) && $_SESSION['flash'] == "yes") {\r
+                       $media_replace[] = "<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
+               } else {\r
+                       $media_replace[] = "<div>\n".\r
+                                      "  <a href=\"##MEDIA1##.flv\">##MEDIA1##.flv</a>\n".\r
+                                      "</div>\n";\r
+               }\r
                \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_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
+\r
+               if (isset($_SESSION['flash']) && $_SESSION['flash'] == "yes") {\r
+                       $media_replace[] = "<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
+               } else {\r
+                       $media_replace[] = "<div>\n".\r
+                                      "  <a href=\"##MEDIA1##.mp4\">##MEDIA1##.mp4</a>\n".\r
+                                      "</div>\n";\r
+               }\r
+               \r
                // Executing the replace\r
                for ($i=0;$i<count($media_replace);$i++){\r
                        foreach($media_matches[$i] as $media)\r