From fc7921d05953d3de3130f9d49b7d73ec4c466b34 Mon Sep 17 00:00:00 2001 From: Sem Date: Thu, 3 Nov 2011 22:18:13 +0100 Subject: Upgraded "add video" page. --- views/default/forms/add.php | 163 ------------- views/default/forms/browsetube.php | 251 --------------------- views/default/forms/edit.php | 43 ---- views/default/forms/labels/googlevideos.php | 27 --- views/default/forms/labels/metacafe.php | 27 --- views/default/forms/labels/vimeo.php | 27 --- views/default/forms/labels/youtube.php | 27 --- views/default/forms/videolist/add.php | 163 +++++++++++++ views/default/forms/videolist/browsetube.php | 251 +++++++++++++++++++++ views/default/forms/videolist/edit.php | 43 ++++ .../forms/videolist/labels/googlevideos.php | 27 +++ views/default/forms/videolist/labels/metacafe.php | 27 +++ views/default/forms/videolist/labels/vimeo.php | 27 +++ views/default/forms/videolist/labels/youtube.php | 27 +++ 14 files changed, 565 insertions(+), 565 deletions(-) delete mode 100644 views/default/forms/add.php delete mode 100644 views/default/forms/browsetube.php delete mode 100644 views/default/forms/edit.php delete mode 100644 views/default/forms/labels/googlevideos.php delete mode 100644 views/default/forms/labels/metacafe.php delete mode 100644 views/default/forms/labels/vimeo.php delete mode 100644 views/default/forms/labels/youtube.php create mode 100644 views/default/forms/videolist/add.php create mode 100644 views/default/forms/videolist/browsetube.php create mode 100644 views/default/forms/videolist/edit.php create mode 100644 views/default/forms/videolist/labels/googlevideos.php create mode 100644 views/default/forms/videolist/labels/metacafe.php create mode 100644 views/default/forms/videolist/labels/vimeo.php create mode 100644 views/default/forms/videolist/labels/youtube.php (limited to 'views') diff --git a/views/default/forms/add.php b/views/default/forms/add.php deleted file mode 100644 index 2ee5d9c2e..000000000 --- a/views/default/forms/add.php +++ /dev/null @@ -1,163 +0,0 @@ - - * @copyright Prateek Choudhary - */ -// Make sure we're logged in (send us to the front page if not) -gatekeeper(); -$page_owner = page_owner_entity(); -$error = array( - 'no-video' => 1 - ); -$error_msg = array( - 'no-video' => "Please enter a valid video url" - ); - -$container_guid = get_input("container_guid"); -set_page_owner($container_guid); - -$confirm_action = get_input('video_action'); -$guid = get_input('guid'); -if(page_owner_entity() instanceof ElggGroup){ - //if in a group, set the access level to default to the group - $access_id = page_owner_entity()->group_acl; -}else{ - $access_id = get_default_access(get_loggedin_user()); -} -//if it is a group, pull out the group access view -if(page_owner_entity() instanceof ElggGroup){ - $options = group_access_options(page_owner_entity()); -}else{ - $options = ''; -} -$title_videourl = get_input('title_videourl'); -$Pagecontainer = get_input('page'); -$get_addvideourl = get_input('add_videourl'); -$timestamp = time(); -$token = generate_action_token(time()); -if (!empty($get_addvideourl) && ($Pagecontainer == "youtube")) { - $title_add_videourl = "http://www.youtube.com/watch?v=".$get_addvideourl; -} else if(!empty($get_addvideourl) && ($Pagecontainer == "metacafe")) { - $title_add_videourl = "http://www.metacafe.com/api/item/".$get_addvideourl; -} else if(!empty($get_addvideourl) && ($Pagecontainer == "vimeo")) { - $title_add_videourl = "http://vimeo.com/".$get_addvideourl; -} else { - $title_add_videourl = ""; -} - -$tags = get_input('videolisttags'); - -function video_youtube_parse_url($url) { - if (!preg_match('/(http:\/\/)([a-zA-Z]{2,3}\.)(youtube\.com\/)(.*)/', $url, $matches)) { - return false; - } - - $domain = $matches[2] . $matches[3]; - $path = $matches[4]; - - if (!preg_match('/^(watch\?v=)([a-zA-Z0-9_-]*)(&.*)?$/',$path, $matches)) { - return false; - } - - $hash = $matches[2]; - return $domain . 'v/' . $hash; -} - -function video_vimeo_parse_url($url) { - if (!preg_match('/(http:\/\/)([a-zA-Z]{2,3}\.)(vimeo\.com\/)(.*)/', $url, $matches)) { - return false; - } - - $domain = $matches[2] . $matches[3]; - $path = $matches[4]; - - $hash = $matches[2]; - - return $domain . '/' . $hash; -} - -function video_metacafe_parse_url($url) { - if (!preg_match('/(http:\/\/)([a-zA-Z]{2,3}\.)(metacafe\.com\/)(.*)/', $url, $matches)) { - return false; - } - - $domain = $matches[2] . $matches[3]; - $path = $matches[4]; - - $hash = $matches[2]; - - return $domain . '/' . $hash; -} - -if(isset($confirm_action) && ($confirm_action == 'add_video')) { - if(isset($title_videourl) && ($title_videourl != '')) { - if($Pagecontainer != "youtube" || $Pagecontainer != "vimeo" || $Pagecontainer != "metacafe"){ - if(preg_match("/youtube/i", $title_videourl)) { - $Pagecontainer = "youtube"; - } - - if(preg_match("/vimeo/i", $title_videourl)) { - $Pagecontainer = "vimeo"; - } - - if(preg_match("/metacafe/i", $title_videourl)) { - $Pagecontainer = "metacafe"; - } - } - if($Pagecontainer == "youtube") { - $is_valid_video = video_youtube_parse_url($title_videourl); - } else if($Pagecontainer == "vimeo") { - $is_valid_video = video_vimeo_parse_url($title_videourl); - $is_valid_video = $get_addvideourl; - } else if($Pagecontainer == "metacafe"){ - $is_valid_video = video_metacafe_parse_url($title_videourl); - $is_valid_video = $get_addvideourl; - } - - if($is_valid_video) { - $error['no-video'] = 1; - $_SESSION['candidate_profile_video'] = $is_valid_video; - $_SESSION['candidate_profile_video_access_id'] = $access_id; - $_SESSION['videolisttags'] = $tags; - $_SESSION['Pagecontainer'] = $Pagecontainer; - $_SESSION['container_guid'] = $container_guid; - $url = "action/videolist/add?__elgg_ts={$timestamp}&__elgg_token={$token}"; - forward($url); - } - else - $error['no-video'] = 0; - } - else { - $error['no-video'] = 0; - } -} - -$body = '
'; -$body .= elgg_view('input/hidden',array('internalname'=>'video_action', 'value'=>'add_video')); -$body .= elgg_view('input/hidden',array('internalname'=>'guid', 'value'=>$vars['guid'])); - - -$body .= '

'.$error_msg['no-video'].'
'; -} -$body .= '

'; - -$body .= '

'; - -$body .= '

'; -$body .= elgg_view('input/submit', array('internalname'=>'submit','value'=>elgg_echo('videolist:submit'))); -$body .= '
'; - -print $body; diff --git a/views/default/forms/browsetube.php b/views/default/forms/browsetube.php deleted file mode 100644 index bbe2b8935..000000000 --- a/views/default/forms/browsetube.php +++ /dev/null @@ -1,251 +0,0 @@ - - * @copyright Prateek Choudhary - */ - -$getcontainer_guid = get_input("container"); -$container_guid = explode(":", $getcontainer_guid); -if($container_guid[0] == "group"){ - $container = $container_guid[1]; -} else{ - $container = $getcontainer_guid; -} -$error = array( - 'no-search' => 1 - ); -$error_msg = array( - 'no-search' => "Please enter a valid search term" - ); -$browseCat = get_input('q'); -if(empty($browseCat) || !isset($browseCat)) { - $browseCat = "youtube"; -} - -$confirm_action = get_input('video_action'); - -if(isset($confirm_action) && ($confirm_action == 'search_video')) { - if(isset($title_search) && ($title_search != '')) { - $error['no-search'] = 0; - } else { - $error['no-search'] = 1; - } -} - -//Load youtube menu -$body .= "
"; -$body .= ""; -$body .= "
"; - -$body .= '
'; -$body .= elgg_view('input/hidden',array('internalname'=>'video_action', 'value'=>'search_video')); -$body .= elgg_view('input/hidden',array('internalname'=>'guid', 'value'=>$vars['guid'])); - -switch($browseCat) { - case "youtube" : - $body .= elgg_view('forms/labels/youtube'); - break; - case "metacafe" : - $body .= elgg_view('forms/labels/metacafe'); - break; - case "vimeo" : - $body .= elgg_view('forms/labels/vimeo'); - break; - case "googlevideos" : - $body .= elgg_view('forms/labels/googlevideos'); - break; - default : - $body .= elgg_view('forms/labels/youtube'); - break; -} -$body .= elgg_view('input/hidden',array('internalname'=>'page', 'value'=>$browseCat)); -$body .= '
'; - -$body .= '
'; -$body .= '
'; - -print $body; - - -?> - - diff --git a/views/default/forms/edit.php b/views/default/forms/edit.php deleted file mode 100644 index 7d7901bcd..000000000 --- a/views/default/forms/edit.php +++ /dev/null @@ -1,43 +0,0 @@ - Edit view -*/ -// Make sure we're logged in (send us to the front page if not) -gatekeeper(); -$page_owner = page_owner_entity(); -$container_guid = $vars['entity']->container_guid; -$owner = get_entity($container_guid); -if($owner instanceof ElggGroup){ - $options = group_access_options($owner); -}else{ - $options = ''; -} -?> - -
- -

- -

- -

- -

- "; - - if (isset($vars['entity'])) { - echo "getGUID()}\" />"; - } - echo elgg_view('input/securitytoken'); - ?> - " /> -

- -
\ No newline at end of file diff --git a/views/default/forms/labels/googlevideos.php b/views/default/forms/labels/googlevideos.php deleted file mode 100644 index 9ce2d607c..000000000 --- a/views/default/forms/labels/googlevideos.php +++ /dev/null @@ -1,27 +0,0 @@ - - * @copyright Prateek Choudhary - */ - -$body = '

'; -$body .= "
"; -$body .= "
"; -$body .= ""; -$body .= "
"; -$body .= "
"; -$body .= ""; -if($error['no-search'] == 0) { - $body .= '
'.$error_msg['no-search'].'
'; -} -$body .= "
"; -$body .= elgg_view('input/submit', array('internalname' => 'submit', 'value' => elgg_echo('videolist:searchTubeVideos:vimeo'))); -$body .= "
"; -$body .= '
Loading...
'; -print $body; \ No newline at end of file diff --git a/views/default/forms/labels/metacafe.php b/views/default/forms/labels/metacafe.php deleted file mode 100644 index 0642153f4..000000000 --- a/views/default/forms/labels/metacafe.php +++ /dev/null @@ -1,27 +0,0 @@ - - * @copyright Prateek Choudhary - */ - -$body = '

'; -$body .= "
"; -$body .= "
"; -$body .= ""; -$body .= "
"; -$body .= "
"; -$body .= ""; -if($error['no-search'] == 0) { - $body .= '
'.$error_msg['no-search'].'
'; -} -$body .= "
"; -$body .= elgg_view('input/submit', array('internalname' => 'submit', 'value' => elgg_echo('videolist:searchTubeVideos:metacafe'))); -$body .= "
"; - -print $body; \ No newline at end of file diff --git a/views/default/forms/labels/vimeo.php b/views/default/forms/labels/vimeo.php deleted file mode 100644 index 24a49a1ee..000000000 --- a/views/default/forms/labels/vimeo.php +++ /dev/null @@ -1,27 +0,0 @@ - - * @copyright Prateek Choudhary - */ - -$body = '

'; -$body .= "
"; -$body .= "
"; -$body .= ""; -$body .= "
"; -$body .= "
"; -$body .= ""; -if ($error['no-search'] == 0) { - $body .= '
'.$error_msg['no-search'].'
'; -} -$body .= "
"; -$body .= elgg_view('input/submit', array('internalname' => 'submit', 'value' => elgg_echo('videolist:searchTubeVideos:vimeo'))); -$body .= "
"; - -print $body; \ No newline at end of file diff --git a/views/default/forms/labels/youtube.php b/views/default/forms/labels/youtube.php deleted file mode 100644 index 4c824f6f3..000000000 --- a/views/default/forms/labels/youtube.php +++ /dev/null @@ -1,27 +0,0 @@ - - * @copyright Prateek Choudhary - */ - -$body = '

'; -$body .= "
"; -$body .= "
"; -$body .= ""; -$body .= "
"; -$body .= "
"; -$body .= ""; -if($error['no-search'] == 0) { - $body .= '
'.$error_msg['no-search'].'
'; -} -$body .= "
"; -$body .= elgg_view('input/submit', array('internalname' => 'submit', 'value' => elgg_echo('videolist:searchTubeVideos'))); -$body .= "
"; - -print $body; \ No newline at end of file diff --git a/views/default/forms/videolist/add.php b/views/default/forms/videolist/add.php new file mode 100644 index 000000000..2ee5d9c2e --- /dev/null +++ b/views/default/forms/videolist/add.php @@ -0,0 +1,163 @@ + + * @copyright Prateek Choudhary + */ +// Make sure we're logged in (send us to the front page if not) +gatekeeper(); +$page_owner = page_owner_entity(); +$error = array( + 'no-video' => 1 + ); +$error_msg = array( + 'no-video' => "Please enter a valid video url" + ); + +$container_guid = get_input("container_guid"); +set_page_owner($container_guid); + +$confirm_action = get_input('video_action'); +$guid = get_input('guid'); +if(page_owner_entity() instanceof ElggGroup){ + //if in a group, set the access level to default to the group + $access_id = page_owner_entity()->group_acl; +}else{ + $access_id = get_default_access(get_loggedin_user()); +} +//if it is a group, pull out the group access view +if(page_owner_entity() instanceof ElggGroup){ + $options = group_access_options(page_owner_entity()); +}else{ + $options = ''; +} +$title_videourl = get_input('title_videourl'); +$Pagecontainer = get_input('page'); +$get_addvideourl = get_input('add_videourl'); +$timestamp = time(); +$token = generate_action_token(time()); +if (!empty($get_addvideourl) && ($Pagecontainer == "youtube")) { + $title_add_videourl = "http://www.youtube.com/watch?v=".$get_addvideourl; +} else if(!empty($get_addvideourl) && ($Pagecontainer == "metacafe")) { + $title_add_videourl = "http://www.metacafe.com/api/item/".$get_addvideourl; +} else if(!empty($get_addvideourl) && ($Pagecontainer == "vimeo")) { + $title_add_videourl = "http://vimeo.com/".$get_addvideourl; +} else { + $title_add_videourl = ""; +} + +$tags = get_input('videolisttags'); + +function video_youtube_parse_url($url) { + if (!preg_match('/(http:\/\/)([a-zA-Z]{2,3}\.)(youtube\.com\/)(.*)/', $url, $matches)) { + return false; + } + + $domain = $matches[2] . $matches[3]; + $path = $matches[4]; + + if (!preg_match('/^(watch\?v=)([a-zA-Z0-9_-]*)(&.*)?$/',$path, $matches)) { + return false; + } + + $hash = $matches[2]; + return $domain . 'v/' . $hash; +} + +function video_vimeo_parse_url($url) { + if (!preg_match('/(http:\/\/)([a-zA-Z]{2,3}\.)(vimeo\.com\/)(.*)/', $url, $matches)) { + return false; + } + + $domain = $matches[2] . $matches[3]; + $path = $matches[4]; + + $hash = $matches[2]; + + return $domain . '/' . $hash; +} + +function video_metacafe_parse_url($url) { + if (!preg_match('/(http:\/\/)([a-zA-Z]{2,3}\.)(metacafe\.com\/)(.*)/', $url, $matches)) { + return false; + } + + $domain = $matches[2] . $matches[3]; + $path = $matches[4]; + + $hash = $matches[2]; + + return $domain . '/' . $hash; +} + +if(isset($confirm_action) && ($confirm_action == 'add_video')) { + if(isset($title_videourl) && ($title_videourl != '')) { + if($Pagecontainer != "youtube" || $Pagecontainer != "vimeo" || $Pagecontainer != "metacafe"){ + if(preg_match("/youtube/i", $title_videourl)) { + $Pagecontainer = "youtube"; + } + + if(preg_match("/vimeo/i", $title_videourl)) { + $Pagecontainer = "vimeo"; + } + + if(preg_match("/metacafe/i", $title_videourl)) { + $Pagecontainer = "metacafe"; + } + } + if($Pagecontainer == "youtube") { + $is_valid_video = video_youtube_parse_url($title_videourl); + } else if($Pagecontainer == "vimeo") { + $is_valid_video = video_vimeo_parse_url($title_videourl); + $is_valid_video = $get_addvideourl; + } else if($Pagecontainer == "metacafe"){ + $is_valid_video = video_metacafe_parse_url($title_videourl); + $is_valid_video = $get_addvideourl; + } + + if($is_valid_video) { + $error['no-video'] = 1; + $_SESSION['candidate_profile_video'] = $is_valid_video; + $_SESSION['candidate_profile_video_access_id'] = $access_id; + $_SESSION['videolisttags'] = $tags; + $_SESSION['Pagecontainer'] = $Pagecontainer; + $_SESSION['container_guid'] = $container_guid; + $url = "action/videolist/add?__elgg_ts={$timestamp}&__elgg_token={$token}"; + forward($url); + } + else + $error['no-video'] = 0; + } + else { + $error['no-video'] = 0; + } +} + +$body = '
'; +$body .= elgg_view('input/hidden',array('internalname'=>'video_action', 'value'=>'add_video')); +$body .= elgg_view('input/hidden',array('internalname'=>'guid', 'value'=>$vars['guid'])); + + +$body .= '

'.$error_msg['no-video'].'
'; +} +$body .= '

'; + +$body .= '

'; + +$body .= '

'; +$body .= elgg_view('input/submit', array('internalname'=>'submit','value'=>elgg_echo('videolist:submit'))); +$body .= '
'; + +print $body; diff --git a/views/default/forms/videolist/browsetube.php b/views/default/forms/videolist/browsetube.php new file mode 100644 index 000000000..bbe2b8935 --- /dev/null +++ b/views/default/forms/videolist/browsetube.php @@ -0,0 +1,251 @@ + + * @copyright Prateek Choudhary + */ + +$getcontainer_guid = get_input("container"); +$container_guid = explode(":", $getcontainer_guid); +if($container_guid[0] == "group"){ + $container = $container_guid[1]; +} else{ + $container = $getcontainer_guid; +} +$error = array( + 'no-search' => 1 + ); +$error_msg = array( + 'no-search' => "Please enter a valid search term" + ); +$browseCat = get_input('q'); +if(empty($browseCat) || !isset($browseCat)) { + $browseCat = "youtube"; +} + +$confirm_action = get_input('video_action'); + +if(isset($confirm_action) && ($confirm_action == 'search_video')) { + if(isset($title_search) && ($title_search != '')) { + $error['no-search'] = 0; + } else { + $error['no-search'] = 1; + } +} + +//Load youtube menu +$body .= "
"; +$body .= ""; +$body .= "
"; + +$body .= '
'; +$body .= elgg_view('input/hidden',array('internalname'=>'video_action', 'value'=>'search_video')); +$body .= elgg_view('input/hidden',array('internalname'=>'guid', 'value'=>$vars['guid'])); + +switch($browseCat) { + case "youtube" : + $body .= elgg_view('forms/labels/youtube'); + break; + case "metacafe" : + $body .= elgg_view('forms/labels/metacafe'); + break; + case "vimeo" : + $body .= elgg_view('forms/labels/vimeo'); + break; + case "googlevideos" : + $body .= elgg_view('forms/labels/googlevideos'); + break; + default : + $body .= elgg_view('forms/labels/youtube'); + break; +} +$body .= elgg_view('input/hidden',array('internalname'=>'page', 'value'=>$browseCat)); +$body .= '
'; + +$body .= '
'; +$body .= '
'; + +print $body; + + +?> + + diff --git a/views/default/forms/videolist/edit.php b/views/default/forms/videolist/edit.php new file mode 100644 index 000000000..7d7901bcd --- /dev/null +++ b/views/default/forms/videolist/edit.php @@ -0,0 +1,43 @@ + Edit view +*/ +// Make sure we're logged in (send us to the front page if not) +gatekeeper(); +$page_owner = page_owner_entity(); +$container_guid = $vars['entity']->container_guid; +$owner = get_entity($container_guid); +if($owner instanceof ElggGroup){ + $options = group_access_options($owner); +}else{ + $options = ''; +} +?> + +
+ +

+ +

+ +

+ +

+ "; + + if (isset($vars['entity'])) { + echo "getGUID()}\" />"; + } + echo elgg_view('input/securitytoken'); + ?> + " /> +

+ +
\ No newline at end of file diff --git a/views/default/forms/videolist/labels/googlevideos.php b/views/default/forms/videolist/labels/googlevideos.php new file mode 100644 index 000000000..9ce2d607c --- /dev/null +++ b/views/default/forms/videolist/labels/googlevideos.php @@ -0,0 +1,27 @@ + + * @copyright Prateek Choudhary + */ + +$body = '

'; +$body .= "
"; +$body .= "
"; +$body .= ""; +$body .= "
"; +$body .= "
"; +$body .= ""; +if($error['no-search'] == 0) { + $body .= '
'.$error_msg['no-search'].'
'; +} +$body .= "
"; +$body .= elgg_view('input/submit', array('internalname' => 'submit', 'value' => elgg_echo('videolist:searchTubeVideos:vimeo'))); +$body .= "
"; +$body .= '
Loading...
'; +print $body; \ No newline at end of file diff --git a/views/default/forms/videolist/labels/metacafe.php b/views/default/forms/videolist/labels/metacafe.php new file mode 100644 index 000000000..0642153f4 --- /dev/null +++ b/views/default/forms/videolist/labels/metacafe.php @@ -0,0 +1,27 @@ + + * @copyright Prateek Choudhary + */ + +$body = '

'; +$body .= "
"; +$body .= "
"; +$body .= ""; +$body .= "
"; +$body .= "
"; +$body .= ""; +if($error['no-search'] == 0) { + $body .= '
'.$error_msg['no-search'].'
'; +} +$body .= "
"; +$body .= elgg_view('input/submit', array('internalname' => 'submit', 'value' => elgg_echo('videolist:searchTubeVideos:metacafe'))); +$body .= "
"; + +print $body; \ No newline at end of file diff --git a/views/default/forms/videolist/labels/vimeo.php b/views/default/forms/videolist/labels/vimeo.php new file mode 100644 index 000000000..24a49a1ee --- /dev/null +++ b/views/default/forms/videolist/labels/vimeo.php @@ -0,0 +1,27 @@ + + * @copyright Prateek Choudhary + */ + +$body = '

'; +$body .= "
"; +$body .= "
"; +$body .= ""; +$body .= "
"; +$body .= "
"; +$body .= ""; +if ($error['no-search'] == 0) { + $body .= '
'.$error_msg['no-search'].'
'; +} +$body .= "
"; +$body .= elgg_view('input/submit', array('internalname' => 'submit', 'value' => elgg_echo('videolist:searchTubeVideos:vimeo'))); +$body .= "
"; + +print $body; \ No newline at end of file diff --git a/views/default/forms/videolist/labels/youtube.php b/views/default/forms/videolist/labels/youtube.php new file mode 100644 index 000000000..4c824f6f3 --- /dev/null +++ b/views/default/forms/videolist/labels/youtube.php @@ -0,0 +1,27 @@ + + * @copyright Prateek Choudhary + */ + +$body = '

'; +$body .= "
"; +$body .= "
"; +$body .= ""; +$body .= "
"; +$body .= "
"; +$body .= ""; +if($error['no-search'] == 0) { + $body .= '
'.$error_msg['no-search'].'
'; +} +$body .= "
"; +$body .= elgg_view('input/submit', array('internalname' => 'submit', 'value' => elgg_echo('videolist:searchTubeVideos'))); +$body .= "
"; + +print $body; \ No newline at end of file -- cgit v1.2.3