X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?p=living-lab-site.git;a=blobdiff_plain;f=application%2Fcontrollers%2Fvideo.php;h=eb4ed80c7630ad9638db097ff93e8b462655e40f;hp=4e31540c65d9259ecccdfcda716606f06cb2c486;hb=080b37a97e93691b3ba1c4aa3982a143167115a7;hpb=9d5e17576e133645963b8e41083baf235c5cceba diff --git a/application/controllers/video.php b/application/controllers/video.php index 4e31540..eb4ed80 100644 --- a/application/controllers/video.php +++ b/application/controllers/video.php @@ -117,6 +117,109 @@ class Video extends CI_Controller { $this->load->view('footer'); $this->load->view('html_end'); } + +// public function upload() +// { +// $this->load->library('form_validation'); +// +// $this->form_validation->set_error_delimiters('', +// ''); +// $error_upload = ''; +// +// if ($this->form_validation->run('upload')) +// { +// if ($_FILES['video-upload-file']['tmp_name']) +// { +// // Upload library +// $config_upload['upload_path'] = './data/upload'; +// $this->load->library('upload', $config_upload); +// +// $b_validation = $this->upload->do_upload('video-upload-file'); +// $error_upload = +// $this->upload->display_errors('', +// ''); +// } +// else +// { +// $b_validation = FALSE; +// } +// } +// else +// $b_validation = FALSE; +// +// if ($b_validation === FALSE) +// { +// $params = array('title' => +// $this->lang->line('ui_nav_menu_upload') +// .' – ' +// . $this->config->item('site_name'), +// //'metas' => array('description'=>'') +// ); +// $this->load->library('html_head_params', $params); +// +// // ** +// // ** LOADING VIEWS +// // ** +// $this->load->view('html_begin', $this->html_head_params); +// $this->load->view('header', +// array('selected_menu' => 'upload')); +// +// $main_params['content'] = $this->load->view( +// 'video/upload_view', +// array('error_upload'=> $error_upload), +// TRUE); +// $main_params['side'] = $this->load->view('side_default', NULL, TRUE); +// $this->load->view('main', $main_params); +// +// $this->load->view('footer'); +// $this->load->view('html_end'); +// } +// else +// { +// +// } +// } + + public function upload() + { + $this->load->library('form_validation'); + + $this->form_validation->set_error_delimiters('', + ''); + $error_upload = ''; + + if ($this->form_validation->run('upload') === FALSE) + { + $params = array('title' => + $this->lang->line('ui_nav_menu_upload') + .' – ' + . $this->config->item('site_name'), + //'metas' => array('description'=>'') + ); + $this->load->library('html_head_params', $params); + + // ** + // ** LOADING VIEWS + // ** + $this->load->view('html_begin', $this->html_head_params); + $this->load->view('header', + array('selected_menu' => 'upload')); + + $main_params['content'] = $this->load->view( + 'video/upload_view', + array('error_upload'=> $error_upload), + TRUE); + $main_params['side'] = $this->load->view('side_default', NULL, TRUE); + $this->load->view('main', $main_params); + + $this->load->view('footer'); + $this->load->view('html_end'); + } + else + { + + } + } /** * Increments (dis)likes count for video with the specified id and returns to @@ -233,6 +336,54 @@ class Video extends CI_Controller { $this->videos_model->comment_video($video_id, $user_id, $comment); } + public function _valid_tags($tags) + { + $tok = strtok($tags, ','); + while ($tok != FALSE) + { + $tok = trim($tok); + if (!ctype_alnum($tok)) + return FALSE; + + $tok = strtok(','); + } + + return TRUE; + } + + public function _required_upload($file) + { + if ($_FILES['video-upload-file']['tmp_name']) + { + return TRUE; + } + + return FALSE; + } + + public function _valid_upload($file) + { + if ($_FILES['video-upload-file']['tmp_name']) + { + // Upload library + $config_upload = array(); + $config_upload['upload_path'] = './data/upload'; + $config_upload['allowed_types'] = '*'; + $this->load->library('upload', $config_upload); + + if ($this->upload->do_upload('video-upload-file')) + { + return TRUE; + } + + $this->form_validation->set_message('_valid_upload', + $this->upload->display_errors('', + '')); + } + + return FALSE; + } + /** * OBSOLETE: AJAX page which retrieves a video plugin. *