Exemplo n.º 1
0
 /**
  * Creates a new ArticleFile entity.
  *
  * @param  Request                   $request
  * @param  Article                   $article
  * @return RedirectResponse|Response
  */
 public function createAction(Request $request, Article $article)
 {
     $journal = $this->get('ojs.journal_service')->getSelectedJournal();
     if (!$this->isGranted('EDIT', $journal, 'articles') && !$this->isGranted('EDIT', $article)) {
         throw new AccessDeniedException("You not authorized for this page!");
     }
     $entity = new ArticleFile();
     $form = $this->createCreateForm($entity, $journal->getId(), $article->getId());
     $form->handleRequest($request);
     $fileHelper = new FileHelper();
     $em = $this->getDoctrine()->getManager();
     $file_entity = new File();
     if ($form->isValid()) {
         $file = $request->request->get('file');
         $file_entity->setName($file);
         $imagePath = $this->get('kernel')->getRootDir() . '/../web/uploads/articlefiles/' . $fileHelper->generatePath($file, false);
         $file_entity->setSize(filesize($imagePath . $file));
         $file_entity->setMimeType(mime_content_type($imagePath . $file));
         $file_entity->setPath('/uploads/articlefiles/' . $fileHelper->generatePath($file, false));
         $em->persist($file_entity);
         $entity->setArticle($article);
         $entity->setFile($file_entity);
         $v = $form->getData()->getVersion();
         if (empty($v)) {
             $entity->setVersion(1);
         }
         $em->persist($entity);
         $article->addArticleFile($entity);
         $em->persist($article);
         $em->flush();
         $this->successFlashBag('Successfully created.');
         return $this->redirect($this->generateUrl('ojs_journal_article_file_index', array('articleId' => $article->getId(), 'journalId' => $journal->getId())));
     }
     return $this->render('OjsJournalBundle:ArticleFile:new.html.twig', array('entity' => $entity, 'form' => $form->createView()));
 }
Exemplo n.º 2
0
 /**
  * @param  Request $request
  * @return RedirectResponse|Response
  */
 public function updateJournalAction(Request $request)
 {
     /** @var Journal $entity */
     $em = $this->getDoctrine()->getManager();
     $entity = $this->get('ojs.journal_service')->getSelectedJournal();
     if (!$this->isGranted('EDIT', $entity)) {
         throw new AccessDeniedException("You not authorized for edit this journal!");
     }
     $this->throw404IfNotFound($entity);
     $editForm = $this->createJournalEditForm($entity);
     $editForm->submit($request);
     if ($editForm->isValid()) {
         if ($request->get('competing_interest_file_id') == '') {
             if ($request->get('competing_interest_file') !== '') {
                 $competingInterestFile = new File();
                 $competingInterestFile->setName('Competing Interest File');
                 $competingInterestFile->setSize($request->get('competing_interest_file_size'));
                 $competingInterestFile->setMimeType($request->get('competing_interest_file_mime_type'));
                 $competingInterestFile->setPath($request->get('competing_interest_file'));
                 $em->persist($competingInterestFile);
                 $em->flush();
                 $entity->setCompetingInterestFile($competingInterestFile);
             }
         }
         $header = $request->request->get('header');
         $cover = $request->request->get('cover');
         $logo = $request->request->get('logo');
         if ($header) {
             $entity->setHeaderOptions(json_encode($header));
         }
         if ($cover) {
             $entity->setImageOptions(json_encode($cover));
         }
         if ($logo) {
             $entity->setLogoOptions(json_encode($logo));
         }
         $em->persist($entity);
         $em->flush();
         $this->successFlashBag('successful.update');
         return $this->redirectToRoute('ojs_journal_settings_index', ['journalId' => $entity->getId()]);
     }
     return $this->redirectToRoute('ojs_journal_settings_index', ['journalId' => $entity->getId()]);
 }
Exemplo n.º 3
0
 /**
  * @param  File $file
  * @return string
  */
 public function downloadArticleFile(File $file)
 {
     return $this->router->generate('ojs_file_download', ['id' => $file->getId()]);
 }
Exemplo n.º 4
0
 /**
  * @param  Request                   $request
  * @param $id
  * @return RedirectResponse|Response
  */
 public function updateAction(Request $request, $id)
 {
     $em = $this->getDoctrine()->getManager();
     /** @var Journal $entity */
     $entity = $em->getRepository('OjsJournalBundle:Journal')->find($id);
     if (!$this->isGranted('EDIT', $entity)) {
         throw new AccessDeniedException("You not authorized for edit this journal!");
     }
     $this->throw404IfNotFound($entity);
     $editForm = $this->createEditForm($entity);
     $editForm->submit($request);
     if ($editForm->isValid()) {
         if ($request->get('competing_interest_file_id') == '') {
             if ($request->get('competing_interest_file') !== '') {
                 $competingInterestFile = new File();
                 $competingInterestFile->setName('Competing Interest File');
                 $competingInterestFile->setSize($request->get('competing_interest_file_size'));
                 $competingInterestFile->setMimeType($request->get('competing_interest_file_mime_type'));
                 $competingInterestFile->setPath($request->get('competing_interest_file'));
                 $em->persist($competingInterestFile);
                 $em->flush();
                 $entity->setCompetingInterestFile($competingInterestFile);
             }
         }
         $header = $request->request->get('header');
         $cover = $request->request->get('cover');
         $logo = $request->request->get('logo');
         if ($header) {
             $entity->setHeaderOptions(json_encode($header));
         }
         if ($cover) {
             $entity->setImageOptions(json_encode($cover));
         }
         if ($logo) {
             $entity->setLogoOptions(json_encode($logo));
         }
         $em->persist($entity);
         $em->flush();
         $this->successFlashBag('successful.update');
         return $this->redirectToRoute('ojs_admin_journal_edit', ['id' => $id]);
     }
     return $this->render('OjsAdminBundle:AdminJournal:edit.html.twig', array('entity' => $entity, 'form' => $editForm->createView()));
 }
 /**
  * @param  Request $request
  * @return JsonResponse
  */
 private function step1Control(Request $request)
 {
     $user = $this->getUser();
     $em = $this->getDoctrine()->getManager();
     /** @var Journal $selectedJournal */
     $selectedJournal = $this->get("ojs.journal_service")->getSelectedJournal();
     $competingInterestFile = new File();
     $competingInterestFile->setName('Competing Interest File');
     $competingInterestFile->setSize($request->get('competing_interest_file_size'));
     $competingInterestFile->setMimeType($request->get('competing_interest_file_mime_type'));
     $competingInterestFile->setPath($request->get('competing_interest_file'));
     $competingInterestFile->setTranslatableLocale($request->getDefaultLocale());
     $em->persist($competingInterestFile);
     $em->flush();
     $article = new Article();
     $article->setJournal($selectedJournal);
     $article->setSubmitterId($user->getId());
     $article->setSetupStatus(0);
     $article->setTitle('');
     $article->setTranslatableLocale($request->getDefaultLocale());
     $article->setCompetingInterestFile($competingInterestFile);
     $em->persist($article);
     $em->flush();
     $articleSubmission = new ArticleSubmissionProgress();
     $articleSubmission->setArticle($article);
     $articleSubmission->setUser($user);
     $articleSubmission->setJournal($selectedJournal);
     $articleSubmission->setChecklist(json_encode($request->get('checklistItems')));
     $articleSubmission->setSubmitted(false);
     $articleSubmission->setCurrentStep(2);
     $em->persist($articleSubmission);
     $em->flush();
     return new JsonResponse(['success' => "1", 'resumeLink' => $this->generateUrl('article_submission_resume', ['submissionId' => $articleSubmission->getId()]) . '#2']);
 }
Exemplo n.º 6
0
 /**
  * Edits an existing Article entity.
  *
  * @param  Request                   $request
  * @param  int                       $id
  * @return RedirectResponse|Response
  */
 public function updateAction(Request $request, $id)
 {
     $journal = $this->get('ojs.journal_service')->getSelectedJournal();
     /** @var Article $entity */
     $em = $this->getDoctrine()->getManager();
     $entity = $em->getRepository('OjsJournalBundle:Article')->findOneBy(array('journal' => $journal, 'id' => $id));
     $this->throw404IfNotFound($entity);
     if (!$this->isGranted('EDIT', $entity->getJournal(), 'articles')) {
         throw new AccessDeniedException("You not authorized for this page!");
     }
     $editForm = $this->createEditForm($entity, $journal);
     $editForm->handleRequest($request);
     if ($editForm->isValid()) {
         $header = $request->request->get('header');
         if ($header) {
             $entity->setHeaderOptions(json_encode($header));
         }
         $files = $request->request->get('articlefiles', []);
         $fileHelper = new FileHelper();
         foreach ($files as $file) {
             $file_entity = new File();
             $file_entity->setName($file);
             $imagepath = $this->get('kernel')->getRootDir() . '/../web/uploads/articlefiles/' . $fileHelper->generatePath($file, false);
             $file_entity->setSize(filesize($imagepath . $file));
             $file_entity->setMimeType(mime_content_type($imagepath . $file));
             $file_entity->setPath('/uploads/articlefiles/' . $fileHelper->generatePath($file, false));
             $em->persist($file_entity);
             $articleFile = new ArticleFile();
             $articleFile->setArticle($entity);
             $articleFile->setFile($file_entity);
             $articleFile->setType(0);
             // TODO: See ArticleFileParams::$FILE_TYPES
             $articleFile->setVersion(1);
             $articleFile->setLangCode('tr');
             // TODO: Don't use hardcoded locale
             $em->persist($articleFile);
             $entity->addArticleFile($articleFile);
         }
         $em->flush();
         $this->successFlashBag('successful.update');
         return $this->redirect($this->generateUrl('ojs_journal_article_edit', array('id' => $id, 'journalId' => $journal->getId())));
     }
     return $this->render('OjsJournalBundle:Article:edit.html.twig', ['entity' => $entity, 'edit_form' => $editForm->createView()]);
 }