if ($type == 'tags') { $input[$name] = string_to_tag_array($input[$name]); } } // Get guids $video_guid = (int) get_input('video_guid'); $container_guid = (int) get_input('container_guid'); elgg_make_sticky_form('videolist'); elgg_load_library('elgg:videolist'); if (!$video_guid) { $input['video_url'] = elgg_trigger_plugin_hook('videolist:preprocess', 'url', $input, $input['video_url']); if (!$input['video_url']) { register_error(elgg_echo('videolist:error:no_url')); forward(REFERER); } $attributesPlatform = videolist_parse_url($input['video_url']); if (!$attributesPlatform) { register_error(elgg_echo('videolist:error:invalid_url')); forward(REFERER); } list($attributes, $platform) = $attributesPlatform; /* @var Videolist_PlatformInterface $platform */ $attributes = array_merge($attributes, $platform->getData($attributes)); $input = array_merge($attributes, $input); } else { unset($input['video_url']); } if ($video_guid) { $video = get_entity($video_guid); if (!$video || !$video->canEdit()) { register_error(elgg_echo('videolist:error:no_save'));
<?php elgg_load_library('elgg:videolist'); $url = get_input('url'); $url = elgg_trigger_plugin_hook('videolist:preprocess', 'url', array(), $url); if (!$url) { $result = array('error' => TRUE, 'msg' => elgg_echo('videolist:error:no_url')); } else { $parsedPlatform = videolist_parse_url($url); if (!$parsedPlatform) { $result = array('error' => TRUE, 'msg' => elgg_echo('videolist:error:invalid_url')); } else { list($parsed, $platform) = $parsedPlatform; $result = array('error' => FALSE, 'data' => $platform->getData($parsed), 'videotype' => $platform->getType()); } } echo json_encode($result); exit;
<?php elgg_load_library('elgg:videolist'); $url = get_input('url', '', false); $url = elgg_trigger_plugin_hook('videolist:preprocess', 'url', array(), $url); if (!$url) { $result = array('error' => true, 'msg' => elgg_echo('videolist:error:no_url')); } else { $attributesPlatform = videolist_parse_url($url); if (!$attributesPlatform) { $result = array('error' => true, 'msg' => elgg_echo('videolist:error:invalid_url')); } else { list($attributes, $platform) = $attributesPlatform; /* @var Videolist_PlatformInterface $platform */ $platform_data = $platform->getData($attributes); $result = array('error' => false, 'data' => array('title' => $platform_data['title'], 'description' => $platform_data['description'])); } } echo json_encode($result); exit;
$input[$name] = string_to_tag_array($input[$name]); } } // Get guids $video_guid = (int) get_input('video_guid'); $container_guid = (int) get_input('container_guid'); elgg_make_sticky_form('videolist'); elgg_load_library('elgg:videolist'); // If new video, get data from video providers if (!$video_guid) { $input['video_url'] = elgg_trigger_plugin_hook('videolist:preprocess', 'url', $input, $input['video_url']); if (!$input['video_url']) { register_error(elgg_echo('videolist:error:no_url')); forward(REFERER); } $parsedPlatform = videolist_parse_url($input['video_url']); if (!$parsedPlatform) { register_error(elgg_echo('videolist:error:invalid_url')); forward(REFERER); } list($parsed, $platform) = $parsedPlatform; /* @var Videolist_PlatformInterface $platform */ unset($input['title']); unset($input['description']); $input = array_merge($parsed, $platform->getData($parsed), $input); $input['videotype'] = $platform->getType(); } else { unset($input['video_url']); } if ($video_guid) { $video = get_entity($video_guid);
function shoutout_handle_video($shoutout, $video_url) { // optionally support video attachments $shoutout_video_add = elgg_get_plugin_setting('video_add', 'shoutout'); if ($shoutout_video_add == 'yes') { if (!$video_url) { // remove video url and return $shoutout->video_url = ''; return TRUE; } elgg_load_library('elgg:shoutout:video'); $video_url = elgg_trigger_plugin_hook('videolist:preprocess', 'url', NULL, $video_url); $parsedPlatform = videolist_parse_url($video_url); if (!$parsedPlatform) { // TODO: do something appropriate here //register_error(elgg_echo('shoutout:video:error:invalid_url')); return FALSE; } list($parsed, $platform) = $parsedPlatform; $input = array_merge($parsed, $platform->getData($parsed)); $input['videotype'] = $platform->getType(); // add all video metadata except title and description to shoutout $shoutout->video_url = $video_url; unset($input['title']); unset($input['description']); foreach ($input as $k => $v) { $shoutout->{$k} = $v; } } return TRUE; }