Merge branch 'MDL-34997-23' of git://github.com/FMCorz/moodle into MOODLE_23_STABLE

This commit is contained in:
Eloy Lafuente (stronk7)
2012-09-05 00:52:43 +02:00
2 changed files with 14 additions and 6 deletions
+3
View File
@@ -57,7 +57,10 @@ class filter_mediaplugin_testcase extends advanced_testcase {
'<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>',
+11 -6
View File
@@ -528,8 +528,8 @@ class core_media_player_youtube extends core_media_player_external {
protected function embed_external(moodle_url $url, $name, $width, $height, $options) {
global $CFG;
$site = $this->matches[1];
$videoid = $this->matches[3];
$site = 'www.youtube.com';
$videoid = end($this->matches);
$info = trim($name);
if (empty($info) or strpos($info, 'http') === 0) {
@@ -564,10 +564,15 @@ OET;
}
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.
$start = '~^https?://(www\.youtube(-nocookie)?\.com)/';
// Middle bit: either watch?v= or v/.
$middle = '(?:watch\?v=|v/)([a-z0-9\-_]+)';
$start = '~^https?://(www\.)?(' . $link . '|' . $shortlink . ')';
// Middle bit: Video key value
$middle = '([a-z0-9\-_]+)';
return $start . $middle . core_media_player_external::END_LINK_REGEX_PART;
}
@@ -578,7 +583,7 @@ OET;
}
public function get_embeddable_markers() {
return array('youtube');
return array('youtube.com', 'youtube-nocookie.com', 'youtu.be', 'y2u.be');
}
}