Inheritance: extends Prezent\Doctrine\Translatable\Entity\AbstractTranslatable, implements Ojs\JournalBundle\Entity\JournalItemInterface, use trait Ojs\CoreBundle\Entity\GenericEntityTrait
 public function importPage($id, $newJournalId)
 {
     $settingsSql = "SELECT setting_name, setting_value, locale FROM static_page_settings WHERE static_page_id = :id";
     $settingsStatement = $this->dbalConnection->prepare($settingsSql);
     $settingsStatement->bindValue('id', $id);
     $settingsStatement->execute();
     $pkpSettings = $settingsStatement->fetchAll();
     $settings = [];
     foreach ($pkpSettings as $setting) {
         $locale = !empty($setting['locale']) ? $setting['locale'] : 'en_US';
         $name = $setting['setting_name'];
         $value = $setting['setting_value'];
         $settings[$locale][$name] = $value;
     }
     $journal = $this->em->getReference('OjsJournalBundle:Journal', $newJournalId);
     if (!$journal) {
         return null;
     }
     $page = new JournalPage();
     $page->setJournal($journal);
     foreach ($settings as $locale => $fields) {
         $title = !empty($fields['title']) ? $fields['title'] : 'Page';
         $content = !empty($fields['content']) ? $fields['content'] : 'This page is intentionally left blank.';
         $page->setCurrentLocale(mb_substr($locale, 0, 2, 'UTF-8'));
         $page->setTitle($title);
         $page->setBody($content);
         $page->setVisible(true);
     }
     return $page;
 }
Exemple #2
0
 /**
  * @param Request $request
  * @param JournalPage $entity
  * @return Response
  */
 public function deleteAction(Request $request, JournalPage $entity)
 {
     $journal = $this->get('ojs.journal_service')->getSelectedJournal();
     $dispatcher = $this->get('event_dispatcher');
     if (!$this->isGranted('DELETE', $journal, 'pages')) {
         throw new AccessDeniedException("You are not authorized for this page!");
     }
     $em = $this->getDoctrine()->getManager();
     $csrf = $this->get('security.csrf.token_manager');
     $token = $csrf->getToken('ojs_journal_page' . $entity->getId());
     if ($token != $request->get('_token')) {
         throw new TokenNotFoundException("Token not found!");
     }
     $event = new JournalItemEvent($entity);
     $dispatcher->dispatch(JournalPageEvents::PRE_DELETE, $event);
     $this->get('ojs_core.delete.service')->check($entity);
     $em->remove($entity);
     $em->flush();
     $event = new JournalEvent($journal);
     $dispatcher->dispatch(JournalPageEvents::POST_DELETE, $event);
     if ($event->getResponse()) {
         return $event->getResponse();
     }
     $this->successFlashBag('successful.remove');
     return $this->redirectToRoute('ojs_journal_page_index', ['journalId' => $journal->getId()]);
 }
 /**
  * Creates a new JournalPage entity.
  *
  * @param  Request $request
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function createAction(Request $request)
 {
     $journal = $this->get('ojs.journal_service')->getSelectedJournal();
     $eventDispatcher = $this->get('event_dispatcher');
     if (!$this->isGranted('CREATE', $journal, 'pages')) {
         throw new AccessDeniedException("You are not authorized for this page!");
     }
     $entity = new JournalPage();
     $entity->setCurrentLocale($request->getDefaultLocale());
     $form = $this->createCreateForm($entity);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $entity->setJournal($journal);
         $entity->setSlug($entity->getTranslationByLocale($request->getDefaultLocale())->getTitle());
         $em = $this->getDoctrine()->getManager();
         $event = new JournalItemEvent($entity);
         $eventDispatcher->dispatch(JournalPageEvents::PRE_CREATE, $event);
         $em->persist($event->getItem());
         $em->flush();
         $event = new JournalItemEvent($event->getItem());
         $eventDispatcher->dispatch(JournalPageEvents::POST_CREATE, $event);
         if ($event->getResponse()) {
             return $event->getResponse();
         }
         $this->successFlashBag('successful.create');
         return $this->redirectToRoute('ojs_journal_page_show', ['id' => $entity->getId(), 'journalId' => $journal->getId()]);
     }
     return $this->render('OjsJournalBundle:JournalPage:new.html.twig', ['entity' => $entity, 'form' => $form->createView()]);
 }
Exemple #4
0
 /**
  * @return int
  */
 public function loadJournalPage()
 {
     $journal = $this->em->getRepository(Journal::class)->find(1);
     $entity = new JournalPage();
     $entity->setCurrentLocale('tr')->setTitle('Title')->setSlug('title-page')->setBody('Content')->setVisible(true)->setTags('tag')->setJournal($journal);
     $this->em->persist($entity);
     $this->em->flush();
     return $entity->getId();
 }
 public function importAboutPage()
 {
     $page = new JournalPage();
     $page->setJournal($this->journal);
     foreach ($this->settings as $language => $field) {
         $content = '';
         !empty($field['focusScopeDesc']) && ($content .= $field['focusScopeDesc']);
         !empty($field['reviewPolicy']) && ($content .= $field['reviewPolicy']);
         !empty($field['reviewGuidelines']) && ($content .= $field['reviewGuidelines']);
         !empty($field['authorGuidelines']) && ($content .= $field['authorGuidelines']);
         !empty($field['authorInformation']) && ($content .= $field['authorInformation']);
         !empty($field['readerInformation']) && ($content .= $field['readerInformation']);
         !empty($field['librarianInformation']) && ($content .= $field['librarianInformation']);
         !empty($field['authorSelfArchivePolicy']) && ($content .= $field['authorSelfArchivePolicy']);
         !empty($field['publisherNote']) && ($content .= $field['publisherNote']);
         !empty($field['pubFreqPolicy']) && ($content .= $field['pubFreqPolicy']);
         !empty($field['openAccessPolicy']) && ($content .= $field['openAccessPolicy']);
         !empty($field['privacyStatement']) && ($content .= $field['privacyStatement']);
         !empty($field['copyrightNotice']) && ($content .= $field['copyrightNotice']);
         !empty($field['copyeditInstructions']) && ($content .= $field['copyeditInstructions']);
         $page->setCurrentLocale(mb_substr($language, 0, 2, 'UTF-8'));
         $page->setTitle('About');
         $page->setBody($content);
     }
     $this->em->persist($page);
 }
Exemple #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('http://weareonline.com/sample');
     $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();
     $publisher2 = new Publisher();
     $publisher2->setCurrentLocale('en');
     $publisher2->setName('Publisher');
     $publisher2->setSlug('www2');
     $publisher2->setEmail('*****@*****.**');
     $publisher2->setAddress('Address');
     $publisher2->setPhone('+908501234567');
     $publisher2->setVerified(1);
     $publisher2->setStatus(PublisherStatuses::STATUS_ONHOLD);
     $publisher2->setPublisherType($publisherType);
     $em->persist($publisher2);
     $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->setTitle('Introduction to OJS');
     $journal->setSubtitle('How to use OJS');
     $journal->setDescription('A journal about OJS');
     $journal->setTitleAbbr('INTROJS');
     $journal->setCurrentLocale('tr');
     $journal->setTitle('OJS Tanıtım');
     $journal->setPublisher($publisher);
     $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);
     $em->persist($journal);
     $em->flush();
     $this->createDemoFiles();
     $block = new Block();
     $block->setCurrentLocale('en');
     $block->setTitle('Block');
     $block->setBlockOrder(1);
     $block->setColor('success');
     $block->setJournal($journal);
     $em->persist($block);
     $em->flush();
     $design = new Design();
     $design->setCurrentLocale('en');
     $design->setTitle('Design');
     $design->setEditableContent('html{}');
     $design->setContent('html{}');
     $design->setPublic(false);
     $design->setOwner($journal);
     $em->persist($design);
     $em->flush();
     $journalAnnouncement = new JournalAnnouncement();
     $journalAnnouncement->setCurrentLocale($journal->getMandatoryLang()->getCode());
     $journalAnnouncement->setTitle('Announcement');
     $journalAnnouncement->setContent('Content');
     $journalAnnouncement->setJournal($journal);
     $em->persist($journalAnnouncement);
     $em->flush();
     $contactType = $em->getRepository('OjsJournalBundle:ContactTypes')->find(1);
     $contact = new JournalContact();
     $contact->setFullName('Contact');
     $contact->setAddress('Adress');
     $contact->setPhone('05001001010');
     $contact->setEmail('*****@*****.**');
     $contact->setContactType($contactType);
     $contact->setJournal($journal);
     $em->persist($contact);
     $em->flush();
     $index = new Index();
     $index->setName('Index');
     $index->setStatus(1);
     $em->persist($index);
     $em->flush();
     $journalIndex = new JournalIndex();
     $journalIndex->setIndex($index);
     $journalIndex->setLink('http://ojs.io');
     $journalIndex->setJournal($journal);
     $em->persist($journalIndex);
     $em->flush();
     $currentLocale = $this->getContainer()->getParameter('locale');
     $journalPage = new JournalPage();
     $journalPage->setCurrentLocale($currentLocale);
     $journalPage->setTitle('Title');
     $journalPage->setSlug('title-page');
     $journalPage->setBody('Content');
     $journalPage->setVisible(true);
     $journalPage->setTags('tag');
     $journalPage->setJournal($journal);
     $em->persist($journalPage);
     $em->flush();
     $journalPost = new JournalPost();
     $journalPost->setCurrentLocale($currentLocale);
     $journalPost->setTitle('Title');
     $journalPost->setSlug('title-post');
     $journalPost->setContent('Content');
     $journalPost->setJournal($journal);
     $em->persist($journalPost);
     $em->flush();
     $journalTheme = new JournalTheme();
     $journalTheme->setTitle('Title');
     $journalTheme->setCss('html{}');
     $journalTheme->setPublic(true);
     $journalTheme->setJournal($journal);
     $em->persist($journalTheme);
     $em->flush();
     $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();
     $journalSubmissionFile = new JournalSubmissionFile();
     $journalSubmissionFile->setTitle('Journal File');
     $journalSubmissionFile->setDetail('File Detail');
     $journalSubmissionFile->setFile('journalSubmissionFile.txt');
     $journalSubmissionFile->setLocale('en');
     $journalSubmissionFile->setRequired(false);
     $journalSubmissionFile->setVisible(true);
     $journalSubmissionFile->setJournal($journal);
     $journalSubmissionFileHistory = new FileHistory();
     $journalSubmissionFileHistory->setFileName('journalSubmissionFile.txt');
     $journalSubmissionFileHistory->setOriginalName('journalSubmissionFile.txt');
     $journalSubmissionFileHistory->setType('submissionfiles');
     $em->persist($journalSubmissionFile);
     $em->persist($journalSubmissionFileHistory);
     $em->flush();
     $journalFile = new JournalFile();
     $journalFile->setName('Journal File');
     $journalFile->setDescription('Description of Journal');
     $journalFile->setTags('journal, file');
     $journalFile->setPath('journalFile.txt');
     $journalFile->setSize('100');
     $journalFile->setJournal($journal);
     $journalFileHistory = new FileHistory();
     $journalFileHistory->setFileName('journalFile.txt');
     $journalFileHistory->setOriginalName('journalFile.txt');
     $journalFileHistory->setType('files');
     $em->persist($journalFile);
     $em->persist($journalFileHistory);
     $em->flush();
     $adminFile = new AdminFile();
     $adminFile->setName('Admin File');
     $adminFile->setDescription('File Description');
     $adminFile->setPath('admin.txt');
     $adminFile->setSize('100');
     $adminFileHistory = new FileHistory();
     $adminFileHistory->setFileName('admin.txt');
     $adminFileHistory->setOriginalName('admin.txt');
     $adminFileHistory->setType('adminfiles');
     $em->persist($adminFile);
     $em->persist($adminFileHistory);
     $em->flush();
     $journalApplicationFile = new JournalApplicationFile();
     $journalApplicationFile->setTitle('Title');
     $journalApplicationFile->setDetail('Detail');
     $journalApplicationFile->setLocale('en');
     $journalApplicationFile->setVisible(true);
     $journalApplicationFile->setRequired(false);
     $journalApplicationFile->setFile('journalApplication.txt');
     $journalApplicationFileHistory = new FileHistory();
     $journalApplicationFileHistory->setFileName('journalApplication.txt');
     $journalApplicationFileHistory->setOriginalName('journalApplication.txt');
     $journalApplicationFileHistory->setType('submissionfiles');
     $em->persist($journalApplicationFile);
     $em->persist($journalApplicationFileHistory);
     $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->setPublished(true);
     $issue->setVolume(1);
     $issue->setYear(new \DateTime('01-01-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();
     $personTitle = new PersonTitle();
     $personTitle->setCurrentLocale('tr');
     $personTitle->setTitle('Dr.');
     $em->persist($personTitle);
     $em->flush();
     $author = new Author();
     $author->setCurrentLocale('en');
     $author->setTitle($personTitle);
     $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->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();
     $issue->addSection($section);
     $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();
 }