create youtube playlist filter. Fixed regex, removed addslash_js, use variable param instead of url because the variable contains the value of the url parameter.
This commit is contained in:
@@ -125,6 +125,9 @@ class filter_mediaplugin extends moodle_text_filter {
|
||||
|
||||
$search = '/<a[^>]*href="([^<]*)youtube.com\/v\/([^"]*)"[^>]*>(.*?)<\/a>/is';
|
||||
$newtext = preg_replace_callback($search, 'filter_mediaplugin_youtube_callback', $newtext);
|
||||
|
||||
$search = '/<a(\s+[^>]+?)?\s+href="((([^"]+)youtube\.com)\/view_play_list\?p=([^"]*))"[^>]*>(.*?)<\/a>/is';
|
||||
$newtext = preg_replace_callback($search, 'filter_mediaplugin_youtube_playlist_callback', $newtext);
|
||||
}
|
||||
|
||||
if (!empty($CFG->filter_mediaplugin_enable_img)) {
|
||||
@@ -349,6 +352,25 @@ function filter_mediaplugin_youtube_callback($link, $autostart=false) {
|
||||
'</object>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Change Youtube playlist into embedded Youtube playlist videos
|
||||
*/
|
||||
function filter_mediaplugin_youtube_playlist_callback($link, $autostart=false) {
|
||||
|
||||
$site = s($link[4]);
|
||||
$param = s($link[5]);
|
||||
$info = s($link[6]);
|
||||
|
||||
return '<object title="'.$info.'"
|
||||
class="mediaplugin mediaplugin_youtube" type="application/x-shockwave-flash"
|
||||
data="'.$site.'youtube.com/p/'.$param.'&fs=1&rel=0" width="400" height="320">'.
|
||||
'<param name="movie" value="'.$site.'youtube.com/p/'.$param.'&fs=1&rel=0" />'.
|
||||
'<param name="FlashVars" value="playerMode=embedded" />'.
|
||||
'<param name="wmode" value="transparent" />'.
|
||||
'<param name="allowFullScreen" value="true" />'.
|
||||
'</object>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Change links to images into embedded images
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user