Inheritance: extends Prezent\Doctrine\Translatable\Entity\AbstractTranslatable, use trait Ojs\CoreBundle\Entity\GenericEntityTrait
Esempio n. 1
0
 public function issueFileAction(IssueFile $issueFile)
 {
     $fileManager = $this->get('jb_fileuploader.file_history.manager');
     $rootDir = $this->getParameter('kernel.root_dir');
     $assetHelper = $this->get('templating.helper.assets');
     $fileHistory = $fileManager->findOneByFileName($issueFile->getFile());
     $path = $rootDir . '/../web' . $fileManager->getUrl($fileHistory);
     $path = preg_replace('/\\?' . $assetHelper->getVersion() . '$/', '', $path);
     $response = new BinaryFileResponse($path);
     $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_INLINE, preg_replace('/[[:^print:]]/', '_', $fileHistory->getOriginalName()));
     $event = new DownloadIssueFileEvent($issueFile);
     $dispatcher = $this->get('event_dispatcher');
     $dispatcher->dispatch(SiteEvents::DOWNLOAD_ISSUE_FILE, $event);
     return $response;
 }
Esempio n. 2
0
 public function testDelete()
 {
     $em = $this->em;
     $entity = new IssueFile();
     $entity->setCurrentLocale('en');
     $entity->setTitle('Demo File');
     $entity->setDescription('A file');
     $entity->setFile('issue.txt');
     $entity->setLangCode('en');
     $entity->setType(0);
     $entity->setVersion(0);
     $issue = $em->getRepository('OjsJournalBundle:Issue')->find('1');
     $entity->setIssue($issue);
     $em->persist($entity);
     $em->flush();
     $id = $entity->getId();
     $this->logIn();
     $client = $this->client;
     $token = $this->generateToken('ojs_journal_issue_file' . $id);
     $client->request('DELETE', '/journal/1/issue/1/file/' . $id . '/delete', array('_token' => $token));
     $this->assertStatusCode(302, $client);
 }
 /**
  * Imports the given issue file
  * @param int    $id    Issue file's ID
  * @param int    $oldId Old issue file's ID
  * @param Issue  $issue File's issue
  * @param string $slug  Journal's slug
  */
 public function importIssueFile($id, $oldId, $issue, $slug)
 {
     $this->consoleOutput->writeln("Reading issue file #" . $id . "... ", true);
     $issueFileSql = "SELECT * FROM issue_files WHERE file_id = :id LIMIT 1";
     $issueFileStatement = $this->dbalConnection->prepare($issueFileSql);
     $issueFileStatement->bindValue('id', $id);
     $issueFileStatement->execute();
     $galleysSql = "SELECT galley_id, issue_id, locale, label FROM issue_galleys " . "WHERE issue_id = :issue_id AND file_id = :id";
     $galleysStatement = $this->dbalConnection->prepare($galleysSql);
     $galleysStatement->bindValue('issue_id', $oldId);
     $galleysStatement->bindValue('id', $id);
     $galleysStatement->execute();
     $pkpIssueFile = $issueFileStatement->fetch();
     $pkpGalleys = $galleysStatement->fetchAll();
     foreach ($pkpGalleys as $galley) {
         $locale = !empty($galley['locale']) ? mb_substr($galley['locale'], 0, 2, 'UTF-8') : 'en';
         $label = !empty($galley['label']) ? $galley['label'] : '-';
         $filename = sprintf('imported/%s/%s.%s', $galley['issue_id'], $galley['galley_id'], FileHelper::$mimeToExtMap[$pkpIssueFile['file_type']]);
         $issueFile = new IssueFile();
         $issueFile->setFile($filename);
         $issueFile->setIssue($issue);
         $issueFile->setVersion(0);
         $issueFile->setType(0);
         // Fill translatable fields
         $issueFile->setCurrentLocale($locale);
         $issueFile->setTitle($label);
         $issueFile->setDescription('-');
         $history = $this->em->getRepository(FileHistory::class)->findOneBy(['fileName' => $filename]);
         if (!$history) {
             $history = new FileHistory();
             $history->setFileName($filename);
             $history->setOriginalName($pkpIssueFile['original_file_name']);
             $history->setType('issuefiles');
             $this->em->persist($history);
         }
         $source = sprintf('%s/issue/download/%s/%s', $slug, $galley['issue_id'], $galley['galley_id']);
         $target = sprintf('/../web/uploads/issuefiles/imported/%s/%s.%s', $galley['issue_id'], $galley['galley_id'], FileHelper::$mimeToExtMap[$pkpIssueFile['file_type']]);
         $pendingDownload = new PendingDownload();
         $pendingDownload->setSource($source);
         $pendingDownload->setTarget($target);
         $this->em->persist($pendingDownload);
         $this->em->persist($issueFile);
     }
 }
Esempio n. 4
0
 /**
  * Displays a form to create a new IssueFile entity.
  *
  * @param $issueId
  * @return Response
  */
 public function newAction($issueId)
 {
     $journal = $this->get('ojs.journal_service')->getSelectedJournal();
     $em = $this->getDoctrine()->getManager();
     if (!$this->isGranted('CREATE', $journal, 'issues')) {
         throw new AccessDeniedException('You are not authorized for create  issue file for this journal!');
     }
     /** @var Issue $issue */
     $issue = $em->getRepository('OjsJournalBundle:Issue')->find($issueId);
     $this->throw404IfNotFound($issue);
     $entity = new IssueFile();
     $entity->setIssue($issue);
     $form = $this->createCreateForm($entity, $journal->getId())->add('create', 'submit', array('label' => 'c'));
     return $this->render('OjsJournalBundle:IssueFile:new.html.twig', array('entity' => $entity, 'form' => $form->createView()));
 }
Esempio n. 5
0
 /**
  * Displays a form to create a new IssueFile entity.
  */
 public function newAction(Request $request, $issueId)
 {
     $journal = $this->get('ojs.journal_service')->getSelectedJournal();
     if (!$this->isGranted('CREATE', $journal, 'issues')) {
         throw new AccessDeniedException('You are not authorized for create  issue file for this journal!');
     }
     $entity = new IssueFile();
     $entity->setIssueId($issueId);
     $form = $this->createCreateForm($entity, $journal->getId());
     return $this->render('OjsJournalBundle:IssueFile:new.html.twig', array('entity' => $entity, 'form' => $form->createView()));
 }
Esempio n. 6
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('Creating sample data...');
     $em = $this->getContainer()->get('doctrine')->getManager();
     $manipulator = $this->getContainer()->get('fos_user.util.user_manipulator');
     $manipulator->create('sample_author', 'author', '*****@*****.**', false, false);
     $user = $em->getRepository('OjsUserBundle:User')->findOneBy(['username' => 'sample_author']);
     $announcement = new AdminAnnouncement();
     $announcement->setTitle('We are online!');
     $announcement->setContent('We are now online and accepting submissions!');
     $em->persist($announcement);
     $em->flush();
     $post = new AdminPost();
     $post->setCurrentLocale('en');
     $post->setTitle('Welcome to OJS!');
     $post->setSlug('Welcome to OJS!');
     $post->setContent('Hello! We are now online and waiting for your submissions. ' . 'Our readers will be able to follow you and read your work ' . 'right after it gets published!');
     $em->persist($post);
     $em->flush();
     $publisherTypes = ['University', 'Government', 'Association', 'Foundation', 'Hospital', 'Chamber', 'Private'];
     foreach ($publisherTypes as $typeName) {
         $publisherType = new PublisherTypes();
         $publisherType->setCurrentLocale('en');
         $publisherType->setName($typeName);
         $em->persist($publisherType);
     }
     $em->flush();
     $slug = $this->getContainer()->getParameter('defaultPublisherSlug');
     $publisherType = $em->getRepository('OjsJournalBundle:PublisherTypes')->find(1);
     $publisher = new Publisher();
     $publisher->setCurrentLocale('en');
     $publisher->setName('OJS');
     $publisher->setSlug($slug);
     $publisher->setEmail('*****@*****.**');
     $publisher->setAddress('First Avenue, Exampletown');
     $publisher->setPhone('+908501234567');
     $publisher->setVerified(1);
     $publisher->setStatus(PublisherStatuses::STATUS_COMPLETE);
     $publisher->setPublisherType($publisherType);
     $em->persist($publisher);
     $em->flush();
     $subject1 = new Subject();
     $subject1->setCurrentLocale('en');
     $subject1->setSubject('Computer Science');
     $subject1->setTags('computer, science');
     $subject2 = new Subject();
     $subject2->setCurrentLocale('en');
     $subject2->setSubject('Journalism');
     $subject2->setTags('journalism');
     $em->persist($subject1);
     $em->persist($subject2);
     $em->flush();
     $language1 = new Lang();
     $language1->setCurrentLocale('en');
     $language1->setName('English');
     $language1->setCode('en');
     $language1->setRtl(false);
     $language2 = new Lang();
     $language2->setCurrentLocale('tr');
     $language2->setName('Türkçe');
     $language2->setCode('tr');
     $language2->setRtl(false);
     $em->persist($language1);
     $em->persist($language2);
     $em->flush();
     $articleTypes = [['Case Report', 'Olgu Sunumu'], ['Research papers', 'Araştırma Makalesi'], ['Translation', 'Çeviri'], ['Note', 'Not'], ['Letter', 'Editöre Mektup'], ['Review Articles', 'Derleme'], ['Book review', 'Kitap İncelemesi'], ['Correction', 'Düzeltme'], ['Editorial', 'Editoryal'], ['Short Communication', 'Kısa Bildiri'], ['Meeting abstract', 'Toplantı Özetleri'], ['Conference Paper', 'Konferans Bildirisi'], ['Biography', 'Biyografi'], ['Bibliography', 'Bibliyografi'], ['News', 'Haber'], ['Report', 'Rapor'], ['Legislation Review', 'Yasa İncelemesi'], ['Decision Review', 'Karar İncelemesi'], ['Art and Literature', 'Sanat ve Edebiyat'], ['Other', 'Diğer']];
     foreach ($articleTypes as $typeNames) {
         $type = new ArticleTypes();
         $type->setCurrentLocale('en');
         $type->setName($typeNames[0]);
         $type->setCurrentLocale('tr');
         $type->setName($typeNames[1]);
         $em->persist($type);
     }
     $em->flush();
     $contactTypes = ['Journal Contact', 'Primary Contact', 'Technical Contact', 'Author Support', 'Subscription Support', 'Publisher Support', 'Submission Support', 'Advertising', 'Media', 'Editor', 'Co-Editor'];
     foreach ($contactTypes as $typeName) {
         $type = new ContactTypes();
         $type->setCurrentLocale('en');
         $type->setName($typeName);
         $em->persist($type);
     }
     $em->flush();
     $journal = new Journal();
     $journal->setCurrentLocale('en');
     $journal->setPublisher($publisher);
     $journal->setTitle('Introduction to OJS');
     $journal->setSubtitle('How to use OJS');
     $journal->setDescription('A journal about OJS');
     $journal->setTitleAbbr('INTROJS');
     $journal->setUrl('http://ojs.io');
     $journal->setSlug('intro');
     $journal->addSubject($subject1);
     $journal->addSubject($subject2);
     $journal->addLanguage($language1);
     $journal->addLanguage($language2);
     $journal->setMandatoryLang($language2);
     $journal->setFounded(new \DateTime('now'));
     $journal->setIssn('1234-5679');
     $journal->setEissn('1234-5679');
     $journal->setStatus(JournalStatuses::STATUS_PUBLISHED);
     $journal->setPublished(1);
     $em->persist($journal);
     $em->flush();
     $this->createDemoFiles();
     $issueFile = new IssueFile();
     $issueFile->setCurrentLocale('en');
     $issueFile->setTitle('Demo File');
     $issueFile->setDescription('A file');
     $issueFile->setFile('issue.txt');
     $issueFile->setLangCode('en');
     $issueFile->setType(0);
     $issueFile->setVersion(0);
     $issueFile->setUpdatedBy($user->getUsername());
     $issueFileHistory = new FileHistory();
     $issueFileHistory->setFileName('issue.txt');
     $issueFileHistory->setOriginalName('issue.txt');
     $issueFileHistory->setType('issuefiles');
     $em->persist($issueFile);
     $em->persist($issueFileHistory);
     $em->flush();
     $issue = new Issue();
     $issue->setCurrentLocale('en');
     $issue->setJournal($journal);
     $issue->setTitle('First Issue: Hello OJS!');
     $issue->setDescription('First issue of the journal');
     $issue->setNumber(1);
     $issue->setVolume(1);
     $issue->setYear(2015);
     $issue->setSpecial(1);
     $issue->setDatePublished(new \DateTime('now'));
     $issue->setTags('first, guide, tutorial');
     $issue->setDatePublished(new \DateTime('now'));
     $issue->addIssueFile($issueFile);
     $em->persist($issue);
     $em->flush();
     $section = new Section();
     $section->setCurrentLocale('en');
     $section->setJournal($journal);
     $section->setTitle('Tutorials');
     $section->setHideTitle(0);
     $section->setAllowIndex(1);
     $em->persist($section);
     $em->flush();
     $citation1 = new Citation();
     $citation1->setCurrentLocale('en');
     $citation1->setRaw('The Matrix [Motion picture]. (2001). Warner Bros. Pictures.');
     $citation1->setOrderNum(0);
     $em->persist($citation1);
     $em->flush();
     $articleFile = new ArticleFile();
     $articleFile->setCurrentLocale('en');
     $articleFile->setTitle('Demo File');
     $articleFile->setDescription('A file');
     $articleFile->setFile('article.txt');
     $articleFile->setLangCode('en');
     $articleFile->setType(0);
     $articleFile->setVersion(0);
     $articleFile->setUpdatedBy($user->getUsername());
     $articleFileHistory = new FileHistory();
     $articleFileHistory->setFileName('article.txt');
     $articleFileHistory->setOriginalName('article.txt');
     $articleFileHistory->setType('articlefiles');
     $em->persist($articleFile);
     $em->persist($articleFileHistory);
     $em->flush();
     $author = new Author();
     $author->setCurrentLocale('en');
     $author->setTitle('Dr.');
     $author->setFirstName('John');
     $author->setLastName('Doe');
     $author->setEmail('*****@*****.**');
     $em->persist($author);
     $em->flush();
     $article1 = new Article();
     $article1->setCurrentLocale('en');
     $article1->setJournal($journal);
     $article1->setSection($section);
     $article1->setIssue($issue);
     $article1->setTitle('Getting Started with OJS');
     $article1->setAbstract('A tutorial about using OJS');
     $article1->setSubjects('OJS');
     $article1->setKeywords('ojs, intro, starting');
     $article1->setDoi('10.5281/zenodo.14791');
     $article1->setSubmissionDate(new \DateTime('now'));
     $article1->setPubdate(new \DateTime('now'));
     $article1->setAnonymous(0);
     $article1->setFirstPage(1);
     $article1->setLastPage(5);
     $article1->setStatus(ArticleStatuses::STATUS_PUBLISHED);
     $article1->addCitation($citation1);
     $article1->addArticleFile($articleFile);
     $em->persist($article1);
     $em->flush();
     $articleAuthor = new ArticleAuthor();
     $articleAuthor->setAuthor($author);
     $articleAuthor->setArticle($article1);
     $articleAuthor->setAuthorOrder(0);
     $em->persist($articleAuthor);
     $em->flush();
     $checklistItems = [['The title page should include necessary information.', "<ul>\n                    <li>The name(s) of the author(s)</li>\n                     <li>A concise and informative title</li>\n                     <li>The affiliation(s) of the author(s)</li>\n                     <li>The e-mail address, telephone number of the corresponding author </li>\n                 </ul>"], ['Manuscript must be approved.', 'All authors must have read and approved the most recent version of the manuscript.'], ['Manuscript must be <i>spell checked</i>.', 'The most recent version of the manuscript must be spell checked.']];
     foreach ($checklistItems as $checklistItem) {
         $label = $checklistItem[0];
         $detail = $checklistItem[1];
         $item = new SubmissionChecklist();
         $item->setLabel($label);
         $item->setDetail($detail);
         $item->setLocale('en');
         $item->setJournal($journal);
         $em->persist($item);
     }
     $em->flush();
     $periods = ['Monthly', 'Bimonthly', 'Quarterly', 'Triquarterly', 'Biannually', 'Annually', 'Spring', 'Summer', 'Fall', 'Winter'];
     foreach ($periods as $period) {
         $journalPeriod = new Period();
         $journalPeriod->setCurrentLocale('en');
         $journalPeriod->setPeriod($period);
         $em->persist($journalPeriod);
     }
     $em->flush();
 }