diff --git a/filter/mediaplugin/filter.php b/filter/mediaplugin/filter.php index f41ea3945e7..222c9f45a7f 100644 --- a/filter/mediaplugin/filter.php +++ b/filter/mediaplugin/filter.php @@ -49,61 +49,61 @@ class filter_mediaplugin extends moodle_text_filter { $newtext = $text; // fullclone is slow and not needed here if ($CFG->filter_mediaplugin_enable_mp3) { - $search = '/]*>.*?<\/a>/is'; + $search = '/]*?href="([^<]+\.mp3)"[^>]*>.*?<\/a>/is'; $newtext = preg_replace_callback($search, 'filter_mediaplugin_mp3_callback', $newtext); } if ($CFG->filter_mediaplugin_enable_swf) { - $search = '/]*>.*?<\/a>/is'; + $search = '/]*?href="([^<]+\.swf)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is'; $newtext = preg_replace_callback($search, 'filter_mediaplugin_swf_callback', $newtext); } if ($CFG->filter_mediaplugin_enable_flv) { - $search = '/]*>.*?<\/a>/is'; + $search = '/]*?href="([^<]+\.flv)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is'; $newtext = preg_replace_callback($search, 'filter_mediaplugin_flv_callback', $newtext); } if ($CFG->filter_mediaplugin_enable_mov) { - $search = '/]*>.*?<\/a>/is'; + $search = '/]*?href="([^<]+\.mov)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is'; $newtext = preg_replace_callback($search, 'filter_mediaplugin_qt_callback', $newtext); - $search = '/]*>.*?<\/a>/is'; + $search = '/]*?href="([^<]+\.mp4)(\?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]*>.*?<\/a>/is'; $newtext = preg_replace_callback($search, 'filter_mediaplugin_qt_callback', $newtext); - $search = '/]*>.*?<\/a>/is'; + $search = '/]*?href="([^<]+\.m4v)(\?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]*>.*?<\/a>/is'; $newtext = preg_replace_callback($search, 'filter_mediaplugin_qt_callback', $newtext); - $search = '/]*>.*?<\/a>/is'; + $search = '/]*?href="([^<]+\.m4a)(\?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]*>.*?<\/a>/is'; $newtext = preg_replace_callback($search, 'filter_mediaplugin_qt_callback', $newtext); } if ($CFG->filter_mediaplugin_enable_wmv) { - $search = '/]*>.*?<\/a>/is'; + $search = '/]*?href="([^<]+\.wmv)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is'; $newtext = preg_replace_callback($search, 'filter_mediaplugin_wmp_callback', $newtext); } if ($CFG->filter_mediaplugin_enable_mpg) { - $search = '/]*>.*?<\/a>/is'; + $search = '/]*?href="([^<]+\.mpe?g)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is'; $newtext = preg_replace_callback($search, 'filter_mediaplugin_qt_callback', $newtext); } if ($CFG->filter_mediaplugin_enable_avi) { - $search = '/]*>.*?<\/a>/is'; + $search = '/]*?href="([^<]+\.avi)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is'; $newtext = preg_replace_callback($search, 'filter_mediaplugin_wmp_callback', $newtext); } if ($CFG->filter_mediaplugin_enable_ram) { - $search = '/]*>.*?<\/a>/is'; + $search = '/]*?href="([^<]+\.ram)"[^>]*>.*?<\/a>/is'; $newtext = preg_replace_callback($search, 'filter_mediaplugin_real_callback', $newtext); } if ($CFG->filter_mediaplugin_enable_rpm) { - $search = '/]*>.*?<\/a>/is'; + $search = '/]*?href="([^<]+\.rpm)"[^>]*>.*?<\/a>/is'; $newtext = preg_replace_callback($search, 'filter_mediaplugin_real_callback', $newtext); } if ($CFG->filter_mediaplugin_enable_rm) { - $search = '/]*>.*?<\/a>/is'; + $search = '/]*?href="([^<]+\.rm)"[^>]*>.*?<\/a>/is'; $newtext = preg_replace_callback($search, 'filter_mediaplugin_real_callback', $newtext); } @@ -118,11 +118,11 @@ class filter_mediaplugin extends moodle_text_filter { } if (!empty($CFG->filter_mediaplugin_enable_img)) { - $search = '/]*>(.*?)<\/a>/is'; + $search = '/]*?href="([^<]+\.jpg)"[^>]*>(.*?)<\/a>/is'; $newtext = preg_replace_callback($search, 'filter_mediaplugin_img_callback', $newtext); - $search = '/]*>(.*?)<\/a>/is'; + $search = '/]*?href="([^<]+\.png)"[^>]*>(.*?)<\/a>/is'; $newtext = preg_replace_callback($search, 'filter_mediaplugin_img_callback', $newtext); - $search = '/]*>(.*?)<\/a>/is'; + $search = '/]*?href="([^<]+\.gif)"[^>]*>(.*?)<\/a>/is'; $newtext = preg_replace_callback($search, 'filter_mediaplugin_img_callback', $newtext); } @@ -155,18 +155,42 @@ function filter_mediaplugin_mp3_callback($link) { $url = addslashes_js($link[1]); - $args = Array(); - $args['movie'] = $CFG->wwwroot.'/filter/mediaplugin/mp3player.swf?src='.$url; - $args['width'] = 90; - $args['height'] = 15; - $args['majorversion'] = 6; - $args['build'] = 40; - $args['flashvars'] = $c; - $args['quality'] = 'high'; + $playerpath = $CFG->wwwroot.'/filter/mediaplugin/mp3player.swf'; + $audioplayerpath = $CFG->wwwroot .'/filter/mediaplugin/flowplayer.audio.swf'; + $colors = explode('&', $c); + $playercolors = array(); + foreach ($colors as $color) { + $color = explode('=', $color); + $playercolors[$color[0]] = $color[1]; + } - $jsoutput = create_ufo_inline($id, $args); + $output = << + +OET; - $output = $link[0].'('.get_string('mp3audio', 'filter_mediaplugin').')'.$jsoutput; + $jsoutput = create_flowplayer($id, $url, 'mp3', $playercolors); + $output .= $jsoutput; return $output; } @@ -208,19 +232,24 @@ function filter_mediaplugin_flv_callback($link) { $height = empty($link[4]) ? '360' : $link[4]; $url = addslashes_js($link[1]); - $args = Array(); - $args['movie'] = $CFG->wwwroot.'/filter/mediaplugin/flvplayer.swf?file='.$url; - $args['width'] = $width; - $args['height'] = $height; - $args['majorversion'] = 6; - $args['build'] = 40; - $args['allowscriptaccess'] = 'never'; - $args['quality'] = 'high'; - $args['allowfullscreen'] = 'true'; - $jsoutput = create_ufo_inline($id, $args); + $playerpath = $CFG->wwwroot.'/filter/mediaplugin/flvplayer.swf'; - $output = $link[0].'('.get_string('flashvideo', 'filter_mediaplugin').')'.$jsoutput; + $output = << + +EOT; + $jsoutput = create_flowplayer($id, $url, 'flv'); + $output .= $jsoutput; return $output; } diff --git a/filter/mediaplugin/flowplayer.audio.swf b/filter/mediaplugin/flowplayer.audio.swf new file mode 100644 index 00000000000..3f1ad82cefd Binary files /dev/null and b/filter/mediaplugin/flowplayer.audio.swf differ diff --git a/filter/mediaplugin/flowplayer.controls.swf b/filter/mediaplugin/flowplayer.controls.swf new file mode 100644 index 00000000000..3f814c0706f Binary files /dev/null and b/filter/mediaplugin/flowplayer.controls.swf differ diff --git a/filter/mediaplugin/flvplayer.swf b/filter/mediaplugin/flvplayer.swf index e2f731ba43a..047492ce8a4 100644 Binary files a/filter/mediaplugin/flvplayer.swf and b/filter/mediaplugin/flvplayer.swf differ diff --git a/filter/mediaplugin/mp3player.swf b/filter/mediaplugin/mp3player.swf index 85487c56dfb..047492ce8a4 100755 Binary files a/filter/mediaplugin/mp3player.swf and b/filter/mediaplugin/mp3player.swf differ diff --git a/lib/flowplayer.js b/lib/flowplayer.js new file mode 100644 index 00000000000..64fc215662d --- /dev/null +++ b/lib/flowplayer.js @@ -0,0 +1,24 @@ +/* + * flowplayer.js 3.2.3. The Flowplayer API + * + * Copyright 2009 Flowplayer Oy + * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see . + * + * Date: 2010-08-10 10:12:09 +0000 (Tue, 10 Aug 2010) + * Revision: 539 + */ +(function(){function g(o){console.log("$f.fireEvent",[].slice.call(o))}function k(q){if(!q||typeof q!="object"){return q}var o=new q.constructor();for(var p in q){if(q.hasOwnProperty(p)){o[p]=k(q[p])}}return o}function m(t,q){if(!t){return}var o,p=0,r=t.length;if(r===undefined){for(o in t){if(q.call(t[o],o,t[o])===false){break}}}else{for(var s=t[0];p1){var t=arguments[1],q=(arguments.length==3)?arguments[2]:{};if(typeof t=="string"){t={src:t}}t=i({bgcolor:"#000000",version:[9,0],expressInstall:"http://static.flowplayer.org/swf/expressinstall.swf",cachebusting:true},t);if(typeof o=="string"){if(o.indexOf(".")!=-1){var s=[];m(n(o),function(){s.push(new b(this,k(t),k(q)))});return new d(s)}else{var r=c(o);return new b(r!==null?r:o,t,q)}}else{if(o){return new b(o,t,q)}}}return null};i(window.$f,{fireEvent:function(){var o=[].slice.call(arguments);var q=$f(o[0]);return q?q._fireEvent(o.slice(1)):null},addPlugin:function(o,p){b.prototype[o]=p;return $f},each:m,extend:i});if(typeof jQuery=="function"){jQuery.fn.flowplayer=function(q,p){if(!arguments.length||typeof arguments[0]=="number"){var o=[];this.each(function(){var r=$f(this);if(r){o.push(r)}});return arguments.length?o[arguments[0]]:new d(o)}return this.each(function(){$f(this,k(q),p?k(p):{})})}}})();(function(){var h=document.all,j="http://www.adobe.com/go/getflashplayer",c=typeof jQuery=="function",e=/(\d+)[^\d]+(\d+)[^\d]*(\d*)/,b={width:"100%",height:"100%",id:"_"+(""+Math.random()).slice(9),allowfullscreen:true,allowscriptaccess:"always",quality:"high",version:[3,0],onFail:null,expressInstall:null,w3c:false,cachebusting:false};if(window.attachEvent){window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){}})}function i(m,l){if(l){for(var f in l){if(l.hasOwnProperty(f)){m[f]=l[f]}}}return m}function a(f,n){var m=[];for(var l in f){if(f.hasOwnProperty(l)){m[l]=n(f[l])}}return m}window.flashembed=function(f,m,l){if(typeof f=="string"){f=document.getElementById(f.replace("#",""))}if(!f){return}if(typeof m=="string"){m={src:m}}return new d(f,i(i({},b),m),l)};var g=i(window.flashembed,{conf:b,getVersion:function(){var f;try{f=navigator.plugins["Shockwave Flash"].description.slice(16)}catch(n){try{var l=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");f=l&&l.GetVariable("$version")}catch(m){}}f=e.exec(f);return f?[f[1],f[3]]:[0,0]},asString:function(l){if(l===null||l===undefined){return null}var f=typeof l;if(f=="object"&&l.push){f="array"}switch(f){case"string":l=l.replace(new RegExp('(["\\\\])',"g"),"\\$1");l=l.replace(/^\s?(\d+\.?\d+)%/,"$1pct");return'"'+l+'"';case"array":return"["+a(l,function(o){return g.asString(o)}).join(",")+"]";case"function":return'"function()"';case"object":var m=[];for(var n in l){if(l.hasOwnProperty(n)){m.push('"'+n+'":'+g.asString(l[n]))}}return"{"+m.join(",")+"}"}return String(l).replace(/\s/g," ").replace(/\'/g,'"')},getHTML:function(o,l){o=i({},o);var n=''}o.width=o.height=o.id=o.w3c=o.src=null;o.onFail=o.version=o.expressInstall=null;for(var m in o){if(o[m]){n+=''}}var p="";if(l){for(var f in l){if(l[f]){var q=l[f];p+=f+"="+(/function|object/.test(typeof q)?g.asString(q):q)+"&"}}p=p.slice(0,-1);n+='"}n+="";return n},isSupported:function(f){return k[0]>f[0]||k[0]==f[0]&&k[1]>=f[1]}});var k=g.getVersion();function d(f,n,m){if(g.isSupported(n.version)){f.innerHTML=g.getHTML(n,m)}else{if(n.expressInstall&&g.isSupported([6,65])){f.innerHTML=g.getHTML(i(n,{src:n.expressInstall}),{MMredirectURL:location.href,MMplayerType:"PlugIn",MMdoctitle:document.title})}else{if(!f.innerHTML.replace(/\s/g,"")){f.innerHTML="

Flash version "+n.version+" or greater is required

"+(k[0]>0?"Your version is "+k:"You have no flash plugin installed")+"

"+(f.tagName=="A"?"

Click here to download latest version

":"

Download latest version from here

");if(f.tagName=="A"){f.onclick=function(){location.href=j}}}if(n.onFail){var l=n.onFail.call(this);if(typeof l=="string"){f.innerHTML=l}}}}if(h){window[n.id]=document.getElementById(n.id)}i(this,{getRoot:function(){return f},getOptions:function(){return n},getConf:function(){return m},getApi:function(){return f.firstChild}})}if(c){jQuery.tools=jQuery.tools||{version:"3.2.3"};jQuery.tools.flashembed={conf:b};jQuery.fn.flashembed=function(l,f){return this.each(function(){$(this).data("flashembed",flashembed(this,l,f))})}}})(); \ No newline at end of file diff --git a/lib/javascript-static.js b/lib/javascript-static.js index c086771f08a..f1baae64918 100644 --- a/lib/javascript-static.js +++ b/lib/javascript-static.js @@ -960,7 +960,7 @@ function openpopup(event, args) { event.returnValue = false; } } - + var fullurl = args.url; if (!args.url.match(/https?:\/\//)) { fullurl = M.cfg.wwwroot + args.url; @@ -974,7 +974,7 @@ function openpopup(event, args) { windowobj.resizeTo(screen.availWidth,screen.availHeight); } windowobj.focus(); - + return false; } @@ -1176,21 +1176,21 @@ M.util.help_icon = { headerContent: closebtn, bodyContent: '', id: 'helppopupbox', - width:'400px', + width:'400px', visible : false, - constrain : true + constrain : true }); this.overlay.render(Y.one(document.body)); closebtn.on('click', this.overlay.hide, this.overlay); - + var boundingBox = this.overlay.get("boundingBox"); // Hide the menu if the user clicks outside of its content boundingBox.get("ownerDocument").on("mousedown", function (event) { var oTarget = event.target; var menuButton = Y.one("#"+args.id); - + if (!oTarget.compareTo(menuButton) && !menuButton.contains(oTarget) && !oTarget.compareTo(boundingBox) && @@ -1261,8 +1261,8 @@ M.util.help_icon = { M.util.help_icon.instance.display(event, args); } }, - init : function(Y) { - this.Y = Y; + init : function(Y) { + this.Y = Y; } } @@ -1273,7 +1273,7 @@ M.core_custom_menu = { /** * This method is used to initialise a custom menu given the id that belongs * to the custom menu's root node. - * + * * @param {YUI} Y * @param {string} nodeid */ @@ -1340,7 +1340,7 @@ M.form.init_smartselect = function(Y, id, options) { } } } - + // Display a loading message first up this.nodes.select = nodes.select; @@ -1501,4 +1501,73 @@ M.form.init_smartselect = function(Y, id, options) { } smartselect.init(Y, id, options, {select:select}); }); +} + +M.util.init_flvflowplayer = function (id, playerpath, fileurl) { + $f(id, playerpath, { + plugins: { + controls: { + autoHide: true + } + }, + clip: { + url: fileurl, + autoPlay: false, + autoBuffering: true + } + }); +} + +M.util.init_mp3flowplayer = function (id, playerpath, audioplayerpath, fileurl, color) { + + $f(id, playerpath, { + + plugins: { + controls: { + fullscreen: false, + height: 25, + autoHide: false, + background: '#'+color['bgColour'], + buttonColor: '#'+color['btnColour'], + sliderColor: '#'+color['handleColour'], + volumeSliderColor: '#'+color['handleColour'], + volumeColor: '#'+color['trackColour'], + durationColor: '#'+color['fontColour'], + buttonOverColor: '#'+color['iconOverColour'], + progressColor: '#'+color['handleColour'] + }, + audio: {url: audioplayerpath} + }, + clip: { url: fileurl, + provider: "audio", + autoPlay: false + } + }); +} + +M.util.init_mp3flowplayerplugin = function (id, playerpath, audioplayerpath, fileurl, color) { + $f(id, playerpath, { + plugins: { + controls: { + all: false, + play: true, + pause: true, + scrubber: true, + autoHide: false, + height: 15, + background: '#'+color['bgColour'], + buttonColor: '#'+color['btnColour'], + sliderColor: '#'+color['handleColour'], + volumeSliderColor: '#'+color['handleColour'], + progressColor: '#'+color['handleColour'], + volumeColor: '#'+color['trackColour'], + buttonOverColor: '#'+color['iconOverColour'] + }, + audio: {url: audioplayerpath} + }, + clip: { url: fileurl, + provider: "audio", + autoPlay: false + } + }); } \ No newline at end of file diff --git a/lib/resourcelib.php b/lib/resourcelib.php index 2b43fc34766..0d4aa225273 100644 --- a/lib/resourcelib.php +++ b/lib/resourcelib.php @@ -182,36 +182,42 @@ function resourcelib_embed_mp3($fullurl, $title, $clicktoopen) { global $CFG, $OUTPUT, $PAGE; $c = $OUTPUT->resource_mp3player_colors(); // You can set this up in your theme/xxx/config.php + $colors = explode('&', $c); + $playercolors = array(); + foreach ($colors as $color) { + $color = explode('=', $color); + $playercolors[$color[0]] = $color[1]; + } - $c .= '&volText='.get_string('vol', 'resource').'&panText='.get_string('pan','resource'); $id = 'filter_mp3_'.time(); //we need something unique because it might be stored in text cache - $ufoargs = array('movie' => $CFG->wwwroot.'/lib/mp3player/mp3player.swf?src='.urlencode($fullurl), - 'width' => 600, - 'height' => 70, - 'majorversion' => 6, - 'build' => 40, - 'flashvars' => $c, - 'quality' => 'high'); + $playerpath = $CFG->wwwroot .'/filter/mediaplugin/mp3player.swf'; + $audioplayerpath = $CFG->wwwroot .'/filter/mediaplugin/flowplayer.audio.swf'; - // If we have Javascript, use UFO to embed the MP3 player, otherwise depend on plugins $code = << - +