mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
Merge branch 'MDL-34997-master' of git://github.com/FMCorz/moodle
This commit is contained in:
commit
4bab07c68c
@ -57,6 +57,9 @@ class filter_mediaplugin_testcase extends advanced_testcase {
|
|||||||
'<a id="movie player" class="center" href="http://moodle.org/testfile/test.mpg">test mpg</a>',
|
'<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://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.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 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="youtube" href="http://www.youtube.com/watch?v=JghQgA2HMX8">test file</a>',
|
'<a class="youtube" href="http://www.youtube.com/watch?v=JghQgA2HMX8">test file</a>',
|
||||||
'<a class="_blanktarget" href="http://moodle.org/testfile/test.flv?d=100x100">test flv</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="hrefcss" href="http://www.youtube.com/watch?v=JghQgA2HMX8">test file</a>',
|
||||||
|
@ -526,8 +526,7 @@ OET;
|
|||||||
*/
|
*/
|
||||||
class core_media_player_youtube extends core_media_player_external {
|
class core_media_player_youtube extends core_media_player_external {
|
||||||
protected function embed_external(moodle_url $url, $name, $width, $height, $options) {
|
protected function embed_external(moodle_url $url, $name, $width, $height, $options) {
|
||||||
$site = $this->matches[1];
|
$videoid = end($this->matches);
|
||||||
$videoid = $this->matches[3];
|
|
||||||
|
|
||||||
$info = trim($name);
|
$info = trim($name);
|
||||||
if (empty($info) or strpos($info, 'http') === 0) {
|
if (empty($info) or strpos($info, 'http') === 0) {
|
||||||
@ -540,17 +539,22 @@ class core_media_player_youtube extends core_media_player_external {
|
|||||||
return <<<OET
|
return <<<OET
|
||||||
<span class="mediaplugin mediaplugin_youtube">
|
<span class="mediaplugin mediaplugin_youtube">
|
||||||
<iframe title="$info" width="$width" height="$height"
|
<iframe title="$info" width="$width" height="$height"
|
||||||
src="https://$site/embed/$videoid?rel=0&wmode=transparent" frameborder="0" allowfullscreen="1"></iframe>
|
src="https://www.youtube.com/embed/$videoid?rel=0&wmode=transparent" frameborder="0" allowfullscreen="1"></iframe>
|
||||||
</span>
|
</span>
|
||||||
OET;
|
OET;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function get_regex() {
|
protected function get_regex() {
|
||||||
|
// Regex for standard youtube link
|
||||||
|
$link = '(youtube(-nocookie)?\.com/(?:watch\?v=|v/))';
|
||||||
|
// Regex for shortened youtube link
|
||||||
|
$shortlink = '((youtu|y2u)\.be/)';
|
||||||
|
|
||||||
// Initial part of link.
|
// Initial part of link.
|
||||||
$start = '~^https?://(www\.youtube(-nocookie)?\.com)/';
|
$start = '~^https?://(www\.)?(' . $link . '|' . $shortlink . ')';
|
||||||
// Middle bit: either watch?v= or v/.
|
// Middle bit: Video key value
|
||||||
$middle = '(?:watch\?v=|v/)([a-z0-9\-_]+)';
|
$middle = '([a-z0-9\-_]+)';
|
||||||
return $start . $middle . core_media_player_external::END_LINK_REGEX_PART;
|
return $start . $middle . core_media_player_external::END_LINK_REGEX_PART;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -561,7 +565,7 @@ OET;
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function get_embeddable_markers() {
|
public function get_embeddable_markers() {
|
||||||
return array('youtube');
|
return array('youtube.com', 'youtube-nocookie.com', 'youtu.be', 'y2u.be');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user