Added Youtube Embedder mod

This commit is contained in:
Travis Burtrum 2014-02-03 23:32:39 -05:00
parent 4dccad1423
commit a7287c3e60
5 changed files with 17 additions and 2 deletions

Binary file not shown.

View File

@ -1 +1 @@
1391538208
1391538735

View File

@ -1531,7 +1531,7 @@ function Post2()
preparsecode($_POST['message']);
// Let's see if there's still some content left without the tags.
if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), '<img>')) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false))
if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), '<object><embed><iframe><object><embed><iframe><img>')) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false))
$post_errors[] = 'no_message';
}
if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '')

View File

@ -1610,6 +1610,18 @@ function parse_bbc($message, $smileys = true, $cache_id = '', $parse_tags = arra
'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
'disabled_after' => ' ($1)',
),
array(
'tag' => 'youtube',
'type' => 'unparsed_content',
'content' => '<iframe style="border:0;" width="642" height="392" src="http://www.youtube.com/embed/$1" allowfullscreen></iframe>',
'validate' => create_function('&$tag, &$data, $disabled', '
if (isset($disabled[\'url\']))
$tag[\'content\'] = \'http://www.youtube.com/watch?v=$1\';
$pattern = \'~(?:http|https|)(?::\/\/|)(?:www.|)(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/ytscreeningroom\?v=|\/feeds\/api\/videos\/|\/user\S*[^\w\-\s]|\S*[^\w\-\s]))([\w\-]{11})[a-z0-9;:@?&%=+\/\$_.-]*~i\';
if (preg_match($pattern, $data, $matches))
$data = $matches[1];'),
'disabled_content' => 'http://www.youtube.com/watch?v=$1',
),
array(
'tag' => 'white',
'before' => '<span style="color: white;" class="bbc_color">',
@ -1853,11 +1865,14 @@ function parse_bbc($message, $smileys = true, $cache_id = '', $parse_tags = arra
$data = strtr($data, array('&#039;' => '\'', '&nbsp;' => $context['utf8'] ? "\xC2\xA0" : "\xA0", '&quot;' => '>">', '"' => '<"<', '&lt;' => '<lt<'));
// Only do this if the preg survives.
//First line in each array added by "Simple_Youtube_Video_Embed_BBC" mod to parse youtube videos automatically
if (is_string($result = preg_replace(array(
'~(?:http|https|)(?::\/\/|)(?:www.|)(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/ytscreeningroom\?v=|\/feeds\/api\/videos\/|\/user\S*[^\w\-\s]|\S*[^\w\-\s]))([\w\-]{11})[a-z0-9;:@?&%=+\/\$_.-]*~i',
'~(?<=[\s>\.(;\'"]|^)((?:http|https)://[\w\-_%@:|]+(?:\.[\w\-_%]+)*(?::\d+)?(?:/[\w\-_\~%\.@!,\?&;=#(){}+:\'\\\\]*)*[/\w\-_\~%@\?;=#}\\\\])~i',
'~(?<=[\s>\.(;\'"]|^)((?:ftp|ftps)://[\w\-_%@:|]+(?:\.[\w\-_%]+)*(?::\d+)?(?:/[\w\-_\~%\.@,\?&;=#(){}+:\'\\\\]*)*[/\w\-_\~%@\?;=#}\\\\])~i',
'~(?<=[\s>(\'<]|^)(www(?:\.[\w\-_]+)+(?::\d+)?(?:/[\w\-_\~%\.@!,\?&;=#(){}+:\'\\\\]*)*[/\w\-_\~%@\?;=#}\\\\])~i'
), array(
'[youtube]$1[/youtube]',
'[url]$1[/url]',
'[ftp]$1[/ftp]',
'[url=http://$1]$1[/url]'