getDefaultLocale() public method

Get the default locale.
public getDefaultLocale ( ) : string
return string
 /**
  * Finds and displays a Users of a Journal with roles
  *
  * @param  Request  $request
  * @return Response
  */
 public function indexAction(Request $request)
 {
     $journal = $this->get('ojs.journal_service')->getSelectedJournal();
     $eventDispatcher = $this->get('event_dispatcher');
     if (!$this->isGranted('VIEW', $journal, 'userRole')) {
         throw new AccessDeniedException("You are not authorized for view this page");
     }
     $source = new Entity('OjsJournalBundle:JournalUser');
     $source->manipulateRow(function (Row $row) use($request) {
         /* @var JournalUser $entity */
         $entity = $row->getEntity();
         if (!is_null($entity)) {
             $entity->getJournal()->setDefaultLocale($request->getDefaultLocale());
             if (!is_null($entity)) {
                 $row->setField('journal', $entity->getJournal()->getTitle());
             }
         }
         return $row;
     });
     $grid = $this->get('grid');
     $grid->setSource($source);
     $gridAction = $this->get('grid_action');
     $rowAction = [];
     $rowAction[] = $gridAction->editAction('ojs_journal_user_edit', ['journalId' => $journal->getId(), 'id']);
     $rowAction[] = $gridAction->deleteAction('ojs_journal_user_delete', ['journalId' => $journal->getId(), 'id']);
     $actionColumn = new ActionsColumn("actions", "actions");
     $actionColumn->setRowActions($rowAction);
     $grid->addColumn($actionColumn);
     $listEvent = new ListEvent();
     $listEvent->setGrid($grid);
     $eventDispatcher->dispatch(JournalUserEvents::LISTED, $listEvent);
     $grid = $listEvent->getGrid();
     return $grid->getGridResponse('OjsJournalBundle:JournalUser:index.html.twig');
 }
Beispiel #2
0
 /**
  * Lists all article entities for journal
  *
  * @param  Request  $request
  * @return Response
  */
 public function indexAction(Request $request)
 {
     $journal = $this->get('ojs.journal_service')->getSelectedJournal();
     $this->throw404IfNotFound($journal);
     if (!$this->isGranted('VIEW', $journal, 'articles')) {
         throw new AccessDeniedException("You not authorized for this page!");
     }
     $source = new Entity('OjsJournalBundle:Article');
     $source->manipulateRow(function (Row $row) use($request) {
         /** @var Article $entity */
         $entity = $row->getEntity();
         $entity->setDefaultLocale($request->getDefaultLocale());
         if (!is_null($entity)) {
             $row->setField('title', $entity->getTitle());
             if (!is_null($entity->getIssue())) {
                 $row->setField('issue', $entity->getIssue()->getTitle());
             }
         }
         return $row;
     });
     $grid = $this->get('grid')->setSource($source);
     $gridAction = $this->get('grid_action');
     $actionColumn = new ActionsColumn("actions", 'actions');
     $rowAction[] = $gridAction->showAction('ojs_journal_article_show', ['id', 'journalId' => $journal->getId()]);
     $rowAction[] = $gridAction->editAction('ojs_journal_article_edit', ['id', 'journalId' => $journal->getId()]);
     $rowAction[] = $gridAction->deleteAction('ojs_journal_article_delete', ['id', 'journalId' => $journal->getId()]);
     $actionColumn->setRowActions($rowAction);
     $grid->addColumn($actionColumn);
     return $grid->getGridResponse('OjsJournalBundle:Article:index.html.twig', ['journal' => $journal]);
 }
 /**
  * @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()));
 }
 public function indexAction(Request $request)
 {
     $data = array();
     $source = new Entity('OjsJournalBundle:Journal');
     $source->manipulateRow(function (Row $row) use($request) {
         /* @var Journal $entity */
         $entity = $row->getEntity();
         $entity->setDefaultLocale($request->getDefaultLocale());
         if (!is_null($entity)) {
             $row->setField('title', $entity->getTitle());
         }
         return $row;
     });
     $alias = $source->getTableAlias();
     $source->manipulateQuery(function (QueryBuilder $query) use($alias) {
         $query->andWhere($alias . '.status = :status')->setParameter('status', '0');
         return $query;
     });
     $grid = $this->get('grid')->setSource($source);
     $gridAction = $this->get('grid_action');
     $rowAction = array();
     $rowAction[] = $gridAction->editAction('ojs_admin_application_journal_edit', 'id');
     $rowAction[] = $gridAction->showAction('ojs_admin_application_journal_show', 'id');
     $rowAction[] = $gridAction->deleteAction('ojs_admin_application_journal_delete', 'id');
     $actionColumn = new ActionsColumn("actions", 'actions');
     $actionColumn->setRowActions($rowAction);
     $grid->addColumn($actionColumn);
     $data['grid'] = $grid;
     return $grid->getGridResponse('OjsAdminBundle:AdminApplication:journal.html.twig', $data);
 }
 /**
  * Lists all Period entities.
  *
  * @param Request $request
  * @return Response
  */
 public function indexAction(Request $request)
 {
     if (!$this->isGranted('VIEW', new Period())) {
         throw new AccessDeniedException("You are not authorized for view this page");
     }
     $source = new Entity('OjsJournalBundle:Period');
     $source->manipulateRow(function (Row $row) use($request) {
         /* @var Journal $entity */
         $entity = $row->getEntity();
         $entity->setDefaultLocale($request->getDefaultLocale());
         if (!is_null($entity)) {
             $row->setField('period', $entity->getPeriod());
         }
         return $row;
     });
     $grid = $this->get('grid')->setSource($source);
     $gridAction = $this->get('grid_action');
     $actionColumn = new ActionsColumn("actions", 'actions');
     $rowAction[] = $gridAction->showAction('ojs_admin_period_show', 'id');
     $rowAction[] = $gridAction->editAction('ojs_admin_period_edit', 'id');
     $rowAction[] = $gridAction->deleteAction('ojs_admin_period_delete', 'id');
     $actionColumn->setRowActions($rowAction);
     $grid->addColumn($actionColumn);
     $data = [];
     $data['grid'] = $grid;
     return $grid->getGridResponse('OjsAdminBundle:AdminPeriod:index.html.twig', $data);
 }
 /**
  * Lists all ArticleAuthor entities.
  *
  * @param  Integer  $articleId
  * @return Response
  */
 public function indexAction($articleId, Request $request)
 {
     $journal = $this->get('ojs.journal_service')->getSelectedJournal();
     $article = $this->getDoctrine()->getRepository('OjsJournalBundle:Article')->find($articleId);
     $this->throw404IfNotFound($article);
     if (!$this->isGranted('VIEW', $journal, 'articles')) {
         throw new AccessDeniedException("You not authorized for this page!");
     }
     $source = new Entity('OjsJournalBundle:ArticleAuthor');
     $source->manipulateRow(function (Row $row) use($request) {
         /* @var ArticleAuthor $entity */
         $entity = $row->getEntity();
         if (!is_null($entity)) {
             $entity->getArticle()->setDefaultLocale($request->getDefaultLocale());
             $row->setField('article', $entity->getArticle()->getTitle());
         }
         return $row;
     });
     $tableAlias = $source->getTableAlias();
     $source->manipulateQuery(function (QueryBuilder $qb) use($article, $tableAlias) {
         return $qb->where($tableAlias . '.article = :article')->setParameter('article', $article);
     });
     $grid = $this->get('grid')->setSource($source);
     $gridAction = $this->get('grid_action');
     $actionColumn = new ActionsColumn("actions", 'actions');
     $rowAction[] = $gridAction->showAction('ojs_journal_article_author_show', ['id', 'journalId' => $journal->getId(), 'articleId' => $articleId]);
     $rowAction[] = $gridAction->editAction('ojs_journal_article_author_edit', ['id', 'journalId' => $journal->getId(), 'articleId' => $articleId]);
     $rowAction[] = $gridAction->deleteAction('ojs_journal_article_author_delete', ['id', 'journalId' => $journal->getId(), 'articleId' => $articleId]);
     $actionColumn->setRowActions($rowAction);
     $grid->addColumn($actionColumn);
     $data = [];
     $data['grid'] = $grid;
     $data['article'] = $article;
     return $grid->getGridResponse('OjsJournalBundle:ArticleAuthor:index.html.twig', $data);
 }
 /**
  * This route decides wheater a request has a missing locale or it is a missing page
  *
  * @param Request $request
  *
  * @return Response
  */
 public function localeRedirectAction(Request $request)
 {
     $requestUri = $request->getRequestUri();
     $explodedUri = explode('/', $requestUri);
     $doubleSlash = substr($requestUri, 0, 2) === '//';
     if (!$doubleSlash) {
         // does not start with 2 slashes
         if (strlen($explodedUri[1]) !== 2) {
             // no locale supplied
             $matchingRoute = $this->get('router')->match("/" . $requestUri);
         } else {
             // 404
             throw $this->createNotFoundException();
         }
     } else {
         $requestUri = substr($requestUri, 2);
         // Removed first 2 slashes
         $locale = empty($request->getLocale()) ? $request->getDefaultLocale() : mb_substr($request->getLocale(), 0, 2);
         $requestUri = '/' . $locale . '/' . $requestUri;
         $matchingRoute = $this->get('router')->match($requestUri);
     }
     if ($matchingRoute['_controller'] === 'Ashura\\OptionalLocaleBundle\\Controller\\DefaultController::localeRedirectAction') {
         throw $this->createNotFoundException();
     }
     return $this->forward($matchingRoute['_controller']);
 }
 /**
  * Lists all JournalIndex entities.
  *
  * @param Request $request
  * @return Response
  */
 public function indexAction(Request $request)
 {
     $journal = $this->get('ojs.journal_service')->getSelectedJournal();
     if (!$this->isGranted('VIEW', $journal, 'index')) {
         throw new AccessDeniedException("You are not authorized for view this page!");
     }
     $source = new Entity('OjsJournalBundle:JournalIndex');
     $source->manipulateRow(function (Row $row) use($request) {
         /* @var JournalIndex $entity */
         $entity = $row->getEntity();
         $entity->getJournal()->setDefaultLocale($request->getDefaultLocale());
         return $row;
     });
     $grid = $this->get('grid')->setSource($source);
     $gridAction = $this->get('grid_action');
     $actionColumn = new ActionsColumn("actions", 'actions');
     $rowAction[] = $gridAction->showAction('ojs_journal_index_show', ['id', 'journalId' => $journal->getId()]);
     $rowAction[] = $gridAction->editAction('ojs_journal_index_edit', ['id', 'journalId' => $journal->getId()]);
     $rowAction[] = $gridAction->deleteAction('ojs_journal_index_delete', ['id', 'journalId' => $journal->getId()]);
     $actionColumn->setRowActions($rowAction);
     $grid->addColumn($actionColumn);
     $data = [];
     $data['grid'] = $grid;
     return $grid->getGridResponse('OjsJournalBundle:JournalIndex:index.html.twig', $data);
 }
 public function indexAction(Request $request)
 {
     $data = array();
     $source = new Entity('OjsJournalBundle:Journal');
     $source->manipulateRow(function (Row $row) use($request) {
         /* @var Journal $entity */
         $entity = $row->getEntity();
         $entity->setDefaultLocale($request->getDefaultLocale());
         if (!is_null($entity)) {
             $row->setField('title', $entity->getTitle());
         }
         return $row;
     });
     $alias = $source->getTableAlias();
     $source->manipulateQuery(function (QueryBuilder $query) use($alias) {
         $query->andWhere($alias . '.status = :status')->setParameter('status', JournalStatuses::STATUS_PREPARING);
         return $query;
     });
     $grid = $this->get('grid')->setSource($source);
     $gridAction = $this->get('grid_action');
     $saveAction = new RowAction('<i class="fa fa-save"></i>', 'ojs_admin_application_journal_save');
     $saveAction->setRouteParameters(['id']);
     $saveAction->setAttributes(['class' => 'btn btn-primary btn-xs', 'title' => $this->get('translator')->trans('journal.merge_as_new_journal')]);
     $rowAction = array();
     $rowAction[] = $saveAction;
     $rowAction[] = $gridAction->editAction('ojs_admin_application_journal_edit', 'id');
     $rowAction[] = $gridAction->showAction('ojs_admin_application_journal_show', 'id');
     $rowAction[] = $gridAction->deleteAction('ojs_admin_application_journal_delete', 'id');
     $actionColumn = new ActionsColumn("actions", 'actions');
     $actionColumn->setRowActions($rowAction);
     $grid->addColumn($actionColumn);
     $data['grid'] = $grid;
     return $grid->getGridResponse('OjsAdminBundle:AdminApplication:journal.html.twig', $data);
 }
Beispiel #10
0
 /**
  * Lists all Design entities.
  *
  * @param Request $request
  * @return Response
  */
 public function indexAction(Request $request)
 {
     $journal = $this->get('ojs.journal_service')->getSelectedJournal();
     if (!$this->isGranted('VIEW', $journal, 'design')) {
         throw new AccessDeniedException("You are not authorized for view this journal's designs!");
     }
     $source = new Entity('OjsJournalBundle:Design');
     $tableAlias = $source->getTableAlias();
     $source->manipulateQuery(function ($query) use($tableAlias, $journal) {
         $query->andWhere($tableAlias . '.owner = :journal')->setParameter('journal', $journal);
     });
     $source->manipulateRow(function (Row $row) use($request) {
         /* @var Design $entity */
         $entity = $row->getEntity();
         if (!is_null($entity)) {
             $entity->getOwner()->setDefaultLocale($request->getDefaultLocale());
             $row->setField('owner', $entity->getOwner()->getTitle());
         }
         return $row;
     });
     $grid = $this->get('grid')->setSource($source);
     $gridAction = $this->get('grid_action');
     $actionColumn = new ActionsColumn("actions", 'actions');
     $rowAction[] = $gridAction->showAction('ojs_journal_design_show', ['id', 'journalId' => $journal->getId()]);
     $rowAction[] = $gridAction->editAction('ojs_journal_design_edit', ['id', 'journalId' => $journal->getId()]);
     $rowAction[] = $gridAction->deleteAction('ojs_journal_design_delete', ['id', 'journalId' => $journal->getId()]);
     $actionColumn->setRowActions($rowAction);
     $grid->addColumn($actionColumn);
     $data = [];
     $data['grid'] = $grid;
     return $grid->getGridResponse('OjsJournalBundle:Design:index.html.twig', $data);
 }
 private function setLocale(Request $request)
 {
     try {
         $this->translator->setLocale($request->getLocale());
     } catch (\InvalidArgumentException $e) {
         $this->translator->setLocale($request->getDefaultLocale());
     }
 }
 /**
  * Displays a form to create a new JournalPost entity.
  *
  * @param Request $request
  * @return Response
  */
 public function newAction(Request $request)
 {
     $journal = $this->get('ojs.journal_service')->getSelectedJournal();
     if (!$this->isGranted('CREATE', $journal, 'posts')) {
         throw new AccessDeniedException("You are not authorized for this post!");
     }
     $entity = new JournalPost();
     $entity->setCurrentLocale($request->getDefaultLocale());
     $form = $this->createCreateForm($entity);
     return $this->render('OjsJournalBundle:JournalPost:new.html.twig', ['entity' => $entity, 'form' => $form->createView()]);
 }
Beispiel #13
0
 /**
  * @param $object
  * @param $field
  * @return mixed
  */
 public function getTranslationsFields($object, $field)
 {
     if ($this->objectTranslations[$object->getId()]->count() > 0) {
         return $this->getCurrentTranslation($object, $field);
     }
     $repoTranslation = $this->em->getRepository('Gedmo\\Translatable\\Entity\\Translation');
     $languages = array_merge($this->request->getLanguages(), [$this->request->getDefaultLocale()]);
     $elements = $repoTranslation->findBy(['foreignKey' => $object->getId(), 'objectClass' => get_class($object), 'locale' => $languages]);
     foreach ($elements as $element) {
         $this->objectTranslations[$object->getId()]->add($element);
     }
     return $this->getCurrentTranslation($object, $field);
 }
Beispiel #14
0
 /**
  * Lists all article entities for journal
  *
  * @param  Request  $request
  * @return Response
  */
 public function indexAction(Request $request)
 {
     $eventDispatcher = $this->get('event_dispatcher');
     $journal = $this->get('ojs.journal_service')->getSelectedJournal();
     $this->throw404IfNotFound($journal);
     $translator = $this->get('translator');
     if (!$this->isGranted('VIEW', $journal, 'articles')) {
         throw new AccessDeniedException("You not authorized for this page!");
     }
     $source = new Entity('OjsJournalBundle:Article');
     $source->manipulateRow(function (Row $row) use($request, $translator) {
         /** @var Article $entity */
         $entity = $row->getEntity();
         if (!is_null($entity)) {
             $entity->setDefaultLocale($request->getDefaultLocale());
             $doi = $entity->getDoi();
             if ($doi !== null) {
                 $row->setField('title', $entity->getTitle() . ' / ' . $doi);
             } else {
                 $row->setField('title', $entity->getTitle());
             }
             $row->setField('status', $translator->trans(Article::$statuses[$entity->getStatus()]));
             if (!is_null($entity->getIssue())) {
                 $row->setField('issue', $entity->getIssue()->getTitle());
             }
         }
         return $row;
     });
     $grid = $this->get('grid')->setSource($source);
     $gridAction = $this->get('grid_action');
     $actionColumn = new ActionsColumn("actions", 'actions');
     $rowAction[] = $gridAction->showAction('ojs_journal_article_show', ['id', 'journalId' => $journal->getId()]);
     $rowAction[] = $gridAction->editAction('ojs_journal_article_edit', ['id', 'journalId' => $journal->getId()]);
     $rowAction[] = $gridAction->deleteAction('ojs_journal_article_delete', ['id', 'journalId' => $journal->getId()]);
     $actionColumn->setRowActions($rowAction);
     $grid->addColumn($actionColumn);
     $grid->getColumn('numerator')->manipulateRenderCell(function ($value, $row, $router) use($journal) {
         if ($journal->getTitleAbbr() !== null) {
             return $journal->getTitleAbbr() . '.' . $value;
         } else {
             return $journal->getSlug() . '.' . $value;
         }
     });
     $listEvent = new ListEvent();
     $listEvent->setGrid($grid);
     $eventDispatcher->dispatch(ArticleEvents::LISTED, $listEvent);
     $grid = $listEvent->getGrid();
     return $grid->getGridResponse('OjsJournalBundle:Article:index.html.twig');
 }
Beispiel #15
0
 /**
  * Creates a new Page entity.
  *
  * @param  Request $request
  * @return RedirectResponse|Response
  */
 public function createAction(Request $request)
 {
     $entity = new AdminPage();
     $entity->setCurrentLocale($request->getDefaultLocale());
     $form = $this->createCreateForm($entity);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $entity->setSlug($entity->getTranslationByLocale($request->getDefaultLocale())->getTitle());
         $em = $this->getDoctrine()->getManager();
         $em->persist($entity);
         $em->flush();
         $this->successFlashBag('successful.create');
         return $this->redirectToRoute('ojs_admin_page_show', ['id' => $entity->getId()]);
     }
     return $this->render('OjsAdminBundle:AdminPage:new.html.twig', ['entity' => $entity, 'form' => $form->createView()]);
 }
 /**
  * Get the context (locale and scope) from the datagrid
  *
  * @throws \LogicException If datasource is not a ProductDatasource
  *
  * @return string[] Returns [] || ['locale' => 'en_US', 'scope' => 'mobile']
  */
 protected function getContextParameters()
 {
     $datagridName = $this->request->get('gridName');
     $datagrid = $this->datagridManager->getDatagrid($datagridName);
     $dataSource = $datagrid->getDatasource();
     if (!$dataSource instanceof ProductDatasource) {
         throw new \LogicException('getContextParameters is only implemented for ProductDatasource');
     }
     $user = $this->getUser();
     $dataSourceParams = $dataSource->getParameters();
     $contextParams = [];
     if (is_array($dataSourceParams)) {
         $contextParams = ['locale' => $dataSourceParams['dataLocale'], 'scope' => $dataSourceParams['scopeCode'], 'ui_locale' => null !== $user ? $user->getUiLocale()->getCode() : $this->request->getDefaultLocale()];
     }
     return $contextParams;
 }
Beispiel #17
0
 public function indexAction($entity, $page, Request $request)
 {
     $request->getSession()->set('_locale', $request->getDefaultLocale());
     $entitiesParams = $this->container->getParameter('skcms_admin.entities');
     //        die(print_r($entitiesParams,true));
     $entityParams = $entitiesParams[$entity];
     $em = $this->getDoctrine()->getManager();
     $repo = $em->getRepository($entityParams['class']);
     //        $repo->setDefaultLocale($this->getRequest()->getLocale());
     $entities = $repo->findAll($request->getLocale());
     if ($entityParams['uniqueEntity']) {
         $id = count($entities) ? $entities[0]->getId() : null;
         return $this->redirectToRoute('sk_admin_edit', ['entity' => $entity, 'id' => $id]);
     }
     //        //dump($this->getRequest()->getLocale());
     //        die();
     return $this->render('SKCMSAdminBundle:Page:list.html.twig', ['entityParams' => $entityParams, 'entities' => $entities]);
 }
Beispiel #18
0
 /**
  * Creates a new Publisher entity.
  *
  * @param  Request                   $request
  * @return RedirectResponse|Response
  */
 public function createAction(Request $request)
 {
     /** @var $dispatcher EventDispatcherInterface */
     $dispatcher = $this->get('event_dispatcher');
     $entity = new Publisher();
     $entity->setCurrentLocale($request->getDefaultLocale());
     $form = $this->createCreateForm($entity);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->persist($entity);
         $em->flush();
         $this->successFlashBag('successful.create');
         $event = new AdminEvent(['eventType' => 'create', 'entity' => $entity]);
         $dispatcher->dispatch(AdminEvents::PUBLISHER_CHANGE, $event);
         return $this->redirectToRoute('ojs_admin_publisher_show', ['id' => $entity->getId()]);
     }
     return $this->render('OjsAdminBundle:AdminPublisher:new.html.twig', array('entity' => $entity, 'form' => $form->createView()));
 }
 /**
  * Finds and displays a PublisherTypes entity.
  *
  * @param Request $request
  * @param PublisherTypes $entity
  * @return Response
  */
 public function showAction(Request $request, PublisherTypes $entity)
 {
     $this->throw404IfNotFound($entity);
     if (!$this->isGranted('VIEW', $entity)) {
         throw new AccessDeniedException("You are not authorized for this page!");
     }
     $entity->setDefaultLocale($request->getDefaultLocale());
     $token = $this->get('security.csrf.token_manager')->refreshToken('ojs_admin_publisher_type' . $entity->getId());
     return $this->render('OjsAdminBundle:AdminPublisherType:show.html.twig', ['entity' => $entity, 'token' => $token]);
 }
 /**
  * Finds and displays a JournalContact entity.
  *
  * @param  Request $request
  * @param  int $id
  * @return Response
  */
 public function showAction(Request $request, $id)
 {
     $em = $this->getDoctrine()->getManager();
     /** @var JournalContact $entity */
     $entity = $em->getRepository('OjsJournalBundle:JournalContact')->findOneBy(['id' => $id]);
     $this->throw404IfNotFound($entity);
     if (!$this->isGranted('VIEW', $entity)) {
         throw new AccessDeniedException("You are not authorized for view this page!");
     }
     $entity->setDefaultLocale($request->getDefaultLocale());
     $token = $this->get('security.csrf.token_manager')->refreshToken('ojs_admin_contact' . $entity->getId());
     return $this->render('OjsAdminBundle:AdminContact:show.html.twig', array('entity' => $entity, 'token' => $token));
 }
 /**
  * Lists all new Article submissions entities.
  *
  * @param  Request                   $request
  * @param  bool                      $all
  * @return RedirectResponse|Response
  */
 public function indexAction(Request $request, $all = false)
 {
     $translator = $this->get('translator');
     /** @var Journal $currentJournal */
     $currentJournal = $this->get('ojs.journal_service')->getSelectedJournal();
     if ($all && !$this->isGranted('VIEW', $currentJournal, 'articles') || !$all && !$this->isGranted('CREATE', $currentJournal, 'articles')) {
         return $this->redirect($this->generateUrl('ojs_user_index'));
     }
     $user = $this->getUser();
     $source1 = new Entity('OjsJournalBundle:Article', 'submission');
     $source2 = new Entity('OjsJournalBundle:Article', 'submission');
     $source1TableAlias = $source1->getTableAlias();
     $source2TableAlias = $source2->getTableAlias();
     $source1->manipulateQuery(function (QueryBuilder $qb) use($source1TableAlias, $user, $currentJournal, $all) {
         $qb->andWhere($source1TableAlias . '.status IN (:notDraftStatuses)')->setParameter('notDraftStatuses', [ArticleStatuses::STATUS_REJECTED, ArticleStatuses::STATUS_UNPUBLISHED, ArticleStatuses::STATUS_INREVIEW, ArticleStatuses::STATUS_PUBLISHED]);
         if (!$all) {
             $qb->andWhere($source1TableAlias . '.submitterUser = :user')->setParameter('user', $user);
         }
         return $qb;
     });
     $source2->manipulateQuery(function (QueryBuilder $qb) use($source2TableAlias, $user, $currentJournal, $all) {
         $qb->andWhere($source2TableAlias . '.status = :status')->setParameter('status', ArticleStatuses::STATUS_NOT_SUBMITTED);
         if (!$all) {
             $qb->andWhere($source2TableAlias . '.submitterUser = :user')->setParameter('user', $user);
         }
     });
     $gridManager = $this->get('grid.manager');
     $submissionsGrid = $gridManager->createGrid('submission');
     $drafts = $gridManager->createGrid('drafts');
     $source1->manipulateRow(function (Row $row) use($translator, $currentJournal) {
         /** @var Article $entity */
         $entity = $row->getEntity();
         $entity->setDefaultLocale($currentJournal->getMandatoryLang()->getCode());
         $row->setField('status', $translator->trans($entity->getStatusText()));
         $row->setField('title', $entity->getTitle());
         return $row;
     });
     $source2->manipulateRow(function (Row $row) use($translator, $request) {
         $entity = $row->getEntity();
         /** @var Article $entity */
         $entity->setDefaultLocale($request->getDefaultLocale());
         $row->setField('status', $translator->trans($entity->getStatusText()));
         $row->setField('title', $entity->getTitle());
         return $row;
     });
     $submissionsGrid->setSource($source1);
     $drafts->setSource($source2);
     /** @var GridAction $gridAction */
     $gridAction = $this->get('grid_action');
     $rowAction = [];
     $actionColumn = new ActionsColumn("actions", 'actions');
     $rowAction[] = $gridAction->submissionResumeAction('ojs_journal_submission_edit', ['journalId' => $currentJournal->getId(), 'id']);
     $rowAction[] = $gridAction->submissionCancelAction('ojs_journal_submission_cancel', ['journalId' => $currentJournal->getId(), 'id']);
     $actionColumn->setRowActions($rowAction);
     $drafts->addColumn($actionColumn);
     $data = ['page' => 'submission', 'submissions' => $submissionsGrid, 'drafts' => $drafts, 'all' => $all];
     return $gridManager->getGridManagerResponse('OjsJournalBundle:ArticleSubmission:index.html.twig', $data);
 }
Beispiel #22
0
 /**
  * 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);
         $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()]);
 }
 /**
  * @param  Request $request
  * @return JsonResponse|Response
  */
 private function step3Control(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $submissionId = $request->get("submissionId");
     /** @var ArticleSubmissionProgress $articleSubmission */
     $articleSubmission = $em->getRepository('OjsJournalBundle:ArticleSubmissionProgress')->find($submissionId);
     $this->throw404IfNotFound($articleSubmission);
     $article = $articleSubmission->getArticle();
     $authorsData = json_decode($request->request->get('authorsData'));
     $articleAuthors = $em->getRepository('OjsJournalBundle:ArticleAuthor')->findByArticle($article);
     $authorIds = [];
     if (empty($authorsData)) {
         return new Response('Missing argument', 400);
     }
     $count_author_data = count($authorsData);
     for ($i = 0; $i < $count_author_data; $i++) {
         if (empty($authorsData[$i]->firstName)) {
             unset($authorsData[$i]);
         } else {
             $authorData = $authorsData[$i];
             if (empty($authorData->authorid)) {
                 $author = new Author();
                 $articleAuthor = new ArticleAuthor();
             } else {
                 $authorIds[] = $authorData->authorid;
                 $author = $em->getRepository('OjsJournalBundle:Author')->find($authorData->authorid);
                 $articleAuthor = $em->getRepository('OjsJournalBundle:ArticleAuthor')->findOneBy(['article' => $article, 'author' => $author]);
             }
             $author->setFirstName($authorData->firstName);
             $author->setEmail($authorData->email);
             $author->setTitle($authorData->title);
             $author->setInitials($authorData->initials);
             $author->setMiddleName($authorData->middleName);
             $author->setLastName($authorData->lastName);
             $author->setPhone($authorData->phone);
             $author->setSummary($authorData->summary);
             $author->setOrcid($authorData->orcid);
             $author->setTranslatableLocale($request->getDefaultLocale());
             if (!empty($authorData->institution)) {
                 /** @var Institution $institution */
                 $institution = $em->getRepository('OjsJournalBundle:Institution')->find($authorData->institution);
                 $author->setInstitution($institution);
             }
             $em->persist($author);
             $articleAuthor->setArticle($article);
             $articleAuthor->setAuthor($author);
             $articleAuthor->setAuthorOrder($authorData->order);
             $em->persist($articleAuthor);
             $em->flush();
             $em->clear();
         }
     }
     //remove removed authors
     /** @var ArticleAuthor $articleAuthor */
     foreach ($articleAuthors as $articleAuthor) {
         if (!in_array($articleAuthor->getAuthorId(), $authorIds)) {
             $em->remove($articleAuthor);
         }
     }
     $articleSubmission->setCurrentStep(4);
     $em->flush();
     $em->clear();
     return new JsonResponse(['success' => 1]);
 }
 private function getNews($newsList, Request $request)
 {
     $locale = $request->getLocale();
     $defaultLocale = $request->getDefaultLocale();
     $newsForLocale = array();
     foreach ($newsList as $news) {
         if (array_key_exists($locale, $news)) {
             $newsForLocale[] = $news[$locale];
         } elseif (array_key_exists($defaultLocale, $news)) {
             $newsForLocale[] = $news[$defaultLocale];
         }
     }
     return $newsForLocale;
 }
Beispiel #25
0
 /**
  * @param  Request $request
  * @return RedirectResponse|Response
  */
 public function journalAction(Request $request)
 {
     /** @var $dispatcher EventDispatcherInterface */
     $dispatcher = $this->get('event_dispatcher');
     $em = $this->getDoctrine()->getManager();
     $journalApplicationFiles = $em->getRepository('OjsJournalBundle:JournalApplicationFile')->findBy(['visible' => true, 'locale' => $request->getLocale()]);
     if (!$request->attributes->get('_system_setting')->isJournalApplicationActive()) {
         return $this->render('OjsSiteBundle:Site:not_available.html.twig', ['title' => 'title.journal_application', 'message' => 'message.application_not_available']);
     }
     $application = new Journal();
     $application = $this->setupJournalContacts($application);
     $defaultCountryId = $this->container->getParameter('country_id');
     $defaultCountry = $em->getRepository('BulutYazilimLocationBundle:Country')->find($defaultCountryId);
     $application->setCountry($defaultCountry);
     $application->setCurrentLocale($request->getDefaultLocale());
     foreach ($journalApplicationFiles as $applicationFile) {
         $uploadFileEntity = new JournalApplicationUploadFile();
         $application->addJournalApplicationUploadFile($uploadFileEntity);
     }
     $newPublisher = new Publisher();
     $newPublisher->setCurrentLocale($request->getDefaultLocale());
     $event = new TypeEvent(new JournalApplicationType());
     $dispatcher->dispatch(JournalEvents::INIT_APPLICATION_FORM, $event);
     $form = $this->createForm($event->getType(), $application);
     $publisherForm = $this->createForm(new MinimalPublisherType(), $newPublisher);
     if ($request->isMethod('POST')) {
         $form->handleRequest($request);
         $publisherForm->handleRequest($request);
         $publisherFormIsOk = !$publisherForm->isSubmitted() || $publisherForm->isValid();
         if ($form->isValid() && $form->isSubmitted() && $publisherFormIsOk) {
             if ($publisherForm->isSubmitted()) {
                 $application->setPublisher($newPublisher);
                 $em->persist($newPublisher);
             }
             $application->setStatus(JournalStatuses::STATUS_APPLICATION);
             $application->getCurrentTranslation()->setLocale($application->getMandatoryLang()->getCode());
             /** @var JournalContact $contact */
             if ($application->getJournalContacts()) {
                 $journalDefaultContacts = $this->setupJournalContacts(new Journal());
                 foreach ($application->getJournalContacts() as $contactKey => $contact) {
                     $contact->setContactType($journalDefaultContacts->getJournalContacts()[$contactKey]->getContactType());
                     $contact->setJournal($application);
                     $em->persist($contact);
                 }
             }
             //setup journal application files
             /** @var JournalApplicationUploadFile $submissionFile */
             foreach ($application->getJournalApplicationUploadFiles() as $fileKey => $submissionFile) {
                 if (empty($submissionFile->getFile()) && $journalApplicationFiles[$fileKey]->getRequired()) {
                     $this->errorFlashBag('please.install.required.files');
                     return $this->render('OjsSiteBundle:Application:journal.html.twig', ['publisherForm' => $publisherForm->createView(), 'form' => $form->createView(), 'journalApplicationFiles' => $journalApplicationFiles]);
                 }
                 $submissionFile->setTitle($journalApplicationFiles[$fileKey]->getTitle())->setDetail($journalApplicationFiles[$fileKey]->getDetail())->setLocale($journalApplicationFiles[$fileKey]->getLocale())->setRequired($journalApplicationFiles[$fileKey]->getRequired())->setJournal($application);
                 $em->persist($submissionFile);
             }
             $application->setSlug($application->getTitle());
             $em->persist($application);
             $em->flush();
             $event = new AdminEvent(['entity' => $application]);
             $dispatcher->dispatch(AdminEvents::JOURNAL_APPLICATION_HAPPEN, $event);
             return $this->redirectToRoute('ojs_apply_journal_success');
         }
         $this->errorFlashBag('An error has occured. Please check the form and resubmit.');
     }
     $event = new ResponseEvent('OjsSiteBundle:Application:journal.html.twig', ['form' => $form->createView(), 'publisherForm' => $publisherForm->createView(), 'journalApplicationFiles' => $journalApplicationFiles]);
     $dispatcher->dispatch(AdminEvents::JOURNAL_APPLICATION_RESPONSE, $event);
     return $this->render($event->getTemplate(), $event->getData());
 }
Beispiel #26
0
 /**
  * Finds and displays a Section entity.
  *
  * @param Request $request
  * @param Section $entity
  * @return Response
  */
 public function showAction(Request $request, Section $entity)
 {
     $journal = $this->get('ojs.journal_service')->getSelectedJournal();
     if (!$this->isGranted('VIEW', $journal, 'sections')) {
         throw new AccessDeniedException("You are not authorized for view this journal's section!");
     }
     $entity->setDefaultLocale($request->getDefaultLocale());
     if (!$entity) {
         throw $this->createNotFoundException('notFound');
     }
     $token = $this->get('security.csrf.token_manager')->refreshToken('ojs_journal_section' . $entity->getId());
     return $this->render('OjsJournalBundle:Section:show.html.twig', array('entity' => $entity, 'token' => $token));
 }
Beispiel #27
0
 /**
  * Finds and displays a IssueFile entity.
  *
  * @param Request $request
  * @param $id
  * @return Response
  */
 public function showAction(Request $request, $id)
 {
     $em = $this->getDoctrine()->getManager();
     /** @var IssueFile $entity */
     $entity = $em->getRepository('OjsJournalBundle:IssueFile')->find($id);
     $journal = $this->get('ojs.journal_service')->getSelectedJournal();
     if (!$this->isGranted('VIEW', $journal, 'issues')) {
         throw new AccessDeniedException('You are not authorized for edit this  issue file!');
     }
     /** @var Issue $issue */
     $issue = $em->getRepository('OjsJournalBundle:Issue')->find($entity->getIssue()->getId());
     $this->throw404IfNotFound($issue);
     $this->throw404IfNotFound($entity);
     $entity->setDefaultLocale($request->getDefaultLocale());
     $token = $this->get('security.csrf.token_manager')->refreshToken('ojs_journal_issue_file' . $entity->getId());
     return $this->render('OjsJournalBundle:IssueFile:show.html.twig', array('entity' => $entity, 'token' => $token));
 }
Beispiel #28
0
 /**
  * Finds and displays a Subject entity.
  *
  * @param Request $request
  * @param Subject $entity
  * @return Response
  */
 public function showAction(Request $request, Subject $entity)
 {
     $this->throw404IfNotFound($entity);
     $entity->setDefaultLocale($request->getDefaultLocale());
     $token = $this->get('security.csrf.token_manager')->refreshToken('ojs_admin_subject' . $entity->getId());
     return $this->render('OjsAdminBundle:AdminSubject:show.html.twig', ['entity' => $entity, 'token' => $token]);
 }
Beispiel #29
0
 /**
  * Finds and displays a JournalContact entity.
  *
  * @param  Request $request
  * @param  int $id
  * @return Response
  */
 public function showAction(Request $request, $id)
 {
     $em = $this->getDoctrine()->getManager();
     /** @var JournalContact $entity */
     $entity = $em->getRepository('OjsJournalBundle:JournalContact')->findOneBy(['id' => $id]);
     $this->throw404IfNotFound($entity);
     $entity->setDefaultLocale($request->getDefaultLocale());
     $token = $this->get('security.csrf.token_manager')->refreshToken('ojs_admin_contact' . $entity->getId());
     return $this->render('OjsAdminBundle:AdminContact:show.html.twig', array('entity' => $entity, 'token' => $token));
 }
Beispiel #30
0
 /**
  * Creates a new Post entity.
  *
  * @param  Request $request
  * @return RedirectResponse|Response
  */
 public function createAction(Request $request)
 {
     if (!$this->isGranted('CREATE', new AdminPost())) {
         throw new AccessDeniedException("You are not authorized for this post!");
     }
     $entity = new AdminPost();
     $entity->setCurrentLocale($request->getDefaultLocale());
     $form = $this->createCreateForm($entity);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $entity->setSlug($entity->getTranslationByLocale($request->getDefaultLocale())->getTitle());
         $em->persist($entity);
         $em->flush();
         $this->successFlashBag('successful.create');
         return $this->redirectToRoute('ojs_admin_post_show', ['id' => $entity->getId()]);
     }
     return $this->render('OjsAdminBundle:AdminPost:new.html.twig', ['entity' => $entity, 'form' => $form->createView()]);
 }