From: moodler Date: Mon, 8 Jan 2007 11:55:18 +0000 (+0000) Subject: Flash-based filters are now strrrrrrrict AND accessible! MDL-7889 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=f6994e71fa4b5c1ccec577f637cf08fe6a532325;p=moodle.git Flash-based filters are now strrrrrrrict AND accessible! MDL-7889 Unfortunately this is only possible using Javascript to rewrite the DOM, so this means Flash content won't work without Javascript on. MDL-7861 --- diff --git a/filter/mediaplugin/filter.php b/filter/mediaplugin/filter.php index 52e466609b..fb4fb6d243 100644 --- a/filter/mediaplugin/filter.php +++ b/filter/mediaplugin/filter.php @@ -18,6 +18,10 @@ function mediaplugin_filter($courseid, $text) { global $CFG, $THEME; + static $count = 0; + + $count++; + include "defaultsettings.php"; if ($CFG->filter_mediaplugin_enable_mp3) { @@ -30,23 +34,21 @@ function mediaplugin_filter($courseid, $text) { $c = 'bgColour=000000&btnColour=ffffff&btnBorderColour=cccccc&iconColour=000000&iconOverColour=00cc00&trackColour=cccccc&handleColour=ffffff&loaderColour=ffffff&waitForPlay=yes&'; } } - // $c = htmlentities($c); // Commented out pending bug 5223 $search = '/]*)>(.*?)<\/a>/is'; - $replace = '\\0 wwwroot/filter/mediaplugin/mp3player.swf?src=\\2.mp3\" />"; - $replace .= ' '; - $replace .= ' '; - $replace .= ' '; - $replace .= " wwwroot/filter/mediaplugin/mp3player.swf?src=\\2.mp3\" "; - $replace .= " quality=\"high\" bgcolor=\"#333333\" width=\"90\" height=\"15\" name=\"mp3player\" "; - $replace .= ' type="application/x-shockwave-flash" '; - $replace .= ' flashvars="'.$c.'" '; - $replace .= ' pluginspage="http://www.macromedia.com/go/getflashplayer">'; - $replace .= ''; - $replace .= ' '; + // We're using the UFO technique to attain XHTML Strict 1.0 + // See: http://www.bobbyvandersluis.com/ufo/ + + $replace = ''."\n". + '\\0 '. + '('.get_string('mp3audio', 'mediaplugin').')'. + ''."\n"; $text = preg_replace($search, $replace, $text); } @@ -59,52 +61,62 @@ function mediaplugin_filter($courseid, $text) { $replace = array(); - $replace[0] = '\\0

"; - $replace[0] .= ' '; - $replace[0] .= ' '; - $replace[0] .= " "; - $replace[1] .= ' '; - $replace[1] .= ' '; - $replace[1] .= " '."\n". + ''."\n". + '\\0 '. + '('.get_string('flashanimation', 'mediaplugin').')'. + ''."\n"; + + $replace[1] = ''."\n". + '\\0 '. + '('.get_string('flashanimation', 'mediaplugin').')'. + ''."\n"; $text = preg_replace($search, $replace, $text); } if ($CFG->filter_mediaplugin_enable_flv) { - $search = '/]*)>(.*?)<\/a>/is'; + $search = array( + '/]*)>(.*?)<\/a>/is', + '/]*)>(.*?)<\/a>/is' + ); - $replace = '\\0 wwwroot/filter/mediaplugin/flvplayer.swf?file=\\2.flv\" />"; - $replace .= ' '; - $replace .= ' '; - $replace .= " wwwroot/filter/mediaplugin/flvplayer.swf?file=\\2.flv\" "; - $replace .= " quality=\"high\" bgcolor=\"#FFFFFF\" width=\"480\" height=\"360\" name=\"flvplayer\" "; - $replace .= ' type="application/x-shockwave-flash" '; - $replace .= ' pluginspage="http://www.macromedia.com/go/getflashplayer">'; - $replace .= ''; - $replace .= ' '; - + $replace[1] = ''."\n". + '\\0 '. + '('.get_string('flashvideo', 'mediaplugin').')'. + ''."\n"; + + $replace[1] = ''."\n". + '\\0 '. + '('.get_string('flashvideo', 'mediaplugin').')'. + ''."\n"; + $text = preg_replace($search, $replace, $text); } @@ -115,16 +127,11 @@ function mediaplugin_filter($courseid, $text) { $replace .= ' codebase="http://www.apple.com/qtactivex/qtplugin.cab" '; $replace .= ' height="300" width="400"'; $replace .= ' id="quicktime" type="application/x-oleobject">'; - $replace .= ""; + $replace .= ''; $replace .= ''; $replace .= ''; $replace .= ''; $replace .= ''; - $replace .= "\n"; + $replace .= ''; $replace .= ''; $replace .= ''; $replace .= ''; @@ -147,11 +154,6 @@ function mediaplugin_filter($courseid, $text) { $replace .= ''; $replace .= ''; $replace .= ''; - $replace .= "\n +