aboutsummaryrefslogtreecommitdiff
path: root/actions/videolist/edit.php
diff options
context:
space:
mode:
authorSem <sembrestels@riseup.net>2012-04-17 23:54:30 -0700
committerSem <sembrestels@riseup.net>2012-04-17 23:54:30 -0700
commita613b944015fd82f97a15392c0de0e7df104706d (patch)
tree5022ba0160427bec07cf9fdf337ef8161e4071b9 /actions/videolist/edit.php
parentf1a0a4d5aa28753620552df9d5e88bd983d0aca4 (diff)
parent4af120de2bd0fe2046795346a40102f00fbe5479 (diff)
downloadelgg-a613b944015fd82f97a15392c0de0e7df104706d.tar.gz
elgg-a613b944015fd82f97a15392c0de0e7df104706d.tar.bz2
Merge pull request #1 from mrclay/master
Partial rewrite
Diffstat (limited to 'actions/videolist/edit.php')
-rw-r--r--actions/videolist/edit.php42
1 files changed, 26 insertions, 16 deletions
diff --git a/actions/videolist/edit.php b/actions/videolist/edit.php
index be566de7e..a5e6ea453 100644
--- a/actions/videolist/edit.php
+++ b/actions/videolist/edit.php
@@ -8,7 +8,8 @@
$variables = elgg_get_config('videolist');
$input = array();
foreach ($variables as $name => $type) {
- $input[$name] = get_input($name);
+ $filter_input = ($name !== 'video_url');
+ $input[$name] = get_input($name, null, $filter_input);
if ($name == 'title') {
$input[$name] = strip_tags($input[$name]);
}
@@ -27,21 +28,27 @@ elgg_load_library('elgg:videolist');
// If new video, get data from video providers
if(!$video_guid) {
- if (!$input['video_url']) {
+
+ $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);
}
- $parsed_url = videolist_parseurl($input['video_url']);
+ $parsedPlatform = videolist_parse_url($input['video_url']);
- if(!$parsed_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(videolist_get_data($parsed_url), $input);
+ $input = array_merge($parsed, $platform->getData($parsed), $input);
+ $input['videotype'] = $platform->getType();
} else {
unset($input['video_url']);
@@ -73,16 +80,19 @@ if ($video->save()) {
elgg_clear_sticky_form('videolist');
// Let's save the thumbnail in the data folder
- $thumbnail = file_get_contents($video->thumbnail);
- if ($thumbnail) {
- $prefix = "videolist/" . $video->guid;
- $filehandler = new ElggFile();
- $filehandler->owner_guid = $video->owner_guid;
- $filehandler->setFilename($prefix . ".jpg");
- $filehandler->open("write");
- $filehandler->write($thumbnail);
- $filehandler->close();
- }
+ $thumb_url = $video->thumbnail;
+ if ($thumb_url) {
+ $thumbnail = file_get_contents($thumb_url);
+ if ($thumbnail) {
+ $prefix = "videolist/" . $video->guid;
+ $filehandler = new ElggFile();
+ $filehandler->owner_guid = $video->owner_guid;
+ $filehandler->setFilename($prefix . ".jpg");
+ $filehandler->open("write");
+ $filehandler->write($thumbnail);
+ $filehandler->close();
+ }
+ }
system_message(elgg_echo('videolist:saved'));