/**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($type, $id)
 {
     if ($id == 'video') {
         $events = Video::all();
         return view('video.show', compact('events'));
     } elseif ($id == 'staff') {
         $events = Staff::all();
         return view('staff.show', compact('events'));
     } elseif ($id == 'gallery') {
         $events = Image::all();
         return view('gallery.show', compact('events'));
     } else {
         $event = Event::where('slug', $id)->where('type', $type)->first();
         $location = Location::where('event_id', $event->id)->first();
         $slider = EventImage::where('event_id', $event->id)->orderBy(\DB::raw('RAND()'))->take(4)->get();
         $gallery = EventImage::where('event_id', $event->id)->first();
         if ($event->type == $type) {
             if ($event->status == 1) {
                 return view($type . '.show', compact('event', 'location', 'slider', 'gallery'));
             } else {
                 return redirect('/' . $type . '/');
             }
         }
     }
 }
 public function topEnrichment(Request $request)
 {
     try {
         $users = MecanexUser::all();
         $videos = Video::all();
         $euscreen_id = $request->video;
         $video_id = $videos->where('video_id', $euscreen_id)->first()->id;
         $username = $request->user;
         $user_id = $users->where('username', $username)->first()->id;
         if ($request->num != 0) {
             $num = $request->num;
         } else {
             $num = 3;
         }
         $topEnrichments = [];
         $listEnrichments = DB::select(DB::raw('SELECT * FROM enrichments_videos_time WHERE video_id=?'), [$video_id]);
         $listEnrichments = json_decode(json_encode($listEnrichments), true);
         $topEnrichments = $this->recommend_enr($listEnrichments, $user_id);
         $topEnrichments = array_slice($topEnrichments, 0, $num, true);
         foreach ($topEnrichments as $key => $score) {
             $response[] = array('enrichment_id' => Enrichment::find($key)->enrichment_id, 'score' => $score);
         }
         $statusCode = 200;
         return $response;
     } catch (Exception $e) {
         $statusCode = 400;
     } finally {
         return Response::json($response, $statusCode);
     }
 }
Exemple #3
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function scores()
 {
     //indexing of video terms
     set_time_limit(0);
     DB::table('videos_terms_scores')->delete();
     //$counts=DB::select('select count(video_id) from videos');  //take number of videos
     //dd($counts);
     $terms = Term::all();
     //take all Profile terms
     $videos = Video::all();
     foreach ($videos as $video) {
         $id = $video->id;
         foreach ($terms as $term) {
             $results = DB::select(DB::raw('select MATCH (genre, topic, geographical_coverage, thesaurus_terms, title) AGAINST (? WITH QUERY EXPANSION)  as rev from videos where id = (?)'), [$term->term, $id]);
             echo 'video_id=' . $id . '  term = ' . $term->term . '   score = ' . $results[0]->rev . '<br>';
             DB::table('videos_terms_scores')->insert(['video_id' => $id, 'term_id' => $term->id, 'video_score' => $results[0]->rev]);
             echo 'record inserted!' . '<br>';
         }
     }
     ///////////////////normalization///////////////////////////////////////////////////
     //this takes for ever....raw db instead
     //				foreach ($videos as $video) {
     //				$id = $video->id;
     //				$max_score = DB::table('videos_terms_scores')->where('video_id',$id)->max('video_score');
     //					foreach ($terms as $term) {
     //						$temp_video = $video->term->find($term);
     //						$video_term_score = $temp_video->pivot->video_score;  //get score of video
     //						$new_score=$video_term_score/$max_score;
     //						$video->term()->sync([$term->id=> ['video_score' => $new_score]], false);
     //
     //					}
     //				}
     $query = DB::select(DB::raw('UPDATE videos_terms_scores as t join (select video_id,MAX(video_score) as maximum FROM videos_terms_scores GROUP BY video_id)as max_scores  on  t.video_id=max_scores.video_id  SET t.video_score=t.video_score/max_scores.maximum'));
     //return view ('video.parser');
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $videos = Video::all();
     if ($videos === null) {
         $videos = null;
     }
     //return $videos;
     return \View::make('admin.video.manage_videos')->withVideos($videos);
 }
Exemple #5
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     //
     $videos = Video::orderBy('views', 'desc')->limit(5)->get();
     $totalViews = Video::all()->sum('views');
     $comments = Video::orderBy('numComments', 'desc')->limit(5)->get();
     $totalComments = Video::all()->sum('numComments');
     $tracker = Tracker::all()->where('date', Carbon::today()->format('m/d/Y'));
     $totalTrackers = Tracker::all()->where('date', Carbon::today()->format('m/d/Y'))->count();
     return view('admin.stats', compact('videos', 'totalViews', 'comments', 'totalComments', 'tracker', 'totalTrackers'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index($type)
 {
     if ($type == 'staff') {
         $events = Staff::all();
         return view('admin.' . $type . '.index')->with('events', $events);
     } elseif ($type == 'video') {
         $events = Video::all();
         return view('admin.' . $type . '.index')->with('events', $events);
     } elseif ($type == 'event' || $type == 'page') {
         $events = Event::where('type', $type)->orderBy('updated_at', 'desc')->get();
         return view('admin.' . $type . '.index')->with('events', $events);
     } else {
         return view('errors.404');
     }
 }
 /**
  * @return Video|best
  */
 public function best()
 {
     $videos = Video::all();
     $best_vidos = [];
     $id_best_videos = [];
     foreach ($videos as $video) {
         $id_best_videos[] = [$video->likes()->count(), $video->id];
     }
     arsort($id_best_videos);
     $id_best_videos = array_slice($id_best_videos, 0, 10);
     foreach ($id_best_videos as $value) {
         $best_vidos[] = Video::find($value[1]);
     }
     return $best_vidos;
 }
 public function remove_duplicates_on_score()
 {
     $terms = Term::all();
     //take all Profile terms
     $videos = Video::all();
     foreach ($videos as $video) {
         $id = $video->id;
         foreach ($terms as $term) {
             $results = DB::select(DB::raw('select * from videos_terms_scores where video_id=? and term_id=?'), [$id, $term->id]);
             if (count($results) > 1) {
                 DB::table('videos_terms_scores')->where('video_id', $id)->where('term_id', $term->id)->delete();
                 DB::table('videos_terms_scores')->insert(['video_id' => $results[0]->video_id, 'term_id' => $results[0]->term_id, 'video_score' => $results[0]->video_score]);
             }
         }
     }
     return "removed duplicates";
 }
 public function index()
 {
     $videos = Video::all();
     $interests = Auth::user()->interests()->lists('name', 'id');
     return view('videos.index', compact('interests', 'videos'));
 }
 /**
  * Show all videos.
  *
  * @return mixed
  */
 public function videos()
 {
     return view('Admin.Videos.Show')->withVideos($this->video->all());
 }
 public function getAllVideos()
 {
     return Video::all();
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $categories = Category::all();
     $videos = Video::all();
     return view('welcome', compact('categories', 'videos'));
 }
 public function importVideoEnrichments()
 {
     set_time_limit(0);
     DB::table('enrichments_videos_time')->delete();
     $uri = "http://mecanex.noterik.com/tools/video_enrichments.php";
     $content = utf8_encode(file_get_contents($uri));
     $json = json_decode($content);
     $videos = Video::all();
     $all_enrichments = Enrichment::all();
     foreach ($json as $item) {
         $euscreen_id = $item->id;
         $video_id = $videos->where('video_id', $euscreen_id)->first()->id;
         foreach ($item->enrichment as $key => $enrichment) {
             $new_key = str_replace("\r", '', $key);
             $enrichment_id = $all_enrichments->where('enrichment_id', $new_key)->first()->id;
             foreach ($enrichment->localization as $localization) {
                 foreach ($localization as $time => $inside) {
                     $time = intval(substr($time, 1));
                     $height = $inside->height;
                     $width = $inside->width;
                     $x_min = $inside->x_min;
                     $y_min = $inside->y_min;
                     DB::table('enrichments_videos_time')->insert(["enrichment_id" => $enrichment_id, "video_id" => $video_id, "time" => $time, "height" => $height, "width" => $width, "x_min" => $x_min, "y_min" => $y_min]);
                 }
             }
         }
     }
     $response = ['message' => 'Successful match of enrichments to videos'];
     $statusCode = 200;
     return Response::json($response, $statusCode);
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $videos = Video::all();
 }
 private function content_similarity($user_id, $limit)
 {
     $result = [];
     $videos = Video::all();
     $terms = Term::all();
     $user = MecanexUser::where('id', $user_id)->get()->first();
     $user_terms_scores = $user->profilescore;
     foreach ($user_terms_scores as $user_term_score) {
         $temp_profile_scores[] = $user_term_score->pivot->profile_score;
     }
     foreach ($videos as $video) {
         $arithmitis = 0;
         $sumA = 0;
         $sumB = 0;
         $temp_video_scores = [];
         $video_terms_scores = DB::select(DB::raw('SELECT * FROM videos_terms_scores WHERE video_id=? ORDER BY term_id'), [$video->id]);
         foreach ($video_terms_scores as $video_term_score) {
             $temp_video_scores[] = $video_term_score->video_score;
         }
         for ($i = 0; $i < count($terms); $i++) {
             $arithmitis = $arithmitis + $temp_video_scores[$i] * $temp_profile_scores[$i];
             $sumA = $sumA + pow($temp_video_scores[$i], 2);
             $sumB = $sumB + pow($temp_profile_scores[$i], 2);
         }
         $videoScores[$video->id] = $arithmitis / (sqrt($sumA) + sqrt($sumB));
     }
     arsort($videoScores);
     $videoScores = array_slice($videoScores, 0, $limit, true);
     foreach ($videoScores as $key => $score) {
         $video = $videos->find($key);
         $result[] = array('video_id' => $video->id, 'title' => $video->title, 'similarity' => $score, 'euscreen_id' => $video->video_id);
     }
     return $result;
 }
 public function initial()
 {
     $allvideo = Video::all();
     return view('video')->with('allvideos', $allvideo);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     return Video::all();
 }
 /**
  * Home page.
  *
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function home()
 {
     return view('Main.Home.Home')->withVideos($this->video->all());
 }
Exemple #19
0
 /**
  * Show the application welcome screen to the user.
  *
  * @return Response
  */
 public function index()
 {
     $videos = Video::all();
     return view('Home.index', compact('videos'));
 }
 private function content_similarity($user_id, $video_ids)
 {
     $temp_profile_scores = [];
     // if there is no video list, search all videos, else only those on the list
     if (count($video_ids) == 0) {
         $videos = Video::all();
     } else {
         //            $videos = Video::whereRaw('video_id  IN (' . $video_ids . ')')->get();
         $tmpArray = explode(',', $video_ids);
         $func = function ($string) {
             return substr($string, 1, -1);
         };
         $myArray = array_map($func, $tmpArray);
         $videos = DB::table('videos')->whereIn('video_id', $myArray)->get();
     }
     //keep all terms of the user in a list
     $terms = Term::all();
     $user = MecanexUser::where('id', $user_id)->get()->first();
     $user_terms_scores = $user->profilescore;
     foreach ($user_terms_scores as $user_term_score) {
         $temp_profile_scores[] = $user_term_score->pivot->profile_score;
     }
     foreach ($videos as $video) {
         $arithmitis = 0;
         $sumA = 0;
         $sumB = 0;
         $temp_video_scores = [];
         //keep all terms of video in a list
         $video_terms_scores = DB::select(DB::raw('SELECT * FROM videos_terms_scores WHERE video_id=? ORDER BY term_id'), [$video->id]);
         foreach ($video_terms_scores as $video_term_score) {
             $temp_video_scores[] = $video_term_score->video_score;
         }
         // calculate the similarity
         for ($i = 0; $i < count($terms); $i++) {
             $arithmitis = $arithmitis + $temp_video_scores[$i] * $temp_profile_scores[$i];
             $sumA = $sumA + pow($temp_video_scores[$i], 2);
             $sumB = $sumB + pow($temp_profile_scores[$i], 2);
         }
         $videoScores[$video->id] = $arithmitis / (sqrt($sumA) + sqrt($sumB));
     }
     return $videoScores;
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create()
 {
     $videos = Video::all();
     return view('admin.pages.create')->with(compact('videos'));
 }
 public function getVideos($id)
 {
     $videos = $id ? User::findOrFail($id)->videos : Video::all();
     return $videos;
 }