f295d2110c9eb5af08742e200eb2ae93b5c5021f
[atutor.git] / mods / 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
7 // .flv - uses Flowplayer 3.0 from flowplayer.org (playing file via full URL)
8 preg_match_all("#\[media[0-9a-z\|]*\]http://([\w\./-]+)\.flv\[/media\]#i",$_input,$media_matches[0],PREG_SET_ORDER);
9 $media_replace[0] ="<a class=\"flowplayerholder\"
10 style=\"display:block;width:##WIDTH##px;height:##HEIGHT##px;\"
11 href=\"http://##MEDIA1##.flv\">
12 </a>";
13
14 // .flv - uses Flowplayer 3.0 from flowplayer.org (playing file from AT_content_dir)
15 preg_match_all("#\[media[0-9a-z\|]*\]([\w\./-]+)\.flv\[/media\]#i",$_input,$media_matches[1],PREG_SET_ORDER);
16 $media_replace[1] ="<a class=\"flowplayerholder\"
17 style=\"display:block;width:##WIDTH##px;height:##HEIGHT##px;\"
18 href=\"".AT_BASE_HREF."get.php/".$_content_base_href."##MEDIA1##.flv\">
19 </a>";
20
21 $has_flv = false;
22 // Executing the replace
23 for ($i=0;$i<count($media_replace);$i++){
24         foreach($media_matches[$i] as $media)
25         {
26                 if (is_array($media)) $has_flv = true;
27                 
28                 //find width and height for each matched media
29                 if (preg_match("/\[media\|([0-9]*)\|([0-9]*)\]*/", $media[0], $matches)) 
30                 {
31                         $width = $matches[1];
32                         $height = $matches[2];
33                 }
34                 else
35                 {
36                         $width = 425;
37                         $height = 350;
38                 }
39                 
40                 //replace media tags with embedded media for each media tag
41                 $media_input = $media_replace[$i];
42                 $media_input = str_replace("##WIDTH##","$width",$media_input);
43                 $media_input = str_replace("##HEIGHT##","$height",$media_input);
44                 $media_input = str_replace("##MEDIA1##","$media[1]",$media_input);
45                 $media_input = str_replace("##MEDIA2##","$media[2]",$media_input);
46                 $_input = str_replace($media[0],$media_input,$_input);
47         }
48 }
49
50 if ($has_flv)
51 {
52         $_input .= '
53         <script language="JavaScript">
54                 $f("a.flowplayerholder", "'.AT_BASE_HREF.'/mods/flowplayer/flowplayer-3.1.2.swf", { 
55                         clip: { autoPlay: false },              
56                 plugins:  { 
57                         controls: { 
58                             all: false,  
59                             play: true,  
60                             scrubber: true 
61                         }         
62                     }
63                 });
64         </script>
65         ';
66 }
67 ?>