From ec14d16cbfd893bf5a290905b35fe9cfe5bd568a Mon Sep 17 00:00:00 2001 From: Cindy Li Date: Mon, 18 Oct 2010 14:45:51 +0000 Subject: [PATCH] Applied atutor changes for flowplayer and adapted content --- docs/home/classes/ContentUtility.class.php | 181 +++++++++++---------- docs/home/course/content.php | 12 +- 2 files changed, 104 insertions(+), 89 deletions(-) diff --git a/docs/home/classes/ContentUtility.class.php b/docs/home/classes/ContentUtility.class.php index b1485d0..cb18256 100644 --- a/docs/home/classes/ContentUtility.class.php +++ b/docs/home/classes/ContentUtility.class.php @@ -142,46 +142,35 @@ class ContentUtility { $media_replace = array(); $media_matches = array(); + $flowplayerholder_class = "atutor.flowplayerholder"; // style class used to play flowplayer medias + $flowplayerholder_def = '$f("*.'.$flowplayerholder_class.'"'; // javascript definition for atutor.flowplayerholder - // .flv (playing file via full URL) - preg_match_all("#\[media[0-9a-z\|]*\]http://([\w\./-]+)\.flv\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER); - $media_replace[] =""; - - // .flv (playing file from TR_content_dir) + // .flv preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+)\.flv\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER); - $media_replace[] =""; - - // .mp4 (playing file via full URL) - preg_match_all("#\[media[0-9a-z\|]*\]http://([\w\./-]+)\.mp4\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER); - $media_replace[] =""; + $media_replace[] ="\n". + "
\n". + " \n". + "
\n". + "
\n". + " ##MEDIA1##.flv\n". + "
\n". + "
"; - // .mp4 (playing file from TR_content_dir) + // .mp4 preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+)\.mp4\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER); - $media_replace[] =""; - - // .mov (playing file via full URL) - preg_match_all("#\[media[0-9a-z\|]*\]http://([\w\./-]+)\.mov\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER); - $media_replace[] =""; - - // .mov (playing file from TR_content_dir) - preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+)\.mov\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER); - $media_replace[] =""; - - // .mp3 (playing file via full URL) - preg_match_all("#\[media[0-9a-z\|]*\]http://([\w\./-]+)\.mp3\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER); - $media_replace[] =""; - - // .mp3 (playing file from TR_content_dir) - preg_match_all("#\[media[0-9a-z\|]*\](.+[^\s\"]+)\.mp3\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER); - $media_replace[] =""; - - $has_flv = false; + //$media_replace[] =""; + $media_replace[] ="\n". + "
\n". + " \n". + "
\n". + "
\n". + " ##MEDIA1##.mp4\n". + "
\n". + "
"; // Executing the replace for ($i=0;$i - '; + $text .= ''."\n"; } - return $text; } @@ -262,52 +255,75 @@ class ContentUtility { $text = preg_replace("/(\[media\])([\s]*)(.*)(\[\/media\])/", '$1$3$4', $text); $text = preg_replace("/(\[media\])(.*)([\s]*)(\[\/media\])/U", '$1$2$4', $text); - $media_matches = Array(); + $media_matches = array(); + $media_replace = array(); // First, we search though the text for all different kinds of media defined by media tags and store the results in $media_matches. - // Then the different replacements for the different media tags are stored in $media_replace. - // 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. - + // Then the different replacements for the different media tags are stored in $media_replace. + // 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. + // youtube videos - preg_match_all("#\[media[0-9a-z\|]*\]http://([a-z0-9\.]*)?youtube.com/watch\?v=(.*)\[/media\]#iU",$text,$media_matches[1],PREG_SET_ORDER); - $media_replace[1] = ''; - + preg_match_all("#\[media[0-9a-z\|]*\]http://([a-z0-9\.]*)?youtube.com/watch\?v=(.*)\[/media\]#iU",$text,$media_matches[],PREG_SET_ORDER); + $media_replace[] = ''; + // .mpg - preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+).mpg\[/media\]#i",$text,$media_matches[2],PREG_SET_ORDER); - $media_replace[2] = "##MEDIA1##.mpg"; + preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+).mpg\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER); + $media_replace[] = "##MEDIA1##.mpg"; // .avi - preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+).avi\[/media\]#i",$text,$media_matches[3],PREG_SET_ORDER); - $media_replace[3] = "##MEDIA1##.avi"; + preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+).avi\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER); + $media_replace[] = "##MEDIA1##.avi"; // .wmv - preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+).wmv\[/media\]#i",$text,$media_matches[4],PREG_SET_ORDER); - $media_replace[4] = "##MEDIA1##.wmv"; + preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+).wmv\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER); + $media_replace[] = "##MEDIA1##.wmv"; + + // .mov + preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+).mov\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER); + $media_replace[] = "\n". + " \n". + " \n". + " \n". + " \n". + " \n". + " \n". + " \n". + " ##MEDIA1##.mov\n". + " \n". + " \n". + " \n". + ""; // .swf - preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+).swf\[/media\]#i",$text,$media_matches[5],PREG_SET_ORDER); - $media_replace[5] = " ##MEDIA1##.swf"; + preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+).swf\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER); + $media_replace[] = " ##MEDIA1##.swf"; + + // .mp3 + preg_match_all("#\[media[0-9a-z\|]*\]([.\w\d]+[^\s\"]+).mp3\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER); + $media_replace[] = "##MEDIA1##.mp3"; // .wav - preg_match_all("#\[media[0-9a-z\|]*\](.+[^\s\"]+).wav\[/media\]#i",$text,$media_matches[6],PREG_SET_ORDER); - $media_replace[6] ="##MEDIA1##.wav"; + preg_match_all("#\[media[0-9a-z\|]*\](.+[^\s\"]+).wav\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER); + $media_replace[] ="##MEDIA1##.wav"; // .ogg - preg_match_all("#\[media[0-9a-z\|]*\](.+[^\s\"]+).ogg\[/media\]#i",$text,$media_matches[7],PREG_SET_ORDER); - $media_replace[7] ="##MEDIA1##.ogg"; - - // .ogm - preg_match_all("#\[media[0-9a-z\|]*\](.+[^\s\"]+).ogm\[/media\]#i",$text,$media_matches[8],PREG_SET_ORDER); - $media_replace[8] ="##MEDIA1##.ogm"; + preg_match_all("#\[media[0-9a-z\|]*\](.+[^\s\"]+).ogg\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER); + $media_replace[] ="##MEDIA1##.ogg"; + + // .ogm + preg_match_all("#\[media[0-9a-z\|]*\](.+[^\s\"]+).ogm\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER); + $media_replace[] ="##MEDIA1##.ogm"; // .mid - preg_match_all("#\[media[0-9a-z\|]*\](.+[^\s\"]+).mid\[/media\]#i",$text,$media_matches[9],PREG_SET_ORDER); - $media_replace[9] ="##MEDIA1##.mid"; + preg_match_all("#\[media[0-9a-z\|]*\](.+[^\s\"]+).mid\[/media\]#i",$text,$media_matches[],PREG_SET_ORDER); + $media_replace[] ="##MEDIA1##.mid"; $text = preg_replace("#\[media[0-9a-z\|]*\](.+[^\s\"]+).mid\[/media\]#i", "\\1.mid", $text); // Executing the replace - for ($i=1;$i<=count($media_replace);$i++){ + for ($i=0;$iaddInfo('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]); -- 2.17.1