Merge branch 'MDL-34997-22' of git://github.com/FMCorz/moodle into MOODLE_22_STABLE
This commit is contained in:
@@ -90,6 +90,9 @@ class filter_mediaplugin extends moodle_text_filter {
|
||||
$search = '/<a\s[^>]*href="(https?:\/\/www\.youtube(-nocookie)?\.com)\/v\/([a-z0-9\-_]+)[^"#]*(#d=([\d]{1,4})x([\d]{1,4}))?[^>]*>([^>]*)<\/a>/is';
|
||||
$newtext = preg_replace_callback($search, 'filter_mediaplugin_youtube_callback', $newtext);
|
||||
|
||||
$search = '/<a\s[^>]*href="(https?:\/\/(www\.)?(youtu|y2u)\.be)\/([a-z0-9\-_]+)"[^>]*>([^>]*)<\/a>/is';
|
||||
$newtext = preg_replace_callback($search, 'filter_mediaplugin_shortened_youtube_callback', $newtext);
|
||||
|
||||
$search = '/<a\s[^>]*href="(https?:\/\/www\.youtube(-nocookie)?\.com)\/view_play_list\?p=([a-z0-9\-_]+)[^"#]*(#d=([\d]{1,4})x([\d]{1,4}))?[^>]*>([^>]*)<\/a>/is';
|
||||
$newtext = preg_replace_callback($search, 'filter_mediaplugin_youtube_playlist_callback', $newtext);
|
||||
|
||||
@@ -758,6 +761,18 @@ OET;
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change shortened links to YouTube into embedded YouTube videos
|
||||
*
|
||||
* @param $link
|
||||
* @return string
|
||||
*/
|
||||
function filter_mediaplugin_shortened_youtube_callback($link) {
|
||||
$newlink = array($link[0], 'https://www.youtube.com','',$link[4],'','','',$link[5]);
|
||||
return filter_mediaplugin_youtube_callback($newlink);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Change links to Vimeo into embedded Vimeo videos
|
||||
*
|
||||
|
||||
@@ -58,7 +58,10 @@ class filter_mediaplugin_test extends UnitTestCase {
|
||||
'<a id="movie player" class="center" href="http://moodle.org/testfile/test.mpg">test mpg</a>',
|
||||
'<a href="http://moodle.org/testfile/test.ram">test</a>',
|
||||
'<a href="http://www.youtube.com/watch?v=JghQgA2HMX8" class="href=css">test file</a>',
|
||||
'<a href="http://www.youtube-nocookie.com/watch?v=JghQgA2HMX8" class="href=css">test file</a>',
|
||||
'<a class="youtube" href="http://www.youtube.com/watch?v=JghQgA2HMX8">test file</a>',
|
||||
'<a href="http://youtu.be/JghQgA2HMX8" class="href=css">test file</a>',
|
||||
'<a href="http://y2u.be/JghQgA2HMX8" class="href=css">test file</a>',
|
||||
'<a class="_blanktarget" href="http://moodle.org/testfile/test.flv?d=100x100">test flv</a>',
|
||||
'<a class="hrefcss" href="http://www.youtube.com/watch?v=JghQgA2HMX8">test file</a>',
|
||||
'<a class="content" href="http://moodle.org/testfile/test.avi">test mp3</a>',
|
||||
|
||||
Reference in New Issue
Block a user