\r
// If new video, get data from video providers\r
if(!$video_guid) {\r
- if (!$input['video_url']) {\r
+\r
+ $input['video_url'] = elgg_trigger_plugin_hook('videolist:preprocess', 'url', $input, $input['video_url']);\r
+\r
+ if (!$input['video_url']) {\r
register_error(elgg_echo('videolist:error:no_url'));\r
forward(REFERER);\r
}\r
\r
- // get_input (htmlawed) "fixes" URLs by breaking them\r
- $input['video_url'] = str_replace('&', '&', $input['video_url']);\r
-\r
$parsedPlatform = videolist_parse_url($input['video_url']);\r
\r
if (!$parsedPlatform) {\r
* @return array [parsed, platform]
*/
function videolist_parse_url($url) {
- $parsed = parse_url($url);
- if (empty($parsed['host']) && ! empty($parsed['path']) && $parsed['path'][0] !== '/') {
- // user probably forgot scheme
- $url = 'http://' . $url;
- }
- $params['url'] = $url;
+ $params = array(
+ 'url' => $url,
+ );
$platforms = videolist_get_default_platforms();
$platforms = elgg_trigger_plugin_hook('videolist:prepare', 'platforms', $params, $platforms);
foreach ($platforms as $list) {
// register for embed
elgg_register_plugin_hook_handler('embed_get_sections', 'all', 'videolist_embed_get_sections');
elgg_register_plugin_hook_handler('embed_get_items', 'videolist', 'videolist_embed_get_items');
+
+ // handle URLs without scheme
+ elgg_register_plugin_hook_handler('videolist:preprocess', 'url', 'videolist_preprocess_url');
// Register actions
$actions_path = elgg_get_plugins_path() . "videolist/actions/videolist";
}
}
+/**
+ * Prepend HTTP scheme if missing
+ * @param string $hook
+ * @param string $type
+ * @param string $returnvalue
+ * @param array $params
+ * @return string
+ */
+function videolist_preprocess_url($hook, $type, $returnvalue, $params) {
+ // undo get_input (htmlawed's) HTML-encoding
+ $returnvalue = str_replace('&', '&', $returnvalue);
+
+ $parsed = parse_url($returnvalue);
+ if (empty($parsed['host']) && ! empty($parsed['path']) && $parsed['path'][0] !== '/') {
+ // user probably forgot scheme
+ $returnvalue = 'http://' . $returnvalue;
+ }
+ return $returnvalue;
+}
+
/**
* Process upgrades for the videolist plugin
*/