diff --git a/sites/all/modules/contrib/editor/video_filter/README.txt b/sites/all/modules/contrib/editor/video_filter/README.txt index e6958da7..a470f08e 100644 --- a/sites/all/modules/contrib/editor/video_filter/README.txt +++ b/sites/all/modules/contrib/editor/video_filter/README.txt @@ -76,7 +76,7 @@ function MODULE_youtube($video) { // $video contains the video URL in source, the codec (as above) and also // [code][matches] with the result of the regexp and [codec][delta] with the // key of the matched regexp. - $video['source'] = 'http://www.youtube.com/v/' . $video['codec']['matches'][1] . ($video['autoplay'] ? '&autoplay=1' : ''); + $video['source'] = '//www.youtube.com/v/' . $video['codec']['matches'][1] . ($video['autoplay'] ? '&autoplay=1' : ''); // Outputs a general for embedding flash players. Needs width, // height, source and optionally align (left or right) and params (a list of diff --git a/sites/all/modules/contrib/editor/video_filter/editors/tinymce/video_filter-4.js b/sites/all/modules/contrib/editor/video_filter/editors/tinymce/video_filter-4.js new file mode 100644 index 00000000..1fae4c7e --- /dev/null +++ b/sites/all/modules/contrib/editor/video_filter/editors/tinymce/video_filter-4.js @@ -0,0 +1,53 @@ +/** + * @file + * Video Filter plugin for TinyMCE 4.x + */ +var video_filter_dialog = {}; + +(function ($) { +video_filter_dialog = { + insert : function() { + var ed = top.tinymce.activeEditor, e; + + var file_url = $('#edit-file-url').val(); + + if (file_url == "") { + // File url is empty, we have nothing to insert, close the window + top.tinymce.activeEditor.windowManager.close(); + } + else { + var str = '[video:' + file_url; + // If field is present (ie. not unset by the admin theme) and if value is not empty: insert value. + if (typeof $('#edit-width').val() != 'undefined' && $('#edit-width').val() !== '') { + str += ' width:' + $('#edit-width').val(); + } + if (typeof $('#edit-height').val() != 'undefined' && $('#edit-height').val() !== '') { + str += ' height:' + $('#edit-height').val(); + } + if (typeof $('#edit-align').val() != 'undefined' && $('#edit-align').val() !== 'none') { + str += ' align:' + $('#edit-align').val(); + } + if ($('#edit-autoplay').is(':checked')) { + str += ' autoplay:' + $('#edit-autoplay').val(); + } + str += ']'; + + ed.execCommand('mceInsertContent', false, str); + top.tinymce.activeEditor.windowManager.close(); + } + } +}; + +Drupal.behaviors.video_filter_tinymce = { + attach: function(context, settings) { + $('#edit-insert').click(function() { + video_filter_dialog.insert(); + }); + + $('#edit-cancel').click(function() { + top.tinymce.activeEditor.windowManager.close(); + }); + } +} + +})(jQuery); diff --git a/sites/all/modules/contrib/editor/video_filter/video_filter.codecs.inc b/sites/all/modules/contrib/editor/video_filter/video_filter.codecs.inc index 06ac3f69..8fcac920 100644 --- a/sites/all/modules/contrib/editor/video_filter/video_filter.codecs.inc +++ b/sites/all/modules/contrib/editor/video_filter/video_filter.codecs.inc @@ -16,7 +16,7 @@ function video_filter_codec_info() { 'sample_url' => 'http://www.archive.org/details/DrupalconBoston2008-TheStateOfDrupal', 'callback' => 'video_filter_archive', 'html5_callback' => 'video_filter_archive', - 'regexp' => '/archive\.org\/details\/([\w-_]+)/i', + 'regexp' => '/archive\.org\/details\/([\w-_\.]+)/i', 'ratio' => 4 / 3, ); @@ -60,15 +60,43 @@ function video_filter_codec_info() { 'control_bar_height' => 0, ); + $codecs['coub'] = array( + 'name' => t('Coub'), + 'sample_url' => 'http://coub.com/view/b7ghv', + 'callback' => 'video_filter_coub', + 'html5_callback' => 'video_filter_coub', + 'regexp' => '/coub\.com\/view\/([a-z0-9]+)/i', + 'ratio' => 4 / 3, + ); + $codecs['dailymotion'] = array( 'name' => t('DailyMotion'), 'sample_url' => 'http://www.dailymotion.com/video/some_video_title', 'callback' => 'video_filter_dailymotion', + 'html5_callback' => 'video_filter_dailymotion_html5', 'regexp' => '/dailymotion\.com\/video\/([a-z0-9\-_]+)/i', 'ratio' => 4 / 3, 'control_bar_height' => 20, ); + $codecs['democracynow_fullshow'] = array( + 'name' => t('DemocracyNow Fullshow'), + 'sample_url' => 'http://www.democracynow.org/shows/2015/3/20', + 'callback' => 'video_filter_democracynow_fullshow', + 'regexp' => '/democracynow\.org\/shows\/([0-9]+)\/([0-9]+)\/([0-9]+)/', + 'ratio' => 16 / 9, + 'control_bar_height' => 0, + ); + + $codecs['democracynow_story'] = array( + 'name' => t('DemocracyNow Story'), + 'sample_url' => 'http://www.democracynow.org/2015/3/23/yemen_in_crisis_us_closes_key', + 'callback' => 'video_filter_democracynow_story', + 'regexp' => '/democracynow\.org\/([0-9]+)\/([0-9]+)\/([0-9]+)\/([a-zA-Z0-9\-_]+)/', + 'ratio' => 16 / 9, + 'control_bar_height' => 0, + ); + $codecs['flickr_slideshows'] = array( 'name' => t('Flickr Slideshows'), 'sample_url' => 'http://www.flickr.com/photos/username/sets/1234567890/show/', @@ -87,6 +115,16 @@ function video_filter_codec_info() { 'control_bar_height' => 0, ); + $codecs['foxnews'] = array( + 'name' => t('Fox News'), + 'sample_url' => 'http://video.foxnews.com/v/123456/the-title/', + 'callback' => 'video_filter_foxnews', + 'html5_callback' => 'video_filter_foxnews', + 'regexp' => '/video\.foxnews\.com\/v\/([0-9]+)\/([a-zA-Z0-9\-]+)/i', + 'ratio' => 466 / 263, + 'control_bar_height' => 0, + ); + $codecs['gametrailers'] = array( 'name' => t('Game Trailers'), 'sample_url' => 'http://www.gametrailers.com/video/some-title/12345', @@ -106,6 +144,15 @@ function video_filter_codec_info() { 'ratio' => 500 / 319, ); + $codecs['giphy'] = array( + 'name' => t('Giphy'), + 'sample_url' => 'http://giphy.com/gifs/disney-kids-peter-pan-[gif-id]', + 'callback' => 'video_filter_giphy', + 'html5_callback' => 'video_filter_giphy', + 'regexp' => '/giphy\.com\/gifs\/(([a-zA-Z0-9\-]+)\-|)([a-zA-Z0-9]+)/i', + 'ratio' => 16 / 9, + ); + $codecs['godtube'] = array( 'name' => t('GodTube'), 'sample_url' => 'http://www.godtube.com/watch/?v=123abc', @@ -123,6 +170,17 @@ function video_filter_codec_info() { 'ratio' => 400 / 326, ); + $codecs['instagram'] = array( + 'name' => t('Instagram'), + 'callback' => 'video_filter_instagram', + 'sample_url' => 'http://instagram.com/p/uN1qUeId', + 'regexp' => array( + '/instagram\.com\/p\/([a-z0-9\-_]+)/i', + '/instagr.am\/p\/([a-z0-9\-_]+)/i', + ), + 'ratio' => 612 / 710, + ); + $codecs['metacafe'] = array( 'name' => t('Meta Cafe'), 'sample_url' => 'http://www.metacafe.com/watch/1234567890/some_title/', @@ -132,6 +190,16 @@ function video_filter_codec_info() { 'control_bar_height' => 32, ); + $codecs['mailru'] = array( + 'name' => t('Mail.Ru'), + 'sample_url' => 'https://my.mail.ru/v/semenikhin_denis/video/_groupvideo/[video-id].html', + 'callback' => 'video_filter_mailru', + 'html5_callback' => 'video_filter_mailru', + 'regexp' => '/my\.mail\.ru\/v\/(.*)\/([0-9]+)\.html/i', + 'ratio' => 16 / 9, + 'control_bar_height' => 0, + ); + $codecs['myspace'] = array( 'name' => t('MySpace'), 'sample_url' => 'http://myspace.com/video/vid/1234567890', @@ -146,6 +214,17 @@ function video_filter_codec_info() { 'control_bar_height' => 40, ); + $codecs['myvideo'] = array( + 'name' => t('MyVideo'), + 'sample_url' => 'http://www.myvideo.de/filme/story-title-1234567890', + 'html5_callback' => 'video_filter_myvideo', + 'callback' => 'video_filter_myvideo', + 'regexp' => array( + '/myvideo\.de\/(.+)\-([0-9]+)/i', + ), + 'ratio' => 400 / 283, + ); + $codecs['picasa_slideshows'] = array( 'name' => t('Picasa Slideshows'), 'sample_url' => 'http://picasaweb.google.com/data/feed/base/user/USER_NAME/albumid/5568104935784209834?alt=rss&kind=photo&hl=en_US', @@ -162,6 +241,17 @@ function video_filter_codec_info() { 'ratio' => 800 / 600, ); + $codecs['rutube'] = array( + 'name' => t('Rutube'), + 'sample_url' => 'http://rutube.ru/video/c80617086143e80ee08f760a2e9cbf43/?pl_type=source&pl_id=8188', + 'html5_callback' => 'video_filter_rutube', + 'callback' => 'video_filter_rutube', + 'regexp' => array( + '/rutube\.ru\/(.*)/i', + ), + 'ratio' => 16 / 9, + ); + $codecs['slideshare'] = array( 'name' => t('Slideshare'), 'sample_url' => 'http://slideshare.net/1759622', @@ -190,6 +280,41 @@ function video_filter_codec_info() { 'ratio' => 16 / 9, ); + $codecs['ted'] = array( + 'name' => t('TED'), + 'sample_url' => 'https://www.ted.com/talks/[story-title]', + 'instructions' => t('Click in Embed and copy the "Link to this talk" link and paste here.'), + 'callback' => 'video_filter_ted', + 'html5_callback' => 'video_filter_ted', + 'regexp' => '/ted\.com\/talks\/lang\/([a-zA-Z]+)\/([a-zA-Z0-9\-_]+)(\.html)?/', + 'ratio' => 4 / 3, + ); + + $codecs['twitch'] = array( + 'name' => t('Twitch'), + 'sample_url' => 'http://www.twitch.tv/uN1qUe-I_d', + 'callback' => 'video_filter_twitch', + 'regexp' => '/twitch\.tv\/([a-z0-9\-_]+)/i', + 'ratio' => 16 / 9, + ); + + $codecs['ustream'] = array( + 'name' => t('Ustream'), + 'sample_url' => 'http://www.ustream.tv/recorded/111212121212', + 'html5_callback' => 'video_filter_ustream', + 'callback' => 'video_filter_ustream', + 'regexp' => '/ustream\.tv\/recorded\/([0-9]+)/i', + 'ratio' => 16 / 9, + ); + + $codecs['vbox'] = array( + 'name' => t('Vbox7'), + 'sample_url' => 'http://vbox7.com/play:b4a7291f3d', + 'callback' => 'video_filter_vbox', + 'regexp' => '/vbox7\.com\/play\:([a-z0-9]+)/i', + 'ratio' => 400 / 345, + ); + $codecs['vimeo'] = array( 'name' => t('Vimeo'), 'sample_url' => 'http://www.vimeo.com/123456', @@ -200,6 +325,24 @@ function video_filter_codec_info() { 'control_bar_height' => 0, ); + $codecs['vine'] = array( + 'name' => t('Vine'), + 'sample_url' => 'https://www.vine.co/v/uN1qUeId', + 'callback' => 'video_filter_vine', + 'regexp' => '/vine\.co\/v\/([0-9a-z]+)/i', + 'ratio' => 4 / 3, + ); + + $codecs['whatchado'] = array( + 'name' => t('whatchado'), + 'sample_url' => 'https://www.whatchado.com/de/some-title', + 'callback' => 'video_filter_whatchado_whatchado', + 'regexp' => array( + '/whatchado\.com\/[a-z]{2}\/([\w-_]+)/i', + ), + 'ratio' => 960 / 540, + ); + $codecs['wistia'] = array( 'name' => t('Wistia'), 'sample_url' => 'http://wistia.com/medias/9pj9n6ftlk', @@ -208,6 +351,19 @@ function video_filter_codec_info() { 'regexp' => '@https?://(.+\.)?(wistia\.(com|net)|wi\.st)/((m|medias|projects)|embed/(iframe|playlists))/([a-zA-Z0-9]+)@', ); + $codecs['youku'] = array( + 'name' => t('YouKu'), + 'sample_url' => 'http://v.youku.com/v_show/id_XNjgzNDM4MzIw.html', + 'callback' => 'video_filter_youku_html5', + 'html5_callback' => 'video_filter_youku_html5', + 'regexp' => array( + '/youku\.com\/v_show\/id_([a-z0-9\-_=]+)\.html/i', + '/youku\.com\/player\.php\/sid\/([a-z0-9\-_=]+)/i', + ), + 'ratio' => 16 / 9, + 'control_bar_height' => 50, + ); + $codecs['youtube'] = array( 'name' => t('YouTube'), 'sample_url' => 'http://www.youtube.com/watch?v=uN1qUeId', @@ -220,7 +376,7 @@ function video_filter_codec_info() { '/youtube\.com\/embed\/([a-z0-9\-_]+)/i', ), 'ratio' => 16 / 9, - 'control_bar_height' => 25, + 'control_bar_height' => 0, ); $codecs['youtube_playlist'] = array( @@ -231,7 +387,7 @@ function video_filter_codec_info() { '/youtube\.com\/playlist\?list=([a-z0-9\-_]+)/i', ), 'ratio' => 16 / 9, - 'control_bar_height' => 25, + 'control_bar_height' => 0, ); return $codecs; @@ -344,17 +500,51 @@ function video_filter_collegehumor($video) { return video_filter_flash($video); } +/** + * HTML5 callback for Coub codec. + * + * @see video_filter_codec_info() + */ +function video_filter_coub($video) { + $attributes = array( + 'autostart' => !empty($video['autoplay']) ? 'autoplay=true' : 'autoplay=false', + 'originalSize' => !empty($video['originalSize']) ? 'originalSize=true' : 'originalSize=false', + 'startWithHD' => !empty($video['startWithHD']) ? 'startWithHD=true' : 'startWithHD=false', + 'muted' => !empty($video['muted']) ? 'muted=true' : 'muted=false', + ); + $video['source'] = '//coub.com/embed/' . $video['codec']['matches'][1] . '?' . implode('&', $attributes); + + return video_filter_iframe($video); +} + /** * Callback for DailyMotion codec. * * @see video_filter_codec_info() */ function video_filter_dailymotion($video) { - $video['source'] = '//www.dailymotion.com/swf/' . $video['codec']['matches'][1]; + $attributes = array( + 'autoplay' => $video['autoplay'] ? 'autoplay=1' : 'autoplay=0', + ); + $video['source'] = '//www.dailymotion.com/swf/' . $video['codec']['matches'][1] . '?' . implode('&', $attributes); return video_filter_flash($video); } +/** + * HTML5 callback for DailyMotion codec. + * + * @see video_filter_codec_info() + */ +function video_filter_dailymotion_html5($video) { + $attributes = array( + 'autoplay' => $video['autoplay'] ? 'autoplay=1' : 'autoplay=0', + ); + $video['source'] = '//www.dailymotion.com/embed/video/' . $video['codec']['matches'][1] . '?' . implode('&', $attributes); + + return video_filter_iframe($video); +} + /** * Callback for Flickr Slideshows codec. * @@ -372,6 +562,50 @@ function video_filter_flickr_slideshows($video) { return video_filter_flash($video, $params); } +/** + * Callback for DemocracyNow Fullshow codec. + * + * @see video_filter_codec_info() + */ +function video_filter_democracynow_fullshow($video) { + $video['source'] = 'http://www.democracynow.org/embed/show/' . $video['codec']['matches'][0]; + // The above is pulling in the url part of the regex, so we need to do a + // search and replace to remove it. + $toomuch = array("http://www.democracynow.org/embed/show/democracynow.org/shows/"); + $justright = array("http://www.democracynow.org/embed/show/"); + $replaced = str_replace($toomuch, $justright, $video); + $video = $replaced; + + return video_filter_iframe($video); +} + +/** + * Callback for DemocracyNow story codec. + * + * @see video_filter_codec_info() + */ +function video_filter_democracynow_story($video) { + $video['source'] = 'http://www.democracynow.org/embed/story/' . $video['codec']['matches'][0]; + // The above is pulling in the url part of the regex, so we need to do a + // search and replace to remove it. + $toomuch = array("http://www.democracynow.org/embed/story/democracynow.org/"); + $justright = array("http://www.democracynow.org/embed/story/"); + $replaced = str_replace($toomuch, $justright, $video); + $video = $replaced; + + return video_filter_iframe($video); +} + +/** + * Callback for Ted.com codec. + * + * @see video_filter_codec_info() + */ +function video_filter_ted($video) { + $video['source'] = '//embed.ted.com/talks/' . $video['codec']['matches'][3] . '.html'; + return video_filter_iframe($video); +} + /** * Callback for Flickr Video codec. * @@ -385,6 +619,17 @@ function video_filter_flickr_video($video) { return video_filter_flash($video, $params); } +/** + * Callback for Fox News codec. + * + * @see video_filter_codec_info() + */ +function video_filter_foxnews($video) { + $video_id = $video['codec']['matches'][1]; + $html = ''; + return $html; +} + /** * Callback for Game Trailers codec. * @@ -413,6 +658,17 @@ function video_filter_gamevideos($video) { return video_filter_flash($video); } +/** + * Callback for Giphy codec. + * + * @see video_filter_codec_info() + */ +function video_filter_giphy($video) { + $video['source'] = '//giphy.com/embed/' . $video['codec']['matches'][3]; + + return video_filter_iframe($video); +} + /** * Callback for GodTube codec. * @@ -435,6 +691,44 @@ function video_filter_google($video) { return video_filter_flash($video); } +/** + * Callback for Instagram codec. + * + * @see video_filter_codec_info() + */ +function video_filter_instagram($video) { + $html = &drupal_static(__FUNCTION__); + $id = $video['codec']['matches'][1]; + if ($cache = cache_get('video_filter_instagram:' . $id)) { + $html = $cache->data; + } + else { + $endpoint = 'https://api.instagram.com/oembed'; + $options = array( + 'url' => 'http://instagr.am/p/' . $id, + ); + $data = video_filter_oembed_request($endpoint, $options); + if (!empty($data['html'])) { + $html = $data['html']; + } + cache_set('video_filter_instagram:' . $id, $html, 'cache'); + } + return $html; +} + +/** + * Callback for Mail.Ru codec. + * + * @see video_filter_codec_info() + */ +function video_filter_mailru($video) { + $attributes = array( + 'autoplay' => !empty($video['autoplay']) ? 'autoplay=' . (int) $video['autoplay'] : '', + ); + $video['source'] = 'https://videoapi.my.mail.ru/videos/embed/v/' . $video['codec']['matches'][1] . '/' . $video['codec']['matches'][2] . '.html?' . implode('&', $attributes); + return video_filter_iframe($video); +} + /** * Callback for Meta Cafe codec. * @@ -459,6 +753,16 @@ function video_filter_myspace($video) { return video_filter_flash($video, $params); } +/** + * Callback for MyVideo codec. + * + * @see video_filter_codec_info() + */ +function video_filter_myvideo($video) { + $video['source'] = 'http://www.myvideo.de/embedded/public/' . $video['codec']['matches'][2]; + return video_filter_iframe($video); +} + /** * Callback for Picasa Slideshows codec. * @@ -475,6 +779,32 @@ function video_filter_picasa_slideshows($video) { return video_filter_flash($video, $params); } +/** + * Callback for Rutube codec. + * + * @see video_filter_codec_info() + */ +function video_filter_rutube($video) { + $attributes = array( + 'skinColor' => (isset($video['skinColor']) && !empty($video['standardColor'])) ? 'skinColor=' . (string) $video['skinColor'] : '', + 'sTitle' => (isset($video['sTitle']) && $video['sTitle'] == 1) ? 'sTitle=true' : 'sTitle=false', + 'sAuthor' => (isset($video['sAuthor']) && $video['sAuthor'] == 1) ? 'sAuthor=true' : 'sAuthor=false', + 'bmstart' => (isset($video['bmstart']) && $video['bmstart'] > 1) ? 'bmstart=' . (int) $video['bmstart'] : 'bmstart=false', + ); + $endpoint = 'http://rutube.ru/api/oembed'; + $options = array( + 'url' => $video['source'], + 'format' => 'json', + ); + $data = video_filter_oembed_request($endpoint, $options); + if (!empty($data['html'])) { + if (preg_match('/src="([^"]+)"/', $data['html'], $match)) { + $video['source'] = $match[1] . '?' . implode('&', $attributes); + return video_filter_iframe($video); + } + } +} + /** * Callback for Slideshare codec. * @@ -514,6 +844,16 @@ function video_filter_streamhoster($video) { return video_filter_flash($video, $params); } +/** + * Callback for Twitch codec. + * + * @see video_filter_codec_info() + */ +function video_filter_twitch($video) { + $video['source'] = '//player.twitch.tv/?channel=' . $video['codec']['matches'][1] ; + return video_filter_iframe($video); +} + /** * Callback for Teachertube codec. * @@ -527,13 +867,51 @@ function video_filter_teachertube($video) { return video_filter_flash($video, $params); } +/** + * Callback for Ustream codec. + * + * @see video_filter_codec_info() + */ +function video_filter_ustream($video) { + $attributes = array( + 'html5ui' => 'html5ui', + 'autoplay' => isset($video['autoplay']) ? 'autoplay=' . (int) $video['autoplay'] : 'autoplay=0', + ); + $video['source'] = 'http://www.ustream.tv/embed/recorded/' . $video['codec']['matches'][1] . '?' . implode('&', $attributes); + return video_filter_iframe($video); +} + +/** + * Callback for VBox7 codec. + * + * @see video_filter_codec_info() + */ +function video_filter_vbox($video) { + $video['source'] = '//vbox7.com/emb/external.php?vid=' . $video['codec']['matches'][1]; + + return video_filter_flash($video); +} + /** * Callback for Vimeo codec. * * @see video_filter_codec_info() */ function video_filter_vimeo($video) { - $video['source'] = '//www.vimeo.com/moogaloop.swf?clip_id=' . $video['codec']['matches'][1] . '&server=www.vimeo.com&fullscreen=1&show_title=1&show_byline=1&show_portrait=0&color=&autoplay=' . $video['autoplay']; + $attributes = array( + 'autopause' => isset($video['autopause']) ? 'autopause=' . (int) $video['autopause'] : 'autopause=1', + 'autoplay' => isset($video['autoplay']) ? 'autoplay=' . (int) $video['autoplay'] : 'autoplay=0', + 'badge' => isset($video['badge']) ? 'badge=' . (int) $video['badge'] : 'badge=1', + 'byline' => isset($video['byline']) ? 'byline=' . (int) $video['byline'] : 'byline=1', + 'loop' => isset($video['loop']) ? 'loop=' . (int) $video['loop'] : 'loop=0', + 'portrait' => isset($video['portrait']) ? 'portrait=' . (int) $video['portrait'] : 'portrait=1', + 'title' => isset($video['title']) ? 'autopause=' . (int) $video['title'] : 'autopause=1', + 'fullscreen' => isset($video['fullscreen']) ? 'fullscreen=' . (int) $video['fullscreen'] : 'fullscreen=1', + ); + if (!empty($video['color'])) { + $attributes['color'] = (string) $video['color']; + } + $video['source'] = '//www.vimeo.com/moogaloop.swf?clip_id=' . $video['codec']['matches'][1] . '&server=www.vimeo.com&' . implode('&', $attributes); return video_filter_flash($video); } @@ -544,7 +922,43 @@ function video_filter_vimeo($video) { * @see video_filter_codec_info() */ function video_filter_vimeo_html5($video) { - $video['source'] = '//player.vimeo.com/video/' . $video['codec']['matches'][1] . ($video['autoplay'] ? '?autoplay=1' : ''); + $attributes = array( + 'autopause' => isset($video['autopause']) ? 'autopause=' . (int) $video['autopause'] : 'autopause=1', + 'autoplay' => isset($video['autoplay']) ? 'autoplay=' . (int) $video['autoplay'] : 'autoplay=0', + 'badge' => isset($video['badge']) ? 'badge=' . (int) $video['badge'] : 'badge=1', + 'byline' => isset($video['byline']) ? 'byline=' . (int) $video['byline'] : 'byline=1', + 'loop' => isset($video['loop']) ? 'loop=' . (int) $video['loop'] : 'loop=0', + 'portrait' => isset($video['portrait']) ? 'portrait=' . (int) $video['portrait'] : 'portrait=1', + 'title' => isset($video['title']) ? 'autopause=' . (int) $video['title'] : 'autopause=1', + 'fullscreen' => isset($video['fullscreen']) ? 'fullscreen=' . (int) $video['fullscreen'] : 'fullscreen=1', + ); + if (!empty($video['color'])) { + $attributes['color'] = (string) $video['color']; + } + $video['source'] = '//player.vimeo.com/video/' . $video['codec']['matches'][1] . '?' . implode('&', $attributes); + + return video_filter_iframe($video); +} + +/** + * Callback for Whatchadoo codec. + * + * @see video_filter_codec_info() + */ +function video_filter_whatchado($video) { + $video['source'] = '//www.whatchado.com/embed/player/' . $video['codec']['matches'][1]; + + return video_filter_iframe($video); +} + +/** + * HTML5 callback for YouKu codec. + * + * @see video_filter_codec_info() + */ +function video_filter_youku_html5($video) { + $attributes = array(); + $video['source'] = 'http://player.youku.com/embed/' . $video['codec']['matches'][1] . '?' . implode('&', $attributes); return video_filter_iframe($video); } @@ -556,18 +970,50 @@ function video_filter_vimeo_html5($video) { */ function video_filter_youtube($video) { $attributes = array( - 'rel' => $video['related'] ? 'rel=1' : 'rel=0', - 'autoplay' => $video['autoplay'] ? 'autoplay=1' : 'autoplay=0', + 'modestbranding' => !empty($video['modestbranding']) ? 'modestbranding=1' : 'modestbranding=0', + 'rel' => !empty($video['related']) ? 'rel=1' : 'rel=0', + 'autoplay' => !empty($video['autoplay']) ? 'autoplay=1' : 'autoplay=0', 'fs' => 'fs=1', + 'loop' => !empty($video['loop']) ? 'loop=1' : 'loop=0', + 'controls' => !empty($video['controls']) ? 'controls=1' : (!isset($video['controls']) ? 'controls=1' : 'controls=0'), + 'autohide' => !empty($video['autohide']) ? 'autohide=1' : 'autohide=0', + 'showinfo' => !empty($video['showinfo']) ? 'showinfo=1' : 'showinfo=0', + 'theme' => !empty($video['theme']) ? 'theme=' . $video['theme'] : 'theme=dark', + 'color' => !empty($video['color']) ? 'color=' . $video['color'] : 'color=red', + 'enablejsapi' => !empty($video['enablejsapi']) ? 'enablejsapi=' . (int) $video['enablejsapi'] : 'enablejsapi=0', ); - $video['source'] = '//www.youtube.com/v/' . $video['codec']['matches'][1] . '?' . implode('&', $attributes); + if (!empty($video['loop'])) { + $attributes['playlist'] = 'playlist=' . $video['codec']['matches'][1]; + } + + if (preg_match('/t=((\d+[m|s])?(\d+[s]?)?)/', $video['source'], $matches)) { + $attributes['start'] = 'start=' . (preg_replace("/[^0-9]/", "", $matches[2]) * 60 + (preg_replace("/[^0-9]/", "", $matches[3]))); + } + if (!empty($video['start'])) { + if (preg_match('/((\d+[m|s])?(\d+[s]?)?)/', $video['start'], $matches)) { + $attributes['start'] = 'start=' . (preg_replace("/[^0-9]/", "", $matches[2]) * 60 + (preg_replace("/[^0-9]/", "", $matches[3]))); + } + } + + $video['source'] = '//www.youtube.com/embed/' . $video['codec']['matches'][1] . '?' . implode('&', $attributes); $params['wmode'] = 'opaque'; return video_filter_flash($video, $params); } +/** + * Callback for Vine codec. + * + * @see video_filter_codec_info() + */ +function video_filter_vine($video) { + $video['source'] = '//vine.co/v/' . $video['codec']['matches'][1] . '/embed/simple'; + + return video_filter_iframe($video); +} + /** * HTML5 callback for YouTube codec. * @@ -575,11 +1021,33 @@ function video_filter_youtube($video) { */ function video_filter_youtube_html5($video) { $attributes = array( + 'modestbranding' => !empty($video['modestbranding']) ? 'modestbranding=1' : 'modestbranding=0', 'html5' => 'html5=1', 'rel' => $video['related'] ? 'rel=1' : 'rel=0', 'autoplay' => $video['autoplay'] ? 'autoplay=1' : 'autoplay=0', 'wmode' => 'wmode=opaque', + 'loop' => !empty($video['loop']) ? 'loop=1' : 'loop=0', + 'controls' => !empty($video['controls']) ? 'controls=1' : (!isset($video['controls']) ? 'controls=1' : 'controls=0'), + 'autohide' => !empty($video['autohide']) ? 'autohide=1' : 'autohide=0', + 'showinfo' => !empty($video['showinfo']) ? 'showinfo=1' : 'showinfo=0', + 'theme' => !empty($video['theme']) ? 'theme=' . $video['theme'] : 'theme=dark', + 'color' => !empty($video['color']) ? 'color=' . $video['color'] : 'color=red', + 'enablejsapi' => !empty($video['enablejsapi']) ? 'enablejsapi=' . (int) $video['enablejsapi'] : 'enablejsapi=0', ); + + if (!empty($video['loop'])) { + $attributes['playlist'] = 'playlist=' . $video['codec']['matches'][1]; + } + + if (preg_match('/t=((\d+[m|s])?(\d+[s]?)?)/', $video['source'], $matches)) { + $attributes['start'] = 'start=' . (preg_replace("/[^0-9]/", "", $matches[2]) * 60 + (preg_replace("/[^0-9]/", "", $matches[3]))); + } + if (!empty($video['start'])) { + if (preg_match('/((\d+[m|s])?(\d+[s]?)?)/', $video['start'], $matches)) { + $attributes['start'] = 'start=' . (preg_replace("/[^0-9]/", "", $matches[2]) * 60 + (preg_replace("/[^0-9]/", "", $matches[3]))); + } + } + $video['source'] = '//www.youtube.com/embed/' . $video['codec']['matches'][1] . '?' . implode('&', $attributes); return video_filter_iframe($video); diff --git a/sites/all/modules/contrib/editor/video_filter/video_filter.info b/sites/all/modules/contrib/editor/video_filter/video_filter.info index 68cef44f..d7da5a9b 100644 --- a/sites/all/modules/contrib/editor/video_filter/video_filter.info +++ b/sites/all/modules/contrib/editor/video_filter/video_filter.info @@ -5,9 +5,9 @@ package = Input filters stylesheets[all][] = video_filter.css -; Information added by Drupal.org packaging script on 2015-09-24 -version = "7.x-3.1+17-dev" +; Information added by Drupal.org packaging script on 2016-06-01 +version = "7.x-3.4" core = "7.x" project = "video_filter" -datestamp = "1443119944" +datestamp = "1464823440" diff --git a/sites/all/modules/contrib/editor/video_filter/video_filter.module b/sites/all/modules/contrib/editor/video_filter/video_filter.module index 5a05024a..b21ad7b0 100644 --- a/sites/all/modules/contrib/editor/video_filter/video_filter.module +++ b/sites/all/modules/contrib/editor/video_filter/video_filter.module @@ -24,6 +24,8 @@ function video_filter_filter_info() { 'video_filter_autoplay' => 1, 'video_filter_related' => 1, 'video_filter_html5' => 1, + 'video_filter_codecs' => _video_filter_map_codecs_name(video_filter_get_codec_info()), + 'video_filter_multiple_sources' => TRUE, ), 'tips callback' => '_video_filter_tips', // See http://drupal.org/node/1061244. @@ -33,7 +35,6 @@ function video_filter_filter_info() { } function _video_filter_settings($form, &$form_state, $filter, $format, $defaults, $filters) { - $settings['video_filter_width'] = array( '#type' => 'textfield', '#title' => t('Default width setting'), @@ -78,12 +79,40 @@ function _video_filter_settings($form, &$form_state, $filter, $format, $defaults ), ); + $settings['video_filter_multiple_sources'] = array( + '#type' => 'radios', + '#title' => t('Allow multiple sources'), + '#description' => t('Allow the use of multiple sources (used source is selected at random).'), + '#default_value' => isset($filter->settings['video_filter_multiple_sources']) ? $filter->settings['video_filter_multiple_sources'] : $defaults['video_filter_multiple_sources'], + '#options' => array( + 0 => t('No'), + 1 => t('Yes'), + ), + ); + + $settings['video_filter_codecs'] = array( + '#type' => 'checkboxes', + '#title' => t('Codecs'), + '#description' => t('Choose which codecs will be available.'), + '#default_value' => isset($filter->settings['video_filter_codecs']) ? $filter->settings['video_filter_codecs'] : $defaults['video_filter_codecs'], + '#options' => _video_filter_map_codecs_name(video_filter_get_codec_info()), + ); + return $settings; } +function _video_filter_map_codecs_name($codecs) { + $codecs_map = array(); + foreach ($codecs as $codec_cod => $codec) { + $codecs_map[$codec_cod] = $codec['name']; + } + + return $codecs_map; +} + function _video_filter_tips($filter, $format, $long = FALSE) { if ($long) { - $codecs = video_filter_get_codec_info(); + $codecs = video_filter_get_codec_enabled($filter->settings['video_filter_codecs']); $supported = array(); $instructions = array(); foreach ($codecs as $codec) { @@ -126,14 +155,14 @@ function _video_filter_process($text, $filter, $format, $langcode, $cache, $cach ); // Pick random out of multiple sources separated by comma (,). - if (strstr($video['source'], ',')) { + if ($filter->settings['video_filter_multiple_sources'] && strstr($video['source'], ',')) { $sources = explode(',', $video['source']); $random = array_rand($sources, 1); $video['source'] = $sources[$random]; } // Load all codecs. - $codecs = video_filter_get_codec_info(); + $codecs = video_filter_get_codec_enabled($filter->settings['video_filter_codecs']); // Find codec. foreach ($codecs as $codec_name => $codec) { @@ -171,17 +200,32 @@ function _video_filter_process($text, $filter, $format, $langcode, $cache, $cach $ratio = $tratio[1] / $tratio[2]; } elseif (isset($video['codec']['ratio'])) { - $ratio = $video['codec']['ratio']; + if (is_float($video['codec']['ratio']) || is_int($video['codec']['ratio'])) { + $ratio = $video['codec']['ratio']; + } + elseif (preg_match('/(\d+)\s*\/\s*(\d+)/', $video['codec']['ratio'], $cratio)) { + $ratio = $cratio[1] / $cratio[2]; + } } // Sets video width & height after any user input has been parsed. // First, check if user has set a width. if (isset($video['width']) && !isset($video['height'])) { - $video['height'] = $filter->settings['video_filter_height']; + if ($ratio) { + $video['height'] = ceil($video['width'] / $ratio); + } + else { + $video['height'] = $filter->settings['video_filter_height']; + } } // Else, if user has set height. elseif (isset($video['height']) && !isset($video['width'])) { - $video['width'] = $video['height'] * $ratio; + if ($ratio) { + $video['width'] = ceil($video['height'] * $ratio); + } + else { + $video['width'] = $filter->settings['video_filter_height']; + } } // Maybe both? elseif (isset($video['height']) && isset($video['width'])) { @@ -204,16 +248,7 @@ function _video_filter_process($text, $filter, $format, $langcode, $cache, $cach // Respect setting provided by codec otherwise. $control_bar_height = $video['codec']['control_bar_height']; } - - // Resize to fit within width and height repecting aspect ratio. - if ($ratio) { - $scale_factor = min(array( - ($video['height'] - $control_bar_height), - $video['width'] / $ratio, - )); - $video['height'] = round($scale_factor + $control_bar_height); - $video['width'] = round($scale_factor * $ratio); - } + $video['height'] += $control_bar_height; $video['autoplay'] = (bool) $video['autoplay']; $video['align'] = (isset($video['align']) && in_array($video['align'], array( @@ -262,6 +297,9 @@ function video_filter_iframe($video) { return theme('video_filter_iframe', array('video' => $video)); } +/** + * Get a list of all available video codecs. + */ function video_filter_get_codec_info() { static $codecs; if (!isset($codecs)) { @@ -271,6 +309,35 @@ function video_filter_get_codec_info() { return $codecs; } +/** + * + */ +function _video_filter_merge_format_codecs($filters_codecs) { + $codecs = array_pop($filters_codecs); + + foreach ($filters_codecs as $format_name => $format_codecs) { + foreach ($format_codecs as $codec_name => $codec_value) { + if (!empty($codec_value) && empty($codecs[$codec_name])) { + $codecs[$codec_name] = $codec_value; + } + } + } + + return $codecs; +} + +/** + * Get a list of enabled video codecs. + */ +function video_filter_get_codec_enabled($video_filter_codecs) { + $codecs = array_intersect_key( + video_filter_get_codec_info(), + array_filter($video_filter_codecs) + ); + + return $codecs; +} + /** * Function that outputs the element. * @@ -323,7 +390,7 @@ function theme_video_filter_iframe($variables) { $attributes = drupal_attributes($video['attributes']); } - $output = '
'; + $output = '
'; return $output; } @@ -431,9 +498,26 @@ function video_filter_dashboard_page($editor) { switch ($editor) { case 'wysiwyg_tinymce': - // Add JavaScript. - drupal_add_js(wysiwyg_get_path('tinymce') . '/jscripts/tiny_mce/tiny_mce_popup.js'); - drupal_add_js(drupal_get_path('module', 'video_filter') . '/editors/tinymce/video_filter.js'); + // Add JavaScript. First, we'll need to determine what version we're on. + $has_added_js = FALSE; + // Solves bug that causes tinymce.inc to not be loaded. + wysiwyg_load_includes('editors', 'editor', 'tinymce'); + + // Check for TinyMCE 4.x first. + if (function_exists('wysiwyg_tinymce_editor')) { + $loaded_editor = wysiwyg_tinymce_editor(); + $version = wysiwyg_tinymce_version($loaded_editor['tinymce']); + if (version_compare($version, '4', '>=')) { + drupal_add_js(drupal_get_path('module', 'video_filter') . '/editors/tinymce/video_filter-4.js'); + $has_added_js = TRUE; + } + } + + // Add JS for <= TinyMCE 3.x. + if (!$has_added_js) { + drupal_add_js(wysiwyg_get_path('tinymce') . '/jscripts/tiny_mce/tiny_mce_popup.js'); + drupal_add_js(drupal_get_path('module', 'video_filter') . '/editors/tinymce/video_filter.js'); + } break; case 'ckeditor': @@ -549,7 +633,7 @@ function _video_filter_instructions_form() { '#weight' => 97, ); - $text = '

' . t('Insert a 3rd party video from one of the following providers.') . '

'; + $text = '

' . t('Insert a 3rd party video from one of the following providers; this list may vary depending on the text format being used.') . '

'; $text .= _video_filter_instructions(); $form['instructions']['text'] = array( @@ -662,10 +746,23 @@ function _video_filter_add_settings($editor) { * Parses Codec into instructions for WYSIWYG popup. */ function _video_filter_instructions() { - $codecs = video_filter_get_codec_info(); + // Get all codecs the user has permission to use in at least one text format. + global $user; + $formats = filter_formats($user); + $filters_codecs = array(); + foreach ($formats as $format) { + $format_filters = filter_list_format($format->format); + if (isset($format_filters['video_filter'])) { + $filters_codecs[$format->name] = $format_filters['video_filter']->settings['video_filter_codecs']; + } + } + $video_filter_codecs = _video_filter_merge_format_codecs($filters_codecs); + + $codecs = video_filter_get_codec_enabled($video_filter_codecs); + $output = ''; return $output; diff --git a/sites/all/modules/contrib/editor/wysiwyg_filter/wysiwyg_filter.admin.inc b/sites/all/modules/contrib/editor/wysiwyg_filter/wysiwyg_filter.admin.inc index 38fb424d..92c29afb 100644 --- a/sites/all/modules/contrib/editor/wysiwyg_filter/wysiwyg_filter.admin.inc +++ b/sites/all/modules/contrib/editor/wysiwyg_filter/wysiwyg_filter.admin.inc @@ -22,7 +22,7 @@ function wysiwyg_filter_filter_wysiwyg_settings(&$form, &$form_state, $filter, $ global $base_url; drupal_add_css(drupal_get_path('module', 'wysiwyg_filter') . '/wysiwyg_filter.admin.css', array('preprocess' => FALSE)); // Load common functions. - module_load_include('inc', 'wysiwyg_filter'); + form_load_include($form_state, 'inc', 'wysiwyg_filter'); $settings = $filter->settings; $settings += $defaults; @@ -232,6 +232,10 @@ function _wysiwyg_filter_clear_messages() { */ function wysiwyg_filter_filter_wysiwyg_settings_validate($form, &$form_state) { $values =& $form_state['values']['filters']['wysiwyg']['settings']; + // Don't validate disabled filters. + if (empty($form_state['values']['filters']['wysiwyg']['status'])) { + return; + } // *** validate valid_elements *** // Check elements against hardcoded backlist. diff --git a/sites/all/modules/contrib/editor/wysiwyg_filter/wysiwyg_filter.inc b/sites/all/modules/contrib/editor/wysiwyg_filter/wysiwyg_filter.inc index 18f68c9c..c76308b3 100644 --- a/sites/all/modules/contrib/editor/wysiwyg_filter/wysiwyg_filter.inc +++ b/sites/all/modules/contrib/editor/wysiwyg_filter/wysiwyg_filter.inc @@ -61,7 +61,7 @@ EOT; * Get HTML elements blacklist. */ function wysiwyg_filter_get_elements_blacklist() { - return array( + $blacklist = array( 'applet', 'area', 'base', @@ -93,6 +93,9 @@ function wysiwyg_filter_get_elements_blacklist() { 'textarea', 'title', ); + + drupal_alter('wysiwyg_filter_elements_blacklist', $blacklist); + return $blacklist; } /** diff --git a/sites/all/modules/contrib/editor/wysiwyg_filter/wysiwyg_filter.info b/sites/all/modules/contrib/editor/wysiwyg_filter/wysiwyg_filter.info index 92fbfe46..891b6601 100644 --- a/sites/all/modules/contrib/editor/wysiwyg_filter/wysiwyg_filter.info +++ b/sites/all/modules/contrib/editor/wysiwyg_filter/wysiwyg_filter.info @@ -9,9 +9,9 @@ files[] = wysiwyg_filter.install files[] = wysiwyg_filter.module files[] = wysiwyg_filter.pages.inc -; Information added by drupal.org packaging script on 2013-10-26 -version = "7.x-1.6-rc2+0-dev" +; Information added by Drupal.org packaging script on 2016-02-04 +version = "7.x-1.6-rc3" core = "7.x" project = "wysiwyg_filter" -datestamp = "1382797388" +datestamp = "1454601540" diff --git a/sites/all/modules/contrib/editor/wysiwyg_filter/wysiwyg_filter.pages.inc b/sites/all/modules/contrib/editor/wysiwyg_filter/wysiwyg_filter.pages.inc index 40b5e3ef..ce2a02e8 100644 --- a/sites/all/modules/contrib/editor/wysiwyg_filter/wysiwyg_filter.pages.inc +++ b/sites/all/modules/contrib/editor/wysiwyg_filter/wysiwyg_filter.pages.inc @@ -22,7 +22,7 @@ * @return string * Filtered HTML text. */ -function wysiwyg_filter_filter_wysiwyg_process($text, $filter, $format, $langcode, $cache, $cache_id) { +function wysiwyg_filter_filter_wysiwyg_process($text, $filter, $format, $langcode = NULL, $cache = NULL, $cache_id = NULL) { // Only operate on valid UTF-8 strings. This is necessary to prevent cross // site scripting issues on Internet Explorer 6. if (!drupal_validate_utf8($text)) { @@ -429,6 +429,9 @@ function _wysiwyg_filter_xss_attributes($attr, $element = '') { // Element ID is valid, check_plain result. $attrinfo['value'] = check_plain($attrinfo['value']); } + elseif ($attrname == 'media') { + $attrinfo['value'] = check_plain($attrinfo['value']); + } else { // All attribute values are checked for bad protocols. This is the same // exact method used by Drupal's filter_xss(). @@ -450,6 +453,15 @@ function _wysiwyg_filter_xss_attributes($attr, $element = '') { } } + // Fix for IE8 broken handling of ` character. + if (strpos($attrinfo['value'], '`') !== FALSE) { + // IE8 quoting would already be triggered by the presence of any "' <> + if (!preg_match('/["\' <>]/', $attrinfo['value'])) { + // Trailing space triggers IE8 to correctly quote the value. + $attrinfo['value'] .= ' '; + } + } + // Build parsed attribute value. $parsed_attribute .= '=' . $attrinfo['delimiter'] . $attrinfo['value'] . $attrinfo['delimiter']; }