public function chooseMediaByTypeAction(Request $request, $type)
 {
     if (!$this->container->get('image_annotator.authentication_manager')->isAuthenticated($request)) {
         return $this->redirect($this->generateUrl('fos_user_security_login'));
     }
     return MediaChooserGatewayController::chooseMedia($request, $type);
 }
 /**
  * A gateway form for uploading/recording or selecting existing files
  *
  * @throws AccessDeniedException
  * @throws NotFoundHttpException
  * @throws BadRequestHttpException
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function gatewayAction(Request $request)
 {
     if (!$this->container->get('image_annotator.authentication_manager')->isAuthenticated($request)) {
         return $this->redirect($this->generateUrl('fos_user_security_login'));
     }
     $user = $this->getUser();
     $paginator = $this->get('knp_paginator');
     $resourceFiles = $paginator->paginate($user->getAnnotations(), $this->get('request')->query->get('page', 1), 25);
     return $this->render('ImageAnnotatorBundle:Annotations:index.html.twig', array('resourceFiles' => $resourceFiles, 'uploadForms' => MediaChooserGatewayController::getUploadForms($this)));
 }
 /**
  * An Ajax function that previews a media with a specific media ID
  *
  * @param Request $request        	
  * @param unknown_type $mediaId        	
  */
 public function browseAction(Request $request, $datasetId)
 {
     if (!$this->container->get('image_annotator.authentication_manager')->isAuthenticated($request)) {
         return $this->redirect($this->generateUrl('fos_user_security_login'));
     }
     $em = $this->get('doctrine')->getManager();
     $dataset = $em->getRepository('ImageAnnotatorBundle:Dataset')->find($datasetId);
     $responseURL = "";
     if ($dataset !== null) {
         $responseURL = 'ImageAnnotatorBundle:DatasetGateway:' . 'browse.html.twig';
     } else {
         throw new EntityNotFoundException("Cannot find dataset with that ID");
     }
     $paginator = $this->get('knp_paginator');
     $resourceFiles = $paginator->paginate($dataset->getImages(), $this->get('request')->query->get('page', 1), 20);
     $response = $this->render($responseURL, array('dataset' => $dataset, 'resourceFiles' => $resourceFiles, 'uploadForms' => MediaChooserGatewayController::getUploadForms($this)));
     return $response;
 }