/** * @param Request $request * @return RedirectResponse|Response */ public function journalAction(Request $request) { $allowanceSetting = $this->getDoctrine()->getRepository('OjsAdminBundle:SystemSetting')->findOneBy(['name' => 'journal_application']); if ($allowanceSetting) { if (!$allowanceSetting->getValue()) { return $this->render('OjsSiteBundle:Site:not_available.html.twig', ['title' => 'title.journal_application', 'message' => 'message.application_not_available']); } } $application = new Journal(); $application->setCurrentLocale($request->getDefaultLocale()); $form = $this->createForm(new JournalApplicationType(), $application); if ($request->isMethod('POST')) { $form->handleRequest($request); if ($form->isValid()) { $application->setStatus(0); /** @var JournalContact $contact */ if ($application->getJournalContacts()) { foreach ($application->getJournalContacts() as $contact) { $contact->setJournal($application); } } $em = $this->getDoctrine()->getManager(); $em->persist($application); $em->flush(); return $this->redirect($this->get('router')->generate('ojs_apply_journal_success')); } $session = $this->get('session'); $session->getFlashBag()->add('error', $this->get('translator')->trans('An error has occured. Please check the form and resubmit.')); $session->save(); } return $this->render('OjsSiteBundle:Application:journal.html.twig', array('form' => $form->createView())); }
/** * @param SitemapPopulateEvent $event * @param Journal $journal * @return SitemapPopulateEvent */ private function generateIssueLinks(SitemapPopulateEvent $event, Journal $journal) { $issues = $journal->getIssues(); /** @var Issue $issue */ foreach ($issues as $issue) { $event->getGenerator()->addUrl(new UrlConcrete($this->router->generate('ojs_issue_page', ['publisher' => $journal->getPublisher()->getSlug(), 'journal_slug' => $journal->getSlug(), 'id' => $issue->getId()], true), new \DateTime(), UrlConcrete::CHANGEFREQ_WEEKLY, 1), 'journals-' . $journal->getSlug()); $event = $this->generateArticleLinks($event, $issue); } return $event; }
/** * @param Journal $journal */ private function normalizeSetting(Journal $journal) { $count = $journal->getArticleTypes()->count(); if ($count > 0) { return; } foreach ($this->allArticleTypes as $articleType) { $journal->addArticleType($articleType); } $this->em->persist($journal); }
/** * Send a mail or add to spool, then log to db. * @param Mail $mail * @param Journal $journal * @return integer */ public function send(Mail $mail, Journal $journal) { if (isset($mail->template)) { $mail->templateData = isset($mail->templateData) ? $mail->templateData : array(); $mail->body = $this->templating->render($mail->template, $mail->templateData); } if (!isset($mail->from)) { $mail->from = $this->systemEmail; } if ($journal) { $mail->body .= $journal->getSetting('emailSignature'); } $message = \Swift_Message::newInstance()->setSubject($mail->subject)->setFrom($mail->from)->setTo($mail->to)->setBody($mail->body)->setContentType('text/html'); return $this->mailer->send($message); }
private function getStatsQuery(Journal $journal) { $filter = new Term(); $filter->setTerm('journalUsers.journal.id', $journal->getId()); $filterQuery = new Query\Filtered(); $filterQuery->setFilter($filter); $query = new Query($filterQuery); $titleAggregation = new Terms('title'); $titleAggregation->setField('title'); $query->addAggregation($titleAggregation); $genderAggregation = new Terms('gender'); $genderAggregation->setField('gender'); $query->addAggregation($genderAggregation); $query->setSize(0); return $query; }
private function getStatsQuery(Journal $journal) { $filter = new Term(); $filter->setTerm('journal.id', $journal->getId()); $filterQuery = new Filtered(); $filterQuery->setFilter($filter); $query = new Query($filterQuery); $dateHistogram = new DateHistogram('dateHistogram', 'created', 'month'); $dateHistogram->setFormat("YYYY-MM-dd"); $query->addAggregation($dateHistogram); $genderAggregation = new Terms('language'); $genderAggregation->setField('locale'); $query->addAggregation($genderAggregation); $query->setSize(0); return $query; }
/** * @param Journal $journal * @return bool|null */ private function normalizeLastIssuesByJournal(Journal $journal) { $this->io->newLine(); $this->io->text('normalizing last issue for ' . $journal->getTitle()); $this->io->progressAdvance(); $findLastIssue = $this->em->getRepository('OjsJournalBundle:Issue')->findOneBy(['journal' => $journal, 'lastIssue' => true]); if ($findLastIssue) { return true; } /** @var Issue|null $getLogicalLastIssue */ $getLogicalLastIssue = $this->em->getRepository('OjsJournalBundle:Issue')->getLastIssueByJournal($journal); if ($getLogicalLastIssue == null) { return null; } $getLogicalLastIssue->setLastIssue(true); $this->em->flush(); }
/** * Admin can create new journal. * admin can resume from where he/she left. * @return \Symfony\Component\HttpFoundation\RedirectResponse */ public function indexAction() { $user = $this->getUser(); $em = $this->getDoctrine()->getManager(); $journalCreatePermission = $this->isGranted('CREATE', new Journal()); /** @var Journal $selectedJournal */ $selectedJournal = $this->get("ojs.journal_service")->getSelectedJournal(); $selectedJournalEditPermission = $this->isGranted('EDIT', $selectedJournal); if (!$journalCreatePermission && !$selectedJournalEditPermission) { throw new AccessDeniedException(); } if (!$selectedJournal && !$journalCreatePermission) { throw new NotFoundHttpException(); } $journalSetup = new JournalSetupProgress(); if ($journalCreatePermission) { /** @var JournalSetupProgress $journalSetup */ $journalSetup = $em->getRepository('OjsJournalBundle:JournalSetupProgress')->findOneByUser($user); if (!$journalSetup) { $newJournal = new Journal(); $newJournal->setTitle(''); $newJournal->setTitleAbbr(''); $newJournal->setSetupStatus(false); $em->persist($newJournal); $journalSetup = new JournalSetupProgress(); $journalSetup->setUser($user); $journalSetup->setCurrentStep(1); $journalSetup->setJournal($newJournal); $em->persist($journalSetup); $em->flush(); } } elseif (!$selectedJournal->getSetupStatus()) { /** @var JournalSetupProgress $userSetup */ $journalSetup = $em->getRepository('OjsJournalBundle:JournalSetupProgress')->findOneByJournal($selectedJournal); } elseif ($selectedJournal->getSetupStatus()) { $selectedJournal->setSetupStatus(false); $journalSetup->setUser($user); $journalSetup->setJournal($selectedJournal); $journalSetup->setCurrentStep(1); $em->persist($journalSetup); $em->flush(); } return $this->redirect($this->generateUrl('ojs_journal_setup_resume', ['setupId' => $journalSetup->getId()]) . '#' . $journalSetup->getCurrentStep()); }
/** * Imports contacts of the given journal. * @param Journal $journal The journal whose contacts are going to be imported * @param int $journalId Old ID of the journal * @throws \Doctrine\DBAL\DBALException */ public function importContacts($journal, $journalId) { $this->consoleOutput->writeln("Importing journal's contacts..."); $settingsSql = "SELECT locale, setting_name, setting_value FROM journal_settings WHERE journal_id = :id"; $settingsStatement = $this->dbalConnection->prepare($settingsSql); $settingsStatement->bindValue('id', $journalId); $settingsStatement->execute(); $settings = array(); $pkpSettings = $settingsStatement->fetchAll(); foreach ($pkpSettings as $setting) { $name = $setting['setting_name']; $value = $setting['setting_value']; $settings[$name] = $value; } $contact = new JournalContact(); $contact->setFullName($settings['contactName']); $contact->setEmail($settings['contactEmail']); $contact->setPhone($settings['contactPhone']); $contact->setAddress($settings['contactMailingAddress']); $types = $this->em->getRepository('OjsJournalBundle:ContactTypes')->findAll(); !empty($types) && $contact->setContactType($types[0]); $journal->addJournalContact($contact); }
public function importSubmissionChecklist($languageCode) { $checklist = new SubmissionChecklist(); $checklist->setLabel('Checklist'); $checklist->setLocale(mb_substr($languageCode, 0, 2, 'UTF-8')); $detail = "<ul>"; if (!empty($this->settings[$languageCode]['submissionChecklist'])) { $items = unserialize($this->settings[$languageCode]['submissionChecklist']); if ($items) { foreach ($items as $item) { $detail .= "<li>" . $item['content'] . "</li>"; } } } $detail .= "</ul>"; $checklist->setDetail($detail); $this->journal->addSubmissionChecklist($checklist); }
/** * @param Journal $journal * @return Journal */ private function setupJournalContacts(Journal $journal) { $contactTypeNames = ['Editor', 'Technical Contact', 'Co-Editor']; $em = $this->getDoctrine()->getManager(); $contactTypes = []; foreach ($contactTypeNames as $contactTypeName) { $contactTypeTranslation = $em->getRepository('OjsJournalBundle:ContactTypesTranslation')->findOneBy(['name' => $contactTypeName]); $this->throw404IfNotFound($contactTypeTranslation, 'Not found ' . $contactTypeName . ' type contact type. please create'); $contactTypes[] = $contactTypeTranslation->getTranslatable(); } /** @var ContactTypes $contactType */ foreach ($contactTypes as $contactType) { if (!is_null($contactType)) { $journalContact = new JournalContact(); $journalContact->setContactType($contactType); $journal->addJournalContact($journalContact); } } return $journal; }
/** * @param Journal $formerlyKnownAsJournal * * @return $this */ public function setFormerlyKnownAsJournal($formerlyKnownAsJournal) { $oldFormerlyKnownAsJournal = $this->formerlyKnownAsJournal; $this->formerlyKnownAsJournal = $formerlyKnownAsJournal; if ($formerlyKnownAsJournal instanceof Journal && empty($formerlyKnownAsJournal->getContinuedAsJournal())) { $formerlyKnownAsJournal->setContinuedAsJournal($this); } elseif (empty($formerlyKnownAsJournal) && !empty($oldFormerlyKnownAsJournal)) { $formerlyKnownAsJournal->setContinuedAsJournal(null); } return $this; }
/** * Creates a form to add Member to Board entity. * * @param BoardMember $entity * @param Board $board * @param Journal $journal * @return Form */ private function createAddMemberForm(BoardMember $entity, Board $board, Journal $journal) { $form = $this->createForm(new BoardMemberType(), $entity, array('action' => $this->generateUrl('ojs_journal_board_member_add', array('boardId' => $board->getId(), 'journalId' => $journal->getId())), 'method' => 'PUT')); return $form; }
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); $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(); $slug = $this->getContainer()->getParameter('defaultPublisherSlug'); $publisher = new Publisher(); $publisher->setCurrentLocale('en'); $publisher->setName('OJS'); $publisher->setSlug($slug); $publisher->setVerified(1); $publisher->setStatus(1); $em->persist($publisher); $em->flush(); $subject1 = new Subject(); $subject1->setCurrentLocale('en'); $subject1->setSubject('Computer Science'); $subject2 = new Subject(); $subject2->setCurrentLocale('en'); $subject2->setSubject('Journalism'); $em->persist($subject1); $em->persist($subject2); $em->flush(); $language1 = new Lang(); $language1->setCurrentLocale('en'); $language1->setName('English'); $language1->setCode('en'); $language1->setRtl(0); $language2 = new Lang(); $language2->setCurrentLocale('tr'); $language2->setName('Türkçe'); $language2->setCode('tr'); $language2->setRtl(0); $em->persist($language1); $em->persist($language2); $em->flush(); $articleTypes = ['Research', 'Analysis', 'Clinical Review', 'Practice', 'Research Methods and Reporting', 'Christmas Issue', 'Editorials', 'Blogs', 'Case Reports', 'Letters (rapid responses)', 'Obituaries', 'Personal Views', 'Fillers', 'Minerva Pictures', 'Endgames', 'What Your Patient is Thinking']; foreach ($articleTypes as $typeName) { $type = new ArticleTypes(); $type->setCurrentLocale('en'); $type->setName($typeName); $em->persist($type); } $em->flush(); $contactTypes = ['Journal Contact', 'Primary Contact', 'Technical Contact', 'Author Support', 'Subscription Support', 'Publisher Support', 'Submission Support', 'Advertising', 'Media']; 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->setTitleAbbr('INTROJS'); $journal->setUrl('http://ojs.io'); $journal->setSlug('intro'); $journal->addSubject($subject1); $journal->addSubject($subject2); $journal->setMandatoryLang($language2); $em->persist($journal); $em->flush(); $issue = new Issue(); $issue->setCurrentLocale('en'); $issue->setJournal($journal); $issue->setTitle('First Issue: Hello OJS!'); $issue->setNumber(1); $issue->setVolume(1); $issue->setYear(2015); $issue->setSpecial(1); $issue->setTags('fisrt, guide, tutorial'); $issue->setDatePublished(new \DateTime('now')); $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.'); $em->persist($citation1); $em->flush(); $article1 = new Article(); $article1->setCurrentLocale('en'); $article1->setJournal($journal); $article1->setSection($section); $article1->setIssue($issue); $article1->setTitle('Getting Started with OJS'); $article1->setKeywords('ojs, intro, starting'); $article1->setDoi('10.5281/zenodo.14791'); $article1->setPubdate(new \DateTime('now')); $article1->setIsAnonymous(0); $article1->setFirstPage(1); $article1->setLastPage(5); $article1->setStatus(3); $article1->addCitation($citation1); $em->persist($article1); $em->flush(); }
/** * * @param Journal $journal * @return string */ public function generateUrl(Journal $journal) { return $this->router->generate('ojs_journal_index', array('slug' => $journal->getSlug()), Router::ABSOLUTE_URL); }
/** * @param EventDetail $eventOptions * @param string $lang * @param Journal|null $journal * @param bool $journalDefault * @param bool $useJournalDefault * @param bool $active */ private function createMailTemplateSkeleton(EventDetail $eventOptions, $lang = 'en', Journal $journal = null, $journalDefault = false, $useJournalDefault = true, $active = true) { $this->io->writeln(sprintf('Creating template for -> %s -> %s', $eventOptions->getName(), $journal == null ? 'admin' : $journal->getTitle())); $mailTemplate = new MailTemplate(); $mailTemplate->setActive($active)->setJournal($journal)->setType($eventOptions->getName())->setLang($lang)->setTemplate('')->setUseJournalDefault($useJournalDefault)->setJournalDefault($journalDefault)->setUpdatedBy('cli'); $this->em->persist($mailTemplate); }
/** * * @param Journal $journal * @return string */ public function generateUrl(Journal $journal) { $publisher = $journal->getPublisher(); $publisherSlug = $publisher ? $publisher->getSlug() : $this->defaultPublisherSlug; return $this->router->generate('ojs_journal_index', array('slug' => $journal->getSlug(), 'publisher' => $publisherSlug), Router::ABSOLUTE_URL); }
private function createEditForm(Article $article, Journal $journal, $locales, $defaultLocale) { $event = new TypeEvent(new ArticleSubmissionType()); $this->get('event_dispatcher')->dispatch(ArticleEvents::INIT_SUBMIT_FORM, $event); $form = $this->createForm($event->getType(), $article, array('action' => $this->generateUrl('ojs_journal_submission_edit', array('journalId' => $journal->getId(), 'id' => $article->getId())), 'method' => 'POST', 'locales' => $locales, 'default_locale' => $defaultLocale, 'citationTypes' => array_keys($this->container->getParameter('citation_types'))))->add('save', 'submit', array('label' => 'save', 'attr' => array('class' => 'btn-block'))); return $form; }
/** * Returns an array of article download statistics which can be displayed in a table * * @param array $dates * @param Journal|null $journal * @return array */ public function generateArticleFileDownloadsData($dates = null, Journal $journal = null) { $whereDate = ''; if ($dates) { $today = $dates[0]; $lastMonthToday = end($dates); $whereDate = "AND statistic.date BETWEEN '" . $lastMonthToday . "' AND '" . $today . "' "; } $journalWhereQuery = ' '; if ($journal) { $journalWhereQuery = 'AND article.journal_id = ' . $journal->getId() . ' '; } $sql = "SELECT article_file.title, SUM(statistic.download) as sum_download, article_file.id FROM statistic " . "join article_file on statistic.article_file_id = article_file.id " . "join article on article_file.article_id = article.id " . "WHERE article_file_id IS NOT NULL " . $whereDate . $journalWhereQuery . "group by article_file_id ,article_file.title, article_file.id " . "ORDER BY sum_download DESC " . "LIMIT 20 "; $rsm = new ResultSetMapping(); $rsm->addScalarResult('title', 'title'); $rsm->addScalarResult('sum_download', 'download'); $rsm->addScalarResult('id', 'id'); $query = $this->manager->createNativeQuery($sql, $rsm); $results = $query->getResult(); return $results; }
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(); }
/** * Set journal * @param Journal $journal * @return $this */ public function setJournal(Journal $journal) { $this->journal = $journal; $journal->addArticle($this); return $this; }
/** * @param Design $entity * @param Journal $journal * @return Form */ private function createEditForm(Design $entity, Journal $journal) { $form = $this->createForm(new DesignType(), $entity, array('action' => $this->generateUrl('ojs_journal_design_update', ['journalId' => $journal->getId(), 'id' => $entity->getId()]), 'method' => 'PUT')); $form->add('submit', 'submit', array('label' => 'Update')); return $form; }
/** * * @param Journal $journal * @return array */ public function getVolumes(Journal $journal) { $issues = $journal->getIssues(); $volumes = []; foreach ($issues as $issue) { /* @var $issue Issue */ $volume = $issue->getVolume(); $volumes[$volume]['issues'][] = $issue; $volumes[$volume]['volume'] = $volume; } return $volumes; }
/** * Displays a form to create a new Journal entity. * * @param Request $request * @return Response */ public function newAction(Request $request) { $em = $this->getDoctrine()->getManager(); $defaultCountry = $em->getRepository('BulutYazilimLocationBundle:Country')->find($this->getParameter('country_id')); $entity = new Journal(); $entity->setCountry($defaultCountry); $entity->setCurrentLocale($request->getDefaultLocale()); $form = $this->createCreateForm($entity); return $this->render('OjsAdminBundle:AdminJournal:new.html.twig', array('entity' => $entity, 'form' => $form->createView())); }
/** * Creates a form to create a Section entity. * * @param Section $entity * @param Journal $journal * @return Form */ private function createCreateForm(Section $entity, Journal $journal) { $form = $this->createForm(new SectionType(), $entity, array('action' => $this->generateUrl('ojs_journal_section_create', ['journalId' => $journal->getId()]), 'method' => 'POST')); $form->add('submit', 'submit', array('label' => 'Create')); return $form; }
/** * @param Journal $journal * @return array */ public function journalsArticlesStats(Journal $journal) { $object_view = $this->dm->getRepository('OjsAnalyticsBundle:ObjectViews'); $stats = []; $affetted_articles = []; foreach ($journal->getArticles() as $article) { $articleStats = $object_view->findBy(['entity' => 'article', 'objectId' => $article->getId()]); if (!$articleStats) { continue; } foreach ($articleStats as $stat) { $dateKey = $stat->getLogDate()->format("d-M-Y"); $stats[$dateKey][$article->getId()] = ['hit' => isset($stats[$dateKey][$article->getId()]['hit']) ? $stats[$dateKey][$article->getId()]['hit'] + 1 : 1, 'title' => $article->getTitle()]; } $affetted_articles[] = ['id' => $article->getId(), 'title' => $article->getTitle()]; } foreach ($stats as $date => $stat) { foreach ($affetted_articles as $article) { if (!isset($stats[$date][$article['id']])) { $stats[$date][$article['id']] = ['hit' => 0, 'title' => $article['title']]; } } } ksort($stats); return ['stats' => $stats, 'articles' => $affetted_articles]; }
/** * Check ban status * @param User $user * @param Journal $journal * @return bool */ public function checkUserPermit(User $user, Journal $journal) { return $journal->getBannedUsers()->contains($user) ? false : true; }
/** * Displays a form to create a new Journal entity. * * @return Response */ public function newAction(Request $request) { $entity = new Journal(); $entity->setCurrentLocale($request->getDefaultLocale()); $form = $this->createCreateForm($entity); return $this->render('OjsAdminBundle:AdminJournal:new.html.twig', array('entity' => $entity, 'form' => $form->createView())); }
/** * Creates a form to edit a ArticleFile entity. * @param ArticleFile $entity The entity * @param Journal $journal * @param Article $article * @return Form The form */ private function createEditForm(ArticleFile $entity, Journal $journal, Article $article) { $form = $this->createForm(new ArticleFileType(), $entity, ['action' => $this->generateUrl('ojs_journal_article_file_update', ['id' => $entity->getId(), 'journalId' => $journal->getId(), 'articleId' => $article->getId()]), 'method' => 'PUT']); return $form; }
public function journalBlocks(Journal $journal) { return $this->findBy(['objectType' => 'journal', 'objectId' => $journal->getId()], ['block_order' => 'asc']); }