From: moodler Date: Tue, 17 Feb 2004 02:37:51 +0000 (+0000) Subject: Cool thing for the morning - a new filter that will turn any link to X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=6de17fde07057116e442b9db64f99c837eb20f12;p=moodle.git Cool thing for the morning - a new filter that will turn any link to an MP3 into an embedded plugin. It would be easy to add movies and things later. --- diff --git a/filter/mediaplugin/mediaplugin.php b/filter/mediaplugin/mediaplugin.php new file mode 100644 index 0000000000..3f0e858f68 --- /dev/null +++ b/filter/mediaplugin/mediaplugin.php @@ -0,0 +1,50 @@ + Configuration -> Variables +// +// filter/mediaplugin/mediaplugin.php'; +// +////////////////////////////////////////////////////////////// + +/// These lines are important - the variable must match the name +/// of the actual function below + + $textfilter_function = 'mediaplugin_filter'; + + if (function_exists($textfilter_function)) { + return; + } + + +/// This is the filtering function itself. It accepts the +/// courseid and the text to be filtered (in HTML form). + +function mediaplugin_filter($courseid, $text) { + global $CFG; + + $search = '/(.*)<\/a>/i'; + + $replace = '\\0 wwwroot/lib/mp3player/mp3player.swf?src=\\2.mp3&autostart=no\">"; + $replace .= ''; + $replace .= ''; + $replace .= "wwwroot/lib/mp3player/mp3player.swf?src=\\2.mp3&autostart=no\" "; + $replace .= " quality=high bgcolor=\"#333333\" width=\"400\" height=\"50\" name=\"mp3player\" "; + $replace .= ' type="application/x-shockwave-flash" '; + $replace .= ' pluginspage="http://www.macromedia.com/go/getflashplayer">'; + $replace .= ''; + $replace .= ''; + + return preg_replace($search, $replace, $text); +} + + +?>