remove old readme
[atutor.git] / mods / _standard / flowplayer / module_format_content.php
1 <?php
2 // input string. DO NOT CHANGE.
3 global $_input, $_content_base_href;
4
5 //Output for flowplayer module.
6 $media_replace = array();
7 $media_matches = array();
8 $flowplayerholder_class = "atutor.flowplayerholder";  // style class used to play flowplayer medias
9 $flowplayerholder_def = '$f("*.'.$flowplayerholder_class.'"';   // javascript definition for atutor.flowplayerholder 
10
11 // .flv
12 preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+)\.flv\[/media\]#i",$_input,$media_matches[],PREG_SET_ORDER);
13 $media_replace[] ="  <div>\n".
14                   "    <a class=\"".$flowplayerholder_class."\" style=\"display:block;width:##WIDTH##px;height:##HEIGHT##px;\" href=\"##MEDIA1##.flv\"></a>\n".
15                   "  </div>\n".
16                   "  <div style=\"margin-top:-2em;\">\n".
17                   "    <a href=\"##MEDIA1##.flv\">##MEDIA1##.flv</a>\n".
18                   "  </div>\n";
19
20 // .mp4
21 preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+)\.mp4\[/media\]#i",$_input,$media_matches[],PREG_SET_ORDER);
22 //$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>";
23 $media_replace[] ="  <div>\n".
24                   "    <a class=\"".$flowplayerholder_class."\" style=\"display:block;width:##WIDTH##px;height:##HEIGHT##px;\" href=\"##MEDIA1##.mp4\"></a>\n".
25                   "  </div>\n".
26                   "  <div style=\"margin-top:-3em;\">\n".
27                   "    <a href=\"##MEDIA1##.mp4\">##MEDIA1##.mp4</a>\n".
28                   "  </div>\n";
29
30 //// .mov
31 //preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+)\.mov\[/media\]#i",$_input,$media_matches[],PREG_SET_ORDER);
32 //$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##.mov\"></a>";
33 //
34 //// .mp3
35 //preg_match_all("#\[media[0-9a-z\|]*\](.+[^\s\"]+)\.mp3\[/media\]#i",$_input,$media_matches[],PREG_SET_ORDER);
36 //$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##.mp3\"></a>";
37
38 // Executing the replace
39 for ($i=0;$i<count($media_replace);$i++){
40         foreach($media_matches[$i] as $media)
41         {
42                 //find width and height for each matched media
43                 if (preg_match("/\[media\|([0-9]*)\|([0-9]*)\]*/", $media[0], $matches)) 
44                 {
45                         $width = $matches[1];
46                         $height = $matches[2];
47                 }
48                 else
49                 {
50                         $width = DEFAULT_VIDEO_PLAYER_WIDTH;
51                         $height = DEFAULT_VIDEO_PLAYER_HEIGHT;
52                 }
53                 
54                 //replace media tags with embedded media for each media tag
55                 $media_input = $media_replace[$i];
56                 $media_input = str_replace("##WIDTH##","$width",$media_input);
57                 $media_input = str_replace("##HEIGHT##","$height",$media_input);
58                 $media_input = str_replace("##MEDIA1##","$media[1]",$media_input);
59                 $media_input = str_replace("##MEDIA2##","$media[2]",$media_input);
60                 $_input = str_replace($media[0],$media_input,$_input);
61         }
62 }
63
64 // Include the javascript only if:
65 // 1. $flowplayerholder_class is used but not defined
66 // 2. exclude from export common cartridge or content package
67 if (strpos($_input, $flowplayerholder_class) 
68     && !strpos($_input, $flowplayerholder_def)
69     && !strpos($_SERVER['PHP_SELF'], "ims_export.php"))
70 {
71         $_input .= '<script type="text/javascript">
72 '.$flowplayerholder_def.', "'.AT_BASE_HREF.'mods/_standard/flowplayer/flowplayer-3.2.4.swf", { 
73   clip: { 
74   autoPlay: false,
75   baseUrl: \''.AT_BASE_HREF.'get.php/'.$_content_base_href.'\'},
76   plugins:  { 
77     controls: { 
78       buttons:true, 
79       play: true,  
80       scrubber: true, 
81       autoHide:false
82     }         
83   }
84 });
85 </script>'."\n";
86 }
87 ?>