Permalink
Browse files

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.
  • Loading branch information...
Rossiani Wijaya
Rossiani Wijaya committed Jan 31, 2011
1 parent 8cdc85a commit 469aa3ba50d604e4806b7cc2956d9b3f91bcb90a
Showing with 22 additions and 0 deletions.
  1. +22 −0 filter/mediaplugin/filter.php
@@ -125,6 +125,9 @@ function filter($text, array $options = array()) {
$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 @@ class="mediaplugin mediaplugin_youtube" type="application/x-shockwave-flash"
'</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.'&amp;fs=1&amp;rel=0" width="400" height="320">'.
+ '<param name="movie" value="'.$site.'youtube.com/p/'.$param.'&amp;fs=1&amp;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
*/

0 comments on commit 469aa3b

Please sign in to comment.