http://atutor.ca/atutor/mantis/view.php?id=3080
authorjoel kronenberg <joel.kronenberg@utoronto.ca>
Fri, 15 Jun 2007 18:44:37 +0000 (18:44 -0000)
committerjoel kronenberg <joel.kronenberg@utoronto.ca>
Fri, 15 Jun 2007 18:44:37 +0000 (18:44 -0000)
http://atutor.ca/atutor/mantis/view.php?id=3081

docs/documentation/instructor/content_edit.php
docs/get.php
docs/include/html/code_picker.inc.php
docs/include/html/filemanager_display.inc.php
docs/include/lib/output.inc.php

index cc9b293..238c7e1 100644 (file)
@@ -42,6 +42,9 @@
                <dt>LaTeX</dt>
                <dd><p>Use <kbd>[tex][/tex]</kbd> to embed LaTeX equations into your content.</p></dd>
 
+               <dt>Multimedia</dt>
+               <dd><p>Use <kbd>[media][/media]</kbd> to embed multimedia into your content. Supported formats are: mpeg, mov, wmv, mov, swf, mp3, wav, ogg, mid, and YouTube hosted videos.</p></dd>
+
                <dt>Upload from File</dt>
                <dd><p>Rather than typing out content, it can be uploaded from a text or HTML file on your local file system. Once uploaded, the content of that file will be displayed in the <em>Body</em> window. Keep in mind that uploading in this manner will replace any existing content in the <em>Body</em> window.</p></dd>
 
index 1e14d6a..de30f26 100644 (file)
@@ -12,7 +12,7 @@
 /************************************************************************/
 // $Id$
 define('AT_INCLUDE_PATH', 'include/');
-ob_end_clean();
+@ob_end_clean();
 header("Content-Encoding: none");
 if (isset($_GET['test'])) {
        header('HTTP/1.1 200 OK', TRUE);
index af3a8c7..99cf9bb 100644 (file)
@@ -45,7 +45,8 @@ if (!defined('AT_INCLUDE_PATH')) { exit; }
        <a href="javascript:smilie('[center] [/center]')" title="[center] [/center]"><?php echo _AT('center'); ?></a>,
        <a href="javascript:smilie('[quote] [/quote]')" title="[quote] [/quote]"><?php echo _AT('quote'); ?></a>,
        <a href="javascript:smilie('http://')" title="http://"><?php echo _AT('link'); ?></a>,
-       <a href="javascript:smilie('[image|alt text][/image]')" title="[image|alt text][/image]"><?php echo _AT('image'); ?></a><?php
+       <a href="javascript:smilie('[image|alt text][/image]')" title="[image|alt text][/image]"><?php echo _AT('image'); ?></a>,
+       <a href="javascript:smilie('[media][/media]')" title="[media] [/media]"><?php echo _AT('media'); ?></a><?php
        if (isset($current_tab)) {
                echo ', <a href="javascript:smilie(\' [?][/?]\')" title="[?][/?]">',_AT('add_term'), '</a>';
                echo '<a href="javascript:smilie(\' [code][/code]\')" title="[code][/code]" onclick="document.form.formatting.html.checked=true;">',_AT('add_code'), '</a>';
index d20c5c2..077e1f6 100644 (file)
@@ -346,7 +346,15 @@ function insertFile(fileName, pathTo, ext) {
                } else {
                        insertAtCursor(window.opener.document.form.body_text, html);
                }
-
+       } else if (ext == "mpg" || ext == "avi" || ext == "wmv" || ext == "mov" || ext == "swf" || ext == "mp3" || ext == "wav" || ext == "ogg" || ext == "mid") {
+               var html = '[media]'+ pathTo + fileName + '[/media]';
+               if (window.parent.tinyMCE) {
+                       window.parent.tinyMCE.execCommand('mceInsertContent', false, html);
+               } else if (window.opener.tinyMCE) {
+                       window.opener.tinyMCE.execCommand('mceInsertContent', false, html);
+               } else {
+                       insertAtCursor(window.opener.document.form.body_text, html);
+               }
        } else {
                var info = "<?php echo _AT('put_link'); ?>";
                var html = '<a href="' + pathTo+fileName + '">' + info + '</a>';
index 01cf319..916223b 100644 (file)
@@ -597,21 +597,59 @@ function highlight_code($code, $html) {
 }
 
 /* contributed by Thomas M. Duffey <tduffey at homeboyz.com> */
-function fix_quotes($text)
-{
+function fix_quotes($text){
        return str_replace('\\"', '"', $text);
 }
 
+function embed_media($text) {
+       if (strpos($text, '[media]') === FALSE) {
+               return $text;
+       }
+
+       // .mpg
+       $text = preg_replace("#\[media\]([.\w\d]+[^\s\"]+).mpg\[/media\]#i", "<object data=\"\\1.mpg\" type=\"video/mpeg\" width=\"320\" height=\"255\"><param name=\"src\" value=\"\\1.mpg\"><param name=\"autoplay\" value=\"false\"><param name=\"autoStart\" value=\"0\"><a href=\"\\1.mpg\">\\1.mpg</a></object>", $text);
+
+       // .avi
+       $text = preg_replace("#\[media\]([.\w\d]+[^\s\"]+).avi\[/media\]#i", "<object data=\"\\1.avi\" type=\"video/x-msvideo\" width=\"320\" height=\"255\"><param name=\"src\" value=\"\\1.avi\"><param name=\"autoplay\" value=\"false\"><param name=\"autoStart\" value=\"0\"><a href=\"\\1.avi\">\\1.avi</a></object>", $text);
+
+       // .wmv
+       $text = preg_replace("#\[media\]([.\w\d]+[^\s\"]+).wmv\[/media\]#i", "<object data=\"\\1.wmv\" type=\"video/x-ms-wmv\" width=\"320\" height=\"255\"><param name=\"src\" value=\"\\1.wmv\"><param name=\"autoplay\" value=\"false\"><param name=\"autoStart\" value=\"0\"><a href=\"\\1.wmv\">\\1.wmv</a></object>", $text);
+
+       // .mov
+       $text = preg_replace("#\[media\]([.\w\d]+[^\s\"]+).mov\[/media\]#i", "<object classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" codebase=\"http://www.apple.com/qtactivex/qtplugin.cab\" width=\"550\" height=\"400\"><param name=\"src\" value=\"\\1.mov\"><param name=\"controller\" value=\"true\"><param name=\"autoplay\" value=\"false\"><!--[if gte IE 7]> <!--><object type=\"video/quicktime\" data=\"\\1.mov\" width=\"550\" height=\"400\"><param name=\"controller\" value=\"true\"><param name=\"autoplay\" value=\"false\"><a href=\"\\1.mov\">\\1.mov</a></object><!--<![endif]--><!--[if lt IE 7]><a href=\"\\1.mov\">\\1.mov</a><![endif]--></object>", $text);
+
+       // .swf
+       $text = preg_replace("#\[media\]([.\w\d]+[^\s\"]+).swf\[/media\]#i", "<object type=\"application/x-shockwave-flash\" data=\"\\1.swf\" width=\"320\" height=\"240\">  <param name=\"movie\" value=\"\\1.swf\"><param name=\"loop\" value=\"false\"><a href=\"\\1.swf\">\\1.swf</a></object>", $text);
+
+       // youtube videos
+       $text = preg_replace("#http://(www.)?youtube.com/watch\?v=([a-z0-9_-]+)#i", '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/\\2"></param><embed src="http://www.youtube.com/v/\\2" type="application/x-shockwave-flash" width="425" height="350"></embed></object>', $text);
+
+       // .mp3
+       $text = preg_replace("#\[media\](.+[^\s\"]+).mp3\[/media\]#i", "<object type=\"audio/mpeg\" data=\"\\1.mp3\" width=\"200\" height=\"20\"><param name=\"src\" value=\"\\1.mp3\"><param name=\"autoplay\" value=\"false\"><param name=\"autoStart\" value=\"0\"><a href=\"\\1.mp3\">\\1.mp3</a></object>", $text);
+
+       // .wav
+       $text = preg_replace("#\[media\](.+[^\s\"]+).wav\[/media\]#i", "<object type=\"audio/x-wav\" data=\"\\1.wav\" width=\"200\" height=\"20\"><param name=\"src\" value=\"\\1.wav\"><param name=\"autoplay\" value=\"false\"><param name=\"autoStart\" value=\"0\"><a href=\"\\1.wav\">\\1.wav</a></object>", $text);
+
+       // .ogg
+       $text = preg_replace("#\[media\](.+[^\s\"]+).ogg\[/media\]#i", "<object type=\"application/ogg\" data=\"\\1.ogg\" width=\"200\" height=\"20\"><param name=\"src\" value=\"\\1.ogg\"><a href=\"\\1.ogg\">\\1.ogg</a></object>", $text);
+
+       // .mid
+       $text = preg_replace("#\[media\](.+[^\s\"]+).ogg\[/media\]#i", "<object type=\"application/x-midi\" data=\"\\1.mid\" width=\"200\" height=\"20\"><param name=\"src\" value=\"\\1.mid\"><a href=\"\\1.mid\">\\1.mid</a></object>", $text);
+
+       return $text;
+}
 
 function make_clickable($text) {
-       $ret = eregi_replace("([[:space:]])(http[s]?)://([^[:space:]<]*)([[:alnum:]#?/&=])", "\\1<a href=\"\\2://\\3\\4\">\\3\\4</a>", $text);
+       $text = embed_media($text);
 
-       $ret = eregi_replace(   '([_a-zA-Z0-9\-]+(\.[_a-zA-Z0-9\-]+)*'.
+       $text = eregi_replace("([[:space:]])(http[s]?)://([^[:space:]<]*)([[:alnum:]#?/&=])", "\\1<a href=\"\\2://\\3\\4\">\\3\\4</a>", $text);
+
+       $text = eregi_replace(  '([_a-zA-Z0-9\-]+(\.[_a-zA-Z0-9\-]+)*'.
                                                        '\@'.'[_a-zA-Z0-9\-]+(\.[_a-zA-Z0-9\-]+)*'.'(\.[a-zA-Z]{1,6})+)',
                                                        "<a href=\"mailto:\\1\">\\1</a>",
-                                                       $ret);
+                                                       $text);
 
-       return $ret;
+       return $text;
 }
 
 function image_replace($text) {