function embed_extender_parser($input, $view, $context) { $allowed_contexts = array('blog', 'messageboard', 'widgets', 'pages', 'bookmarks', 'file', 'event_calendar', 'photos', 'polls'); if (($view == 'annotation/generic_comment' || $view == 'annotation/default') && !in_array($context, $allowed_contexts)) { return $input; } if ($view == 'annotation/default' && elgg_get_plugin_setting('messageboard_show', 'embed_extender') == 'no') { return $input; } if ($context == 'widgets' || $context == 'profile') { $width = elgg_get_plugin_setting('widget_width', 'embed_extender'); if (!isset($width) || !is_numeric($width) || $width < 0) { $width = 240; //Size for widgets and messageboard } } else { $width = elgg_get_plugin_setting('width', 'embed_extender'); if (!isset($width) || !is_numeric($width) || $width < 0) { $width = 400; //Size for content } } $patterns = array('#(((http://)?)|(^./))(((www.)?)|(^./))youtube\\.com/watch[?]v=([^\\[\\]()<.,\\s\\n\\t\\r]+)#i', '#(((http://)?)|(^./))(((www.)?)|(^./))youtu\\.be/([^\\[\\]()<.,\\s\\n\\t\\r]+)#i', '/(http:\\/\\/)(www\\.)?(vimeo\\.com\\/groups)(.*)(\\/videos\\/)([0-9]*)/', '/(http:\\/\\/)(www\\.)?(metacafe\\.com\\/watch\\/)([0-9a-zA-Z_-]*)(\\/[0-9a-zA-Z_-]*)(\\/)/', '/(http:\\/\\/)(www\\.)?(vimeo.com\\/)([0-9]*)/'); $custom_provider = elgg_get_plugin_setting('custom_provider', 'embed_extender'); if ($custom_provider == 'yes') { $customPatterns = return_custom_patterns(); } //Parses only hyperlinks $regexp = "<a\\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\\/a>"; //Replace video providers with embebed content if (preg_match_all("/{$regexp}/siU", $input, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { if (empty($match[3])) { continue; } foreach ($patterns as $pattern) { if (preg_match($pattern, $match[2]) > 0) { $input = str_replace($match[0], videoembed_create_embed_object($match[2], uniqid('embed_'), $width, $match[0]), $input); } } if ($custom_provider == 'yes') { foreach ($customPatterns as $pattern) { if (preg_match($pattern, $match[2]) > 0) { $input = str_replace($match[0], custom_videoembed_create_embed_object($match[2], uniqid('embed_'), $width, $match[0]), $input); } } } } } return $input; }
/** * Process the Elgg views for a matching video URL */ function videos_view_filter($hook, $entity_type, $returnvalue, $params) { elgg_load_library('elgg:videos:embed'); $patterns = array('#(((https?://)?)|(^./))(((www.)?)|(^./))youtube\\.com/watch[?]v=([^\\[\\]()<.,\\s\\n\\t\\r]+)#i', '#(((https?://)?)|(^./))(((www.)?)|(^./))youtu\\.be/([^\\[\\]()<.,\\s\\n\\t\\r]+)#i', '/(https?:\\/\\/)(www\\.)?(vimeo\\.com\\/groups)(.*)(\\/videos\\/)([0-9]*)/', '/(https?:\\/\\/)(www\\.)?(vimeo.com\\/)([0-9]*)/', '/(https?:\\/\\/)(www\\.)?(metacafe\\.com\\/watch\\/)([0-9a-zA-Z_-]*)(\\/[0-9a-zA-Z_-]*)(\\/)/', '/(https?:\\/\\/www\\.dailymotion\\.com\\/.*\\/)([0-9a-z]*)/'); $regex = "/<a[\\s]+[^>]*?href[\\s]?=[\\s\"\\']+" . "(.*?)[\"\\']+.*?>" . "([^<]+|.*?)?<\\/a>/"; if (preg_match_all($regex, $returnvalue, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { foreach ($patterns as $pattern) { if (preg_match($pattern, $match[2]) > 0) { $returnvalue = str_replace($match[0], videoembed_create_embed_object($match[2], uniqid('videos_embed_'), 350), $returnvalue); } } } } return $returnvalue; }
<div class="video elgg-content mts"> <?php echo $description; ?> <div style="margin-left:100px;"> <?php echo videoembed_create_embed_object($video_url, $video->getGUID(), 500); ?> </div> </div> <?php } elseif (elgg_in_context('gallery')) { echo <<<HTML <div class="videos-gallery-item"> \t<h3>{$video->title}</h3> \t<p class='subtitle'>{$owner_link} {$date}</p> </div> HTML; } else { // brief view $excerpt = elgg_get_excerpt($video->description); if ($excerpt) { $excerpt = "{$excerpt}"; } $video_icon = videoembed_create_embed_object($video_url, $video->getGUID(), 150); $content = "{$excerpt}"; $params = array('entity' => $video, 'metadata' => $metadata, 'subtitle' => $subtitle, 'tags' => $tags, 'content' => $content); $params = $params + $vars; $body = elgg_view('object/elements/summary', $params); echo elgg_view_image_block($owner_icon, $body); }
$group_string = ''; $container = $object->getContainerEntity(); if ($container instanceof ElggGroup) { $params = array( 'href' => $container->getURL(), 'text' => $container->name, ); $group_link = elgg_view('output/url', $params); $group_string = elgg_echo('river:ingroup', array($group_link)); } $link = elgg_echo('videos:river:created', array($link)); echo " $link $group_string"; if ($excerpt) { echo '<div class="elgg-river-content">'; echo "<div style='width: 160px;float:left; '>"; echo videoembed_create_embed_object($video_url, $guid,300); echo "</div>"; echo "<div style='margin:-100px 0 0 200px;float:left;width:500px;'>"; echo $excerpt; echo '</div>'; echo '</div>'; } */ $object = $vars['item']->getObjectEntity(); $excerpt = elgg_get_excerpt($object->description); echo elgg_view('river/item', array('item' => $vars['item'], 'message' => $excerpt, 'attachments' => videoembed_create_embed_object($video_url, $guid, 300)));
echo '<span itemprop="description">' . $description . '</span>'; ?> </div> </div> <?php } elseif (elgg_in_context('gallery')) { echo <<<HTML \t<div class="videos-gallery-item"> \t<h3>{$video->title}</h3> \t<p class='subtitle'>{$owner_link} {$date}</p> </div> HTML; } else { // brief view $excerpt = elgg_get_excerpt($video->description); if ($excerpt) { $excerpt = "{$excerpt}"; } $video_icon = videoembed_create_embed_object($video_url, $video->guid, 450); $content = "{$excerpt}"; $params = array('entity' => $video, 'metadata' => $metadata, 'subtitle' => $subtitle, 'tags' => $tags, 'content' => $content); $params = $params + $vars; $list_body = elgg_view('object/elements/summary', $params); if ($mobile == true || elgg_get_context() == widgets) { $video_icon = videoembed_create_embed_object($video_url, $video->guid, 280); echo elgg_view_image_block($video_icon, ""); echo elgg_view_image_block($list_body, ""); } else { echo elgg_view_image_block($video_icon, $list_body); } }